Read fields from files from disk or from an OPeNDAP server.
Currently supports netCDF and PP formats.
Each field contains it’s file name in its file attribute and, where appropiate, its netCDF variable name in its ncvar attribute. Note that fields may be selected by netCDF variable name by setting a value (or values) of ‘ncvar’ via the priv keyword.
Fields referenced by formula_terms transforms are not included in the returned list of fields.
Parameters : |
|
---|---|
Returns : |
|
Raises : |
|
Examples:
>>> f = cf.read('file*.nc')
>>> type(f)
<class 'cf.field.FieldList'>
>>> f
[<CF Field: pmsl(30, 24)>,
<CF Field: z-squared(17, 30, 24)>,
<CF Field: temperature(17, 30, 24)>,
<CF Field: temperature_wind(17, 29, 24)>]
>>> cf.read('file*.nc')[0:2]
[<CF Field: pmsl(30, 24)>,
<CF Field: z-squared(17, 30, 24)>]
>>> cf.read('file*.nc', index=0)
[<CF Field: pmsl(30, 24)>]
>>> cf.read('file*.nc')[-1]
<CF Field: temperature_wind(17, 29, 24)>
>>> cf.read('file*.nc', attr={'units': 'K'})
[<CF Field: temperature(17, 30, 24)>,
<CF Field: temperature_wind(17, 29, 24)>]
>>> cf.read('file*.nc', priv={'ncvar': 'ta'})
[<CF Field: temperature(17, 30, 24)>]
>>> cf.read('file*.nc', attr={'standard_name': '.*pmsl*', 'units':'K|Pa'})[0]
<CF Field: pmsl(30, 24)>
>>> cf.read('file*.nc', attr={'units':['K, 'Pa']})
[<CF Field: pmsl(30, 24)>,
<CF Field: temperature(17, 30, 24)>,
<CF Field: temperature_wind(17, 29, 24)>]