@@ -1203,12 +1203,18 @@ def _populate_calculated_defaults(df: DataFrame, model: TimesModel):
12031203 )
12041204
12051205
1206- def apply_fixups (
1206+ def prepare_for_querying (
12071207 config : Config ,
12081208 tables : dict [str , DataFrame ],
12091209 model : TimesModel ,
12101210) -> 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+ """
12121218 exclude_tags = {Tag .tfm_mig , Tag .tfm_upd }
12131219 attribute_tags = [Tag .fi_t , Tag .uc_t ]
12141220 currency = tables [Tag .currencies ]["currency" ][0 ]
@@ -1447,12 +1453,12 @@ def create_model_cgs(
14471453 return tables
14481454
14491455
1450- def process_trade_links (
1456+ def process_tradelinks (
14511457 config : Config ,
14521458 tables : list [EmbeddedXlTable ],
14531459 model : TimesModel ,
14541460) -> list [EmbeddedXlTable ]:
1455- """Process trade links and create model trade (between internal regions)."""
1461+ """Process tradelinks and create model trade (between internal regions)."""
14561462 cols_list = ["origin" , "in" , "destination" , "out" , "process" ]
14571463 cols_list .extend (dm_cols )
14581464 result = []
@@ -1823,7 +1829,7 @@ def generate_dummy_processes(
18231829 return tables
18241830
18251831
1826- def process_tradelinks (
1832+ def harmonise_tradelinks (
18271833 config : Config ,
18281834 tables : list [EmbeddedXlTable ],
18291835 model : TimesModel ,
@@ -3199,7 +3205,7 @@ def apply_final_fixup(
31993205 tables : dict [str , DataFrame ],
32003206 model : TimesModel ,
32013207) -> dict [str , DataFrame ]:
3202-
3208+ """Clean up remaining issues. Includes handling of aliases that could not be generalised."""
32033209 veda_ire_sets = model .custom_sets
32043210 reg_com_flows = model .topology [["region" , "process" , "commodity" ]].copy ()
32053211 reg_com_flows .drop_duplicates (inplace = True , ignore_index = True )
0 commit comments