Commit e7c17d88 authored by PIOLLE's avatar PIOLLE
Browse files

added sizes attr in Field class + updated default time dtype when saving to netcdf

parent 19080530
...@@ -2135,7 +2135,7 @@ class Dataset(ABC): ...@@ -2135,7 +2135,7 @@ class Dataset(ABC):
self.add_field_attrs(dataset, vattrs, force_profile=force_profile) self.add_field_attrs(dataset, vattrs, force_profile=force_profile)
# add field encoding from custom settings # add field encoding from custom settings
self.add_field_encoding(dataset, encoding) self.add_field_encoding(dataset, encoding, force_profile=force_profile)
return dataset return dataset
......
...@@ -331,10 +331,18 @@ class Field(object): ...@@ -331,10 +331,18 @@ class Field(object):
self._array.encoding = attrs self._array.encoding = attrs
@property @property
def dims(self) -> Tuple[str, int]: def sizes(self) -> Mapping[Hashable, int]:
"""A tuple of the field dimensions name and size""" """A tuple of the field dimensions name and size"""
if self.dataset is None: if self.dataset is None:
return tuple(self._array.dims) return self._array.sizes
else:
return self.dataset.get_field_sizes(self.name)
@property
def dims(self) -> Tuple[str]:
"""A tuple of the field dimensions name and size"""
if self.dataset is None:
return self._array.dims.keys()
else: else:
return self.dataset.get_field_sizes(self.name) return self.dataset.get_field_sizes(self.name)
...@@ -463,7 +471,7 @@ class Field(object): ...@@ -463,7 +471,7 @@ class Field(object):
self.attrs['standard_name'] = standard_name[0] self.attrs['standard_name'] = standard_name[0]
self.attrs['authority'] = standard_name[1] self.attrs['authority'] = standard_name[1]
elif standard_name is not None: elif standard_name is not None:
self.attrs['standard_name'] = standard_name[0] self.attrs['standard_name'] = standard_name
self.attrs['authority'] = cf.CF_AUTHORITY self.attrs['authority'] = cf.CF_AUTHORITY
else: else:
self.attrs['standard_name'] = None self.attrs['standard_name'] = None
......
...@@ -91,12 +91,15 @@ encoding: ...@@ -91,12 +91,15 @@ encoding:
lat: lat:
dtype: float32 dtype: float32
_FillValue: 1.e+20
least_significant_digit: 3 least_significant_digit: 3
lon: lon:
dtype: float32 dtype: float32
_FillValue: 1.e+20
least_significant_digit: 3 least_significant_digit: 3
time: time:
dtype: int32 dtype: float64
_FillValue: 1.e+20
units: 'seconds since 1981-01-01 00:00:00.000000Z' units: 'seconds since 1981-01-01 00:00:00.000000Z'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment