@@ -60,10 +60,10 @@ def get_conversion_dictionary(flag: str) -> dict:
60
60
"Nuclear - Large" : "nuclear" ,
61
61
"Nuclear - AP1000" : "nuclear" ,
62
62
"Geothermal - Hydro / Flash" : "geothermal" ,
63
- "Land-Based Wind - Class 1 " : "onwind" ,
64
- "Land-Based Wind - Class 1 - Technology 1" : "onwind" ,
65
- "Offshore Wind - Class 1 " : "offwind" ,
66
- "Utility PV - Class 1 " : "solar-utility" ,
63
+ "Land-Based Wind - Class 4 " : "onwind" ,
64
+ "Land-Based Wind - Class 4 - Technology 1" : "onwind" ,
65
+ "Offshore Wind - Class 3 " : "offwind" ,
66
+ "Utility PV - Class 5 " : "solar-utility" ,
67
67
"Commercial PV - Class 1" : "solar-rooftop" ,
68
68
"Utility-Scale Battery Storage - 6Hr" : "battery storage" ,
69
69
"Biopower" : "biomass" ,
@@ -72,9 +72,9 @@ def get_conversion_dictionary(flag: str) -> dict:
72
72
}
73
73
elif flag .casefold () == "atb_technology_name" :
74
74
return {
75
+ "Land-Based Wind - Class 1" : "Land-Based Wind - Class 1 - Technology 1" ,
75
76
"Land-Based Wind - Class 2" : "Land-Based Wind - Class 2 - Technology 1" ,
76
77
"Land-Based Wind - Class 3" : "Land-Based Wind - Class 3 - Technology 1" ,
77
- "Land-Based Wind - Class 4" : "Land-Based Wind - Class 4 - Technology 1" ,
78
78
"Land-Based Wind - Class 5" : "Land-Based Wind - Class 5 - Technology 1" ,
79
79
"Land-Based Wind - Class 6" : "Land-Based Wind - Class 6 - Technology 1" ,
80
80
"Land-Based Wind - Class 7" : "Land-Based Wind - Class 7 - Technology 1" ,
@@ -357,23 +357,65 @@ def pre_process_manual_input_usa(
357
357
"technology == @tech and parameter == @param"
358
358
)
359
359
360
- s = pd .Series (
361
- index = list_of_years ,
362
- data = np .interp (list_of_years , c ["year" ], c ["value" ]),
363
- name = param ,
364
- )
365
- s ["parameter" ] = param
366
- s ["technology" ] = tech
367
- try :
368
- s ["currency_year" ] = int (c ["currency_year" ].values [0 ])
369
- except ValueError :
370
- s ["currency_year" ] = np .nan
371
- for col in ["unit" , "source" , "further description" ]:
372
- s [col ] = "; and\n " .join (c [col ].unique ().astype (str ))
373
- s = s .rename (
374
- {"further_description" : "further description" }
375
- ) # match column name between manual_input and original TD workflow
376
- list_dataframe_row .append (s )
360
+ # Consider differences among scenarios
361
+ scenarios = c ["scenario" ].dropna ().unique ()
362
+
363
+ for scenario in scenarios :
364
+ scenario_value = c [c ["scenario" ] == scenario ][
365
+ "value"
366
+ ].values # Extract values for each scenario
367
+
368
+ if scenario_value .size > 0 :
369
+ scenario_years = c [c ["scenario" ] == scenario ]["year" ].values
370
+ scenario_values = c [c ["scenario" ] == scenario ]["value" ].values
371
+
372
+ interpolated_values = np .interp (
373
+ list_of_years , scenario_years , scenario_values
374
+ )
375
+
376
+ # Create a row for each scenario
377
+ s_copy = pd .Series (
378
+ index = list_of_years ,
379
+ data = interpolated_values , # values are now interpolated
380
+ name = param ,
381
+ )
382
+
383
+ s_copy ["parameter" ] = param
384
+ s_copy ["technology" ] = tech
385
+ s_copy ["scenario" ] = scenario
386
+ try :
387
+ s_copy ["currency_year" ] = int (c ["currency_year" ].values [0 ])
388
+ except ValueError :
389
+ s_copy ["currency_year" ] = np .nan
390
+
391
+ # Add the other columns in the data file
392
+ for col in ["unit" , "source" , "further description" ]:
393
+ s_copy [col ] = c [col ].unique ()[0 ]
394
+
395
+ # Add a separate row for each `financial_case`
396
+ for financial_case in c ["financial_case" ].unique ():
397
+ s_copy ["financial_case" ] = financial_case
398
+ list_dataframe_row .append (s_copy .copy ())
399
+ if len (scenarios ) == 0 :
400
+ s = pd .Series (
401
+ index = list_of_years ,
402
+ data = [scenario_value ] * len (list_of_years ),
403
+ name = param ,
404
+ )
405
+ s ["parameter" ] = param
406
+ s ["technology" ] = tech
407
+ s ["scenario" ] = ""
408
+ try :
409
+ s ["currency_year" ] = int (c ["currency_year" ].values [0 ])
410
+ except ValueError :
411
+ s ["currency_year" ] = np .nan
412
+ for col in ["unit" , "source" , "further description" ]:
413
+ s [col ] = c [col ].unique ()[0 ]
414
+
415
+ # Add a separate row for each `financial_case`
416
+ for financial_case in c ["financial_case" ].unique ():
417
+ s ["financial_case" ] = financial_case
418
+ list_dataframe_row .append (s .copy ())
377
419
manual_input_usa_file_df = pd .DataFrame (list_dataframe_row ).reset_index (drop = True )
378
420
379
421
# Filter the information for a given year
@@ -386,25 +428,56 @@ def pre_process_manual_input_usa(
386
428
"source" ,
387
429
"further description" ,
388
430
"currency_year" ,
431
+ "financial_case" ,
432
+ "scenario" ,
389
433
]
390
434
].rename (columns = {year : "value" })
391
435
436
+ # Filter data to get technologies with scenario differentiation
437
+ with_scenario_df = manual_input_usa_file_df [
438
+ manual_input_usa_file_df ["scenario" ].notna ()
439
+ ]
440
+ without_scenario_df = manual_input_usa_file_df [
441
+ manual_input_usa_file_df ["scenario" ].isna ()
442
+ ]
443
+
444
+ final_rows = []
445
+
446
+ for tech in manual_input_usa_file_df ["technology" ].unique ():
447
+ tech_with_scenario = with_scenario_df [with_scenario_df ["technology" ] == tech ]
448
+ if len (tech_with_scenario ) > 0 :
449
+ # Keep rows where a scenario exists
450
+ final_rows .append (tech_with_scenario )
451
+ else :
452
+ # If a scenario is not defined, keep the row without scenario
453
+ tech_without_scenario = without_scenario_df [
454
+ without_scenario_df ["technology" ] == tech
455
+ ]
456
+ final_rows .append (tech_without_scenario )
457
+
458
+ manual_input_usa_file_df = pd .concat (final_rows , ignore_index = True )
459
+
392
460
# Cast the value column to float
393
461
manual_input_usa_file_df ["value" ] = manual_input_usa_file_df ["value" ].astype (float )
394
462
395
463
# Correct the cost assumptions to the inflation rate
396
- inflation_adjusted_manual_input_usa_file_df = adjust_for_inflation (
397
- inflation_rate_series ,
398
- manual_input_usa_file_df ,
399
- manual_input_usa_file_df .technology .unique (),
400
- eur_year ,
401
- "value" ,
402
- usa_costs_flag = True ,
464
+ mask = manual_input_usa_file_df ["unit" ].str .startswith ("EUR" , na = False )
465
+
466
+ inflation_adjusted_manual_input_usa_file_df = manual_input_usa_file_df .copy ()
467
+ inflation_adjusted_manual_input_usa_file_df .loc [mask , "value" ] = (
468
+ adjust_for_inflation (
469
+ inflation_rate_series ,
470
+ manual_input_usa_file_df .loc [mask ],
471
+ manual_input_usa_file_df .loc [mask , "technology" ].unique (),
472
+ eur_year ,
473
+ "value" ,
474
+ usa_costs_flag = True ,
475
+ )["value" ]
403
476
)
404
477
405
478
# Round the results
406
479
inflation_adjusted_manual_input_usa_file_df .loc [:, "value" ] = round (
407
- inflation_adjusted_manual_input_usa_file_df . value .astype (float ), n_digits
480
+ inflation_adjusted_manual_input_usa_file_df [ " value" ] .astype (float ), n_digits
408
481
)
409
482
410
483
return inflation_adjusted_manual_input_usa_file_df
@@ -688,6 +761,7 @@ def pre_process_cost_input_file(
688
761
def pre_process_atb_input_file (
689
762
input_file_path : str ,
690
763
nrel_source : str ,
764
+ nrel_further_description : str ,
691
765
year : int ,
692
766
list_columns_to_keep : list ,
693
767
list_core_metric_parameter_to_keep : list ,
@@ -803,7 +877,7 @@ def pre_process_atb_input_file(
803
877
atb_input_df ["source" ] = nrel_source
804
878
805
879
# Add further description column
806
- atb_input_df ["further description" ] = pd . Series ( dtype = "str" )
880
+ atb_input_df ["further description" ] = nrel_further_description
807
881
808
882
# Rename columns and select just columns used in PyPSA
809
883
column_rename_dict = get_conversion_dictionary ("output_column" )
@@ -923,6 +997,9 @@ def duplicate_fuel_cost(input_file_path: str, list_of_years: list) -> pd.DataFra
923
997
"nrel_atb_core_metric_parameter_to_keep"
924
998
]
925
999
nrel_atb_source_link = snakemake .config ["nrel_atb" ]["nrel_atb_source_link" ]
1000
+ nrel_atb_further_description = snakemake .config ["nrel_atb" ][
1001
+ "nrel_atb_further_description"
1002
+ ]
926
1003
nrel_atb_technology_to_remove = snakemake .config ["nrel_atb" ][
927
1004
"nrel_atb_technology_to_remove"
928
1005
]
@@ -989,6 +1066,7 @@ def duplicate_fuel_cost(input_file_path: str, list_of_years: list) -> pd.DataFra
989
1066
atb_e_df = pre_process_atb_input_file (
990
1067
input_atb_path ,
991
1068
nrel_atb_source_link ,
1069
+ nrel_atb_further_description ,
992
1070
year_val ,
993
1071
nrel_atb_columns_to_keep ,
994
1072
nrel_atb_core_metric_parameter_to_keep ,
0 commit comments