Stitching SLCF3D from multiple meshes to a single file

52 views
Skip to first unread message

Rakesh Yuvaraj

unread,
Jan 26, 2023, 8:21:20 AM1/26/23
to FDS and Smokeview Discussions
Previously, I did find a way to reading the SLCF3D (.sf format) files using pyfdsTools (https://github.com/johodges/pyfdstools), when I was testing with just 1 mesh. Right now, I have more than different 30 meshes dividing the domain in all three directions differently. I was wondering if someone had some experience with saving the SLCF3D files from different meshes in a single file with all the meshes stitched in the correct order ?

Jonathan Hodges

unread,
Jan 26, 2023, 8:38:09 AM1/26/23
to FDS and Smokeview Discussions
In examples.py the subroutine "exampleReadSlcf3dResults" will read in all 3D slices for a specific quantity from all meshes and create a stitched grid. What kind of file format are you looking to save out?

Rakesh Yuvaraj

unread,
Jan 26, 2023, 8:57:50 AM1/26/23
to FDS and Smokeview Discussions
Thank you for your reply. I am trying the subroutine "exampleReadSlcf3dResults". 

I would like to save the files in a NetCDF format 

Message has been deleted

Jonathan Hodges

unread,
Jan 26, 2023, 11:30:05 AM1/26/23
to FDS and Smokeview Discussions
pyfdstools does not currently support a netcdf output. If you want to write a plugin and make a pull request to add it to the repository, that would be welcome. Here is a brief set of code to get started. This will import 3D temperature data, establish the dimensions of the netCDF4 file and write temperature data. Note that each dimension is still unitless. If you want to visualize this data in an external tool you will need to assign altitude, latitude, and longitude coordinates to the empty dimensions based on the values stored in grid2.

import netCDF4

# Get case information from examples
systemPath = os.path.dirname(os.path.abspath(__file__))
chid = "case001"
resultDir = os.path.join(systemPath, "examples", "%s.zip"%(chid))
qty = 'TEMPERATURE'

# Read data
grid, data, times = fds.readSLCF3Ddata(chid, resultDir, qty)

# Convert axes to netcdf4 ordering
data2 = np.moveaxis(data, [3,2,1,0], [0,1,2,3])
grid2 = np.moveaxis(grid, [2,1,0,3], [0,1,2,3])

# Open netcdf4 file
rootgrp = netCDF4.Dataset('output.nc','w')

# Establish basic dimension information for netcdf file
time = rootgrp.createDimension('time', None)
lon = rootgrp.createDimension('lon', grid.shape[0])
lat = rootgrp.createDimension('lat', grid.shape[1])
level = rootgrp.createDimension('level', grid.shape[2])

# Establish netcdf variable
temp = rootgrp.createVariable("temp","f4",("time","level","lat","lon"))
temp.units = "K"
temp[:] = data2 + 273 # Fill temperature variable with values from FDS in K

# Close file
rootgrp.close()

Rakesh Yuvaraj

unread,
Jan 27, 2023, 8:15:07 AM1/27/23
to FDS and Smokeview Discussions
Thank you for your answer. It is quite helpful. I will write a plugin and post it here, so that you can verify and validate it.
Reply all
Reply to author
Forward
0 new messages