This Python module provides a command-line interface to WindNinja, a tool for simulating wind flow over complex terrain. The module includes classes and functions for configuring and running WindNinja simulations, generating station files, and handling WindNinja output.
- WindNinja (CLI version)
- Python 3.x
- Additional packages:
yaml
,csv
,subprocess
Clone or download this repository, then install the required Python packages:
pip install pyyaml
The WindNinja CLI path is stored in a windninja_path.yml
file. To set the path to your WindNinja installation:
from windninja_cli import setWN_path
setWN_path("/path/to/WindNinja")
To create a WindNinja station file with specified variables:
from windninja_cli import genWxStnFile
station_vars = [
# Populate with station variables, for example:
["Station1", "GEOGCS", "WGS84", 45.0, -123.0, 10, "meters", 5, "mph", 180, 70, "F", 50, -1, "miles", ""]
]
genWxStnFile("output_directory", "station_file_name", station_vars)
The main class WN
provides configuration and execution options for WindNinja simulations:
from windninja_cli import WN
simulation = WN(
num_threads=2,
elevation_file="path/to/elevation_file.tif",
initialization_method="domainAverageInitialization",
vegetation="grass",
output_path="output_directory",
input_speed=10.0,
input_speed_units="kph",
input_direction=270,
output_wind_height=10.0,
units_output_wind_height="m",
output_speed_units="kph"
)
simulation.runWN()
Run tests for different initialization methods with example data:
from windninja_cli import testWN
testWN(init_method="pointInitialization", out_folder="output_directory", vegetation="grass", time_scale="daily")
Sets the WindNinja path in the configuration file.
Retrieves the WindNinja path from the configuration file.
Generates a WindNinja station file based on input parameters.
out_folder
: Directory where the station file is saved.file_name
: Name of the output station file.stn_vars
: List of station variables, including station ID, location, and weather data.
The WN
class manages WindNinja configurations and runs the CLI.
Verifies that required parameters for the chosen initialization method are provided.
Retrieves or displays all configuration parameters for the current WindNinja run.
Writes a configuration file for WindNinja based on user input.
Executes the WindNinja CLI using the generated configuration file.
Runs the full WindNinja workflow, from parameter verification to execution.
MIT License.