Class ReadYaml#
- class tools.inputparser.ReadYaml(filename)[source]#
Class for reading simulation input file and initialising model parameters.
Definition of input parameters is provided in the User Documentation
Initialise
__init__(filename)Parsing YAML file.
Private Methods
_get_param(*keys[, default])Safe traversal into
self.input.Update some forcing parameters in case of a restart.
Read domain definition, boundary conditions and flow direction parameters.
Read domain additional information.
Read domain additional information.
Read simulation time declaration.
_addTime(timeDict)Read additional time parameters.
_readSPL()Read surface processes erosion and deposition laws parameters.
Read hillslope parameters.
Read extra hillslope parameters.
Read soil information parameters.
Define sealevel evolution.
_isKeyinFile(dmap)Check if a numpy compressed file exists and that the corresponding keys are present in it.
_storeTectonics(k, tecStart, hMap, tMap, ...)Record tectonic conditions.
_defineTectonics(k, tecSort, tecdata)Define tectonics conditions.
Parse tectonics forcing conditions.
_defineErofactor(k, sStart, sMap, sUniform, ...)Define sediment surface erodibility factor conditions.
Parse erodibility factor based on surface geology.
_getTe(k, tStart, tMap, tUniform, tedata)Define elastic map.
Parse elastic map forcing conditions.
_defineRain(k, rStart, rMap, rUniform, ...)Define precipitation conditions.
_defineEvap(k, eStart, eMap, eUniform, evapdata)Define evaporation conditions for one climate event.
Parse rain and evaporation forcing conditions.
Read compaction parameters.
Parse the optional dual-lithology (coarse/fine) stratigraphy block.
Parse the optional in-model sediment-provenance tracer block.
Parse flexural isostasy variables.
Read flexure additional information.
Parse orographic precipitation variables.
_extraOrography(oroDict)Read domain additional information.
_readIce()Parse ice flow variables.
_iceGeomField(val)Split a glacier-geometry input (
hela/hice/hterm) into a scalar fallback and an optional[file, key]map spec._buildIceSeries(glaciers, elaTop, iceTop, ...)Build the glacier-geometry time series consumed by
_updateIce._extraIce(icefile, elaH, iceH, iceT)Legacy uniform glacier geometry: build the scalar time functions
self.iceT/self.elaH/self.iceHfrom anevolCSV or from constanthterm/hela/hice._checkMap(spec, name)Validate that a
[file, key]npz map exists and contains the field, without loading the (potentially large) array._loadIceMap(spec, name)Load a per-vertex glacier-geometry map (full-mesh array) from a validated
[file, key]npz spec — the same convention as the precipitation/tectonic maps._readOut()Parse output directory.
Private functions#
- ReadYaml._get_param(*keys, default=None)[source]#
Safe traversal into
self.input.Returns
default(None by default) if any key in the chain is missing, or if an intermediate node is not a dict. Never raises KeyError.Examples:
self._get_param("name") # self.input.get("name", default) self._get_param("domain", "flowdir") # self.input["domain"].get("flowdir", default) self._get_param("spl", "K", default=1e-12)
Use this for direct access through
self.input. For inner keys on a pre-extracted section dict (e.g.splDict = self.input["spl"]bound on an earlier line), prefer the Python builtinsplDict.get(key, default)— it makes the data flow more visible and avoids a redundant top-level lookup.Out of scope: this helper navigates
self.inputonly. For NPZ-archive accesses elsewhere in this file (_isKeyinFile, the rainKey/sedKey blocks inside_readRain/_readErofactor/_readTeMap), keep the existingtry/except KeyErrorsince those exceptions carry user-facing diagnostics about missing fields in the data file.See AGENTS.md > The
_extra*methods are mandatory continuations: the call chain (_readDomain → _extraDomain → _extraDomain2,_readHillslope → _extraHillslope, etc.) is load-bearing. The internaltry/except KeyErrorblocks inside those methods are NOT load-bearing and use this helper.
- ReadYaml._readDomain()[source]#
Read domain definition, boundary conditions and flow direction parameters.
- ReadYaml._isKeyinFile(dmap)[source]#
Check if a numpy compressed file exists and that the corresponding keys are present in it.
- ReadYaml._storeTectonics(k, tecStart, hMap, tMap, zMap, tecEnd, tecdata)[source]#
Record tectonic conditions.
- Parameters:
k – tectonic event number
tecStart – tectonic event start time
hMap – horizontal tectonic information
tMap – vertical tectonic displacement information
zMap – elevation information
tEnd – tectonic event end time
tecdata – pandas dataframe storing each tectonic event
- Returns:
appended tecdata
- ReadYaml._defineTectonics(k, tecSort, tecdata)[source]#
Define tectonics conditions.
- Parameters:
k – tectonic event number
tecSort – sorted tectonic event
tecdata – pandas dataframe storing each tectonic event
- Returns:
appended tecdata
- ReadYaml._defineErofactor(k, sStart, sMap, sUniform, sedfacdata)[source]#
Define sediment surface erodibility factor conditions.
- Parameters:
k – erodibility factor map number
sStart – erodibility factor map start time
sMap – erodibility factor map file event
sUniform – erodibility factor uniform value event
sedfacdata – pandas dataframe storing each erodibility factor map
- Returns:
appended sedfacdata
- ReadYaml._getTe(k, tStart, tMap, tUniform, tedata)[source]#
Define elastic map.
- Parameters:
k – elastic map event number
teStart – elastic map event start time
teMap – elastic map file event
teUniform – elastic map uniform thickness value event
tedata – pandas dataframe storing each elastic map event
- Returns:
appended tedata
- ReadYaml._defineRain(k, rStart, rMap, rUniform, rZscale, raindata)[source]#
Define precipitation conditions.
- Parameters:
k – precipitation event number
rStart – precipitation event start time
rMap – precipitation map file event
rUniform – precipitation uniform value event
rZscale – precipitation scaled with elevation value event
raindata – pandas dataframe storing each precipitation event
- Returns:
appended raindata
- ReadYaml._defineEvap(k, eStart, eMap, eUniform, evapdata)[source]#
Define evaporation conditions for one climate event.
Mirrors _defineRain but for evaporation. Evaporation is opt-in per-row: if both eMap and eUniform are None for this event, evapdata is returned unchanged (no row appended).
- Parameters:
k – climate event number
eStart – event start time
eMap – evaporation map (tuple of path+key) or None
eUniform – evaporation uniform scalar (m/yr) or None
evapdata – pandas dataframe storing each evaporation event (or None on first call)
- Returns:
appended evapdata (or unchanged if this row has no evap)
- ReadYaml._readRain()[source]#
Parse rain and evaporation forcing conditions.
Both share the same [climate] YAML block. Each climate event row may declare rainfall (uniform/map/zscale) and, optionally, evaporation (evap_uniform/evap_map). Evaporation is opt-in: if no row has an evap field, self.evapdata ends up as None and the downstream solver bypasses both evap hooks.
- ReadYaml._extraStrata()[source]#
Parse the optional dual-lithology (coarse/fine) stratigraphy block.
Continuation of
_readCompaction(the coarse porosity curve defaults to the single-fractioncompactionvalues, so a model withstrata: dual: False— or nostratablock at all — runs the existing single-fraction path bitwise-unchanged).Sets
self.stratLith(master opt-in flag) plus the per-lithology parameters consumed by later phases (porosity-depth curves, bedrock composition, marine fine transport efficiency, per-fraction lake inlet bias, and subaerial/subaqueous diffusivities). All of these are inert whileself.stratLithis False.Dual lithology is only meaningful when stratigraphy recording is on; if requested with stratigraphy disabled (
self.stratNb == 0) the flag is forced back to False with a rank-0 warning.See
docs/DESIGN_DUAL_LITHOLOGY.mdand AGENTS.md > The_extra*methods are mandatory continuations.
- ReadYaml._extraProvenance()[source]#
Parse the optional in-model sediment-provenance tracer block. N source-rock classes are carried (as a passive label — no physics feedback) through erosion, transport, deposition and the stratigraphic record, giving conservation-exact, recycling-aware provenance per layer. See
docs/DESIGN_PROVENANCE.md§6.Sets
self.provOn(master opt-in),self.provNb(class count), the per-vertex source-class source (uniformscalar orsource[file, key]map, resolved post-mesh inreadStratLayers), and an optionalcu_weight. All inert whileprovOnis False; like dual lithology it requires stratigraphy (stratNb > 0).
- ReadYaml._iceGeomField(val)[source]#
Split a glacier-geometry input (
hela/hice/hterm) into a scalar fallback and an optional[file, key]map spec. A list/tuple value is a per-vertex npz map; anything else is a uniform scalar.- Returns:
(scalar_or_None, map_spec_or_None)
- ReadYaml._buildIceSeries(glaciers, elaTop, iceTop, termTop)[source]#
Build the glacier-geometry time series consumed by
_updateIce.glaciers(when given) is a list of{start, hela, hice, hterm}events (each altitude uniform-or-map); otherwise the top-levelhela/hice/htermdefine a single interval starting attStart. Each interval stores, per field, a(scalar, map_spec)pair (exactly one is non-None). Map files/keys are validated here; the arrays are loaded lazily on interval change in_updateIce.- Returns:
list of intervals sorted by start time.
- ReadYaml._extraIce(icefile, elaH, iceH, iceT)[source]#
Legacy uniform glacier geometry: build the scalar time functions
self.iceT/self.elaH/self.iceHfrom anevolCSV or from constanthterm/hela/hice. The per-vertex / time-series map path is handled separately by_buildIceSeries+_updateIce.
- ReadYaml._checkMap(spec, name)[source]#
Validate that a
[file, key]npz map exists and contains the field, without loading the (potentially large) array. Used at parse time for the glacier-geometry maps; the array is loaded lazily by_loadIceMapon interval change.