scripts.misc

Define several global variables, paths and basic functions.

This module contains utility functions for the Inhabit housing allocation model. It provides functions for data manipulation, path handling, validation, and various preprocessing operations for household and dwelling data.

Functions

add_mean_ls(ip, inhabit[, mean_ls_inh])

Add mean living space (ls) data to the inhabit dataframe from multiple sources.

check_absolute_path(path)

Adjust file path based on current working directory.

check_empty(df, source)

Check if a DataFrame is empty and raise an error if it is.

clean_nan(df[, on_cols])

Remove rows containing NaN values in specified columns from DataFrame.

create_stocks(inhabit, ip)

Create aggregated household and dwelling stock dataframes.

debug_messages(message, ip)

Append debugging messages to a cumulative debug string if debug flag is enabled.

get_age_classes(ip)

Generate age class mappings based on age limiters in input parameters.

get_full_inhabit(all_dimensions, ip, ...)

Create a full inhabit matrix by cross-joining all dimension combinations.

get_negative_dict()

Create a dictionary mapping negative integers to NaN values.

get_save_path(folder1, folder2)

Create and return a save path by combining two folder names.

get_split(ip, split_large_dwell)

Calculate how to split large dwellings with many rooms into smaller units.

load_inhabit_moving(inhabit_or_move, year, ...)

Load inhabit or move_out data from CSV files to DataFrames.

order_move_in_want(move_in_want_v, ip)

Sort households by allocation priority based on configurable attributes.

printd(str, ip)

Print debugging information if debug flag is enabled.

save_params_to_file(ip)

Save input parameters dictionary to a formatted text file.

stock_assertions(dwell_stock, hh_stock)

Validate consistency and integrity of household and dwelling stock data.

timer_func(func)

Decorator that measures and prints the execution time of a function.