Skip to content

Commit

Permalink
Refactor hysplit_config_init()
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-iannone committed Sep 20, 2019
1 parent af8fa75 commit 0427871
Showing 1 changed file with 65 additions and 27 deletions.
92 changes: 65 additions & 27 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,56 @@ hysplit_config_init <- function(dir) {

# Default `SETUP.CFG` configuration file
cat(
" &SETUP", " tratio = 0.75,", " initd = 0,", " kpuff = 0,", " khmax = 9999,",
" kmixd = 0,", " kmix0 = 250,", " kzmix = 0,", " kdef = 0,", " kbls = 1,",
" kblt = 2,", " conage = 48,", " numpar = 2500,", " qcycle = 0.0,", " efile = '',",
" tkerd = 0.18,", " tkern = 0.18,", " ninit = 1,", " ndump = 1,", " ncycl = 1,",
" pinpf = 'PARINIT',", " poutf = 'PARDUMP',", " mgmin = 10,", " kmsl = 0,",
" maxpar = 10000,", " cpack = 1,", " cmass = 0,", " dxf = 1.0,", " dyf = 1.0,",
" dzf = 0.01,", " ichem = 0,", " maxdim = 1,", " kspl = 1,", " krnd = 6,",
" frhs = 1.0,", " frvs = 0.01,", " frts = 0.10,", " frhmax = 3.0,", " splitf = 1.0,",
" tm_pres = 0,", " tm_tpot = 0,", " tm_tamb = 0,", " tm_rain = 0,", " tm_mixd = 0,",
" tm_relh = 0,", " tm_sphu = 0,", " tm_mixr = 0,", " tm_dswf = 0,", " tm_terr = 0,",
" /",
"&SETUP",
"tratio = 0.75,",
"initd = 0,",
"kpuff = 0,",
"khmax = 9999,",
"kmixd = 0,",
"kmix0 = 250,",
"kzmix = 0,",
"kdef = 0,",
"kbls = 1,",
"kblt = 2,",
"conage = 48,",
"numpar = 2500,",
"qcycle = 0.0,",
"efile = '',",
"tkerd = 0.18,",
"tkern = 0.18,",
"ninit = 1,",
"ndump = 1,",
"ncycl = 1,",
"pinpf = 'PARINIT',",
"poutf = 'PARDUMP',",
"mgmin = 10,",
"kmsl = 0,",
"maxpar = 10000,",
"cpack = 1,",
"cmass = 0,",
"dxf = 1.0,",
"dyf = 1.0,",
"dzf = 0.01,",
"ichem = 0,",
"maxdim = 1,",
"kspl = 1,",
"krnd = 6,",
"frhs = 1.0,",
"frvs = 0.01,",
"frts = 0.10,",
"frhmax = 3.0,",
"splitf = 1.0,",
"tm_pres = 0,",
"tm_tpot = 0,",
"tm_tamb = 0,",
"tm_rain = 0,",
"tm_mixd = 0,",
"tm_relh = 0,",
"tm_sphu = 0,",
"tm_mixr = 0,",
"tm_dswf = 0,",
"tm_terr = 0,",
"/",
sep = "\n",
file = paste0(dir, "/", "SETUP.CFG")
)
Expand All @@ -70,22 +109,21 @@ hysplit_config_init <- function(dir) {
)
}

#' Modify default `SETUP.CFG` for extended meteorology
#' @param extended_met An option to report additional meteorological data along
#' each output trajectory.
#' @param dir The directory to which the files should be written.
#'
#' @noRd
hysplit_config_extended_met <- function(extended_met,
exec_dir) {

if (extended_met) {
setup_cfg <- readLines(con = file.path(exec_dir, "SETUP.CFG"))
setup_cfg <- gsub("(tm_.* )(0),", "\\11,", setup_cfg)
cat(setup_cfg, file = file.path(exec_dir, "SETUP.CFG"), sep = "\n")
}
}

# #' Modify default `SETUP.CFG` for extended meteorology
# #' @param extended_met An option to report additional meteorological data along
# #' each output trajectory.
# #' @param dir The directory to which the files should be written.
# #'
# #' @noRd
# hysplit_config_extended_met <- function(extended_met,
# exec_dir) {
#
# if (extended_met) {
# setup_cfg <- readLines(con = file.path(exec_dir, "SETUP.CFG"))
# setup_cfg <- gsub("(tm_.* )(0),", "\\11,", setup_cfg)
# cat(setup_cfg, file = file.path(exec_dir, "SETUP.CFG"), sep = "\n")
# }
# }

#' Determine which operating system is in use
#'
Expand Down

0 comments on commit 0427871

Please sign in to comment.