Using MFDataset to combine netcdf files in python

Isaac Won winefrog at gmail.com
Mon Dec 2 20:40:19 EST 2013


I am trying to combine netcdf files, but it contifuously shows " File "CBL_plot.py", line 11, in f = MFDataset(fili) File "utils.pyx", line 274, in netCDF4.MFDataset.init (netCDF4.c:3822) IOError: master dataset THref_11:00.nc does not have a aggregation dimension."

So, I checked only one netcdf files and the information of a netcdf file is as below:

float64 th_ref(u't',) unlimited dimensions = () current size = (30,)

It looks there is no aggregation dimension. However, I would like to combine those netcdf files rather than just using one by one. Is there any way to create aggregation dimension to make this MFData set work?

Below is the python code I used:
    import numpy as np
    from netCDF4 import MFDataset
    varn = 'th_ref'
    fili = THref_*nc'
    f    = MFDataset(fili)
    Th  = f.variables[varn]
    Th_ref=np.array(Th[:])
    print Th.shape

I will really appreciate any help, idea, and hint.

Thank you, Isaac



More information about the Python-list mailing list