runner¶
runner ¶
PyAERMOD Runner
Executes AERMOD binaries from Python with error handling, progress monitoring, and batch processing capabilities.
AERMODRunResult
dataclass
¶
Result from an AERMOD execution
AERMODRunner ¶
Execute AERMOD simulations from Python
Handles subprocess management, file I/O, error detection, and batch processing.
run ¶
run(input_file: Union[str, Path], working_dir: Optional[Union[str, Path]] = None, timeout: int = 3600, capture_output: bool = True) -> AERMODRunResult
Execute AERMOD with given input file
Args: input_file: Path to AERMOD input file (.inp) working_dir: Working directory for execution (defaults to input file location) timeout: Maximum execution time in seconds (default 1 hour) capture_output: Whether to capture stdout/stderr
Returns: AERMODRunResult with execution details and file paths
run_batch ¶
run_batch(input_files: List[Union[str, Path]], n_workers: int = 4, timeout: int = 3600, stop_on_error: bool = False) -> List[AERMODRunResult]
Run multiple AERMOD simulations in parallel
Args: input_files: List of input file paths n_workers: Number of parallel workers timeout: Timeout per run (seconds) stop_on_error: Whether to stop if any run fails
Returns: List of AERMODRunResult objects
validate_input ¶
Validate AERMOD input file (basic checks)
Args: input_file: Path to input file
Returns: (is_valid, list_of_issues)
BatchRunner ¶
Helper class for running parameter sweeps and scenario comparisons
parameter_sweep ¶
parameter_sweep(base_project, parameter_name: str, parameter_values: List, output_dir: Union[str, Path], n_workers: int = 4, source_index: int = 0) -> Dict
Run AERMOD over a sweep of one parameter on one source.
For each value in parameter_values:
- Deep-copy
base_project - Set
parameter_nameon the indicated source (or on the project if the name contains a dot, e.g."control.title_one") - Write the modified project to
output_dir/run_{name}_{value}.inp - Queue the file for batch execution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_project
|
AERMODProject
|
Template project that gets cloned for each run. |
required |
parameter_name
|
str
|
Attribute to modify. If it contains |
required |
parameter_values
|
list
|
Values to substitute in. |
required |
output_dir
|
Path
|
Directory for generated .inp files and AERMOD outputs. |
required |
n_workers
|
int
|
Number of parallel AERMOD workers. |
4
|
source_index
|
int
|
Which source to mutate when |
0
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of parameter value -> AERMODRunResult. |
run_aermod ¶
run_aermod(input_file: Union[str, Path], executable_path: Optional[Union[str, Path]] = None, timeout: int = 3600) -> AERMODRunResult
Quick function to run AERMOD
Args: input_file: Path to input file executable_path: Optional path to AERMOD executable timeout: Timeout in seconds
Returns: AERMODRunResult