Getting the data written out to a grid structure format that is readable as HDF5/netCDF is tricky. The datasets and attributes can be written and all of that information is stored in the output structure.
The challenge is to link the longitude (x) and latitude (y) datasets to the z-dimensions, which requires the need to construct a compound reference list; at the moment it is not clear how this works.
Cannot see a way to replicate this structure:
Longitude dataset (as an example)
ATTRIBUTE “REFERENCE_LIST” {
DATATYPE H5T_COMPOUND {
H5T_STD_REF_OBJECT “dataset”;
H5T_STD_I32LE “dimension”;
}
DATASPACE SIMPLE { ( 1 ) / ( 1 ) }
DATA {
(0): {
DATASET 4111 /z,
1
}
}
}
Zdata has a similar issue:
DATASET “z” {
DATATYPE H5T_IEEE_F32LE
DATASPACE SIMPLE { ( 1200, 1200 ) / ( 1200, 1200 ) }
STORAGE_LAYOUT {
CHUNKED
SIZE 2973243
ATTRIBUTE "DIMENSION_LIST" {
DATATYPE H5T_VLEN { H5T_STD_REF_OBJECT }
DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
DATA {
(0): (DATASET 817 /lat),
(1): (DATASET 480 /lon)
}
}
Running the code will generate a file with three datasets corresponding to longitude, latitude and zdata. Getting netCDF data into Scilab is the easy part; I guess one could eithe ESRI ascii raster format or some image structure (need to think on that one). If anyone is familiar with HDF5 that would be good!
Lester
The code so far:
NCout=h5open('test.sod', 'w');
// Root level global attributes
h5attr(NCout,'/','Conventions','CF-1.7')
h5attr(NCout,'/','_NCProperties','version=2,netcdf=4.8.2-development,hdf5=1.10.5')
// write datasets to the root group
// x-axis
h5write(NCout, '/lon', longitude);
h5attr(NCout,'/lon','long_name','longitude')
h5attr(NCout,'/lon','units','degrees_east')
h5attr(NCout,'/lon','standard_name','longitude')
h5attr(NCout,'/lon','axis','x')
h5attr(NCout,'/lon','CLASS','DIMENSION_SCALE')
h5attr(NCout,'/lon','actual_range',[xmin xmax]')
// y-axis
h5write(NCout, '/lat', latitude);
h5attr(NCout,'/lat','long_name','latitude')
h5attr(NCout,'/lat','units','degrees_north')
h5attr(NCout,'/lat','standard_name','latitude')
h5attr(NCout,'/lat','axis','y')
h5attr(NCout,'/lat','CLASS','DIMENSION_SCALE')
h5attr(NCout,'/lat','actual_range',[ymin ymax]')
// Data
h5write(NCout, '/z', zdata);
h5attr(NCout,'/z','_FillValue',%nan)
h5attr(NCout,'/z','actual_range',[zmin zmax]')
// Close the file (ID)
h5close(NCout)