Emission Profile Calculator
Collection of classes and functions for managing and calculating emission profiles of emissions from multiple reservoirs constructed at different dates.
- class reemission.profile.AssetSimDateManager(construction_year: int | None = None, sim_start_year: int | None = None)[source]
Manages construction and simulation dates for asset simulations.
- construction_date
The construction date of the asset.
- Type:
datetime
- sim_start_date
The start date for the simulation.
- Type:
datetime
- asset_status()[source]
Returns the construction stage of the asset.
- asset_age()
Returns the age of the asset.
- property asset_age: int
Calculates the asset age in years.
- asset_status() AssetConstructionStage [source]
Determines the asset status (EXISTING/FUTURE) based on its age.
- construction_date: datetime
- sim_start_date: datetime
- class reemission.profile.CombinedEmissionProfile(emission_profiles: dataclasses.InitVar[Iterable[reemission.profile.EmissionProfileSeries]])[source]
Represents a combined emission profile from multiple sources.
Note
Enables addition of several profiles from different reservoirs constructed in different years. Enforces that each of the added emission profiles has to have the same length and unit.
- emission_profiles
The list of emission profiles to combine.
- Type:
Iterable[EmissionProfileSeries]
- profile
The combined emission profile.
- Type:
- unit()
Returns the unit of the combined emission profile.
- plot(title, marker, linestyle, linewidth)[source]
Plots the combined emission profile.
- __post_init__(emission_profiles: Iterable[EmissionProfileSeries]) None [source]
- emission_profiles: dataclasses.InitVar[Iterable[reemission.profile.EmissionProfileSeries]]
- plot(title: str = 'Combined emission profile', marker: str = 'o', linestyle: str = '-', linewidth: float = 1.0) None [source]
Plots the combined emission profile.
- Parameters:
title (str) – The title of the plot.
marker (str) – The marker style.
linestyle (str) – The line style.
linewidth (float) – The line width.
- profile: EmissionProfileSeries
- property unit: str
Returns the unit of the combined emission profile.
- class reemission.profile.EmissionProfile(values: Iterable[EmissionQuantity], years: Iterable[int])[source]
Stores and manipulates emission profiles.
- values
List of emission quantities.
- Type:
Iterable[EmissionQuantity]
- years
List of corresponding years.
- Type:
Iterable[int]
- __next__()[source]
Returns the next emission quantity.
- convert_unit(new_unit)[source]
Converts all emission quantities to a new unit.
- unit(check_consistency)[source]
Returns the unit of the emission profile.
- _is_equally_spaced(spacing)[source]
Checks if the years are equally spaced.
- interpolate(spacing)[source]
Interpolates the emission profile to have equally spaced years.
- plot()[source]
Plots the emission profile.
- to_series(construction_year, interpolate)[source]
Converts the emission profile to a Pandas Series.
- convert_unit(new_unit: str) None [source]
Converts all emission quantities in the profile to a different unit.
- interpolate(spacing: int = 1) EmissionProfile [source]
Construct emission profile with equal year spacing given in argument spacing (default = 1) spanning from the first to the last year in self.years
- plot() None [source]
Plots the emission profile.
Attention
Not implemented yet.
- to_series(construction_year: int, interpolate: bool = False) EmissionProfileSeries [source]
Converts the emission profile (a list of emission quantities) to a Pandas Series with DateTimeIndex.
Hint
Allows subsequent addition of multiple profiles with different lengths and starting/ending in different years.
- Parameters:
construction_year (int) – The construction year of the reservoir.
interpolate (bool) – Whether to interpolate the profile if years are not equally spaced.
- Raises:
YearsNotEquallySpacedError – If emissions in are not equally spaced.
- Returns:
The emission profile as a Pandas Series.
- Return type:
- unit(check_consistency: bool = False) str [source]
Returns the unit of the emission profile.
- values: Iterable[EmissionQuantity]
- years: Iterable[int]
- class reemission.profile.EmissionProfileCalculator(profile_fun: Callable[[int], EmissionQuantity])[source]
Calculates emission profiles using a provided profile function.
Note
It is assumed that emission functions for years above certain time horizon plateau and becomes constant.
- time_horizon
The time horizon for the emission profile.
- Type:
ClassVar[int]
- profile_fun
The function to calculate emissions.
- Type:
Callable[[int], EmissionQuantity]
- emission(no_years)[source]
Calculates the emission for a given number of years.
- calculate(years)[source]
Calculates the emission profile for a range of years.
- integrate(start_year, end_year)[source]
Integrates the emission profile over a range of years.
- calculate(years: Iterable[int]) EmissionProfile [source]
Calculates the emission profile for a range of years.
- Parameters:
years (Iterable[int]) – The range of years.
- Returns:
The calculated emission profile.
- Return type:
- emission(no_years: int) EmissionQuantity [source]
Calculates the emission for a given number of years elapsed from impoundment.
- Parameters:
no_years (int) – The number of years elapsed from impoundment.
- Returns:
The calculated emission.
- Return type:
- integrate(start_year: int = 0, end_year: int | None = None) EmissionQuantity [source]
Integrates the emission profile over a range of years.
Note
Uses scipy’s trapezoidal rule.
- Parameters:
start_year (int) – The start year for the integration.
end_year (Optional[int]) – The end year for the integration.
- Returns:
The integrated emission quantity.
- Return type:
- profile_fun: Callable[[int], EmissionQuantity]
- time_horizon: ClassVar[int] = 100
- class reemission.profile.EmissionProfileSeries(values: pd.Series[EmissionQuantity], unit: str)[source]
Represents an emission profile as a Pandas Series.
- values
The emission profile values.
- Type:
pd.Series[EmissionQuantity]
- unit
The unit of the emission profile.
- Type:
str
- plot(title, marker, linestyle, linewidth)[source]
Plots the emission profile.
- plot(title: str, marker: str = 'o', linestyle: str = '-', linewidth: float = 1.0) None [source]
Plots the emission profile as a Pandas time-series.
- Parameters:
title (str) – The title of the plot.
marker (str) – The marker style.
linestyle (str) – The line style.
linewidth (float) – The line width.
- unit: str
- values: pd.Series[EmissionQuantity]
- class reemission.profile.EmissionQuantity(value: float, unit: str = <property object>)[source]
Represents emission magnitude and unit.
- value
The emission value.
- Type:
float
- unit
The unit of the emission.
- Type:
str
- convert_unit(new_unit)[source]
Converts the emission quantity to a different unit.
- __add__(emission2)[source]
Adds two emission quantities.
- __sub__(emission2)[source]
Subtracts two emission quantities.
- __add__(emission2: EmissionQuantity) EmissionQuantity [source]
Adds two emission quantities.
Note
Currently supports single units but it is meant to expand to adding emissions with different units using unit conversion tools like pint.
- __sub__(emission2: EmissionQuantity) EmissionQuantity [source]
Subtracts two emission quantities.
Note
Currently supports single units but it is meant to expand to adding emissions with different units using unit conversion tools like pint.
- convert_unit(new_unit: str) None [source]
Converts the emission quantity to a different unit.
- Model: self.value = self.value * CONV_VALUE
self.unit = new_unit
Attention
Not implemented yet.
- property unit: str
Returns the unit as a string.
- value: float
- class reemission.profile.TotalEmissionCalculator(integral_fun: Callable[[int], EmissionQuantity])[source]
Calculates total emissions using an analytical integral function.
- time_horizon
The time horizon for the emission profile.
- Type:
ClassVar[int]
- integral_fun
The function to calculate total emissions.
- Type:
Callable[[int], EmissionQuantity]
- calculate(start_year, end_year)[source]
Calculates total emissions over a range of years.
- calculate(start_year: int = 0, end_year: int | None = None) EmissionQuantity [source]
Calculates total emissions over a range of years.
Note
If integral function integral_fun not given, use numerical integration.
- Parameters:
start_year (int) – The start year for the calculation.
end_year (Optional[int]) – The end year for the calculation.
- Returns:
The calculated total emission.
- Return type:
- integral_fun: Callable[[int], EmissionQuantity]
- time_horizon: ClassVar[int] = 100
- exception reemission.profile.YearsNotEquallySpacedError[source]
Custom exception raised if years in the emission profile are not equally spaced.