Re: [netcdfgroup] simple commandline query of data-variable statistics to stdout?

  • To: netCDF Mail List <netcdfgroup@xxxxxxxxxxxxxxxx>
  • Subject: Re: [netcdfgroup] simple commandline query of data-variable statistics to stdout?
  • From: Charlie Zender <zender@xxxxxxx>
  • Date: Fri, 07 Sep 2012 10:16:19 -0700
Hello Tom,

Your query matches a category of commands which I call filters.
Filters answer requests for specific information and are, I think,
best implemented as short shell scripts that cull information from
more complex, and difficult to remember, command line arguments.
Filters are described in more detail at
http://nco.sf.net/nco.html#filters

Below are sample implementations of the filters you want.
ncwa and ncks, or ncap2, are both amenable to this task.
ncap2 would be better for arbitrarily complex and longer filters.
They all produce the same results, of course, and can be strung
together and reformatted as desired.

Charlie

Usage:
ncmax variable file # Prints maximum
function ncmax { ncwa -y max -O -C -v ${1} ${2} ~/foo.nc ; ncks -H -C -v
${1} ~/foo.nc | cut -f 3- -d ' ' ; }
function ncmax { ncap2 -O -C -v -s "foo=${1}.max();print(foo)" ${2}
~/foo.nc | cut -f 3- -d ' ' ; }

ncavg variable file # Prints average
function ncavg { ncwa -y avg -O -C -v ${1} ${2} ~/foo.nc ; ncks -H -C -v
${1} ~/foo.nc | cut -f 3- -d ' ' ; }
function ncavg { ncap2 -O -C -v -s "foo=${1}.avg();print(foo)" ${2}
~/foo.nc | cut -f 3- -d ' ' ; }

ncrng variable file # Prints range
function ncrng { ncap2 -O -C -v -s
"foo_min=${1}.min();foo_max=${1}.max();print(foo_min,\"%f\");print(\" to
\");print(foo_max,\"%f\")" ${2} ~/foo.nc ; }

-- 
Charlie Zender, Earth System Sci. & Computer Sci.
University of California, Irvine 949-891-2429 )'(



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