src/ei_mcoe/ei_mcoe.py
def build_part2_output(raw_eia_df, pudl_out):
    """Compile final data output for Part 2.

    A function that compiles the neccesary data for Part 2 and outputs a
    DataFrame with mcoe variables. It also adds a data validation check for
    heat rate, implementing a boolean to indicate whether there are units
    within the plant/fuel aggregation that are outliers. Finally, it adds a
    field for plant_id_eia.

    Args:
        raw_eia_df (pandas.DataFrame): A DataFrame containing EIA data from the
            pudl_out.mcoe() function that has been run through date_to_year()
            and add_generator_age() functions.

    Returns:
        pandas.DataFrame: A DataFrame with the MCOE variables and calculations.
    """
    logger.info('Building Part 2 output')
    # Prep data for EIA-FERC integration
    eia_plant_fuel_df = prep_plant_fuel_data_eia(raw_eia_df)
    ferc1_plant_df = prep_plant_fuel_data_ferc1(pudl_out)
    # Find EIA fuel breakdown percents and apply them to FERC Form 1 data.
    eia_pct_df = compile_fuel_pcts_eia(raw_eia_df)
    ferc1_plant_fuel_df = disaggregate_ferc1(eia_pct_df, ferc1_plant_df)
    # Merge FERC, EIA, and NEMS; calculate mcoe
    eia_ferc1_merge_df = (
        merge_ferc1_eia_mcoe_factors(eia_plant_fuel_df, ferc1_plant_fuel_df))
    # fixed_var_breakdown_df = calc_fixed_var_breakdown(eia_ferc1_merge_df)
    # Add NEMS data for most recent year O&M cost
    with_nems_df = add_nems(eia_ferc1_merge_df, pudl_out)
    # Check NEMS data against our calculations.
    # fi = with_nems_df.loc[(with_nems_df['fixed_cost'].notna())
    #                       & (with_nems_df['fixed_om_mw_18'].notna())]
    # fi['fixed_NEMS'] = (fi['fixed_om_mw_18'] * fi['net_generation_mwh']
    #                     / fi['capacity_mw'])
    # fi.plot.scatter(x='fixed_NEMS', y='fixed_cost')
    # va = with_nems_df.loc[(with_nems_df['variable_cost'].notna())
    #                       & (with_nems_df['variable_om_mwh_18'].notna())]
    # va['variable_NEMS'] = va['variable_om_mwh_18'] * va['net_generation_mwh']
    # va.plot.scatter(x='variable_NEMS', y='variable_cost')
    logger.info('checking nems inside build_part2_output')
    check_nems_records(with_nems_df, pudl_out)
    # Validate NEMS data_eia
    # validate_nems(with_nems_df)
    # Add significant heat rate identifier (pudl id 125 = Comanche for test)
    with_sig_hr_df = compare_heatrate(raw_eia_df, with_nems_df)
    with_sig_hr_df = with_sig_hr_df  # .round(1)
    logger.info('Finished compiling Part 2 data compilation')
    return with_sig_hr_df
Compile final data output for Part 2.

    A function that compiles the neccesary data for Part 2 and outputs a
    DataFrame with mcoe variables. It also adds a data validation check for
    heat rate, implementing a boolean to indicate whether there are units
    within the plant/fuel aggregation that are outliers. Finally, it adds a
    field for plant_id_eia.

    Args:
        raw_eia_df (pandas.DataFrame): A DataFrame containing EIA data from the
            pudl_out.mcoe() function that has been run through date_to_year()
            and add_generator_age() functions.

    Returns:
        pandas.DataFrame: A DataFrame with the MCOE variables and calculations.
    
Compile final data output for Part 2.
A function that compiles the neccesary data for Part 2 and outputs a
DataFrame with mcoe variables. It also adds a data validation check for
heat rate, implementing a boolean to indicate whether there are units
within the plant/fuel aggregation that are outliers. Finally, it adds a
field for plant_id_eia.
Compile final data output for Part 2 . A function that compiles the neccesary data for Part 2 and outputs a DataFrame with mcoe variables . It also adds a data validation check for heat rate implementing a boolean to indicate whether there are units within the plant / fuel aggregation that are outliers . Finally it adds a field for plant_id_eia .
def build_part2_output(raw_eia_df, pudl_out):
    logger.info('Building Part 2 output')
    eia_plant_fuel_df = prep_plant_fuel_data_eia(raw_eia_df)
    ferc1_plant_df = prep_plant_fuel_data_ferc1(pudl_out)
    eia_pct_df = compile_fuel_pcts_eia(raw_eia_df)
    ferc1_plant_fuel_df = disaggregate_ferc1(eia_pct_df, ferc1_plant_df)
    eia_ferc1_merge_df = (
        merge_ferc1_eia_mcoe_factors(eia_plant_fuel_df, ferc1_plant_fuel_df))
    with_nems_df = add_nems(eia_ferc1_merge_df, pudl_out)
    logger.info('checking nems inside build_part2_output')
    check_nems_records(with_nems_df, pudl_out)
    with_sig_hr_df = compare_heatrate(raw_eia_df, with_nems_df)
    with_sig_hr_df = with_sig_hr_df  
    logger.info('Finished compiling Part 2 data compilation')
    return with_sig_hr_df
def build_part2_output ( raw_eia_df , pudl_out ) : logger . info ( 'Building Part 2 output' ) eia_plant_fuel_df = prep_plant_fuel_data_eia ( raw_eia_df ) ferc1_plant_df = prep_plant_fuel_data_ferc1 ( pudl_out ) eia_pct_df = compile_fuel_pcts_eia ( raw_eia_df ) ferc1_plant_fuel_df = disaggregate_ferc1 ( eia_pct_df , ferc1_plant_df ) eia_ferc1_merge_df = ( merge_ferc1_eia_mcoe_factors ( eia_plant_fuel_df , ferc1_plant_fuel_df ) ) with_nems_df = add_nems ( eia_ferc1_merge_df , pudl_out ) logger . info ( 'checking nems inside build_part2_output' ) check_nems_records ( with_nems_df , pudl_out ) with_sig_hr_df = compare_heatrate ( raw_eia_df , with_nems_df ) with_sig_hr_df = with_sig_hr_df logger . info ( 'Finished compiling Part 2 data compilation' ) return with_sig_hr_df
Compile final data output for Part 2.
Compile final data output for Part 2 .
"""Compile final data output for Part 2.

    A function that compiles the neccesary data for Part 2 and outputs a
    DataFrame with mcoe variables. It also adds a data validation check for
    heat rate, implementing a boolean to indicate whether there are units
    within the plant/fuel aggregation that are outliers. Finally, it adds a
    field for plant_id_eia.

    Args:
        raw_eia_df (pandas.DataFrame): A DataFrame containing EIA data from the
            pudl_out.mcoe() function that has been run through date_to_year()
            and add_generator_age() functions.

    Returns:
        pandas.DataFrame: A DataFrame with the MCOE variables and calculations.
    """ # Prep data for EIA-FERC integration # Find EIA fuel breakdown percents and apply them to FERC Form 1 data. # Merge FERC, EIA, and NEMS; calculate mcoe # fixed_var_breakdown_df = calc_fixed_var_breakdown(eia_ferc1_merge_df) # Add NEMS data for most recent year O&M cost # Check NEMS data against our calculations. # fi = with_nems_df.loc[(with_nems_df['fixed_cost'].notna()) #                       & (with_nems_df['fixed_om_mw_18'].notna())] # fi['fixed_NEMS'] = (fi['fixed_om_mw_18'] * fi['net_generation_mwh'] #                     / fi['capacity_mw']) # fi.plot.scatter(x='fixed_NEMS', y='fixed_cost') # va = with_nems_df.loc[(with_nems_df['variable_cost'].notna()) #                       & (with_nems_df['variable_om_mwh_18'].notna())] # va['variable_NEMS'] = va['variable_om_mwh_18'] * va['net_generation_mwh'] # va.plot.scatter(x='variable_NEMS', y='variable_cost') # Validate NEMS data_eia # validate_nems(with_nems_df) # Add significant heat rate identifier (pudl id 125 = Comanche for test) # .round(1)
A DataFrame with the MCOE variables and calculations.
A DataFrame with the MCOE variables and calculations .
pandas.DataFrame
raw_eia_df
A DataFrame containing EIA data from the
pudl_out.mcoe() function that has been run through date_to_year()
and add_generator_age() functions.
A DataFrame containing EIA data from the pudl_out . mcoe () function that has been run through date_to_year () and add_generator_age () functions .
pudl_out