Skip to content
Snippets Groups Projects

Add docs, tests for data interface

1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
+ 23
1
@@ -30,6 +30,8 @@ class VariableType(IntEnum):
class DataStore1001:
"""Data model for FFI1001"""
def __init__(self, ivar, dvars):
self.ivarname = ivar.shortname
@@ -111,6 +113,8 @@ class DataStore1001:
class DataStore2110(collections.UserDict):
"""Data model for FFI2110"""
def __init__(self, ivar, ibvar, auxvars, dvars):
self.ivarname = ivar.shortname
self.ibvarname = ibvar.shortname
@@ -162,6 +166,19 @@ class DataStore2110(collections.UserDict):
self.data[ivarValue] = {"AUX": auxds, "DEP": depds}
def add(self, newAuxData, newDepData):
"""(bulk) add data, providing (structured) numpy arrays for both the auxiliary and dependent data line(s)
for a given ivar value.
Arrays have to have shape [ (ivar, auxvar, auxvar, ...) ] and
[ (ibvar, depvar, depvar, ...), ... ] for auxiliary and dependent data line(s), respectively.
missing values have to be set to np.nan.
:param newAuxData: auxiliary data line to be added
:type newAuxData: numpy.ndarray
:param newDepData: auxiliary data line(s) to be added
:type newDepData: numpy.ndarray
"""
auxds = DataStore1001(self.ivar, self.auxvars)
depds = DataStore1001(self.ibvar, self.dvars)
@@ -424,7 +441,12 @@ class Dataset:
if self.defineMode:
return np.datetime64("NaT")
if self.data.data is None or self.data.data == {}:
# for 1001, its an array, for 2110 a dict
if not isinstance(self.data.data, (np.ndarray, dict)):
return np.datetime64("NaT")
# it is possible to have an empty dict
if isinstance(self.data.data, dict) and not self.data.data:
return np.datetime64("NaT")
ref_dt = np.datetime64(datetime.datetime(*self.dateOfCollection), "ns")
Loading