Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.

Re: [netcdfgroup] how to extract data

> I have a NetCDF file and the description is in accessary,   I use  " ncdump
> -v layer_absorber profile.nc > out.txt" to extract the data, but there are
> so many data extracted.
> For instance, The description of "layer_absorber" as following:
> #
>     double layer_absorber(n_profiles, n_absorbers, n_layers) ;
>                 layer_absorber:long_name = "Layer absorber" ;
>                 layer_absorber:units = "Variable (see Absorber_Units_ID)" ;
>                 layer_absorber:_FillValue = -999. ;
> #
> Could you  tell me how to extract the data of " layer_absorber(1,1,1:100) "
> ?

In addition to the ncview, NCL, or NCO solutions already mentioned, you
could just use ncdump options "-v" (variable) and "-f" (full annotation)
and pipe the output into grep.  For example:

  ncdump -v layer_absorber -f c profile.nc | grep "// layer_absorber(0,0,.*)"

will output an annotated list of values such as

    1.091546e-06,  // layer_absorber(0,0,0)
    1.054535e-06,  // layer_absorber(0,0,1)
    1.078923e-06,  // layer_absorber(0,0,2)
    1.016285e-06,  // layer_absorber(0,0,3)
  ...

If you really want only the indices in the range 1 to 100 for the last
dimension, a longer grep regular expression is required or use a pattern
matcher that knows arithmetic, such as awk.

To use 1-based Fortran column-major indices rather than 0-based C
row-major indices, instead use

  ncdump -v layer_absorber -f f profile.nc | grep "// 
layer_absorber([0-9]*,1,1)"

to get output such as

    1.091546e-06,  // layer_absorber(1,1,1)
    1.054535e-06,  // layer_absorber(2,1,1)
    1.078923e-06,  // layer_absorber(3,1,1)
    1.016285e-06,  // layer_absorber(4,1,1)
  ...

--Russ



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