Run the Newmark steps of a project
runProcess.RdProduces the ts, dn and kmax products of a hazard project declared by
a JSON contract. It reads the contract, reads the hazard inputs, calls the
in-memory calculations (getGeometry(), getTs(), fitDnProducts(),
getDnTables(), fitKmaxProducts(), getKmaxTable()) and replaces each
product atomically. It is the only function of the package that reads and
writes the project's Newmark products; buildGMDP() reads a directory of
hazard exports, and every other calculation receives and returns tables.
Arguments
- file
Path of the JSON contract, resolved against
rootwhen it is relative.- root
Project root; the paths of the contract are resolved against it. It must exist.
- steps
Character vector with any of
"ts","dn"and"kmax"; they always run in that order.- sites
Site identifiers to process; empty selects every site with a rock file.
- models
Model identifiers; when given they must include
ID.gmdp.- seed
Optional non-negative integer that seeds
tsthroughset.seed(), which replaces the caller's random stream.NULLleaves that stream alone and letstsconsume it;dnkeeps its own per-demand seeds either way. The message oftsreports the seed it used. Withouttsthe seed has no effect, but it is checked on every run.- dryRun
Logical; resolve and check the run, report the steps, the selected sites and every product it would write or replace, and return without calculating, seeding, creating a directory or writing anything. A contract or an input the real run would reject fails here the same way. With
tsselected the MCE demands and the heights are left unchecked, because the shear table that fixes them is a product of that run.
Details
Every product is written under path.products, the directory newmark owns.
ts writes the global ShearTable.Rds there, creating that directory when
it is absent. dn writes DnTable.Rds, DnDraws.Rds and PGATable.csv
under <path.products>/<ID.gmdp>/<siteID>/, plus the global DnTable.Rds
and DnPlotTable.Rds. kmax reads those draws and PGA tables and writes
the per-site and global kmaxTable.Rds. The hazard directories are only
read: MCETable.Rds from path.data, and the UHSRock.Rds of every
selected site from <path.uhs>/<ID.gmdp>/<siteID>/, which is also where
the sites are discovered. dn and kmax read back the ShearTable.Rds of
path.products. An input that is absent fails naming the file and the step
that writes it.
Global tables are rebuilt from every site product found under the model
directory, selected or not. dn is reproducible: every site and demand is
sampled with its own fixed seed.
The contract, the paths and the inputs of every selected step are resolved
before the first product is calculated or written, so a key the contract
lacks, an input no selected step produces, an unknown site, a selected
site the MCE table does not carry or, for kmax, a shear table without
heights stops the run with nothing replaced. An
input a selected step writes earlier in the same run is not required in
advance: with ts,dn the shear table is a product, not a prerequisite.
Project contract
The contract is one JSON object. Its path block and file itself are
resolved against root when they are relative; the working directory is
never changed. Reading it evaluates no code.
path.productsDirectory newmark writes, and the only one it writes: the global tables at its root and the products of each site under
<ID.gmdp>/<siteID>/.tscreates it when it is absent, anddncreates the directory of each site it processes. Always required; a contract that does not declare it fails naming it, and no product falls back to the hazard directories.path.dataDirectory of the hazard tables, read only:
dntakesMCETable.Rdsfrom it. Always required.path.uhsDirectory holding
<ID.gmdp>/<siteID>/UHSRock.Rds, read only; it is also where the sites are discovered. Required bydnandkmax.path.calcJSON of the classical calculation behind the rock spectra. Required by
dn, which samples with itsjob.calculation.truncation_level.Vref.gmdp,ID.gmdp,TR.gmdp,NS,Mw.gmdp,subductionThe reference velocity, model identifier, return periods, realisations per cell, magnitude and subduction regime. Required by
dnandkmax;Vref.gmdpis also required byts.DaH.gmdpAdmissible displacements relative to the height, in percent of
Hs. Required bykmax, which forms the levelsDaH.gmdptimesHsover every height of the shear table, in centimetres (a percent of metres) rounded to six significant digits, and inverts every geometry at that whole set: a geometry's own relative levels are the rows whoseDaissignif(DaH.gmdp * Hs, 6)for itsHs. Absolute displacements remain available throughfitKmaxProducts(),getKmaxTable()andinvertDnDraws().Dn_weightsObject of displacement model names and numeric weights, such as
{"AM88": 1, "BM19": 1}.uscs,IDmObject of USCS code arrays indexed by material, and the selected material identifiers. Required by
ts.geometryTableOptional array of
IDg,Hs,bandsrow objects. It replaces the range construction below.Hs,Hs.min,Hs.max,NTS,lo.min,lo.max,s.min,s.maxRange construction of
ts: explicitHs, otherwiseNTS(10 when absent) heights betweenHs.minandHs.max, otherwise the defaultseq(10, 120, by = 10). Theloandsends are required.pairsOptional array of
IDg/IDmrow objects restricting the geometry by material product ofts.DN_PARALLEL,DN_WORKERS,KMAX_PARALLEL,KMAX_WORKERSOptional parallel controls. The flags are logical and default to true; the worker counts are positive integers and default to one less than the detected cores, capped by the work of the step.
Every numeric setting, including the numeric columns of geometryTable, is
read as a double: JSON spells a whole number without a decimal point and a
parser reports it as an integer, so a project keeps the values it declares.
A required key that is absent, a contract that does not exist and a
contract that is not one JSON object each fail naming the contract.
Examples
if (FALSE) { # \dontrun{
# Requires a project root holding newmark.json, the hazard inputs it
# declares and the classical calculation JSON; not bundled with the package.
runProcess(root = "path/to/project", steps = c("dn", "kmax"))
} # }