pathways¶
pathways ¶
PyAERMOD Pathway dataclasses — Control, Meteorology, Output, and Event pathways.
Also contains enums used across multiple pathways (TerrainType, PollutantType, SourceType) and the chemistry-options cluster (ChemistryMethod, OzoneData, ChemistryOptions).
This module is an internal implementation detail. Public imports should go
through :mod:pyaermod.input_generator (the backwards-compatible facade)
or :mod:pyaermod.api.
TerrainType ¶
Bases: Enum
AERMOD terrain types
PollutantType ¶
Bases: Enum
Common pollutant types
SourceType ¶
Bases: Enum
AERMOD source types
ChemistryMethod ¶
Bases: Enum
AERMOD NO2 chemistry conversion methods.
NotAValueList ¶
Bases: TypeError
An iterable given as a profile's values that is no list of them.
kind is its type's name and reason says why, as a noun
phrase: it is a one-shot iterator, or no ordered sequence.
one_shot is True for a one-shot iterator, so a caller that words
the refusal for something other than a profile (the project-file
writer) can say why without repeating the rules.
TemporalValues
dataclass
¶
A background concentration that varies by season, month, hour...
The runstream form is O3VALUES <flag> <values> or NOX_VALS
<flag> <values>; AERMOD accepts the values over as many lines as
needed and requires exactly :data:TEMPORAL_FLAG_COUNTS of them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flag
|
str
|
One of the keys of :data: |
required |
values
|
list of float
|
The values, in AERMOD's order for that flag: a list, tuple,
range, numpy array or pandas Series (see :func: |
list()
|
BackgroundSpec
dataclass
¶
One background-concentration specification.
Used for the whole domain, or for one wind-direction sector when
O3SECTOR / NOXSECTR is in effect. AERMOD lets an hourly file
coexist with a value or a temporal profile (the latter substitutes
for hours the file is missing), but refuses value together with
varying.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
|
None
|
value_units
|
str
|
Units on that line (PPB, PPM, UG/M3); AERMOD's default is UG/M3. |
None
|
hourly_file
|
str
|
|
None
|
file_units
|
str
|
Units field on the file line. |
None
|
file_format
|
str
|
Fortran read format on the file line, or |
None
|
varying
|
TemporalValues
|
|
None
|
OzoneData
dataclass
¶
Ozone data for NO2 chemistry options (CO pathway ozone keywords).
ozone_file and uniform_value are the simplest ways to say
"one file" or "one value"; the other fields express everything
AERMOD's OZONEVAL / OZONEFIL / O3VALUES / O3SECTOR / OZONUNIT
keywords can. :meth:spec returns the whole-domain part as a
:class:BackgroundSpec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ozone_file
|
str
|
Path to the hourly ozone file ( |
None
|
uniform_value
|
float
|
Constant ozone concentration ( |
None
|
sector_values
|
dict
|
Mapping of sector index to a constant ozone value
( |
None
|
uniform_units
|
str
|
Units field on the |
None
|
ozone_file_units
|
str
|
Units field on the |
None
|
ozone_file_format
|
str
|
Fortran read format on the |
None
|
varying
|
TemporalValues
|
|
None
|
sectors
|
list of float
|
|
list()
|
by_sector
|
dict
|
Sector index -> :class: |
dict()
|
units
|
str
|
|
None
|
NOxBackground
dataclass
¶
Bases: BackgroundSpec
NOx background for GRSM (CO NOXVALUE / NOX_FILE / NOX_VALS / NOX_UNIT / NOXSECTR).
The :class:BackgroundSpec fields carry the whole-domain form;
sectors and by_sector carry the NOXSECTR form, in which
every value/file/profile line names its sector. AERMOD treats
NOXVALUE together with NOX_VALS as a fatal conflict (E605).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
units
|
str
|
|
None
|
sectors
|
list of float
|
|
list()
|
by_sector
|
dict
|
Sector index -> :class: |
dict()
|
ChemistryOptions
dataclass
¶
AERMOD NO2 chemistry configuration.
Controls the NO2-to-NOx conversion method used in AERMOD. Requires pollutant to be NO2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
ChemistryMethod
|
Chemistry algorithm (OLM, PVMRM, ARM2, GRSM). |
ARM2
|
ozone_data
|
OzoneData
|
Ozone data for OLM/PVMRM/GRSM methods. |
None
|
default_no2_ratio
|
float
|
Default in-stack NO2/NOx ratio (0-1), written as NO2STACK. Default
0.5. None writes no NO2STACK: every source then needs its own
|
0.5
|
olm_groups
|
list of SourceGroupDefinition
|
Source groups for OLM method. |
list()
|
nox_file
|
str
|
NOx background file (GRSM only): shorthand for
|
None
|
nox_background
|
NOxBackground
|
The full NOx background specification (GRSM only). |
None
|
effective_nox_background ¶
nox_background, or one built from the nox_file shorthand.
SaveFile
dataclass
¶
CO SAVEFILE [savfil [dayinc [savfl2]]]: periodic result save.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Save file; |
None
|
day_increment
|
int
|
Days between saves (AERMOD's default is 1). |
None
|
alternate_filename
|
str
|
Second file to alternate saves with. |
None
|
InitFile
dataclass
¶
CO INITFILE [inifil]: initialise results from a save file.
filename=None writes a bare INITFILE and AERMOD reads
:data:DEFAULT_RESTART_FILE.
MultiYear
dataclass
¶
CO MULTYEAR [H6H] savfil [initfil]: chain one-year runs.
Each year's run saves its result arrays to save_file; the next
year's deck names that file as its init_file. AERMOD accepts the
keyword for PM10, PM2.5, NO2, SO2, LEAD and OTHER only, and refuses
it together with SAVEFILE or INITFILE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save_file
|
str
|
This year's save file. |
required |
init_file
|
str
|
The previous year's save file. |
None
|
h6h
|
bool
|
Write the legacy |
False
|
GasDepositionDefaults
dataclass
¶
CO GASDEPDF fo fseas2 fseas5 [refspe]: gas deposition defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reactivity
|
float
|
Reactivity factor |
required |
fseas2
|
float
|
Fraction of maximum green LAI for seasonal category 2. |
required |
fseas5
|
float
|
Fraction of maximum green LAI for seasonal category 5. |
required |
reference_species
|
str
|
Optional reference species field. |
None
|
UrbanArea
dataclass
¶
One CO URBANOPT line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
population
|
float
|
Urban population (AERMOD rejects values below 100, E203). |
required |
urban_id
|
str
|
Urban area ID; required by AERMOD when a deck defines more than one area, meaningless when it defines one. |
None
|
name
|
str
|
Descriptive name (free text without blanks). |
None
|
roughness
|
float
|
Urban surface roughness length in metres (default 1.0 in AERMOD). |
None
|
ControlPathway
dataclass
¶
AERMOD Control (CO) pathway configuration
Defines overall model behavior, pollutant type, averaging periods, and other global settings.
elevated_terrain
property
¶
Whether AERMOD runs this deck with elevated terrain.
coset.f MODOPT starts from ELEV and switches to FLAT only for a
FLAT token without DFAULT (DFAULT overrides FLAT with W206; FLAT
with ELEV is FLATSRCS, still ELEV for receptors). Under ELEV
every receptor needs an elevation and a hill height, which is
what :meth:ReceptorPathway.to_aermod_input writes when told.
debug_files ¶
The file names on the DEBUGOPT line (fields that are not options).
debug_cards ¶
debug_options as the DEBUGOPT cards the writer puts out.
coset.f DEBOPT rejects a card of more than 11 fields (E202) and, since v26135 (D144), pools every DEBUGOPT card in order before reading the options, so a longer list goes on several cards. A card break falls only before an option name, keeping each option with its file name. A list of 11 fields or fewer stays on one card, which v24142 (no repeated DEBUGOPT, E135) also reads.
to_aermod_input ¶
Generate AERMOD CO pathway text.
event_processing writes the CO pathway of an EVENT deck:
coset.f dispatches EVENTFIL, SAVEFILE, INITFILE and MULTYEAR
only when the run is not an EVENT run (.NOT.EVONLY), so they
are left off, as AERMOD leaves them off the event deck it writes.
ScimOptions
dataclass
¶
ME SCIMBYHR start interval [wetstart wetint] [sfcfile pflfile].
Sampled Chronological Input Model: process hour start_hour of the
first day and every interval-th hour after it. meset.f SCIMIT
dispatches the keyword only under MODELOPT SCIM and reads 4, 6 or
8 fields; the wet-SCIM pair is no longer supported (W157, ignored)
but is kept so EPA's scimtest deck round-trips, and a six-field
card holds either that pair or the two summary files, told apart by
non-numeric characters, which is how they are written back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_hour
|
int
|
First hour sampled, 1-24 (E380). |
required |
interval
|
int
|
Hours between samples, at least 1 (E380); EPA uses 25. |
required |
wet_start_hour
|
int
|
The obsolete wet-SCIM fields, written back if given. |
None
|
wet_interval
|
int
|
The obsolete wet-SCIM fields, written back if given. |
None
|
surface_summary_file
|
str
|
Files AERMOD writes the sampled surface and profile records to. |
None
|
profile_summary_file
|
str
|
Files AERMOD writes the sampled surface and profile records to. |
None
|
MeteorologyPathway
dataclass
¶
AERMOD Meteorology (ME) pathway
Defines meteorological data files and processing options.
AERMOD requires five mandatory ME keywords: SURFFILE -- path to the .sfc file PROFFILE -- path to the .pfl file SURFDATA -- surface station ID + start year UAIRDATA -- upper-air station ID + start year PROFBASE -- base elevation (m MSL) of the profile data
to_aermod_input ¶
Generate AERMOD ME pathway text.
event_processing writes the ME pathway of an EVENT deck, which
meset.f reads without STARTEND (the events name their own dates;
the keyword is dispatched only when .NOT.EVONLY).
MaxiFile
dataclass
¶
OU MAXIFILE aveper grpid thresh filnam [funit].
Every value above threshold for one averaging period and source
group is written to filename as it occurs. ouset.f (OUMXFL)
counts fields: fewer than four data fields is fatal (E201), so there
is no shorter form -- the one-field MAXIFILE filename pyaermod
once wrote was rejected by every AERMOD release.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
averaging_period
|
str
|
One of the AVERTIME periods ( |
required |
source_group
|
str
|
Source group ID ( |
required |
threshold
|
float
|
Concentration above which a value is written. |
required |
filename
|
str
|
Output file. |
required |
file_unit
|
int
|
Fortran unit number; AERMOD allocates one when omitted. |
None
|
MaxDailyFile
dataclass
¶
OU MAXDAILY grpid filnam [funit] or OU MXDYBYYR ....
MAXDAILY writes every day's maximum 1-hour value (24-hour value for PM2.5) at every receptor; MXDYBYYR writes each year's ranked daily maxima. AERMOD accepts both only for the 1-hour NO2/SO2 and 24-hour PM2.5 NAAQS processing, i.e. POLLUTID NO2/SO2 with AVERTIME 1, or PM25 with AVERTIME 24 (ouset.f, E162/E163).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_group
|
str
|
Source group ID ( |
required |
filename
|
str
|
Output file. |
required |
file_unit
|
int
|
Fortran unit number; AERMOD allocates one when omitted. |
None
|
MaxDailyContribution
dataclass
¶
OU MAXDCONT grpid upper lower filnam [funit] or
OU MAXDCONT grpid upper THRESH thresh filnam [funit].
Source-group contributions to the ranked daily maxima, from
upper_rank down to lower_rank, or down to the rank whose
value first falls below threshold. Exactly one of lower_rank
and threshold is given. RECTABLE must cover upper_rank, and
AERMOD refuses MAXDCONT together with SAVEFILE, INITFILE or
MULTYEAR (E153).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_group
|
str
|
Source group whose contributions are wanted. |
required |
upper_rank
|
int
|
Highest rank (1 = the highest value) to analyse. |
required |
filename
|
str
|
Output file. |
required |
lower_rank
|
int
|
Lowest rank to analyse, >= |
None
|
threshold
|
float
|
Stop once the ranked value drops below this concentration. |
None
|
file_unit
|
int
|
Fortran unit number. |
None
|
RankFile
dataclass
¶
OU RANKFILE aveper rank filnam [funit] (ouset.f OURANK).
The rank highest values for one averaging period across all
receptors and groups, ranked; one card per averaging period (a second
is E211) and the period must be on AVERTIME (E203). EPA's flatelev,
lovett and mcr decks write one per short-term period.
:meth:read returns the file through
:func:pyaermod.aermod_outputs.read_rankfile.
read ¶
The ranked values AERMOD wrote (base_dir resolves a relative name).
SeasonHourFile
dataclass
¶
OU SEASONHR grpid filnam [funit] (ouset.f OUSEAS).
Season-by-hour-of-day averages for one source group (one card per
group, E211; the group must exist, E203). Refused under SCIM (E154).
:meth:read returns it through
:func:pyaermod.aermod_outputs.read_seasonhr.
EvalFile
dataclass
¶
OU EVALFILE srcid filnam [funit] (ouset.f OUEVAL).
The model-evaluation file for one source: arc maxima at the EVALCART
receptor arcs. The source must exist (E203) and the deck needs
EVALCART receptors (E256 at OUTQA; probe deck 28); EVALCART lines are
kept in unparsed_lines and written back before the RE pathway
ends. There is no reader for the file.
ToxxFile
dataclass
¶
OU TOXXFILE aveper thresh filnam [funit] (ouset.f OUTOXX).
Every value above threshold for one averaging period, for the
TOXX post-processor; one card per period (E211), the period on
AVERTIME (E203), and a warning (W296) for any period but 1 hour.
AERMOD opens the file FORM='UNFORMATTED', so it is binary;
:meth:read hands it to :func:pyaermod.aermod_outputs.read_toxxfile,
which reads the text layout of the same records.
read ¶
The threshold records, through :func:read_toxxfile.
OutputPathway
dataclass
¶
AERMOD Output (OU) pathway
Controls output file generation and formats.
period_plot_file_names ¶
{period: file name} of the plot files :attr:period_plot_files writes.
period_postfile_names ¶
{period: file name} of the POSTFILEs :attr:period_postfiles writes.
to_aermod_input ¶
to_aermod_input(event_processing: bool = False, event_output: Optional[str] = None, averaging_periods: Optional[Iterable[str]] = None) -> str
Generate AERMOD OU pathway text.
event_processing writes the OU pathway of an EVENT deck, which
evset.f EV_OUCARD reads: FILEFORM and EVENTOUT, nothing else (a
RECTABLE there is E110). event_output overrides
:attr:event_output for that line; with neither, AERMOD's own
default DETAIL is written. averaging_periods are the run's
(ControlPathway.averaging_periods), for which
:attr:period_plot_files and :attr:period_postfiles write one
file each; without them those two write nothing.
EventLocation
dataclass
¶
EV EVENTLOC evname XR= x YR= y zelev [zhill [zflag]].
The receptor of one event, in the layout evset.f EVLOC reads: the
coordinate pair is introduced by XR=/YR= (Cartesian) or
RNG=/DIR= (a range in metres and a direction in degrees,
which AERMOD converts to x and y). The elevation is not optional --
EVLOC wants at least eight fields on the card (E201 otherwise, probe
deck 30) -- and the hill height and flagpole height follow it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Receptor coordinates, or range and direction when |
required |
y
|
float
|
Receptor coordinates, or range and direction when |
required |
z_elev
|
float
|
Terrain elevation of the receptor (m). |
0.0
|
z_hill
|
float
|
Hill-height scale (m). |
0.0
|
z_flag
|
float
|
Flagpole receptor height (m); |
None
|
polar
|
bool
|
Write |
False
|
to_aermod_fields ¶
The fields after the event name, as AERMOD's MXEVNT writes them.
EventPeriod
dataclass
¶
EV EVENTPER evname aveper grpid date conc: one event.
evset.f EVPER reads exactly five fields: the event name, the
averaging period (one of the AVERTIME periods, 24 hours at most,
E297), the source group, the date of the end of the period as
YYMMDDHH, and the concentration the main run found for it, which
the event run checks its own result against. AERMOD writes the
events it generates (EVENTFIL) in this form, one EVENTLOC
after each EVENTPER.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Up to :data: |
required |
averaging_period
|
int
|
Hours; must appear on |
required |
date
|
str or int
|
|
required |
source_group
|
str
|
A |
'ALL'
|
original_conc
|
float
|
The concentration the main run reported (0 when unknown). |
0.0
|
location
|
EventLocation
|
The receptor; every event needs one (E130). |
None
|
EventPathway
dataclass
¶
AERMOD Event (EV) pathway.
An EVENT run re-models specific averaging periods at specific
receptors and reports each source's contribution. Its deck has the
pathways CO SO ME EV OU -- no RE, and the EV block must come
before OU (AERMOD's PRESET stops reading at OU FINISHED, so an EV
block after it is never seen, probe deck 30). The OU pathway of such
a deck holds only EVENTOUT and FILEFORM
(:attr:OutputPathway.event_output, :attr:OutputPathway.file_format).
:meth:AERMODProject.to_aermod_input writes that layout when
event_processing is set, which the reader sets for any deck with
an EV pathway; :meth:AERMODProject.write writes it to
event_filename.
unquote_path ¶
The file name AERMOD opens for a runstream field.
A field that starts with a double quote loses it and its closing quote (setup.f DEFINE); any other field is the name as written.
unquote_path('"My Met/a.sfc"'), unquote_path('x"y') ('My Met/a.sfc', 'x"y')
quote_path ¶
name as a runstream field: double-quoted when it holds a blank.
A name that already starts with a double quote is a field as written (setup.f DEFINE) and is returned unchanged, so quoting twice is harmless.
quote_path("My Met/a.sfc"), quote_path('"My Met/a.sfc"'), quote_path("a.sfc") ('"My Met/a.sfc"', '"My Met/a.sfc"', 'a.sfc')
exact_num ¶
value as :func:_num writes it when that reads back to exactly
the same float (1, 3.5, 0.1), otherwise the shortest text
that does (repr: 12.3456789012345), so a profile written to a
deck reads back the same numbers. The test is against float(value),
as the deck is read: a numpy float32 would compare at its own
precision, and 0.1000000015 reads back as another double. An
exponent always follows a decimal point (1.0e-05), the only form
AERMOD's STODBL reads.
one_decimal_or_exact ¶
value with one decimal, as EPA's own decks write it, when that
reads back to exactly the same float; otherwise the shortest text that
does (repr), so a rewritten deck reads back the same number
(22.25 stays 22.25, not 22.2).
profile_values ¶
values as a list, and whether it was a sequence of values.
The one place the rules of :func:value_list live (the project-file
writer uses them too). A list, a tuple, a range, or anything with a
tolist() that gives a list (a numpy array, a pandas Series (its
values, in order, not its index), Index or Categorical) is a
sequence: (its values, True). A string or bytes-like object is one
value, not a sequence of characters or bytes, and so is anything that
is not iterable: ([values], False); a numpy scalar or 0-d array
gives its Python value (tolist()) in place of itself.
Any other iterable raises :class:NotAValueList (a
:class:TypeError): a one-shot iterator (a map, a generator, a zip)
would be used up by the first pass over it (the validator's), and the
deck would then get a card without values; a set or a dict has no
order AERMOD's could be. Nothing is taken from it.
value_list ¶
The values of a profile as a list, by :func:profile_values' rules.
continued_value_lines ¶
Runstream lines for a value profile continued over several lines.
AERMOD reads the values of O3VALUES, NOX_VALS and BACKGRND
profiles over as many lines as needed, each repeating the keyword
and prefix (the temporal flag, after SECTn for a sector).
values is a number or a list, tuple, range, numpy array or
pandas Series of numbers (see :func:value_list; anything else
iterable, such as a one-shot iterator, raises :class:TypeError
rather than give a card without values); per_line values go on
each line, each written by :func:exact_num so it reads back as the
same number.
dayrange_field_is_valid ¶
True for the four field forms meset.f DAYRNG reads: a Julian day
(50), a Julian range (50-60), a month/day (3/15) or a
month/day range (3/15-4/30).
period_file_name ¶
The name of a per-period output file: <stem>_<label><suffix>.
The label follows EPA's own decks (AERTEST_01H.PLT): an hourly
period is its hours in two digits and H (01H, 24H); MONTH,
PERIOD and ANNUAL are themselves. period_file_name("run", "1",
".plt") is "run_01H.plt".
plot_rank_number ¶
The rank (1 = highest) of a PLOTFILE's high value.
Takes what OUPLOT takes, a number, FIRST...TENTH or
1ST...10TH, and also the H2H / H8H shorthand for the
highest-second-high and highest-eighth-high. Raises ValueError
for anything else.
plot_rank_token ¶
rank as written on a PLOTFILE card: 1ST...10TH, else the number.
FIRST stays FIRST, the spelling pyaermod has always written.
plot_file_group_fields ¶
(averaging, group, filename, rank) of a plot_file_groups entry.
An entry is (averaging, group, filename), for the highest value,
or (averaging, group, filename, rank).
rectable_rank ¶
The highest rank a RECTABLE (or MAXTABLE) rank field names, or None if it names none.
A range ("1-10", "FIRST-THIRD") counts by its upper end; "8TH" and "8" both mean rank 8.