aermet_runner¶
aermet_runner ¶
AERMET binary runner + pipeline.
Parallel to :class:pyaermod.runner.AERMODRunner but for AERMET. AERMET
11 and later run in two stages: Stage 1 extracts and quality-assures the
raw observations (:class:~pyaermod.aermet.AERMETStage1), and the
METPREP stage merges them and computes the boundary-layer parameters
(:class:~pyaermod.aermet.AERMETStage3, AERMET's "stage 2"). Each run
takes a runstream file named on the command line.
from pyaermod import AERMETStage1, AERMETStage3
from pyaermod.aermet_runner import AERMETRunner, run_aermet_pipeline
runner = AERMETRunner()
result1 = runner.run_stage(1, stage1_inp_path, working_dir=tmp)
...
Or, for the whole pipeline:
results = run_aermet_pipeline(stage1, None, stage3, working_dir=tmp)
# one AERMETRunResult per AERMET run; check all `.success`.
How success is decided
AERMET exits with code 0 whether or not it succeeds, so the exit code
says nothing. At the end of every run the main program (aermet.f90)
prints one of two banners to the screen and to the REPORT file:
AERMET FINISHED SUCCESSFULLY
AERMET FINISHED UN-SUCCESSFULLY
and write_msg (mod_reports.f90) writes a MESSAGE SUMMARY to the
REPORT file with the number of ERROR, WARNING, INFORMATION and QA
messages. A run succeeds here only when the exit code is 0, the screen
output carries the "FINISHED SUCCESSFULLY" banner and no error is
counted. The individual messages come from the MESSAGES file, one per
line in the layout (1x,a10,1x,a3,5x,a10,1x,...): pathway, code
(E01), routine and text. A few errors found before the MESSAGES file
is open go to the screen in the same layout, so the screen is read too.
AERMETMessage
dataclass
¶
One line of an AERMET MESSAGES file (or of its screen output).
Attributes:
pathway: The pathway that raised it (UPPERAIR, SURFACE,
ONSITE, METPREP, JOB), or empty when AERMET leaves
it blank.
severity: 'E' (error), 'W' (warning), 'I'
(information) or 'Q' (QA).
code: The severity and number together, such as 'E01'.
module: The AERMET routine, such as 'CHECK_LINE'.
text: The message text.
AERMETRunResult
dataclass
¶
Outcome of a single AERMET run.
success is AERMET's own verdict (see the module docstring).
messages are the messages AERMET listed (its MESSAGES file and any
it printed to the screen), and message_counts the counts from the
REPORT file's MESSAGE SUMMARY, keyed 'E', 'W', 'I' and
'Q'.
AERMETRunner ¶
Execute AERMET runs from Python.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
executable_path
|
Optional[Union[str, Path]]
|
Path to the |
None
|
log_level
|
str
|
Python logging level name. |
'INFO'
|
run_stage ¶
run_stage(stage: int, input_file: Union[str, Path], *, working_dir: Union[str, Path], timeout: int = 600) -> AERMETRunResult
Run AERMET on one runstream file in working_dir.
stage labels the run (the result's stage and the captured
stage{N}.subproc.stdout/.stderr files); AERMET itself
decides which stages to run from the pathways in the deck.
parse_aermet_messages ¶
Parse the messages in the text of an AERMET MESSAGES file.
read_aermet_messages ¶
Read the messages of an AERMET MESSAGES file.
run_aermet_pipeline ¶
run_aermet_pipeline(stage1: AERMETStage1, stage2: Optional[AERMETStage2], stage3: AERMETStage3, *, working_dir: Union[str, Path], executable_path: Optional[Union[str, Path]] = None, stop_on_failure: bool = True, timeout: int = 600) -> List[AERMETRunResult]
Run AERMET's Stage 1 and then its METPREP stage in working_dir.
Writes stage1.inp and stage3.inp into working_dir and runs
them in turn. The METPREP deck reads Stage 1's QAOUT files
(:meth:AERMETStage3.with_inputs_from) unless stage3 names its
own. stage2 is ignored: AERMET 11 and later have no merge stage;
pass None. If Stage 1 fails and stop_on_failure is True (default),
METPREP is not run.
Returns one :class:AERMETRunResult per AERMET run made, with
stage 1 and 3 (two results, not three).