<div dir="ltr">Hi all,<br><br>The Scilab (SOD) format is the way forward since netCDF and HDF5 are very similar, but have slightly different naming conventions. I have a Geographic grid with the structure below, but cannot seem to get the output file dimensions right, i.e. the x and y coordinates in degrees and not pixel reference.<br><br>File structure from ncdisp('filename')<br><br>Source:    Test_10-FAA.grd<br>Format:    netcdf4<br><br>Global Attributes:<br>           Conventions = "COARDS, CF-1.5"<br>           title       = ""<br>           history     = "grdsample -R-10/10/-10/10 -I1m @GMTAPI@-000001 -Gc:\Temp\Test_10-FAA.grd -fg --GMT_HISTORY=false"<br>           description = ""<br>           GMT_version = "5.4.3 (r19528) [64-bit] [MP]"<br>           node_offset = 1<br>Dimensions:<br>           lon = 1200<br>           lat = 1200<br>Variables:<br>    lon<br>           Size:       1200<br>           Dimensions: lon<br>           Datatype:   double<br>           Attributes:<br>                      long_name    = "longitude"<br>                      units        = "degrees_east"<br>                      actual_range = -10  10<br>    lat<br>           Size:       1200<br>           Dimensions: lat<br>           Datatype:   double<br>           Attributes:<br>                      long_name    = "latitude"<br>                      units        = "degrees_north"<br>                      actual_range = -10  10<br>    z<br>           Size:       1200x1200<br>           Dimensions: lon,lat<br>           Datatype:   single<br>           Attributes:<br>                      long_name    = "z"<br>                      _FillValue   = NaN<br>                      actual_range = -104.9617      456.6511<br><br>b=h5open('Test_out.grd','w');<br>h5write(b,'lat',lat);<br>h5write(b,'lon',lon);<br>h5write(b,'data',data);<br>h5close(b)<br><br>save('Test_output.sod','lon','lat','data')<br><br>Saving the output creates a file composed of the three datasets (lon, lat, data). Plotting the data in Scilab via Sgrayplot(x,y,z) it looks correct, oriented properly and axes of longitude and latitude.<br><br>Anyone know how to set the correct attributes to get the HDF5 file recognised as Geographic?<br><br>Lester<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 25 May 2022 at 15:17, Lester Anderson <<a href="mailto:arctica1963@gmail.com">arctica1963@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I just found a useful way of getting netCDF files into Scilab via HDF5 (just found this!):</div><div><br></div><div><pre style="font-family:Arial"><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(50,185,185)">h5open</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">Test_10-FAA.grd</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>

<span style="color:rgb(50,185,185)">h5ls</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(74,85,219)">)</span>

<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">lat</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">                     </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">dataset</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">  </span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">lon</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">                    </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">dataset</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">  </span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">z</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">                       </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">dataset</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">  </span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">Conventions</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">      </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">attribute</span><span style="color:rgb(100,174,100)">"</span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">GMT_version</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">     </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">attribute</span><span style="color:rgb(100,174,100)">"</span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">_NCProperties</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">   </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">attribute</span><span style="color:rgb(100,174,100)">"</span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">description</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">        </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">attribute</span><span style="color:rgb(100,174,100)">"</span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">history</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">              </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">attribute</span><span style="color:rgb(100,174,100)">"</span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">node_offset</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">       </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">attribute</span><span style="color:rgb(100,174,100)">"</span>
<span style="color:rgb(100,174,100)">//  </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">title</span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">                   </span><span style="color:rgb(100,174,100)">"</span><span style="color:rgb(100,174,100)">attribute</span><span style="color:rgb(100,174,100)">"</span>

<span style="color:rgb(0,0,0)">lon</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(50,185,185)">h5read</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">lon</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">lat</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(50,185,185)">h5read</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">lat</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">data</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(50,185,185)">h5read</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">z</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span></pre><pre style="font-family:Arial"><span style="color:rgb(50,185,185)">h5close</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span></pre>The data plots fine via Sgrayplot(lon,lat,data,zminmax=[-25,25]) . I need to know how to write data out to essentially replicate the input netCDF file, so any pointers/examples would be helpful. It would be good to output a file in a format that GMT (Generic Mapping Tools) would recognise.<br><br>The use of HDF5 seems to solve the issues of working with netCDF-4 files.</div><div><br></div><div>Lester<br></div></div>
</blockquote></div>