gcages.harmonisation#
General harmonisation tools
Modules:
| Name | Description |
|---|---|
aneris |
Harmonisation using aneris |
common |
Common tools across different approaches |
Classes:
| Name | Description |
|---|---|
AnerisHarmoniser |
Harmoniser that uses aneris |
NotHarmonisedError |
Raised when a pd.DataFrame is not harmonised |
Functions:
| Name | Description |
|---|---|
assert_harmonised |
Assert that the input is harmonised |
AnerisHarmoniser #
Harmoniser that uses aneris
Methods:
| Name | Description |
|---|---|
__call__ |
Harmonise |
validate_aneris_overrides |
Validate the aneris overrides value |
validate_historical_emissions |
Validate the historical emissions value |
Attributes:
| Name | Type | Description |
|---|---|---|
aneris_overrides |
Series[str] | None
|
Overrides to supply to |
harmonisation_year |
int
|
Year in which to harmonise |
historical_emissions |
DataFrame
|
Historical emissions to use for harmonisation |
n_processes |
int | None
|
Number of processes to use for parallel processing. |
progress |
bool
|
Should progress bars be shown for each operation? |
region_level |
str
|
Level in data indexes that represents the region of the timeseries |
run_checks |
bool
|
If |
scenario_group_levels |
list[str]
|
Levels in data indexes to use to group data into scenarios |
unit_level |
str
|
Level in data indexes that represents the unit of the timeseries |
variable_level |
str
|
Level in data indexes that represents the variable of the timeseries |
Source code in src/gcages/harmonisation/aneris.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
aneris_overrides
class-attribute
instance-attribute
#
Overrides to supply to aneris.convenience.harmonise_all
For source code and docs, see e.g. https://github.com/iiasa/aneris/blob/v0.4.2/src/aneris/convenience.py.
historical_emissions
class-attribute
instance-attribute
#
Historical emissions to use for harmonisation
n_processes
class-attribute
instance-attribute
#
Number of processes to use for parallel processing.
Set to None to process in serial.
progress
class-attribute
instance-attribute
#
progress: bool = True
Should progress bars be shown for each operation?
region_level
class-attribute
instance-attribute
#
region_level: str = 'region'
Level in data indexes that represents the region of the timeseries
run_checks
class-attribute
instance-attribute
#
run_checks: bool = True
If True, run checks on both input and output data
If you are sure about your workflow, you can disable the checks to speed things up (but we don't recommend this unless you really are confident about what you're doing).
scenario_group_levels
class-attribute
instance-attribute
#
Levels in data indexes to use to group data into scenarios
Here, 'scenarios' means groups of timeseries that will be run through a climate model.
unit_level
class-attribute
instance-attribute
#
unit_level: str = 'unit'
Level in data indexes that represents the unit of the timeseries
variable_level
class-attribute
instance-attribute
#
variable_level: str = 'variable'
Level in data indexes that represents the variable of the timeseries
__call__ #
Harmonise
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_emissions
|
DataFrame
|
Emissions to harmonise |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Harmonised emissions |
Source code in src/gcages/harmonisation/aneris.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
validate_aneris_overrides #
Validate the aneris overrides value
If self.run_checks is False, then this is a no-op
Source code in src/gcages/harmonisation/aneris.py
validate_historical_emissions #
Validate the historical emissions value
If self.run_checks is False, then this is a no-op
Source code in src/gcages/harmonisation/aneris.py
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
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
|
|