Module netCDF4 :: Class MFTime

Class MFTime

object --+    
         |    
 _Variable --+
             |
            MFTime

MFTime(self, time, units=None)

Class providing an interface to a MFDataset time Variable by imposing a unique common time unit to all files.

Example usage:

>>> import numpy
>>> f1 = Dataset('mftest_1.nc','w', format='NETCDF4_CLASSIC')
>>> f2 = Dataset('mftest_2.nc','w', format='NETCDF4_CLASSIC')
>>> f1.createDimension('time',None)
>>> f2.createDimension('time',None)
>>> t1 = f1.createVariable('time','i',('time',))
>>> t2 = f2.createVariable('time','i',('time',))
>>> t1.units = 'days since 2000-01-01'
>>> t2.units = 'days since 2000-02-01'
>>> t1.calendar = 'standard'
>>> t2.calendar = 'standard'
>>> t1[:] = numpy.arange(31)
>>> t2[:] = numpy.arange(30)
>>> f1.close()
>>> f2.close()
>>> # Read the two files in at once, in one Dataset.
>>> f = MFDataset('mftest*nc')
>>> t = f.variables['time']
>>> print t.units
days since 2000-01-01
>>> print t[32] # The value written in the file, inconsistent with the MF time units.
1
>>> T = MFTime(t)
>>> print T[32]                        
32
Instance Methods
 
__getitem__(...)
Get records from a concatenated set of variables.
 
__init__(self, time, units=None)
Create a time Variable with units consistent across a multifile dataset.

Inherited from _Variable: __getattr__, __len__, __str__, ncattrs, set_auto_maskandscale, typecode

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__getitem__(...)
(Indexing operator)

 

Get records from a concatenated set of variables.

Overrides: _Variable.__getitem__
(inherited documentation)

__init__(self, time, units=None)
(Constructor)

 

Create a time Variable with units consistent across a multifile dataset.

Parameters:
  • time - Time variable from a MFDataset.
  • units - Time units, for example, 'days since 1979-01-01'. If None, use the units from the master record.
Overrides: object.__init__