cfdm.Domain.to_xarray¶
- Domain.to_xarray(group=True)[source]¶
Convert the Domain to an
xarraydataset.If the
cf_xarraypackage (https://cf-xarray.readthedocs.io) is installed then thecf_xarrayaccessors that allow some interpretation of CF attributes will be present onxarray.DataArrayandxarray.Datasetobjects.Note that
ds = f.to_xarray()is identical tods = cfdm.write(f, fmt='XARRAY'); and multiple domains may be written to the samexarraydataset withcfdm.write(e.g.ds = cfdm.write([f, g], fmt='XARRAY')). Also,cfdm.writeallows a mixture of fields and domains to be written to the samexarraydataset.An
xarraydataset can be converted to one or more fields withf = cfdm.read(ds), or domains withf = cfdm.read(ds, domain=True).Added in version (cfdm): 1.13.2.0
See also
- Parameter:
- group:
bool, optional If False then create a “flat” dataset, i.e. one with only the root group, regardless of any group structure specified by the netCDF interfaces of the domain and its components. If True (the default) then any sub-groups will be created and populated.
- group:
- Returns:
xarray.Datasetorxarray.DataTreeThe equivalent
xarraydataset.If there are no sub-groups of the root group, or if group is False, then an
xarray.Datasetis returned.If there are sub-groups of the root group and group is True, then an
xarray.DataTreeis returned.