This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Unidata Support <address@hidden> writes: > ------- Forwarded Message > >>To: address@hidden >>From: Selina Satterfield <address@hidden> >>Subject: splitting netcdf file into multiple files by date >>Organization: UCAR/Unidata >>Keywords: 200504081920.j38JKnv2016454 > > Being new to netCDf development I'm not sure if this > is considered a simple question about use or not so I > apologize if I am mailing the wrong group in advanced. > > Currently I will 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 Sorry, I don't have any such example, but I suggest that you post this question on the netcdf mailing list - send it to address@hidden The netcdf list has a wide readership, and you may be able to get an answer there. Good luck, Ed -- Ed Hartnett -- address@hidden