@@ -325,12 +325,12 @@ def get_sheet_location(
325325 return key_list [0 ]
326326 elif len (key_list ) > 1 :
327327 logger .info (f"{ tech_name } appears in more than one sheet name" )
328- return None
328+ return "Multiple sheets found"
329329 else :
330330 logger .info (
331331 f"tech { tech_name } with sheet name { sheet_names_dict [tech_name ]} not found in excel sheets. "
332332 )
333- return None
333+ return "Sheet not found"
334334
335335
336336def get_dea_maritime_data (
@@ -582,6 +582,7 @@ def get_dea_vehicle_data(
582582def get_data_DEA (
583583 years : list ,
584584 tech_name : str ,
585+ sheet_names_dict : dict ,
585586 input_data_dict : dict ,
586587 offwind_no_grid_costs_flag : bool = True ,
587588 expectation : str = None ,
@@ -596,6 +597,8 @@ def get_data_DEA(
596597 years for which a cost assumption is provided
597598 tech_name : str
598599 technology name
600+ sheet_names_dict : dict
601+ dictionary having the technology name as keys and Excel sheet names as values
599602 input_data_dict : dict
600603 dictionary where the keys are the path to the DEA inputs and the values are the sheet names
601604 offwind_no_grid_costs_flag : bool
@@ -609,10 +612,10 @@ def get_data_DEA(
609612 technology data from DEA
610613 """
611614
612- excel_file = get_sheet_location (tech_name , dea_sheet_names , input_data_dict )
613- if excel_file is None :
615+ excel_file = get_sheet_location (tech_name , sheet_names_dict , input_data_dict )
616+ if excel_file == "Sheet not found" or excel_file == "Multiple sheets found" :
614617 logger .info (f"excel file not found for technology: { tech_name } " )
615- return None
618+ return pd . DataFrame ()
616619
617620 if tech_name == "battery" :
618621 usecols = "B:J"
@@ -655,7 +658,7 @@ def get_data_DEA(
655658
656659 excel = pd .read_excel (
657660 excel_file ,
658- sheet_name = dea_sheet_names [tech_name ],
661+ sheet_name = sheet_names_dict [tech_name ],
659662 index_col = 0 ,
660663 usecols = usecols ,
661664 skiprows = skiprows ,
@@ -1380,14 +1383,12 @@ def biochar_pyrolysis_harmonise_dea(df: pd.DataFrame) -> pd.DataFrame:
13801383 inplace = True ,
13811384 )
13821385
1383- # df = df.astype(float)
1384- # df = df.mask(df.apply(pd.to_numeric, errors='coerce').isna(), df.astype(str).apply(lambda x: x.str.strip()))
1385-
13861386 return df
13871387
13881388
13891389def get_data_from_DEA (
13901390 years : list ,
1391+ sheet_names_dict : dict ,
13911392 input_data_dictionary : dict ,
13921393 offwind_no_grid_costs : bool = True ,
13931394 expectation : str = None ,
@@ -1399,6 +1400,8 @@ def get_data_from_DEA(
13991400 ----------
14001401 years : list
14011402 years for which a cost assumption is provided
1403+ sheet_names_dict : dict
1404+ dictionary having the technology name as keys and Excel sheet names as values
14021405 input_data_dictionary : dict
14031406 dictionary where the keys are the path to the DEA inputs and the values are the sheet names
14041407 offwind_no_grid_costs : bool
@@ -1414,11 +1417,12 @@ def get_data_from_DEA(
14141417
14151418 data_by_tech_dict = {}
14161419
1417- for tech_name , dea_tech in dea_sheet_names .items ():
1420+ for tech_name , dea_tech in sheet_names_dict .items ():
14181421 logger .info (f"{ tech_name } in PyPSA corresponds to { dea_tech } in DEA database." )
14191422 df = get_data_DEA (
14201423 years ,
14211424 tech_name ,
1425+ sheet_names_dict ,
14221426 input_data_dictionary ,
14231427 offwind_no_grid_costs ,
14241428 expectation ,
@@ -3957,6 +3961,7 @@ def prepare_inflation_rate(fn: str) -> pd.DataFrame:
39573961 # create dictionary with raw data from DEA sheets
39583962 d_by_tech = get_data_from_DEA (
39593963 years_list ,
3964+ dea_sheet_names ,
39603965 data_in ,
39613966 snakemake .config ["offwind_no_gridcosts" ],
39623967 expectation = snakemake .config ["expectation" ],
0 commit comments