metobs_toolkit.modeltimeseries.ModelTimeSeries#
- class ModelTimeSeries(site, datarecords: ~numpy.ndarray, timestamps: ~numpy.ndarray, modelobstype: ~metobs_toolkit.obstypes.ModelObstype, datadtype: type = <class 'numpy.float32'>, timezone: str = 'UTC', modelname: str | None = None, modelvariable: str | None = None, _convert_to_standard_units: bool = True)[source]#
Class for model-based timeseries at one location.
This class stores model data at a specific location and automatically converts the data from the model’s native units to standard units as defined by the observation type. The unit conversion is performed during initialization.
- Parameters:
site (object) – The site object representing the location.
datarecords (np.ndarray) – Array of data records in the model’s native units. These will be automatically converted to standard units during initialization.
timestamps (np.ndarray) – Array of timestamps corresponding to the data records.
modelobstype (ModelObstype) – The observation type containing unit information. Must have a model_unit attribute set for unit conversion to work properly.
datadtype (type, optional) – Data type for the records, by default np.float32.
timezone (str, optional) – Timezone for the timestamps, by default “UTC”.
modelname (str, optional) – Name of the model, by default None.
modelvariable (str, optional) – Name of the model variable, by default None.
Notes
The stored data in the series attribute will be in standard units as defined by modelobstype.std_unit, not in the original model units. The conversion is performed automatically.
- Raises:
MetObsUnitUnknown – If the modelobstype does not have a model_unit set, which is required for unit conversion.
- __init__(site, datarecords: ~numpy.ndarray, timestamps: ~numpy.ndarray, modelobstype: ~metobs_toolkit.obstypes.ModelObstype, datadtype: type = <class 'numpy.float32'>, timezone: str = 'UTC', modelname: str | None = None, modelvariable: str | None = None, _convert_to_standard_units: bool = True)[source]#
Initialize a ModelTimeSeries with data and model metadata.
- Parameters:
site (Site) – The site object representing the measurement location.
datarecords (numpy.ndarray) – Observation values in the model’s native units. Automatically converted to standard units unless _convert_to_standard_units is
False.timestamps (numpy.ndarray) – Timestamps corresponding to datarecords.
modelobstype (ModelObstype) – Observation type that carries unit-conversion and band information.
datadtype (type, optional) – Numeric dtype for the stored series. Default is
numpy.float32.timezone (str, optional) – Timezone of timestamps. Default is
'UTC'.modelname (str, optional) – Human-readable name of the model (e.g.
'ERA5_land').modelvariable (str, optional) – Model variable / band name.
_convert_to_standard_units (bool, optional) – If
True(default), converts datarecords from model units to standard units. Set toFalsewhen data are already in standard units (e.g. during__add__).
- Raises:
TypeError – If modelobstype is not a
ModelObstypeinstance.MetObsUnitUnknown – If the
model_unitof modelobstype isNone.
Methods
__init__(site, datarecords, timestamps, ...)Initialize a ModelTimeSeries with data and model metadata.
get_info([printout])Print or return information about the ModelTimeSeries.
make_plot([linecolor, ax, figkwargs, title])Create a plot of the model time series.
pd_plot(**pdplotkwargs)A wrapper on the pandas.series.plot function for ModelTimeSeries.
to_xr()Convert a Modelimeseries object to an xarray.Dataset.
Attributes
ModelTimeSeries DataFrame constructor.
Return the end datetime of the series.
Return the frequency of the series.
Return the start datetime of the series.
Return the name of the station this SensorData belongs to.
Return the timezone of the stored timestamps.