[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #SCT-388171]: FW: Data extraction



Hi,

Using the "ncdump" utility program that is part of the freely available netCDF 
software shows that the precipitation is in a 3D variable:

        float precip(time, lat, lon) ;
                precip:long_name = "Average Monthly Rate of Precipitation" ;
                precip:valid_range = 0.f, 70.f ;
                precip:units = "mm/day" ;
                precip:add_offset = 0.f ;

where the sizes of the dimensions are:

        lon = 144 ;
        lat = 72 ;
        time = UNLIMITED ; // (12 currently)

So one way to extract the values as comma-separated values is to use the ncdump 
utility, specifying just the precip variable, which produces text output:

 $ ncdump -bf -v precip precip.mon.ltm.nc
 ...
 precip =
  // precip(1-144 ,1,1)
    0.2890909, 0.2954545, 0.2918182, 0.29, 0.2886364, 0.2890909, 0.2886364, 
    0.2872727, 0.2890909, 0.2913636, 0.2895454, 0.2895454, 0.2913636, 
  ...
    0.3122727, 0.3072727, 0.2940909,
  // precip(1-144 ,2,1)
    0.3104545, 0.345, 0.3609091, 0.3836364, 0.4081818, 0.4336364, 0.4581818, 
    0.4831818, 0.4990909, 0.5077273, 0.5090909, 0.5013636, 0.49, 0.475, 
  ...

and so on, where I've omitted some of the output.  The "// ..." lines are 
comments to help navigate through the output, but will only appear if the "-bf" 
option for "brief annotation using Fortran indexing" is specified for ncdump.  
To import data in this form into Excel should not be too difficult, but may 
require a little massaging with a scripting language such as awk, perl, python, 
or ruby.

Another approach would be to read the data into MATLAB (or IDL or Octave or 
some package that can read netCDF data) and export the data specifically for 
Excel or as comma-delimited text.  A large list of software packages (most 
freely available) that can read netCDF data is maintained here:
  http://www.unidata.ucar.edu/software/netcdf/software.html

Here's some other methods for examining netCDF files and getting the data into 
Excel:
  
http://www.bodc.ac.uk/data/online_delivery/international_sea_level/woce_netcdf.html#seven

You could even use Excel directly with an OPeNDAP (DODS) data server
that serves netCDF data, since Excel can read from URLs and you can
specify a netCDF query to such a data server with a URL.  Details to
that approach are here: 
  http://www.opendap.org/faq/useExcel.html

There is also a freely available application called the OPeNDAP Data Connector 
(ODC) that can import remote netCDF data:
  http://www.opendap.org/ODC/

I hope this helps ...

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: SCT-388171
Department: Support netCDF
Priority: Normal
Status: Closed