<div class="gmail_quote">On Fri, May 15, 2009 at 3:43 PM, P.R. <span dir="ltr"><<a href="mailto:romero619@hotmail.com">romero619@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I need help setting up the control file for a netcdf file.<br>
The file has a strange variable & dimensions setup, so I couldn’t open it<br>
automatically with sdfopen.<br>
Here's an 'ncdump' of the netcdf header<br>
<br>
#ncdump -h GEBCO_08.nc<br>
<br>
netcdf GEBCO_08 {<br>
dimensions:<br>
side = 2 ;<br>
xysize = 933120000 ;<br>
variables:<br>
double x_range(side) ;<br>
x_range:units = "user_x_unit" ;<br>
double y_range(side) ;<br>
y_range:units = "user_y_unit" ;<br>
short z_range(side) ;<br>
z_range:units = "user_z_unit" ;<br>
double spacing(side) ;<br>
int dimension(side) ;<br>
short z(xysize) ;<br>
z:scale_factor = 1. ;<br>
z:add_offset = 0. ;<br>
z:node_offset = 1 ;<br>
<br>
// global attributes:<br>
:title = "GEBCO_08 Grid" ;<br>
:source = "20090202" ;<br>
}<br>
<br>
This file contains bathymetric/elevation data in meters in the 'z' variable.<br>
However, it doesn’t appear to have x&y variables, just the total x*y grid<br>
size (933120000).<br>
Here's a description of the grid from the file's documentation:<br>
<br>
The complete data set gives global coverage.<br>
It consists of 21,600 rows x 43,200 columns, resulting in 9,331,200,000 data<br>
points.<br></blockquote><div><br></div><div>Yikes, everything is lumped into a single 1D array, I don't think grads will be able to read it since the array has rank 1. The simplest solution is to write a small program to read this data and write it in a more grads friendly way. Since I know you have pygrads installed you could try something like this:</div>
<div><br></div><div>[] ga-> from mpl_toolkits.basemap import NetCDFFile<br></div><div>[] ga-> z = NetCDFFile('GEBCO.nc').variables['z'][:].astype(float32)<br></div><div><br></div><div>at this point point z should be a 1D array of size 933120000. Just write it to a flat binary file</div>
<div><br></div><div>[] ga-> z.tofile('GEBCO.bin')</div><div><br></div><div>and prepare a ctl to go along with it. If you are inspired you could also reshape z as a 2D array and write it to a coards compatible NetCDF file that grads can read. Here is the API: </div>
<div><br></div><div> <a href="http://www-md.fsl.noaa.gov/eft/developer/netCDFPythonInterface.html">http://www-md.fsl.noaa.gov/eft/developer/netCDFPythonInterface.html</a></div><div><br></div><div> Arlindo</div><div><br>
</div><div><br></div></div>-- <br>Arlindo da Silva<br><a href="mailto:dasilva@alum.mit.edu">dasilva@alum.mit.edu</a><br>