Skip to contents

For each station with raw/AT.<RID>.csv / .json, calls getRawIntensities() to compute the 20 AT-derivable scalars per direction via getIntensity(). Emits one row per (RecordID, DIR) - three rows per record.

Usage

buildRawIntensityTable(
  path.records,
  path.index,
  owners = NULL,
  incremental = TRUE,
  force = FALSE
)

Arguments

path.records

Absolute path to the records root. Required – no default.

path.index

Absolute path to the index root where per-owner CSVs are written. Required – no default.

owners

Character vector of OwnerIDs. NULL = scan all.

incremental

Logical. If TRUE, skip records already present in RawIntensityTable.<O>.csv. Default: TRUE.

force

Logical. If TRUE, ignore incremental cache and recompute everything. Default: FALSE.

Value

Invisibly, the per-owner row counts.

Details

Schema:

RecordID, DIR, OCID,
  AI, AId, AIu, ARMS, ATn, ATo, AZC, CAV, CAV5,
  D0575, D0595, D2080, Dmax, EPI, Fs, NP, PDI,
  PGA, TmA, dt

All amplitude scalars are in TARGET_UNITS = "mm"-derived units (mm/s2, mm/s, etc. per getIntensity() contract).

Examples

root <- file.path(tempdir(), "gmsp-raw-intensity-table-example")
index <- file.path(tempdir(), "gmsp-raw-intensity-table-index")
unlink(c(root, index), recursive = TRUE)
raw <- file.path(root, "AAA", "E1", "S1", "raw")
dir.create(raw, recursive = TRUE)
dir.create(index)
t <- seq(0, 1, by = 0.01)
data.table::fwrite(
  data.table::data.table(
    H1 = sin(2 * pi * t),
    H2 = 0.5 * cos(2 * pi * t),
    UP = 0.25 * sin(4 * pi * t)
  ),
  file.path(raw, "AT.R1.csv")
)
jsonlite::write_json(
  list(RecordID = "R1", OwnerID = "AAA", EventID = "E1",
       StationID = "S1", NetworkID = "NW",
       DIR = c("H1", "H2", "UP"), OCID = c("H1", "H2", "UP"),
       NP = rep(length(t), 3), dt = 0.01, Fs = 100, Units = "mm"),
  file.path(raw, "AT.R1.json"), auto_unbox = TRUE
)
suppressMessages(buildRawIntensityTable(root, index, owners = "AAA",
                                        incremental = FALSE))
data.table::fread(file.path(index, "RawIntensityTable.AAA.csv"))
#>    RecordID    DIR   OCID    AI   AId   AIu  ARMS   ATn   ATo   AZC   CAV  CAV5
#>      <char> <char> <char> <int> <int> <int> <int> <int> <int> <int> <int> <int>
#> 1:       R1     H1     H1     0     0     0     1     0     0     1     1     0
#> 2:       R1     H2     H2     0     0     0     0     0     0     2     0     0
#> 3:       R1     UP     UP     0     0     0     0     0     0     3     0     0
#>    D0575 D0595 D2080  Dmax   EPI    Fs    NP   PDI   PGA   TmA    dt
#>    <num> <num> <num> <int> <int> <int> <int> <int> <int> <num> <num>
#> 1:   0.6   0.7   0.6     1     0   100   101     0     1   0.5  0.01
#> 2:   0.8   1.0   0.8     1     0   100   101     0     0   0.5  0.01
#> 3:   0.7   0.8   0.7     1     0   100   101     0     0   0.3  0.01