forked from NCAS-CMS/cf-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcfimplementation.py
More file actions
224 lines (187 loc) · 6.83 KB
/
Copy pathcfimplementation.py
File metadata and controls
224 lines (187 loc) · 6.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import cfdm
from . import (
AuxiliaryCoordinate,
Bounds,
CellConnectivity,
CellMeasure,
CellMethod,
CoordinateConversion,
CoordinateReference,
Count,
Datum,
DimensionCoordinate,
Domain,
DomainAncillary,
DomainAxis,
DomainTopology,
Field,
FieldAncillary,
Index,
InteriorRing,
InterpolationParameter,
List,
NodeCountProperties,
PartNodeCountProperties,
Quantization,
TiePointIndex,
)
from .data import Data
from .data.array import (
AggregatedArray,
BoundsFromNodesArray,
CellConnectivityArray,
GatheredArray,
H5netcdfArray,
NetCDF4Array,
PointTopologyArray,
PyfiveArray,
RaggedContiguousArray,
RaggedIndexedArray,
RaggedIndexedContiguousArray,
ScipyNetcdfFileArray,
SubsampledArray,
ZarrArray,
)
from .functions import CF
class CFImplementation(cfdm.CFDMImplementation):
"""A container for the CF data model implementation for `cf`.
.. versionadded:: 3.0.0
"""
def nc_set_dataset_chunksizes(self, data, sizes, override=False):
"""Set the data dataset chunksizes.
.. versionadded:: 3.16.2
:Parameters:
data: `Data`
The data.
sizes: sequence of `int`
The new dataset chunk sizes.
override: `bool`, optional
If True then set the dataset chunks sizes even if some
have already been specified. If False, the default,
then only set the dataset chunks sizes if some none
have already been specified.
:Returns:
`None`
"""
if override or not data.nc_dataset_chunksizes():
data.nc_set_dataset_chunksizes(sizes)
def set_construct(self, parent, construct, axes=None, copy=True, **kwargs):
"""Insert a construct into a field or domain.
Does not attempt to conform cell method nor coordinate
reference constructs, as that has been handled by `cfdm`.
.. versionadded:: 3.14.0
:Parameters:
parent: `Field` or `Domain`
On what to set the construct
construct:
The construct to set.
axes: `tuple` or `None`, optional
The construct domain axes, if applicable.
copy: `bool`, optional
Whether or not to set a copy of *construct*.
kwargs: optional
Additional parameters to the `set_construct` method of
*parent*.
:Returns:
`str`
The construct identifier.
"""
kwargs.setdefault("conform", False)
return super().set_construct(
parent, construct, axes=axes, copy=copy, **kwargs
)
_implementation = CFImplementation(
cf_version=CF(),
AggregatedArray=AggregatedArray,
AuxiliaryCoordinate=AuxiliaryCoordinate,
CellConnectivity=CellConnectivity,
CellMeasure=CellMeasure,
CellMethod=CellMethod,
CoordinateReference=CoordinateReference,
DimensionCoordinate=DimensionCoordinate,
Domain=Domain,
DomainAncillary=DomainAncillary,
DomainAxis=DomainAxis,
DomainTopology=DomainTopology,
Field=Field,
FieldAncillary=FieldAncillary,
Bounds=Bounds,
InteriorRing=InteriorRing,
InterpolationParameter=InterpolationParameter,
CoordinateConversion=CoordinateConversion,
Datum=Datum,
List=List,
Index=Index,
Count=Count,
NodeCountProperties=NodeCountProperties,
PartNodeCountProperties=PartNodeCountProperties,
Data=Data,
BoundsFromNodesArray=BoundsFromNodesArray,
CellConnectivityArray=CellConnectivityArray,
GatheredArray=GatheredArray,
H5netcdfArray=H5netcdfArray,
NetCDF4Array=NetCDF4Array,
ScipyNetcdfFileArray=ScipyNetcdfFileArray,
PointTopologyArray=PointTopologyArray,
PyfiveArray=PyfiveArray,
Quantization=Quantization,
RaggedContiguousArray=RaggedContiguousArray,
RaggedIndexedArray=RaggedIndexedArray,
RaggedIndexedContiguousArray=RaggedIndexedContiguousArray,
SubsampledArray=SubsampledArray,
TiePointIndex=TiePointIndex,
ZarrArray=ZarrArray,
)
def implementation():
"""Return a container for the CF data model implementation.
.. versionadded:: 3.1.0
.. seealso:: `cf.example_field`, `cf.read`, `cf.write`
:Returns:
`CFImplementation`
A container for the CF data model implementation.
**Examples**
>>> i = cf.implementation()
>>> i
<CFImplementation: >
>>> i.classes()
{'AuxiliaryCoordinate': cf.auxiliarycoordinate.AuxiliaryCoordinate,
'BoundsFromNodesArray': cf.data.array.boundsfromnodesarray.BoundsFromNodesArray,
'CellConnectivity': cf.cellconnectivity.CellConnectivity,
'CellConnectivityArray': cf.data.array.cellconnectivityarray.CellConnectivityArray,
'CellMeasure': cf.cellmeasure.CellMeasure,
'CellMethod': cf.cellmethod.CellMethod,
'CoordinateReference': cf.coordinatereference.CoordinateReference,
'DimensionCoordinate': cf.dimensioncoordinate.DimensionCoordinate,
'Domain': cf.domain.Domain,
'DomainAncillary': cf.domainancillary.DomainAncillary,
'DomainAxis': cf.domainaxis.DomainAxis,
'DomainTopology': cf.domaintopology.DomainTopology,
'Field': cf.field.Field,
'FieldAncillary': cf.fieldancillary.FieldAncillary,
'Bounds': cf.bounds.Bounds,
'InteriorRing': cf.interiorring.InteriorRing,
'InterpolationParameter': cf.interpolationparameter.InterpolationParameter,
'CoordinateConversion': cf.coordinateconversion.CoordinateConversion,
'Datum': cf.datum.Datum,
'List': cf.list.List,
'Index': cf.index.Index,
'Count': cf.count.Count,
'NodeCountProperties': cf.nodecountproperties.NodeCountProperties,
'PartNodeCountProperties': cf.partnodecountproperties.PartNodeCountProperties,
'Data': cf.data.data.Data,
'GatheredArray': cf.data.array.gatheredarray.GatheredArray,
'H5netcdfArray': cf.data.array.h5netcdfarray.H5netcdfArray,
'NetCDF4Array': cf.data.array.netcdf4array.NetCDF4Array,
'ScipyNetcdfFileArray': cf.data.array.scipynetcdffilearray.ScipyNetcdfFileArray,
'PointTopologyArray': <class 'cf.data.array.pointtopologyarray.PointTopologyArray'>,
'PyfiveArray': cf.data.array.pyfivearray.PyfiveArray,
'Quantization': cf.quantization.Quantization,
'RaggedContiguousArray': cf.data.array.raggedcontiguousarray.RaggedContiguousArray,
'RaggedIndexedArray': cf.data.array.raggedindexedarray.RaggedIndexedArray,
'RaggedIndexedContiguousArray': cf.data.array.raggedindexedcontiguousarray.RaggedIndexedContiguousArray,
'SubsampledArray': cf.data.array.subsampledarray.SubsampledArray,
'TiePointIndex': cf.tiepointindex.TiePointIndex,
'ZarrArray': cf.data.array.zarrarray.ZarrArray,
}
"""
return _implementation.copy()