EmissionsReader¶
Module for reading and processing emissions-related data.
This module provides functionality to read and analyze emissions data from various energy sources (coal, oil, gas) and calculate emissions factors. It handles both direct emissions from fuel consumption and indirect emissions from refining processes.
Key Features
- Emissions factors for different fuel types
- Energy conversion rates
- Price data handling for fuels
- Local currency unit (LCU) conversions
- Refining process emissions calculations
Classes:
| Name | Description |
|---|---|
- EmissionsReader |
Reads and processes fuel price data |
- EmissionsData |
Stores emissions factors in local currency units |
- EmissionsEnergyFactors |
Manages energy-to-emissions conversion factors |
Example
Note
- All emissions factors are in tCO2 (metric tons of CO2)
- Energy units vary by fuel type (tons, barrels, MBTU)
- Prices are expected in USD
EmissionsReader
dataclass
¶
Reader class for emissions-related price data.
This class handles reading and processing price data for different fuel types (coal, oil, gas) and calculates emissions factors based on these prices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prices_df
|
DataFrame
|
DataFrame containing fuel prices with columns 'coal_price', 'oil_price', and 'gas_price' |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
prices_df |
DataFrame
|
DataFrame containing historical fuel prices, indexed by date with columns for each fuel type |
prices_df: pd.DataFrame
instance-attribute
¶
__init__(prices_df: pd.DataFrame) -> None
¶
read_price_data(data_path: Path | str)
classmethod
¶
Read fuel price data from CSV files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_path
|
Path | str
|
Path to directory containing price data files (downloaded from the |
required |
Federal
|
Reserve Bank of St. Louis FRED database
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
EmissionsReader |
New instance with loaded price data |
Note
- Expects specific file names for each fuel type
- Resamples data to yearly frequency (first value of each year)
- All prices should be in USD
get_emissions_factors(year: int) -> dict[str, float]
¶
Calculate emissions factors for each fuel type based on prices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Year to get emissions factors for |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
dict[str, float]: Dictionary mapping fuel types ('coal', 'oil', 'gas') to their emissions factors in tCO2 per USD |
Note
Emissions factors are calculated by dividing the standard emissions factor for each fuel by its price, giving tCO2 per USD spent