Skip to content

__init__.py

Matt Jamieson edited this page May 18, 2020 · 5 revisions

Description: This is the file containing the main API functions, the functions to be used by the end user. This is also the place where the logging configuration is stored, so if you would like to change the logging level for debugging purposes, it's done here.

Functions:

  • get_generation_process_df() - Create a dataframe of emissions from power generation by fuel type in each region. kwargs would include the upstream emissions dataframe (upstream_df) if upstream emissions are being included.

    Parameters:
    regions : bool, optional
    Regions to include in the analysis (the default is None, which uses the value read from a settings YAML file). Other options include "eGRID", "NERC", "BA", "US", "FERC", and "EIA"

  • get_generation_mix_process_df - Create a dataframe of generation mixes by fuel type in each subregion. This function imports and uses the parameter 'replace_egrid' and 'gen_mix_from_model_generation_data' from model_config.py. If 'replace_egrid' is true or the specified 'regions' is true, then the generation mix will come from EIA 923 data. If 'replace_egrid' is false then the generation mix will either come from the eGRID reference data ('gen_mix_from_model_generation_data' is false) or from the generation data from this model ('gen_mix_from_model_generation_data' is true).

  • write_generation_process_database_to_dict - Create olca formatted dictionaries of individual processes for the dataframe returned by get_generation_process_df.

  • write_generation_mix_database_to_dict - Create olca formatted dictionaries for the dataframe returned by get_generation_mix_process_df. Must pass both the generation mix dataframe and the dictionary from write_generation_process_database_to_dict to properly create the links to the power plant types.

  • write_surplus_pool_and_consumption_mix_dict - Create olca formatted dictionaries for the consumption mix as calculated by consumption_mix.py. Note that this funcion directly pulls the dataframes, converts the data into the dictionary and then returns the dictionary.

  • write_distribution_dict - Create olca formatted dictionaries for the creation of processes that account for electricity distribution losses.

  • write_process_dicts_to_jsonld - Send one or more process dictionaries to be written to json-ld. Multiple dictionaries can be sent to this process at once.

  • get_upstream_process_df() - Automatically loads all of the upstream emissions data from the various modules. Will return a dataframe with upstream emissions from coal, natural gas, petroleum, nuclear, and power plant construction.

  • write_upstream_process_database_to_dict - Convert the upstream dataframe generated by get_upstream_process_df to dictionaries to be written to json-ld.

  • write_upstream_dicts_to_jsonld - Write the upstream dictionaries, created by write_upstream_process_database_to_dict to jsonld.

  • combine_upstream_and_gen_df - Combine the generation and upstream dataframes (passed as parameters) into a single dataframe. The emissions represented here are the annual emissions for all power plants. This dataframe would be suitable for further analysis. This function should return a dataframe with approximately 5 million rows.

  • get_alternate_gen_plus_netl - This will combine the netl life cycle data for solar, solar thermal, geothermal, wind, and hydro and will include impacts from construction, etc. that would be omitted from the regular sources of emissions. It also uses generation.py to get reported power plant emissions. The two different dataframes are combined to provide a single dataframe representing annual emissions or life cycle emissions apportioned over the appropriate number of years for all reporting power plants.

  • aggregate_gen - Runs the alternate aggregation routine to place all emissions and fuel inputs on the basis of a MWh generated at the power plant gate. This is in preparation for generating power plant unit processes for openLCA.

  • add_fuels_to_gen - Add the upstream fuels to the generation dataframe as fuel inputs. This dataframe is suitable for converting into a dictionary and writing to jsonld to see a complete system in openLCA. Note that 4 different items must be passed to this function: dataframes from get_alternate_gen_plus_netl (the generation and Canadian dataframes), get_upstream_process_df, and the upstream dictionary as returned by write_upstream_process_database_to_dict. The reason for the dictionary is to ensure UUIDs can be used for default providers.

  • write_gen_fuel_database_to_dict - Write the generation dataframe that has been augmented with fuel inputs to a dictionary for conversion to openlca.

  • get_distribution_mix_df - Alternative to write_distribution_dict. This function uses EIA data for state-level loss factors. These state-level factors are applied to each plant and then aggregated to the appropriate level. This function returns a dataframe rather than a dictionary.

  • write_distribution_mix_to_dict - Convert the dataframe from get_distribution_mix_df into an openLCA formatted dictionary. Must provide the dataframe from get_distribution_mix_df and the dictionary as returned by write_process_dicts_to_jsonld, again to allow the use of UUIDs for default providers.

  • get_consumption_mix_df - Alternative to write_surplus_pool_and_consumption_mix_dict. This function uses EIA trading data to calculate the consumption mix for balancing authority areas or FERC region. The aggregation choices are limited to these 2 because the data is available only at the balancing authority area.

  • write_consumption_mix_to_dict - Convert the dataframe from get_consumption_mix_df into an openLCA formatted dictionary. The dataframe provided by get_consumption_mix_df and the dictionary returned by write_process_dicts_to_jsonld using the dataframe from get_generation_mix_process_df.

Parameters:

  • regions : str, optional
    Many of the function calls above have a parameter to specify regions (or subregions). Regions to include in the analysis (the default is None, which uses the value read from a settings YAML file). Other options include "eGRID", "NERC", "BA", "US", "FERC", and "EIA".
Clone this wiki locally