NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: splitting netcdf file into multiple files by date

Hi,

This is nasty, but it would be quick. Your C++ program could make a call
to the ncks utility (which is part of the NetCDF operators). In C you
use the system function ... I guess it is similar or the same in C++.
Compared to using the C++ interface, this will save you many many lines
of code, at the expense of being a very inelegant solution.

Tim Hume


On Mon, 11 Apr 2005 11:42:20 -0700 (PDT)
Selina Satterfield <satterfields2000@xxxxxxxxx> wrote:

> I'm new to netCDF development and currently I have a
> large number of netcdf files
> that contain multiple dimensions, variables , and data
> for a period of time.  Here is a cdl that I generated
> with ncdump of one of the files
> 
> netcdf test {
> dimensions:
>       lat = 141 ;
>       lon = 360 ;
>       time = UNLIMITED ; // (31 currently)
> variables:
>       float lat(lat) ;
>               lat:long_name = "Latitude" ;
>               lat:units = "degrees_north" ;
>       float lon(lon) ;
>               lon:long_name = "Longitude" ;
>               lon:units = "degrees_east" ;
>       float time(time) ;
>               time:long_name = "Time" ;
>               time:units = "hours since 1997-01-01" ;
>       float age_rcnt_obs(time, lat, lon) ;
>               age_rcnt_obs:_FillValue = 999.f ;
>               age_rcnt_obs:long_name = "Age of Recent Observation"
> ;
>               age_rcnt_obs:missing_value = 999.f ;
>               age_rcnt_obs:units = "Hours" ;
>               age_rcnt_obs:valid_max = 255.f ;
>               age_rcnt_obs:valid_min = 0.f ;
>       float anal_temp(time, lat, lon) ;
>               anal_temp:_FillValue = 9999.f ;
>               anal_temp:long_name = "Analysis Temperature" ;
>               anal_temp:missing_value = 999.9f ;
>               anal_temp:scale_factor = 0.1f ;
>               anal_temp:units = "Deg. C" ;
>               anal_temp:valid_max = 70.f ;
>               anal_temp:valid_min = -10.f ;
>       float avgrad(time, lat, lon) ;
>               etc.....;
> 
> // global attributes:
>               :title = "SST 100 KM FIELD" ;
> data:
> 
>  lat = -70, -69, -68, -67, -66, -65, -64, -63, -62,
> -61, -60, -59, -58, -57, 
>     -56, -55, -54, -53, -52, -51, -50, -49, -48, -47,
> -46, -45, -44, -43, 
>     etc..............;
> 
>  lon = -180, -179, -178, -177, -176, -175, -174, -173,
> -172, -171, -170, 
>     -169, -168, -167, -166, -165, -164, -163, -162,
> -161, -160, -159, -158, 
>     -157, -156, -155, -154, -153, -152, -151, -150,
> -149, -148, -147, -146, 
>     -145, -144, -143, -142, -141, -140, -139, -138,
> -137, -136, -135, -134, 
>     etc..............;
> 
>  time = 60600, 60624, 60648, 60672, 60696, 60720,
> 60744, 60768, 60792, 60816, 
>     60840, 60864, 60888, 60912, 60936, 60960, 60984,
> 61008, 61032, 61056, 
>     61080, 61104, 61128, 61152, 61176, 61200, 61224,
> 61248, 61272, 61296, 
>     61320 ;
> 
>  age_rcnt_obs
>   .........etc
> 
> As you can see with the time there is data for 31
> days. What I would like to do is create 31 separate
> files using the NetCDF C++ Interface. Each file would
> include all dimensions variables attributes and only
> the data for that single day. I can't use a utility I
> need to create this myself since dates and other
> information needs to be obtained from a database. My
> question is can anyone send a code example of how I
> might do this? Thank you for your time and
> consideration.
> 
> Selina
> 
> 
> 
> 
>               
> __________________________________ 
> Do you Yahoo!? 
> Make Yahoo! your home page 
> http://www.yahoo.com/r/hs
> 

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