Skip to content

internals

Module internals contains ...

internal_get_single_model_time_series(ts_provider, var_id, api_get_ts_func)

Internal only - Perform an action on a uchronia object that is expected to return a time series

Perform an action on a uchronia object that is expected to return a time series. This function is internal to the package, to prevent code duplication between retrieval of time series from a time series provider, or played/recorded time series into/out of a model simulation

Parameters:

Name Type Description Default
ts_provider TimeSeriesProvider

an external pointer to a uchronia Time Series Provider or model simulation

required
var_id str

character, a data identifier for the time series

required
api_get_ts_func TsRetrievalSignature

a function, that takes as arguments ts_provider and varId, and returns a list as suitable for marshaledTimeSeriesToXts

required

Returns:

Name Type Description
NdTimeSeries NdTimeSeries

a uni- or multidimensional time series

Source code in uchronia/internals.py
def internal_get_single_model_time_series(
    ts_provider: "TimeSeriesProvider", var_id: str, api_get_ts_func: "TsRetrievalSignature"
) -> "NdTimeSeries":
    """
    Internal only - Perform an action on a uchronia object that is expected to return a time series

    Perform an action on a uchronia object that is expected to return a time series.
    This function is internal to the package, to prevent code duplication between
    retrieval of time series from a time series provider, or played/recorded
    time series into/out of a model simulation

    Args:
        ts_provider (TimeSeriesProvider): an external pointer to a uchronia Time Series Provider or model simulation
        var_id (str): character, a data identifier for the time series
        api_get_ts_func (TsRetrievalSignature): a function, that takes as arguments ts_provider and varId, and returns a list as suitable for marshaledTimeSeriesToXts

    Returns:
        NdTimeSeries: a uni- or multidimensional time series

    """
    if not isinstance(var_id, str):
        raise ValueError(
            "internal_get_single_model_time_series must work on a single variable identifier"
        )
    time_series_info = api_get_ts_func(ts_provider, var_id)
    # return(marshaledTimeSeriesToXts(time_series_info))
    return time_series_info

is_ensemble_time_series(s)

Is the object a 'uchronia' ensemble of time series

Is the object a 'uchronia' ensemble of time series

Parameters:

Name Type Description Default
s Any

an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer

required
Source code in uchronia/internals.py
def is_ensemble_time_series(s: Any):
    """
    Is the object a 'uchronia' ensemble of time series

    Is the object a 'uchronia' ensemble of time series

    Args:
        s (Any): an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer

    """
    return is_cffi_native_handle(s, type_id="ENSEMBLE_PTR_TIME_SERIES_PTR")

is_singular_time_series(s)

Is the object a 'uchronia' univariate time series

Is the object a 'uchronia' univariate time series

Parameters:

Name Type Description Default
s Any

an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer

required
Source code in uchronia/internals.py
def is_singular_time_series(s: Any):
    """
    Is the object a 'uchronia' univariate time series

    Is the object a 'uchronia' univariate time series

    Args:
        s (Any): an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer

    """
    return is_cffi_native_handle(s, type_id="TIME_SERIES_PTR")

is_time_series_of_ensemble_time_series(s)

Is the object a 'uchronia' time series of ensembles of time series

Is the object a 'uchronia' time series of ensembles of time series

Parameters:

Name Type Description Default
s Any

an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer

required
Source code in uchronia/internals.py
def is_time_series_of_ensemble_time_series(s: Any):
    """
    Is the object a 'uchronia' time series of ensembles of time series

    Is the object a 'uchronia' time series of ensembles of time series

    Args:
        s (Any): an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer

    """
    return is_cffi_native_handle(s, type_id="ENSEMBLE_FORECAST_TIME_SERIES_PTR")