p.set_property('standard_name', 'precipitation_flux') p dc = cf.DimensionCoordinate() dc dc.set_property('long_name', 'Longitude') dc.set_data(cf.Data([1, 2, 3.])) dc fa = cf.FieldAncillary(data=cf.Data(numpy.array([0, 0, 2], dtype='int8'))) fa fa.set_property('standard_name', 'precipitation_flux status_flag') fa longitude_axis = p.set_construct(cf.DomainAxis(3)) longitude_axis key = p.set_construct(dc, axes=longitude_axis) key cm = cf.CellMethod(axes=longitude_axis, method='minimum') p.set_construct(cm) import numpy import cf # Initialise the field construct with properties Q = cf.Field(properties={ 'project': 'research', 'standard_name': 'specific_humidity', 'units': '1' }) # Create the domain axis constructs domain_axisT = cf.DomainAxis(1) domain_axisY = cf.DomainAxis(5)
p dc = cf.DimensionCoordinate() dc dc.set_property('long_name', 'Longitude') dc.set_data(cf.Data([1, 2, 3.])) dc fa = cf.FieldAncillary( data=cf.Data(numpy.array([0, 0, 2], dtype='int8'))) fa fa.set_property('standard_name', 'precipitation_flux status_flag') fa longitude_axis = p.set_construct(cf.DomainAxis(3)) longitude_axis key = p.set_construct(dc, axes=longitude_axis) key cm = cf.CellMethod(axes=longitude_axis, method='minimum') p.set_construct(cm) raise Exception("To proceeed, insert code block 1") Q.dump() raise Exception("To proceeed, insert code block 2") print(tas) q, t = cf.read('file.nc') print(q.creation_commands()) import netCDF4 nc = netCDF4.Dataset('file.nc', 'r') v = nc.variables['ta'] netcdf_array = cf.NetCDFArray(filename='file.nc', ncvar='ta', dtype=v.dtype, ndim=v.ndim, shape=v.shape, size=v.size) data_disk = cf.Data(netcdf_array) numpy_array = v[...]