1

I would like to find a way in Python to aggregate over the slow index (time) of a NetCDF dataset with dimensions (time,y,x) where the files store blocks of time. Apparently NetCDF4-python do this for a NetCDF4 classic file or NetCDF3, but the files are a done deal. Can anyone explain if there is a way to do this in NetCDF4, either with a multfile access or with something like NcML wrappers?

Or does NetCDF4 not do this for a reason that cannot be overcome?

Thanks.

Eli S
  • 1,379
  • 4
  • 14
  • 35
  • If I understand you correctly, then netCDF4's [MFDataset](http://netcdf4-python.googlecode.com/svn/trunk/docs/netCDF4.MFDataset-class.html) is ideal. It enables concatenating netCDF files into a single python object containing all of the timesteps. Is that what you're looking for? Not sure what you mean by the files being a "done deal". – Spencer Hill Dec 01 '14 at 03:42
  • Unless I am mistaken MFDataset does not support NetCDF4 unless it is NetCDF4 CLASSIC. My data source data are in ordinary NetCDF4. I cannot easily change that, although the data don't use groups and probably could be expressed in NetCDF3 or NetCDF4 classic. – Eli S Dec 01 '14 at 06:53
  • The documentation suggests that it does support netCDF4: http://netcdf4-python.googlecode.com/svn/trunk/docs/netCDF4.Dataset-class.html. Have you tried? – Spencer Hill Dec 01 '14 at 12:52
  • I take that back...looking closer you're right, netCDF4 is not supported. Sorry about that. – Spencer Hill Dec 02 '14 at 22:25
  • If your data doesn't use any NetCDF4 features but isn't officially NetCDF4-classic there may be a way to get MFDataset to work. Have you tried MFDataset and what error do you get? Can you give a CDL example of what your data looks like (possibly simplified)? – Stephen Pascoe Dec 15 '14 at 20:38
  • How would I get around this? I get a ValueError in __init__(). When I convert the files to netcdf4-classic it works. The data are just a time, x and y plus the main dataset. I am not using groups or NetCDF4 features unless there are hidden gotchas. The ValueError seems to be generated by the type flag, not an actual issue. – Eli S Dec 31 '14 at 07:14

0 Answers0