API Reference
This section provides a detailed reference for the functions and classes in the SOLWEIG-GPU package.
Entry points:
thermal_comfort(...)– One-shot: runs preprocessing, wall/aspect, and UTCI in one call. Use this for normal runs (CLI and GUI call this).preprocess(...),run_walls_aspect(preprocess_dir),run_utci_tiles(...)– Staged execution: call these when you need to run preprocessing once, then wall/aspect, then UTCI (optionally for a subset of tiles). See Developer Guide – Pipeline stages and the repository’s REFACTORING.md.
thermal_comfort()
Main function to run a full SOLWEIG-GPU simulation (preprocess → wall/aspect → UTCI). Same behavior as before the staged API; CLI and GUI are unchanged.
from solweig_gpu import thermal_comfort
thermal_comfort(
base_path,
selected_date_str,
building_dsm_filename='Building_DSM.tif',
dem_filename='DEM.tif',
trees_filename='Trees.tif',
landcover_filename: Optional[str] = None,
tile_size=3600,
overlap = 20,
use_own_met=True,
start_time=None,
end_time=None,
data_source_type=None,
data_folder=None,
own_met_file=None,
save_tmrt=True,
save_svf=False,
save_kup=False,
save_kdown=False,
save_lup=False,
save_ldown=False,
save_shadow=False
)
Parameters
base_path(str): Base directory foroutput_folder/andprocessed_inputs/; also used to resolve relative raster paths. To write outputs elsewhere, set this to that directory and pass complete paths for the raster parameters.selected_date_str(str): The date for the simulation inYYYY-MM-DDformat.building_dsm_filename(str): Path or filename of the Building DSM raster (relative tobase_path, or a complete path). Defaults to'Building_DSM.tif'.dem_filename(str): Path or filename of the DEM raster. Defaults to'DEM.tif'.trees_filename(str): Path or filename of the Tree DSM raster. Defaults to'Trees.tif'.landcover_filename(str, optional): Path or filename of the land cover raster. Defaults toNone.tile_size(int): The size of the tiles in pixels. Defaults to3600.overlap(int): The overlap between tiles in pixels. Defaults to20.use_own_met(bool): Whether to use a custom meteorological file. Defaults toTrue.start_time(str, optional): The start time of the simulation inYYYY-MM-DD HH:MM:SSformat (UTC). Required ifuse_own_metisFalse.end_time(str, optional): The end time of the simulation inYYYY-MM-DD HH:MM:SSformat (UTC). Required ifuse_own_metisFalse.data_source_type(str, optional): The type of meteorological data source ('ERA5'or'wrfout'). Required ifuse_own_metisFalse.data_folder(str, optional): The directory containing the meteorological data files. Required ifuse_own_metisFalse.own_met_file(str, optional): The path to the custom meteorological file. Required ifuse_own_metisTrue.save_tmrt(bool, optional): Whether to save the Mean Radiant Temperature output. Defaults toTrue.save_svf(bool, optional): Whether to save the Sky View Factor output. Defaults toFalse.save_kup(bool, optional): Whether to save the upwelling shortwave radiation output. Defaults toFalse.save_kdown(bool, optional): Whether to save the downwelling shortwave radiation output. Defaults toFalse.save_lup(bool, optional): Whether to save the upwelling longwave radiation output. Defaults toFalse.save_ldown(bool, optional): Whether to save the downwelling longwave radiation output. Defaults toFalse.save_shadow(bool, optional): Whether to save the shadow map output. Defaults toFalse.
preprocess()
Runs only preprocessing: validates rasters, creates tiles, and prepares metfiles. Use when you want to call the pipeline in stages.
from solweig_gpu import preprocess
preprocess_dir = preprocess(
base_path="/path/to/data",
selected_date_str="2020-08-13",
building_dsm_filename="Building_DSM.tif",
dem_filename="DEM.tif",
trees_filename="Trees.tif",
landcover_filename=None,
tile_size=1000,
overlap=100,
use_own_met=True,
own_met_file="/path/to/met.txt",
preprocess_dir=None, # optional; default is base_path/processed_inputs
)
Returns: Path to the preprocessing directory (string).
Parameters: Same as the first part of thermal_comfort (base_path, selected_date_str, raster filenames, tile_size, overlap, met options). Optional preprocess_dir overrides the default output directory.
run_walls_aspect()
Computes wall heights and aspects for all tiles in the preprocessing directory. Call after preprocess().
from solweig_gpu import run_walls_aspect
run_walls_aspect(preprocess_dir)
Parameters:
preprocess_dir(str): Path returned bypreprocess()(contains Building_DSM/, DEM/, Trees/, etc.).
Returns: None. Writes to {preprocess_dir}/walls/ and {preprocess_dir}/aspect/.
run_utci_tiles()
Runs the SOLWEIG/UTCI computation for tiles. Call after preprocess() and run_walls_aspect().
from solweig_gpu import run_utci_tiles
run_utci_tiles(
base_path="/path/to/data",
preprocess_dir=preprocess_dir,
selected_date_str="2020-08-13",
tile_keys=None, # None = all tiles; or ["0_0", "1000_0"] for a subset
save_tmrt=True,
save_svf=False,
save_kup=False,
save_kdown=False,
save_lup=False,
save_ldown=False,
save_shadow=False,
)
Parameters:
base_path(str): Base directory;output_folder/is created under it.preprocess_dir(str): Path returned bypreprocess().selected_date_str(str): Simulation dateYYYY-MM-DD.tile_keys(list, optional): IfNone, process all tiles. If a list (e.g.["0_0", "1000_0"]), process only those tile keys.save_tmrt,save_svf,save_kup,save_kdown,save_lup,save_ldown,save_shadow: Same as inthermal_comfort().
Returns: None. Writes GeoTIFFs to {base_path}/output_folder/{tile_key}/.