Skip to content

aerscreen_runner

aerscreen_runner

AERSCREEN binary runner.

AERSCREEN is interactive and spawns other programs, so running it takes more staging than the other EPA binaries:

  • It reads its answers from stdin, in the order :meth:~pyaermod.aerscreen.AERSCREENConfig.to_stdin_answers gives them, or, when an aerscreen.inp restart file is in the working directory, asks whether to continue with it.
  • Before starting a run it checks that AERMOD.EXE, MAKEMET.EXE and (when needed) BPIPPRM.EXE and AERMAP.EXE exist in the working directory, then invokes them through the shell as aermod, makemet, bpipprm and aermap. The runner stages both spellings as links to the real binaries and puts the working directory first on PATH.
  • Its call bpipprm <inp> <out> <sum> assumes a BPIP-PRIME that takes file names; the one scripts/build_bpip.sh builds reads fort.10 and writes fort.12 / fort.14 (EPA's OPEN statements are commented out), so the staged bpipprm is a small wrapper that bridges the two.
  • Auxiliary inputs the configuration names (surface-characteristics file, discrete-receptor file, BPIP file, DEMs, NADCON grids) are copied in beside it, and DEMlist.txt is written for terrain runs.

Typical usage::

from pyaermod import AERSCREENConfig, AERSCREENSourceType
from pyaermod.aerscreen_runner import AERSCREENRunner

cfg = AERSCREENConfig(...)
result = AERSCREENRunner().run(cfg, working_dir="/tmp/aerscreen_so2")
if result.success:
    print(result.summary.maximum.conc_1hr, "ug/m3 at",
          result.summary.maximum.distance, "m")

Build the binaries with scripts/build_aerscreen.sh (AERSCREEN and MAKEMET), scripts/build_aermod.sh (AERMOD and AERMAP) and scripts/build_bpip.sh.

AERSCREENRunResult dataclass

Outcome of an AERSCREEN execution.

AERSCREENRunner

Execute AERSCREEN from Python.

Parameters:

Name Type Description Default
executable_path Optional[Union[str, Path]]

Path to the aerscreen binary. If None, searches $PATH.

None
aermod_path Optional[Union[str, Path]]

The programs AERSCREEN spawns. Each defaults to the first match on $PATH; AERMOD and MAKEMET are required for any screening run, BPIP-PRIME only with building downwash and AERMAP only with terrain, so a missing one is reported when a run needs it.

None
makemet_path Optional[Union[str, Path]]

The programs AERSCREEN spawns. Each defaults to the first match on $PATH; AERMOD and MAKEMET are required for any screening run, BPIP-PRIME only with building downwash and AERMAP only with terrain, so a missing one is reported when a run needs it.

None
bpipprm_path Optional[Union[str, Path]]

The programs AERSCREEN spawns. Each defaults to the first match on $PATH; AERMOD and MAKEMET are required for any screening run, BPIP-PRIME only with building downwash and AERMAP only with terrain, so a missing one is reported when a run needs it.

None
aermap_path Optional[Union[str, Path]]

The programs AERSCREEN spawns. Each defaults to the first match on $PATH; AERMOD and MAKEMET are required for any screening run, BPIP-PRIME only with building downwash and AERMAP only with terrain, so a missing one is reported when a run needs it.

None
log_level str

Python logging level name.

'INFO'

required_helpers

required_helpers(config: AERSCREENConfig) -> List[str]

The spawned programs this configuration will call.

stdin_text

stdin_text(config: AERSCREENConfig, mode: str) -> str

What the runner types: the prompt answers, or the restart reply.

stage

stage(config: AERSCREENConfig, work: Path, mode: str) -> Path

Put everything AERSCREEN will look for into work.

Returns the path of the file the run reads its configuration from: aerscreen.inp in restart mode, the answers file in prompt mode.

run

run(config: AERSCREENConfig, *, working_dir: Union[str, Path], timeout: int = 1800, mode: str = 'prompts') -> AERSCREENRunResult

Run AERSCREEN for one configuration.

Parameters:

Name Type Description Default
config AERSCREENConfig

The run.

required
working_dir Union[str, Path]

Directory AERSCREEN runs in. It fills it with met files, AERMOD decks and outputs; use one per run.

required
timeout int

Seconds before the run is killed. A flat run takes seconds, a terrain run with AERMAP minutes.

1800
mode str

"prompts" types the answers of :meth:~pyaermod.aerscreen.AERSCREENConfig.to_stdin_answers; "restart" writes the restart file of :meth:~pyaermod.aerscreen.AERSCREENConfig.to_aerscreen_input as aerscreen.inp and accepts it. Both end in the same run; the prompt path is the one a user at the keyboard takes, and the only one that keeps a title with a comma in it whole (AERSCREEN's restart reader cuts the title at the first comma).

'prompts'