Re: [netcdfgroup] easy/quick way to get attribute value from shell?

Tom Roche Sun, 20 May 2012 12:49:22 -0400
>>> Ideally we could combine the clarities of R package=ncdf4 and the
>>> NCO print statement, e.g.

>>> ncatt_get 'N2O@var_desc' /path/to/file
>>> or, for global attributes
>>> ncatt_get '@NVARS' /path/to/file

>>> that could be used like

>>> if [[ "$(ncatt_get 'N2O@units' /path/to/file)" == 'kg/ha' ]] ; then
>>>   # convert kg to mol
>>>   # convert ha to map-scaled gridcell area
>>> fi

Charlie Zender Sat, 19 May 2012 14:05:16 -0700
>> http://nco.sf.net/nco.html#ncattget

Interesting! but

- when I access that link, I only get the top of the document.
  Furthermore, when I search the page for 'ncattget' I get no hits.
  Am I missing something?

- on my (debian) box (which is up-to-date with debian testing), I see

me@it:~$ which ncattget
me@it:~$ which ncap2
> /usr/bin/ncap2
me@it:~$ $(which ncap2) --version
> NCO netCDF Operators version "4.0.9" last modified 2012/01/01 built Mar  8 
> 2012 on brahms by buildd
> ncap2 version 4.0.9

What must one do to see `ncattget` docs and binaries?

One thing that WFM is

BUTOWSKY HENRY Sun, 20 May 2012 18:28:00 +0100
> you can add a regular C type format string to the ncap2 print
> command to just print the value

me@it:~$ FOO="$(ncap2 -v -O -s 'print(N2O@var_desc, "%f")' 
/tmp/emis_mole_onlyN2O_windowed.ncf)"
me@it:~$ echo -e "FOO='${FOO}'"
FOO='Denitrification_N2     '

No more parsing of output!

FWIW, Tom Roche <Tom_Roche@xxxxxxxxx>



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