[Thread Prev][Thread Next][Index]

Re: How do I add a dimension to a netCDF?



Hi Mark,
There is a way to do this, but first a bit of an explantion. Your
input data has a normal T axis when it's read into Ferret, so it
can't be directly regridded onto a grid with a time axis. If you do:

    yes? let newvar = mydata[GX=cols,GY=rows,GT=time]
    yes? show grid newvar

You'll see that newvar still has a normal T axis; there was no
T axis on mydata to be regridded onto the axis called TIME.

You can make a new variable based on mydata, having a time axis,
by adding a variable having that axis onto mydata:

    yes? let newvar = mydata[GX=cols,GY=rows] + 0*t[GT=time]
    yes? show grid newvar

Now newvar has a time axis, and if you save it to a file, the time
axis will show up in the NetCDF file.

For more on the techniques for combining variables of different
dimensions, see Ch3, Sec 2.2, "Multi-dimensional Expressions" in
the Users Guide.
 

Mark A Ohrenschall wrote:

Hello,

I have a netCDF file with this description:

[mao@panther dods]$ ncdump -h ims2003097.cdf
netcdf ims2003097 {
dimensions:
        cols = 2500 ;
        rows = 1250 ;
variables:
        float MyData(rows, cols) ;
                MyData:TITLE = "ims2003097" ;
}
I'd like to add cols and rows coordinate variables, plus a time dimension (with one element) and make MyData a 3-D grid. I tried this in ferret:
yes? use ims2003097.cdf
yes? define axis/x=-179.856:179.856/npoints=2500 cols
yes? define axis/y=89.856:-89.856/npoints=1250 rows
yes? define axis/t=12149:12149:1/npoints=1/units=days time
yes? save/file=ims2003097.nc/clobber mydata[GX=cols,GY=rows,GT=time]
 LISTing to file ims2003097.nc
yes?
resulting in this netCDF file description:
[mao@panther dods]$ ncdump -h ims2003097.nc
netcdf ims2003097 {
dimensions:
        COLS = 2500 ;
        ROWS = 1250 ;
variables:
        double COLS(COLS) ;
                COLS:point_spacing = "even" ;
        double ROWS(ROWS) ;
                ROWS:point_spacing = "even" ;
        float MYDATA(ROWS, COLS) ;
                MYDATA:missing_value = -1.e+34f ;
                MYDATA:_FillValue = -1.e+34f ;
                MYDATA:long_name = "MYDATA" ;
                MYDATA:long_name_mod = "regrid: 0.14 delta on X, 0.14 delta on Y" ;
                MYDATA:history = "From ims2003097" ;

// global attributes:
                :history = "FERRET V5.40   28-May-03" ;
}
So I created the cols and rows coordinate variables just fine, but failed to add a time coordinate variable and make MYDATA a 3-D grid.

How do I do this?

Thanks in advance,

Mark

--
Ansley Manke  Pacific Marine Environmental Laboratory  Seattle WA  (206)526-6246
 


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement