Re: [netcdfgroup] Extracting data from NetCDF

Hi Dave & netcdfgroup community

thank you so much for everyone's suggestions & insights! They were all really helpful... I was able to successfully extract the data I needed. I ended up using NCO's ncks utility. This did the trick quite well for what I needed to do...

ncks -v u -d time,2 infile.nc > outfile.asc

Thanks again everyone!

         Lucas


On 4/15/2011 9:58 AM, Dave Allured wrote:
You should probably do this with one of the Netcdf tool applications.

http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial.html#Tools
http://www.unidata.ucar.edu/software/netcdf/software.html

If you do not need the ascii output formatted into columns, then you can extract the desired subset into a separate Netcdf file with one NCO command. Then use ncdump to print that file as ascii CSV.

NCL can read Netcdf, get the desired subset, and output formatted ascii with only a few script commands. There is a learning curve for the script language.

There are plenty of other alternatives. Perhaps you should take inventory of which Netcdf tools are already on your computer system.

You can also use the Netcdf API interfaces directly from C, Fortran, and Java, if that seems better for what you want to do. See the Netcdf tutorial for more details. In particular, the examples for "pres_temp_4D" show how to read a Netcdf variable of the same dimensionality as your data. You then just subscript as needed, and add formatted write commands.

Also, if you are just reading the ascii result into another software package, check the documentation and available extensions carefully before putting your energy into making an ascii file. Many numeric processing applications now have the ability to read Netcdf files and subsets directly. HTH.

--Dave

On 4/15/2011 1:02 PM, Lucas.Moxey wrote:
Dear netcdfgroup community

I'm trying to extract some data from a netcdf file I have. The file
has various dimensions & variables, these being (hereby summarized):

dimensions:
time = 216 ; (note: these are the number of months)
depth = 1 ;
lat = 60 ;
lon = 97 ;

variables:
float time(time) ;
float depth(depth) ;
float lat(lat) ;
float lon(lon) ;
float u(time, depth, lat, lon) ;
float v(time, depth, lat, lon) ;

I'm a bit confused... how can I specifically extract the data for
the "u" variable specifically for time #3 (e.g.: month 3) in ascii
format? I'm confused on how to do this... I've been trying ncdump,
but haven't quite made it work. Currently, I'm using netcdf v3.5.0.

Any thoughts on this would be very helpful. Thanks!

Lucas

_______________________________________________
netcdfgroup mailing list
netcdfgroup@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit:
http://www.unidata.ucar.edu/mailing_lists/



  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: