R/makeAccelerationFile.R

Defines functions makeAccelerationFile

Documented in makeAccelerationFile

makeAccelerationFile <- function(supDF=NULL, fname=NULL) {
  # supmat: matrix with depth [m] and corresponding acceleration value
  zstr <-
       "500.00   1500.00   2500.00   3500.00   4500.00   5500.00   6500.00
       7500.00   8500.00   9500.00  10500.00  11500.00  12500.00  13500.00
      14500.00  15500.00  16509.84  17547.90  18629.13  19766.03  20971.14
      22257.83  23640.88  25137.02  26765.42  28548.37  30511.92  32686.80
      35109.35  37822.76  40878.46  44337.77  48273.67  52772.80  57937.29
      63886.26  70756.33  78700.25  87882.52  98470.59 110620.42 124456.69
     140049.72 157394.64 176400.33 196894.42 218645.66 241397.16 264900.12
     288938.47 313340.47 337979.34 362767.03 387645.19 412576.81 437539.25
     462519.03 487508.34 512502.81 537500.00"
  z <- as.numeric(strsplit(gsub('\n',' ',zstr),split=' {1,}')[[1]]) / 100 # [m]
  if (is.null(supDF))
     supDF <- data.frame(z=c(1115, 5000), # as Danabasoglu (2004)
                         a=c(1,    20))
  a <- round(approx(supDF$z, supDF$a, z, rule=2)$y,1)
  if (!is.null(fname))
    write(a, fname, ncolumns=1)
  return(a)
}
garciapintado/rdafCESM documentation built on July 18, 2019, 4:41 p.m.