Hillslope-Link Model
Project description
ifc-hlm
A Python version of the Iowa Flood Center’s (IFC’s) Hillslope-Link Model (HLM) implementing the Basic Model Interface (BMI).
Installation
pip install ifc-hlm
Usage
import numpy as np
from ifc_hlm.vectorized import Model252
CONFIG_TOML_FILE = "config.toml"
PCP_MPS = 100.0 / (1000 * 3600) # mm/hour -> m/s
PET_MPS = 19.0 / (1000 * 30 * 24 * 3600) # mm/month -> m/s
def main() -> None:
# Instantiate Model252 and initialize it from a config file
model = Model252()
model.initialize(CONFIG_TOML_FILE)
# Retrieve component name
component_name = model.get_component_name()
print(f"{component_name=}")
# component_name='Model252'
# Retrieve input and output variable_names and units
input_vars = {
name: model.get_var_units(name) for name in model.get_input_var_names()
}
print(f"{input_vars=}")
# input_vars={'pcp': 'm s-1', 'pet': 'm s-1'}
output_vars = {
name: model.get_var_units(name) for name in model.get_output_var_names()
}
print(f"{output_vars=}")
# output_vars={'q': 'm3 s-1', 's_p': 'm', 's_t': 'm', 's_s': 'm'}
# Get grid id for precipitation (or any other var since all vars use the same grid)
grid = model.get_var_grid("pcp")
print(f"{grid=}")
# grid=0
# Retrieve number of elements ( = number of links = number of hillslopes)
grid_size = model.get_grid_size(grid)
print(f"{grid_size=}")
# grid_size=6359
# Set precicipitation value (same value on all hillslopes)
pcp = np.full(shape=grid_size, fill_value=PCP_MPS)
model.set_value("pcp", pcp)
# Set potential evapotranspiration value (same value on all hillslopes)
pet = np.full(shape=grid_size, fill_value=PET_MPS)
model.set_value("pet", pet)
# Run 15 steps using this values
target_time = model.get_start_time() + 15 * model.get_time_step()
model.update_until(target_time)
# Stop rain (set value to zero)
pcp = np.zeros(shape=grid_size)
model.set_value("pcp", pcp)
# Run without rain until the end of the simulation
target_time = model.get_end_time()
model.update_until(target_time)
# Get final values for discharge
q = model.get_value_ptr("q")
print(f"{q=}")
# q=array([2.99072493e-06, 1.44644734e-05, 2.32179070e-05, ...,
# 6.39214042e-06, 3.08428987e-06, 3.50394797e-06], shape=(6359,))
model.finalize()
if __name__ == "__main__":
main()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ifc_hlm-0.5.0.tar.gz
(30.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ifc_hlm-0.5.0-py3-none-any.whl
(37.8 kB
view details)
File details
Details for the file ifc_hlm-0.5.0.tar.gz.
File metadata
- Download URL: ifc_hlm-0.5.0.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbccc83a4de42cef180194e35c870cd8aec4d3bee52d24050607942b8bb93bb5
|
|
| MD5 |
b9d36f4562425bfa861c39ab972109ec
|
|
| BLAKE2b-256 |
8c342d82b691a86350d24a544a82cf5c1fc50f6cd5553d279ecc565b3af00bef
|
File details
Details for the file ifc_hlm-0.5.0-py3-none-any.whl.
File metadata
- Download URL: ifc_hlm-0.5.0-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac822c92e9c85adaaa628c0a629da6764f711f34503dde74ad7ab3f4fb1d2556
|
|
| MD5 |
dfbfcafe67ae494f1f8939bbc83d770d
|
|
| BLAKE2b-256 |
39c636fbb75863cd02fb8aa0282beac3455e2fd1d644bc880ef38fe4405c343a
|