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

On Sep 6, 2012, at 7:03 PM, Tom Roche <Tom_Roche@xxxxxxxxx> wrote:

> 
> summary: Suppose you have a netCDF file in the cwd named 'foo.nc'
> which has a datavar named 'bar' which contains numeric data ranging
> from +1.23e-4 to +5.67e8. I'm looking for executable(s) that supports
> use roughly similar to the following commandline input and output:
> 
> $ ncmax ./foo.nc bar
> 5.67e8
> 
> details:
> 
> I'd like to be able to simply, quickly, and automatically test netCDF
> data, e.g. to ensure manipulations I'm making don't make unintentional
> changes. One obvious way to do this is to check simple statistics,
> like the range (max and min) or central tendency (mean or median), of
> a datavar, to ensure it changes (or not) as expected.
> 
> I don't particularly care about the technology/API used for the task,
> but thought this would be easy to do with NCO, so I tried that first.
> After 30 min I still couldn't figure out how, so I punted to google,
> where I found
> 
> http://sourceforge.net/projects/nco/forums/forum/9830/topic/4008865
> 
> which suggests this should be easy to do ... but doesn't say how.
> Taking the bait, I examined ncks and ncap2, but, after another 30 min,
> was still unenlightened: I can see relatively easily how to create an
> output netCDF file, some datavar of which contains the desired value,
> but again, that's not what I (and the asker of the above) want--we
> just want good old-fashioned stdout.

Suggest using the "print" function in ncap2.  You still will need an output 
file, but it can be a dummy file that you ignore.

> 
> So I wrote an R script which demonstrates (albeit crudely) something
> like the desired functionality. If you have R and Rscript (with R
> packages ncdf4 and fields), you should be able to
> 
> 1 clone https://github.com/TomRoche/GEIA_to_NetCDF to a local folder
> 
> 2 download
> 
> https://github.com/downloads/TomRoche/GEIA_to_netCDF/N2OOC90Y.1A
> 
>  to the local folder
> 
> 3 in that folder, run ./GEIA.to.netCDF.r to create ./GEIA_N2O_oceanic.nc
> 
> 4 in that folder, run
> 
> $ Rscript ./netCDF.stats.to.stdout.r 'netcdf.fp="./GEIA_N2O_oceanic.nc"' 
> 'var.name="emi_n2o"'
>> For ./GEIA_N2O_oceanic.nc var=emi_n2o
>>      cells=64800
>>      obs=36143
>>      min=5.96e-08
>>      max=1.17e+03
>>      mean=99.5
>>      med=67.7
> 
> But I strongly suspect there's an easier way--i.e., not involving
> writing R--and that someone has scratched this itch before. Am I
> missing something?
> 
> TIA, Tom Roche <Tom_Roche@xxxxxxxxx>
> 
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe,  visit: 
> http://www.unidata.ucar.edu/mailing_lists/ 

--
Dr. Christopher Lynnes, NASA/GSFC, Code 610.2, 301-614-5185



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