build.projection: Project a time series based on estimated quantile changes

Description Usage Arguments Details Value Output On project.climate parameters

View source: R/wrapper_project_climate.R

Description

build.projection is a wrapper for project.climate that allows for file management, batch processing, bootstrapping, and saving of output, if all the directory and filename/structure defaults are followed, for the projection of climate time series by changes in the distribution shape estimated across a different dataset/model, with potentially multiple runs of data over the same time frame, calculated using wrapper_get_quantiles.R.

Usage

1
2
build.projection(defaults, log = T, max.runtime = 4 * 60 * 60,
  assumed.avg.processing.time = 5, process.inputs = list())

Arguments

defaults

the output from set.defaults (see Section "On project.climate parameters," below)

log

whether to log the output using sink() in the directory [defaults$aux.data.dir]/run_logs/. By default, true. Log filenames are (using run start time): estimate_quantiles_run_YYYY-MM-DD_HH-MM-SS.txt.

max.runtime

if batch processing on a server with a maximum allocated runtime, you can set it here, and the run will stop when the next block of time might take longer to run than the remaining allocated time. This prevents empty, un-processed temporary output files from preventing the complete processing of all data 'blocks'. Explicitly, the next block isn't processed and the function run is interrupted if the current system time if start.time + max.runtime - Sys.time() < (2 * 160) * [num pixels in block] seconds, assuming that it takes roughly 160 seconds per pixel to run this code (for 40 runs, 121 years of data, on the server this code was written on etc.); this time assumption can be changed with the assumed.avg.processing.time option, detailed below. Set to 0 if you don't want this feature interefering.

assumed.avg.processing.time

by default 5 (seconds), the estimated processing time per pixel. Used in interrupting batch run if time is running out.

process.inputs

add custom process.inputs list. By default, the code attempts to load [defaults$mod.data.dir]/process_inputs.RData. If this is not desired (i.e. you want to just process a subset of process chunks), put a subsetted output of get.process.chunkshere , or make your own - just make sure that it's a list of process chunks, with every element containing at least the fields [global_loc] (used to load the correct [params] file), [lat] (just one lat, by lat band), [lon] (all the lon values desired), and [fn] (the raw data filename from which the params were calculated).

Details

build.projection runs project.climate on a pixel-by-pixel basis. These pixels are loaded and processed on a latitude-by-region/subset basis - in other words, a 'block' of pixels is every pixel in one subset/region (determined by a separate .nc file in the mod.data.dir set by the set.defaults function) with the same latitude. This 'block' of pixels is loaded and sent through get.quantiles one at a time; the resultant coefficients are saved in files 'block' by 'block' (and can be recombined later using combine.locs). The 'blocks' are identified through the saved output of get.process.chunks.

CURRENTLY, the code requires that the 'base data' (the data to be projected) is saved in the SAME chunk-by-chunk format as the model data being used to calculated the quantile changes. In other words, each model .nc file in mod.data.dir must have an equivalent file with the same suffix and covering the same pixels in base.data.dir. Since memory usage is a much bigger issue in the model quantile fits, a future version of this will allow for the use of more 'standard' base data (not saved in chunks).

Value

Nothing. Output is saved instead.

Output

the output="full" output in project.climate option is used, returning (within the function) a list for each latitude-by-region/subset chunk giving the projected time series as an xts object (proj.data), the coefficients of the quantiles used for normalizing the base climate time series (base.norm.coef), the lat and lon of the pixel, the output.years, and the linear indices (in the base period) used a the reference year/days in the projected period (base.idxs). This list object is saved for each processing chunk in the "[defaults$base.data.dir]/output/" directory, under the filename: "[filevar]_day_[base.name]_[mod.name]proj_[proj.method]_[proj.year.range]_locs[global_loc(1)-global_loc(end)]([fn.suffix]).RData", where proj.method is a quick shorthand for the projection method (set by index.type and resampling.timescale in defaults), and fn.suffix is set by set.defaults.

On project.climate parameters

Inputs to project.climate are governed through the defaults object, generated by the set.defaults function. These include which data to use as 'base' data for the projection (index.type and resampling.timescale) and bootstrap/uncertainty quantification parameters (bootstrapping, nboots, and block.size). See project.climate and set.defaults for details.


ks905383/quantproj documentation built on Nov. 1, 2020, 9:12 p.m.