@@ -1203,12 +1203,18 @@ def _populate_calculated_defaults(df: DataFrame, model: TimesModel):
1203
1203
)
1204
1204
1205
1205
1206
- def apply_fixups (
1206
+ def prepare_for_querying (
1207
1207
config : Config ,
1208
1208
tables : dict [str , DataFrame ],
1209
1209
model : TimesModel ,
1210
1210
) -> dict [str , DataFrame ]:
1211
- """Apply fixups to the tables."""
1211
+ """Prepare tables for querying by harmonising them and filling in missing values.
1212
+ This includes
1213
+ - Adding expected columns with NA if they are missing.
1214
+ - Expanding year columns if they contain ranges.
1215
+ - Applying attribute-specific default values (incl. if specified under a different column).
1216
+ - Filling in missing values in year and currency columns with defaults.
1217
+ """
1212
1218
exclude_tags = {Tag .tfm_mig , Tag .tfm_upd }
1213
1219
attribute_tags = [Tag .fi_t , Tag .uc_t ]
1214
1220
currency = tables [Tag .currencies ]["currency" ][0 ]
@@ -1447,12 +1453,12 @@ def create_model_cgs(
1447
1453
return tables
1448
1454
1449
1455
1450
- def process_trade_links (
1456
+ def process_tradelinks (
1451
1457
config : Config ,
1452
1458
tables : list [EmbeddedXlTable ],
1453
1459
model : TimesModel ,
1454
1460
) -> list [EmbeddedXlTable ]:
1455
- """Process trade links and create model trade (between internal regions)."""
1461
+ """Process tradelinks and create model trade (between internal regions)."""
1456
1462
cols_list = ["origin" , "in" , "destination" , "out" , "process" ]
1457
1463
cols_list .extend (dm_cols )
1458
1464
result = []
@@ -1823,7 +1829,7 @@ def generate_dummy_processes(
1823
1829
return tables
1824
1830
1825
1831
1826
- def process_tradelinks (
1832
+ def harmonise_tradelinks (
1827
1833
config : Config ,
1828
1834
tables : list [EmbeddedXlTable ],
1829
1835
model : TimesModel ,
@@ -3199,7 +3205,7 @@ def apply_final_fixup(
3199
3205
tables : dict [str , DataFrame ],
3200
3206
model : TimesModel ,
3201
3207
) -> dict [str , DataFrame ]:
3202
-
3208
+ """Clean up remaining issues. Includes handling of aliases that could not be generalised."""
3203
3209
veda_ire_sets = model .custom_sets
3204
3210
reg_com_flows = model .topology [["region" , "process" , "commodity" ]].copy ()
3205
3211
reg_com_flows .drop_duplicates (inplace = True , ignore_index = True )
0 commit comments