@@ -2091,34 +2091,34 @@ def order_data(years: list, technology_dataframe: pd.DataFrame) -> pd.DataFrame:
20912091 )
20922092 ].copy ()
20932093
2094- if tech_name == "Fischer-Tropsch" :
2095- efficiency [ years ] *= 100
2096- with_district_heat_recovery = efficiency . index . str . contains ( "District Heat Output," )
2097- efficiency_heat = efficiency [with_district_heat_recovery ]. copy ()
2098- efficiency_heat [ "parameter" ] = "efficiency-heat"
2099- clean_df [ tech_name ] = pd . concat ([ clean_df [ tech_name ], efficiency_heat ])
2100-
2101- if tech_name == "methanolisation" :
2102- with_district_heat_recovery = efficiency . index . str . contains ( " District heating" )
2103- efficiency_heat = efficiency [ with_district_heat_recovery ]. copy ()
2104- efficiency_heat [ "parameter" ] = "efficiency- heat"
2105- clean_df [ tech_name ] = pd . concat ([ clean_df [ tech_name ], efficiency_heat ])
2106-
2107- if tech_name == "Haber-Bosch" :
2108- with_high_value_heat_recovery = efficiency . index . str . contains ( "High value heat Output" )
2109- with_district_heat_recovery = efficiency . index . str . contains ( "District Heating Output," )
2110-
2111- efficiency_high_value_heat = efficiency [ with_high_value_heat_recovery ]. copy ( )
2112- efficiency_district_heat = efficiency [ with_district_heat_recovery ]. copy ()
2113-
2114- # change dtype at years columns to float to avoid issues with summation
2115- efficiency_high_value_heat [ years ] = efficiency_high_value_heat [years ].astype (float )
2116- efficiency_district_heat [years ] = efficiency_district_heat [ years ]. astype ( float )
2117-
2118- efficiency_heat = efficiency_high_value_heat
2119- efficiency_heat [ years ] += efficiency_district_heat [ years ]. iloc [ 0 ]
2120- efficiency_heat [ "parameter" ] = "efficiency-heat"
2121- clean_df [ tech_name ] = pd . concat ([ clean_df [ tech_name ], efficiency_heat ] )
2094+ if tech_name in [ "Fischer-Tropsch" , "methanolisation" , "Haber-Bosch" ] :
2095+ # Technology-specific setup
2096+ if tech_name == "Fischer-Tropsch" :
2097+ efficiency [years ] *= 100
2098+ patterns = [ "District Heat Output," ]
2099+ elif tech_name == "methanolisation" :
2100+ patterns = [ "District heating" ]
2101+ else : # Haber-Bosch
2102+ patterns = [ "High value heat Output" , " District Heating Output," ]
2103+
2104+ # Find all matching heat recovery rows
2105+ heat_masks = [ efficiency . index . str . contains ( pattern ) for pattern in patterns ]
2106+ matching_data = [ efficiency [ mask ] for mask in heat_masks if mask . any ()]
2107+
2108+ if matching_data :
2109+ # Start with the first matching dataset
2110+ efficiency_heat = matching_data [ 0 ]. copy ()
2111+ efficiency_heat [ years ] = efficiency_heat [ years ]. astype ( float )
2112+
2113+ # Add any additional heat sources
2114+ for additional_heat in matching_data [ 1 :]:
2115+ additional_heat_values = additional_heat [years ].astype (float )
2116+ efficiency_heat [years ] += additional_heat_values . iloc [ 0 ]
2117+
2118+ efficiency_heat [ "parameter" ] = "efficiency-heat"
2119+ clean_df [ tech_name ] = pd . concat ([ clean_df [ tech_name ], efficiency_heat ])
2120+ else :
2121+ raise ValueError ( f"No heat recovery data found for { tech_name } with patterns: { patterns } " )
21222122
21232123 # take annual average instead of name plate efficiency, unless central air-sourced heat pump
21242124 if (
0 commit comments