RUFAS.EEE.emissions module#

class RUFAS.EEE.emissions.EmissionsEstimator#

Bases: object

Estimates emissions associated with purchased feeds used for animals.

Attributes#

imInputManager

An instance of the InputManager class.

omOutputManager

An instance of the OutputManager class.

crop_species_to_purchased_feed_iddict[str, list[str]]

A dictionary mapping crop species to their corresponding RuFaS feed IDs.

purchased_feed_emissions_by_locationdict[str, float]

A dictionary mapping RuFaS feed IDs to their emissions factors (kg CO2e / kg dry matter) for the location of the simulation.

land_use_change_emissions_by_locationdict[str, float]

A dictionary mapping RuFaS feed IDs to their land use change emissions factors (kg CO2e / kg dry matter) for the location of the simulation.

_missing_purchased_idsset[str]

A set of RuFaS feed IDs that were used in the simulation but do not have purchased feed emissions data.

_missing_land_use_idsset[str]

A set of RuFaS feed IDs that were used in the simulation but do not have land use change emissions data.

__init__() None#
check_available_purchased_feed_data(available_feed_ids: list[int]) None#

Checks that all purchased feed IDs used in the simulation have emissions data available for them.

calculate_purchased_feed_emissions(purchased_feeds: dict[int, float]) None#

Calculates the emissions from purchased feeds and land use changes. If there are feed IDs with missing emissions factor data, they will be omitted from the calculations and not reported.

_get_feed_emissions_data(county_code: int, feed_emissions_data: dict[str, list[float]]) dict[str, float]#

Grabs the appropriate list of emissions for purchased feeds for the location of the simulation.

estimate_farmgrown_feed_emissions() None#

Estimates the emissions and resources used associated with farmgrown feeds production.

_parse_farmgrown_feeds_emission_data() dict[str, dict[str, dict[int, float]]]#

Parses farmgrown feeds emission data from the OutputManager and returns a dictionary with emission data for each field on every simulation day.

_parse_manure_and_fertilizer_application_data(simulation_start_date: datetime) dict[str, dict[str, dict[int, dict[str, float]]]]#

Parses manure and fertilizer application data from the OutputManager and returns a dictionary with application data for each field by simulation day.

_parse_farmgrown_feed_deductions_data(all_simulation_days: list[int]) dict[int, dict[int, float]]#

Parses farmgrown feed deductions data by feed_id and simulation day from the simulation OutputManager.

_parse_crop_to_feed_id_mapping() dict[tuple[str, str], int]#

Parses the mapping of crop names and field names to RUFAS feed IDs.

_parse_harvest_data(crop_to_feed_id_mapping: dict[tuple[str, str], int], simulation_start_date: datetime) dict[str, dict[int, dict[str, Any]]]#

Parses harvest data by field name and simulation day from the simulation OutputManager.

_calculate_daily_farmgrown_feed_emissions_and_resources(emission_data: dict[str, dict[str, dict[int, float]]], resource_data: dict[str, dict[str, dict[int, dict[str, float]]]], harvest_yield_by_field: dict[str, dict[int, dict[str, Any]]], all_simulation_days: list[int]) dict[int, dict[int, dict[str, float]]]#

Calculates daily emissions and resources used for farmgrown feeds production.

_gather_farmgrown_feed_inventory_data(all_simulation_days: list[int]) dict[int, dict[int, float]]#

Gathers farmgrown feed inventory data by feed_id and simulation day index.

_calculate_harvest_dates_by_feed_id(harvest_yield_by_field: dict[str, dict[int, dict[str, Any]]]) dict[int, list[int]]#

Generates a mapping of feed IDs to their respective harvest dates based on the harvest data of multiple fields.

Parameters#

harvest_yield_by_fielddict: dict[str, dict[int, dict[str, Any]]]

A dictionary containing harvest data organized by field name. Each field name maps to another dictionary where keys represent harvest dates, and values are dictionaries containing details like “feed_id”.

Returns#

dict: dict[RUFAS_ID, list[int]]

A dictionary where each key is a feed ID, and the value is a sorted list of harvest dates associated with that feed ID.

_calculate_daily_farmgrown_feed_fed_emissions_and_resources(daily_farmgrown_feed_emissions_and_resources: dict[int, dict[int, dict[str, float]]], feed_deductions_data: dict[int, dict[int, float]], all_simulation_days: list[int]) dict[int, dict[int, dict[str, float]]]#

Calculates daily farmgrown feed emissions and resources used for farmgrown feeds fed to the animals.

_report_daily_farmgrown_feed_fed_emissions_and_resources(daily_farmgrown_feed_fed_emissions_and_resources: dict[int, dict[int, dict[str, float]]]) None#

Reports the emissions and resources for daily farmgrown feeds fed to the animals.

_calculate_and_report_lca_emissions(farm_grown_feeds_fed_to_animals: list[int], feed_deductions_data: dict[int, dict[int, float]]) None#

Calculates and reports LCA and Land-Use-Change emissions.