gcages.harmonisation.common#
Common tools across different approaches
Classes:
| Name | Description |
|---|---|
NotHarmonisedError |
Raised when a pd.DataFrame is not harmonised |
Functions:
| Name | Description |
|---|---|
align_history_to_data_at_time |
Align history to a given set of data for a given column |
assert_harmonised |
Assert that the input is harmonised |
NotHarmonisedError #
Bases: ValueError
Raised when a pd.DataFrame is not harmonised
Methods:
| Name | Description |
|---|---|
__init__ |
Initialise the error |
Source code in src/gcages/harmonisation/common.py
__init__ #
__init__(
comparison: DataFrame, harmonisation_time: TIME_POINT
) -> None
Initialise the error
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comparison
|
DataFrame
|
Results of comparing the data and history |
required |
harmonisation_time
|
TIME_POINT
|
Expected harmonisation time |
required |
Source code in src/gcages/harmonisation/common.py
align_history_to_data_at_time #
align_history_to_data_at_time(
df: TimeseriesDataFrame,
*,
history: TimeseriesDataFrame,
time: Any,
) -> tuple[Series[NUMERIC_DATA], Series[NUMERIC_DATA]]
Align history to a given set of data for a given column
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
TimeseriesDataFrame
|
Data to which to align history |
required |
history
|
TimeseriesDataFrame
|
History data to align |
required |
time
|
Any
|
Time (i.e. column) for which to align the data |
required |
Returns:
| Type | Description |
|---|---|
tuple[Series[NUMERIC_DATA], Series[NUMERIC_DATA]]
|
History, aligned with |
Raises:
| Type | Description |
|---|---|
AssertionError
|
|
Source code in src/gcages/harmonisation/common.py
assert_harmonised #
assert_harmonised(
df: TimeseriesDataFrame,
*,
history: TimeseriesDataFrame,
harmonisation_time: TIME_POINT,
rounding: int = 10,
df_unit_level: str = "unit",
history_unit_level: str | None = None,
ur: UnitRegistry | None = None,
) -> None
Assert that the input is harmonised
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
TimeseriesDataFrame
|
Data to check |
required |
history
|
TimeseriesDataFrame
|
History to which |
required |
harmonisation_time
|
TIME_POINT
|
Time at which |
required |
rounding
|
int
|
Rounding to apply to the data before comparing |
10
|
df_unit_level
|
str
|
Level in Only used if unit conversion is required |
'unit'
|
history_unit_level
|
str | None
|
Level in If not provided, we assume this is the same as Only used if unit conversion is required |
None
|
ur
|
UnitRegistry | None
|
Unit registry to use for determining unit conversions Passed to gcages.units_helpers.convert_unit_like Only used if unit conversion is required |
None
|
Raises:
| Type | Description |
|---|---|
NotHarmonisedError
|
|