@@ -190,25 +190,17 @@ def _parse_dimensions(self):
190
190
"attrs" : [attrs [dim ] for dim in dims ],
191
191
}
192
192
193
- def get_name (self ) -> str :
193
+ @property
194
+ def name (self ) -> str :
194
195
"""
195
- Get the name of the grid from the grid header.
196
-
197
- Returns
198
- -------
199
- name
200
- The name of the grid.
196
+ Name of the grid.
201
197
"""
202
198
return "z"
203
199
204
- def get_data_attrs (self ) -> dict :
200
+ @property
201
+ def data_attrs (self ) -> dict [str , Any ]:
205
202
"""
206
- Get the attributes for the data variable from the grid header.
207
-
208
- Returns
209
- -------
210
- attrs
211
- The attributes for the data variable.
203
+ Attributes for the data variable from the grid header.
212
204
"""
213
205
attrs : dict [str , Any ] = {}
214
206
attrs ["Conventions" ] = "CF-1.7"
@@ -223,56 +215,33 @@ def get_data_attrs(self) -> dict:
223
215
attrs ["actual_range" ] = np .array ([self .z_min , self .z_max ])
224
216
return attrs
225
217
226
- def get_dims (self ):
218
+ @property
219
+ def dims (self ) -> list :
227
220
"""
228
- Get the dimension names from the grid header.
229
-
230
- Returns
231
- -------
232
- dims : tuple
233
- The dimension names.
221
+ List of dimension names.
234
222
"""
235
223
if not hasattr (self , "_nc" ):
236
224
self ._parse_dimensions ()
237
225
return self ._nc ["dims" ]
238
226
239
- def get_dim_attrs (self ) -> list :
227
+ @property
228
+ def dim_attrs (self ) -> list [dict ]:
240
229
"""
241
- Get the attributes for each dimension from the grid header.
242
-
243
- Returns
244
- -------
245
- attrs
246
- List of attributes for each dimension.
230
+ List of attributes for each dimension.
247
231
"""
248
232
if not hasattr (self , "_nc" ):
249
233
self ._parse_dimensions ()
250
234
return self ._nc ["attrs" ]
251
235
252
- def get_gtype (self ) -> int :
236
+ @property
237
+ def gtype (self ) -> int :
253
238
"""
254
- Get the grid type from the grid header .
239
+ Grid type. 0 for Cartesian grid and 1 for geographic grid .
255
240
256
241
The grid is assumed to be Cartesian by default. If the x/y dimensions are named
257
242
"lon"/"lat" or have units "degrees_east"/"degrees_north", then the grid is
258
243
assumed to be geographic.
259
-
260
- Returns
261
- -------
262
- gtype
263
- The grid type. 0 for Cartesian grid and 1 for geographic grid.
264
244
"""
265
- dims = self .get_dims ()
245
+ dims = self .dims
266
246
gtype = 1 if dims [0 ] == "lat" and dims [1 ] == "lon" else 0
267
247
return gtype
268
-
269
- def get_registration (self ) -> int :
270
- """
271
- Get the grid registration from the grid header.
272
-
273
- Returns
274
- -------
275
- registration
276
- The grid registration. 0 for gridline and 1 for pixel.
277
- """
278
- return self .registration
0 commit comments