Skip to content

buildings_bench.utils

Common Utilities

buildings_bench.utils

get_puma_county_lookup_table(metadata_dir)

Build a puma-county lookup table.

The weather files are organized by U.S. county. We need to map counties to PUMAs and ensure we drop counties without weather data (only done when using weather).

Parameters:

Name Type Description Default
metadata_dir Path

Path to the metadata folder of BuildingsBench

required

Returns:

Type Description
DataFrame

pd.DataFrame: the puma-county lookup table

load_model_checkpoint(path, model, optimizer, scheduler, local_rank)

Load model checkpoint.

save_model_checkpoint(model, optimizer, scheduler, step, path)

Save model checkpoint.

set_seed(seed=42)

Set random seed for reproducibility.

time_features_to_datetime(time_features, year)

Convert time features to datetime objects.

Parameters:

Name Type Description Default
time_features ndarray

Array of time features. [:,0] is day of year, [:,1] is day of week, [:,2] is hour of day.

required
year int

Year to use for datetime objects.

required

Returns:

Type Description
array

np.array: Array of datetime objects.

worker_init_fn_eulp(worker_id)

Set random seed for each worker and init file pointer for Buildings-900K dataset workers.

Parameters:

Name Type Description Default
worker_id int

worker id

required