From e256a0142e479a45c15f94b6f2900fdb87085ed5 Mon Sep 17 00:00:00 2001 From: Luke Winslow Date: Fri, 18 Mar 2016 16:54:42 -0500 Subject: [PATCH 1/8] fixing up bias check for new NHD runs --- demo/cluster_GCMs_future_all_out.R | 126 ----------------------- demo/cluster_bias_check.R | 159 ----------------------------- demo/cluster_cont_calibrate_bias.R | 76 +++++++------- demo/cluster_cont_hab_out.R | 22 ++-- 4 files changed, 51 insertions(+), 332 deletions(-) delete mode 100644 demo/cluster_GCMs_future_all_out.R delete mode 100644 demo/cluster_bias_check.R diff --git a/demo/cluster_GCMs_future_all_out.R b/demo/cluster_GCMs_future_all_out.R deleted file mode 100644 index 50086d0..0000000 --- a/demo/cluster_GCMs_future_all_out.R +++ /dev/null @@ -1,126 +0,0 @@ -## Lets cluserify things - -library(parallel) - -#lets try 100 to start -c1 = makePSOCKcluster(paste0('licon', 1:50), manual=TRUE, port=4042) - - -clusterCall(c1, function(){install.packages('devtools', repos='http://cran.rstudio.com')}) -clusterCall(c1, function(){install.packages('rLakeAnalyzer', repos='http://cran.rstudio.com')}) -clusterCall(c1, function(){install.packages('dplyr', repos='http://cran.rstudio.com')}) - - -clusterCall(c1, function(){library(devtools)}) - -glmr_install = clusterCall(c1, function(){install_github('lawinslow/GLMr')}) -glmtools_install = clusterCall(c1, function(){install_github('lawinslow/glmtools')}) -lakeattr_install = clusterCall(c1, function(){install_github('lawinslow/lakeattributes')}) -mdalakes_install = clusterCall(c1, function(){install_github('lawinslow/mda.lakes')}) - -library(lakeattributes) -library(mda.lakes) -library(dplyr) -library(glmtools) - -lakes = read.table(system.file('supporting_files/managed_lake_info.txt', package = 'mda.lakes'), - sep='\t', quote="\"", header=TRUE, as.is=TRUE, colClasses=c(WBIC='character')) - -to_run = paste0('WBIC_', lakes$WBIC) - - -model_future_habitat = function(site_id){ - - modern_era = 1979:1999 - future_era = 2040:2069 - - library(lakeattributes) - library(mda.lakes) - library(dplyr) - library(glmtools) - library(stringr) - - tryCatch({ - fastdir = tempdir() - if(file.exists('/mnt/ramdisk')){ - fastdir = '/mnt/ramdisk' - } - - run_dir = file.path(fastdir, site_id) - dir.create(run_dir) - cat(run_dir, '\n') - - secchi = get_kd_best(site_id, years=modern_era) - - bare_wbic = substr(site_id, 6, nchar(site_id)) - - driver_path = get_driver_path(paste0(site_id, '.csv'), driver_name = "GENMOM") - driver_path = gsub('\\\\', '/', driver_path) - - #run with different driver and ice sources - - prep_run_chained_glm_kd(bare_wbic, kd=1.7/secchi$secchi_avg, path=run_dir, years=modern_era, - ice_src='empirical.cm2.0.ice.tsv', - nml_args=list( - dt=3600, subdaily=FALSE, nsave=24, - timezone=-6, - csv_point_nlevs=0, - meteo_fl=driver_path)) - - - secchi = get_kd_best(site_id, years=future_era) - - prep_run_chained_glm_kd(bare_wbic, kd=1.7/secchi$secchi_avg, path=run_dir, years=future_era, - ice_src='empirical.cm2.0.ice.tsv', - nml_args=list( - dt=3600, subdaily=FALSE, nsave=24, - timezone=-6, - csv_point_nlevs=0, - meteo_fl=driver_path)) - - out = chained.habitat.calc(run_dir, lakeid = bare_wbic) - - secchi = get_kd_best(site_id, years=c(modern_era, future_era)) - names(secchi) = c('year', 'secchi_avg', 'secchi_source') - out = merge(out, secchi, by='year') - - out$site_id = site_id - - ################################################################################ - # Water temps out - ################################################################################ - sims = Sys.glob(file.path(run_dir, 'output*.nc')) - - depths = get.offsets(get_temp(sims[1], reference = 'surface')) - - #loop over years - all.data = data.frame() - for(i in 1:length(sims)){ - tmp = get_temp(sims[i], reference='surface', z_out=depths) - all.data = rbind(all.data, tmp) - } - - all.data$site_id = site_id - - ################################################################################ - # Cleanup - ################################################################################ - - unlink(run_dir, recursive=TRUE) - - - - list(out, all.data) - - }, error=function(e){unlink(run_dir, recursive=TRUE);e}) -} - - -out = clusterApplyLB(c1, to_run, model_future_habitat) - -all_habitat = do.call('rbind', out[unlist(lapply(out, inherits, what='data.frame'))]) - -#fix the gap between present and future model runs -all_habitat$`winter_dur_0-4`[all_habitat$`winter_dur_0-4` > 300] = NA - -write.table(all_habitat, '~/2015-06-15_THE_FUTURE.tsv', sep='\t', row.names=FALSE) diff --git a/demo/cluster_bias_check.R b/demo/cluster_bias_check.R deleted file mode 100644 index 59ac4aa..0000000 --- a/demo/cluster_bias_check.R +++ /dev/null @@ -1,159 +0,0 @@ -## Lets cluserify things - -library(parallel) - -#lets try 100 to start -c1 = makePSOCKcluster(paste0('licon', 1:50), manual=TRUE, port=4042) - - -#clusterCall(c1, function(){install.packages('devtools', repos='http://cran.rstudio.com')}) -clusterCall(c1, function(){install.packages('rLakeAnalyzer', repos='http://cran.rstudio.com')}) -clusterCall(c1, function(){install.packages('dplyr', repos='http://cran.rstudio.com')}) -clusterCall(c1, function(){install.packages('lubridate', repos='http://cran.rstudio.com')}) - -clusterCall(c1, function(){library(devtools)}) - -glmr_install = clusterCall(c1, function(){install_github('lawinslow/GLMr')}) -glmtools_install = clusterCall(c1, function(){install_github('lawinslow/glmtools')}) -lakeattr_install = clusterCall(c1, function(){install_github('lawinslow/lakeattributes')}) -mdalakes_install = clusterCall(c1, function(){install_github('lawinslow/mda.lakes')}) - -library(lakeattributes) -library(lubridate) -library(mda.lakes) -library(dplyr) -library(glmtools) - - -read_debias = function(prism_path, dscale_path, dbiased_path, shortwave=FALSE){ - library(dplyr) - library(lubridate) - - dscale = read.csv(dscale_path, header=TRUE) - obs = read.csv(prism_path, header=TRUE) - - dbiased = dscale - - names(obs) = paste0('obs_', names(obs)) - names(obs)[1] = 'time' - - #prism is monthly avg, so avg dscale to monthly first - - mon_dscale = group_by(dscale, year = year(as.POSIXct(time)), month=month(as.POSIXct(time))) %>% - summarise(AirTemp=mean(AirTemp)) - mon_dscale$time = as.character(ISOdate(mon_dscale$year, mon_dscale$month, 1, hour = 0)) - - overlap = merge(obs, mon_dscale , by='time') - - builk_emis = dscale$LongWave/(5.67E-8 * (dscale$AirTemp + 273.13)^4) - - #debias airT with offset model - dbiased$AirTemp = dbiased$AirTemp + (mean(overlap$obs_AirTemp) - mean(overlap$AirTemp)) - - dbiased$LongWave = builk_emis * 5.67E-8 * (dbiased$AirTemp + 273.13)^4 - - if(missing(dbiased_path)){ - return(dbiased) - }else{ - write.csv(dbiased, dbiased_path, row.names=FALSE, quote=FALSE) - } -} - - -obs = read.table(system.file('supporting_files/wtemp.obs.tsv', package = 'mda.lakes'), - sep='\t', header=TRUE, as.is=TRUE, , colClasses=c(WBIC='character')) -to_run = unique(paste0('WBIC_', obs$WBIC)) - -clusterExport(c1, varlist = 'read_debias') - -downscale_cal_out = function(site_id){ - - modern_era = 1979:1999 - future_era = 2040:2069 - - library(lakeattributes) - library(mda.lakes) - library(dplyr) - library(glmtools) - library(stringr) - - tryCatch({ - fastdir = tempdir() - if(file.exists('/mnt/ramdisk')){ - fastdir = '/mnt/ramdisk' - } - - run_dir = file.path(fastdir, site_id) - dir.create(run_dir) - cat(run_dir, '\n') - - bare_wbic = substr(site_id, 6, nchar(site_id)) - - - obs = read.table(system.file('supporting_files/wtemp.obs.tsv', package = 'mda.lakes'), - sep='\t', header=TRUE, as.is=TRUE, , colClasses=c(WBIC='character')) - obs$site_id = paste0('WBIC_', obs$WBIC) - - - lake_obs = obs[obs$WBIC == bare_wbic, c('DATETIME', 'DEPTH', 'WTEMP')] - lake_obs$year = as.POSIXlt(lake_obs$DATETIME)$year+1900 - - write.table(lake_obs, file.path(run_dir, 'obs.tsv'), sep='\t', row.names=FALSE) - years = unique(lake_obs$year) - years = years[years <= 1999 & years >=1979] - - cat(years) - - secchi = get_kd_best(site_id, years=years) - - #driver_path = get_driver_path(paste0(site_id, '.csv'), 'GENMOM', loc_cache=FALSE) - driver_path = tempfile(fileext='.csv') - read_debias(get_driver_path(paste0(site_id, '.csv'), 'PRISM'), - get_driver_path(paste0(site_id, '.csv'), 'GENMOM'), - dbiased_path=driver_path, shortwave=TRUE) - - driver_path = gsub('\\\\', '/', driver_path) - - #run with different driver and ice sources - - prep_run_chained_glm_kd(bare_wbic, kd=1.7/secchi$secchi_avg, path=run_dir, years=years, - ice_src='empirical.cm2.0.ice.tsv', - nml_args=list( - dt=3600, subdaily=FALSE, nsave=24, - timezone=-6, - csv_point_nlevs=0, - meteo_fl=driver_path)) - - - sims = Sys.glob(file.path(run_dir, 'output*.nc')) - #browser() - #loop over years - cal.data = data.frame() - for(i in 1:length(sims)){ - tryCatch({ - tmp = NULL - tmp = resample_to_field(sims[i], file.path(run_dir,'obs.tsv')) - }, error=function(e){e}) - if(!is.null(tmp)){ - cal.data = rbind(cal.data, tmp) - } - } - unlink(run_dir, recursive=TRUE) - - cal.data - - }, error=function(e){unlink(run_dir, recursive=TRUE);e}) -} - -for(i in 1:length(c1)){ - tryCatch({ - clusterCall(c1[i], 1, function(){R.version}) - cat(i, ',')}, error=function(e){}) -} - - -out = clusterApplyLB(c1, to_run, downscale_cal_out) - -all_cal = do.call('rbind', out[unlist(lapply(out, inherits, what='data.frame'))]) - -mean(all_cal$Observed_wTemp - all_cal$Modeled_wTemp, na.rm=TRUE) diff --git a/demo/cluster_cont_calibrate_bias.R b/demo/cluster_cont_calibrate_bias.R index 4e6e08c..7653464 100644 --- a/demo/cluster_cont_calibrate_bias.R +++ b/demo/cluster_cont_calibrate_bias.R @@ -21,28 +21,18 @@ clusterCall(c1, function(){install.packages('lubridate', repos='http://cran.rstu clusterCall(c1, function(){library(devtools)}) #start http-server (npm install http-server -g) on a suitable port - -glmr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/GLMr_3.1.4.tar.gz'))}) -glmtools_install = clusterCall(c1, function(){install_github('lawinslow/glmtools')}) -lakeattr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/lakeattributes_0.3.0.tar.gz'))}) -mdalakes_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/mda.lakes_2.10.4.tar.gz'))}) +#glmr_install = clusterCall(c1, function(){install.packages('glmtools', repos=c('http://owi.usgs.gov/R', 'http://cran.rstudio.com'))}) +glmr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/GLMr_3.1.10.tar.gz'))}) +glmtools_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/glmtools_0.13.0.tar.gz'))}) +lakeattr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/lakeattributes_0.7.2.tar.gz'))}) +mdalakes_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/mda.lakes_3.0.1.tar.gz'))}) library(lakeattributes) library(mda.lakes) library(dplyr) library(glmtools) -obs = read.table(system.file('supporting_files/wtemp.obs.tsv', package = 'mda.lakes'), - sep='\t', header=TRUE, as.is=TRUE, , colClasses=c(WBIC='character')) -obs$site_id = paste0('WBIC_', obs$WBIC) - -#secchi_obs = filter(secchi, source=='in-situ') - -#currently using in-situ secchi data, switch to all? -#best_clarity = intersect(secchi_obs$site_id, turbidity$site_id) -#to_run = intersect(obs$site_id, secchi_obs$site_id) -to_run = unique(obs$site_id) - +## setup run function run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nml_args=list()){ @@ -60,24 +50,22 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm secchi_conv = 1.7 tryCatch({ - #get_driver_path(paste0(site_id, '.csv')) run_dir = file.path(fastdir, site_id) dir.create(run_dir) - bare_wbic = substr(site_id, 6, nchar(site_id)) - - obs = read.table(system.file('supporting_files/wtemp.obs.tsv', package = 'mda.lakes'), - sep='\t', header=TRUE, as.is=TRUE, , colClasses=c(WBIC='character')) - obs$site_id = paste0('WBIC_', obs$WBIC) + #rename for dplyr + nhd_id = site_id - lake_obs = obs[obs$WBIC == bare_wbic, c('DATETIME', 'DEPTH', 'WTEMP')] + obs = filter(wtemp, site_id == nhd_id) %>% + transmute(DateTime=date, Depth=depth, temp=wtemp) + #having a weird issue with resample_to_field, make unique - lake_obs = lake_obs[!duplicated(lake_obs[,1:2]), ] - + obs = obs[!duplicated(obs[,1:2]), ] - write.table(lake_obs, file.path(run_dir, 'obs.tsv'), sep='\t', row.names=FALSE) + write.table(obs, file.path(run_dir, 'obs.tsv'), sep='\t', row.names=FALSE) + #get driver data driver_path = driver_function(site_id) driver_path = gsub('\\\\', '/', driver_path) @@ -86,7 +74,7 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm kd_avg = secchi_conv/mean(kds$secchi_avg, na.rm=TRUE) - prep_run_glm_kd(site_id=bare_wbic, + prep_run_glm_kd(site_id=site_id, path=run_dir, years=years, kd=kd_avg, @@ -99,6 +87,7 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm nml_args)) cal.data = resample_to_field(file.path(run_dir, 'output.nc'), file.path(run_dir,'obs.tsv')) + cal.data$site_id = site_id unlink(run_dir, recursive=TRUE) @@ -109,7 +98,7 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm driver_fun = function(site_id){ - nldas = read.csv(get_driver_path(paste0(site_id, '.csv'), driver_name = 'NLDAS'), header=TRUE) + nldas = read.csv(get_driver_path(paste0(site_id), driver_name = 'NLDAS'), header=TRUE) drivers = driver_nldas_wind_debias(nldas) drivers = driver_add_burnin_years(drivers, nyears=2) drivers = driver_add_rain(drivers, month=7:9, rain_add=0.5) ##keep the lakes topped off @@ -120,6 +109,8 @@ driver_fun = function(site_id){ #ramdisk = clusterCall(c1, function(){file.exists('/mnt/ramdisk')}) #c1 = c1[unlist(ramdisk)] +to_run = intersect(wtemp$site_id, zmax$site_id) + out = clusterApplyLB(c1, to_run, run_cal, driver_function = driver_fun, nml_args=list()) # # groups = split(to_run, ceiling(seq_along(to_run)/100)) @@ -141,17 +132,30 @@ sqrt(mean((out_df$Observed_wTemp - out_df$Modeled_wTemp)^2, na.rm=TRUE)) mean(out_df$Observed_wTemp - out_df$Modeled_wTemp, na.rm=TRUE) ################################################################################ -## GENMOM +## ACCESS ################################################################################ - -groups = split(to_run, ceiling(seq_along(to_run)/100)) -out = list() -for(grp in groups){ - tmp = clusterApplyLB(c1, grp, run_cal, years=1980:1999, driver_name='GENMOM') - out = c(out, tmp) - cat('iteration\n') +driver_fun = function(site_id, gcm){ + drivers = read.csv(get_driver_path(paste0(site_id, ''), driver_name = gcm, timestep = 'daily'), header=TRUE) + nldas = read.csv(get_driver_path(paste0(site_id, ''), driver_name = 'NLDAS'), header=TRUE) + drivers = driver_nldas_debias_airt_sw(drivers, nldas) + drivers = driver_add_burnin_years(drivers, nyears=2) + drivers = driver_add_rain(drivers, month=7:9, rain_add=0.5) ##keep the lakes topped off + driver_save(drivers) } +clusterExport(c1, 'driver_fun') + +clusterApplyLB(c1, to_run, run_cal, years=1980:1999, driver_function=function(site_id){driver_fun(site_id, 'GENMOM')}) + + +# groups = split(to_run, ceiling(seq_along(to_run)/100)) +# out = list() +# for(grp in groups){ +# tmp = clusterApplyLB(c1, grp, run_cal, years=1980:1999, driver_function=function(site_id){driver_fun(site_id, 'GENMOM')}) +# out = c(out, tmp) +# cat('iteration\n') +# } + #out = clusterApplyLB(c1, to_run[1:50], run_cal) ##results diff --git a/demo/cluster_cont_hab_out.R b/demo/cluster_cont_hab_out.R index b0d13a4..fc56e03 100644 --- a/demo/cluster_cont_hab_out.R +++ b/demo/cluster_cont_hab_out.R @@ -3,7 +3,7 @@ library(parallel) #lets try 100 to start -c1 = makePSOCKcluster(paste0('licon', 1:50), manual=TRUE, port=4041) +c1 = makePSOCKcluster(paste0('licon', 1:50), manual=TRUE, port=4043) # now devtools installed on cluster #clusterCall(c1, function(){install.packages('devtools', repos='http://cran.rstudio.com')}) @@ -20,7 +20,7 @@ lakeattr_install = clusterCall(c1, function(){install_github('lawinslow/lakeattr mdalakes_install = clusterCall(c1, function(){install_github('lawinslow/mda.lakes')}) -out_dir = 'E:/WiLMA/Results/2015-09-23_wtr_hab' +out_dir = 'C:/WiLMA/2016-02-19_wtr_hab' library(lakeattributes) library(mda.lakes) @@ -31,11 +31,11 @@ library(reshape2) Sys.setenv(TZ='GMT') -lakes = read.table(system.file('supporting_files/managed_lake_info.txt', package = 'mda.lakes'), - sep='\t', quote="\"", header=TRUE, as.is=TRUE, colClasses=c(WBIC='character')) - -to_run = paste0('WBIC_', lakes$WBIC) +#lakes = read.table(system.file('supporting_files/managed_lake_info.txt', package = 'mda.lakes'), +# sep='\t', quote="\"", header=TRUE, as.is=TRUE, colClasses=c(WBIC='character')) +#to_run = paste0('WBIC_', lakes$WBIC) +to_run = unique(get_driver_index('NLDAS')$id) future_hab_wtr = function(site_id, years=1979:2012, future_era, driver_function=get_driver_path){ @@ -82,13 +82,13 @@ future_hab_wtr = function(site_id, years=1979:2012, future_era, driver_function= #wtr_all = wtr[to_keep, ] - habitat = continuous.habitat.calc(run_dir, lakeid=bare_wbic) + habitat = continuous.habitat.calc(run_dir, lakeid=site_id) #Run future era only if requested if(!missing(future_era)){ secchi = get_kd_best(site_id, years=future_era) - prep_run_glm_kd(bare_wbic, kd=1.7/secchi$secchi_avg, path=run_dir, + prep_run_glm_kd(site_id, kd=1.7/secchi$secchi_avg, path=run_dir, years=future_era, nml_args=list( dt=3600, subdaily=FALSE, nsave=24, @@ -107,7 +107,7 @@ future_hab_wtr = function(site_id, years=1979:2012, future_era, driver_function= ##now hab - habitat = rbind(habitat, continuous.habitat.calc(run_dir, lakeid=bare_wbic)) + habitat = rbind(habitat, continuous.habitat.calc(run_dir, lakeid=site_id)) } unlink(run_dir, recursive=TRUE) @@ -156,8 +156,8 @@ gc() ## Lets run GENMOM 1980-1999, 2020-2089 ################################################################################ driver_fun = function(site_id, gcm){ - drivers = read.csv(get_driver_path(paste0(site_id, '.csv'), driver_name = gcm), header=TRUE) - nldas = read.csv(get_driver_path(paste0(site_id, '.csv'), driver_name = 'NLDAS'), header=TRUE) + drivers = read.csv(get_driver_path(paste0(site_id, ''), driver_name = gcm, timestep = 'daily'), header=TRUE) + nldas = read.csv(get_driver_path(paste0(site_id, ''), driver_name = 'NLDAS'), header=TRUE) drivers = driver_nldas_debias_airt_sw(drivers, nldas) drivers = driver_add_burnin_years(drivers, nyears=2) drivers = driver_add_rain(drivers, month=7:9, rain_add=0.5) ##keep the lakes topped off From 7302886b06f73a76e4cafcfc733ec40948d97642 Mon Sep 17 00:00:00 2001 From: Luke Winslow Date: Tue, 22 Mar 2016 12:46:58 -0500 Subject: [PATCH 2/8] change wind averaging to being cube-based --- DESCRIPTION | 2 +- R/get_driver_nhd.R | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8ca7788..c5c8ed5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mda.lakes Type: Package Title: Tools for combining models, data, and processing for lakes -Version: 3.0.1 +Version: 3.0.2 Date: 2015-12-03 Author: Luke Winslow, Jordan Read Maintainer: Luke Winslow diff --git a/R/get_driver_nhd.R b/R/get_driver_nhd.R index a426535..0d9b17d 100644 --- a/R/get_driver_nhd.R +++ b/R/get_driver_nhd.R @@ -47,7 +47,18 @@ get_driver_nhd = function(id, driver_name, loc_cache, timestep){ daily = trunc(as.POSIXct(glm_drivers$time), units='days') glm_drivers$time = format(daily,'%Y-%m-%d %H:%M:%S') - glm_drivers = plyr::ddply(glm_drivers,'time', function(df){colMeans(df[,-1])}) + glm_drivers = plyr::ddply(glm_drivers,'time', function(df){ + + data.frame( + ShortWave = mean(df$ShortWave), + LongWave = mean(df$LongWave), + AirTemp = mean(df$AirTemp), + RelHum = mean(df$RelHum), + WindSpeed = mean(df$WindSpeed^3)^(1/3), + Rain = mean(df$Rain), + Snow = mean(df$Snow) + ) + }) } From 6e1799180c5eaab332e6af9f9cbbf6444a59017c Mon Sep 17 00:00:00 2001 From: Luke Winslow Date: Tue, 22 Mar 2016 16:12:48 -0500 Subject: [PATCH 3/8] addition of rmarkdown template for calibration results --- R/calc_mod_obs_metric.R | 2 +- demo/cluster_cont_calibrate_bias.R | 56 +++++----- ...document_calibration_overview_template.Rmd | 101 ++++++++++++++++++ 3 files changed, 132 insertions(+), 27 deletions(-) create mode 100644 demo/document_calibration_overview_template.Rmd diff --git a/R/calc_mod_obs_metric.R b/R/calc_mod_obs_metric.R index 6f54f3e..04d0b3d 100644 --- a/R/calc_mod_obs_metric.R +++ b/R/calc_mod_obs_metric.R @@ -20,7 +20,7 @@ calc_mod_obs_metric = function(mod_obs_df, metric){ for(lid in uids){ lake_data = subset(mod_obs_df, site_id == lid) lake_data$site_id = NULL - bathy = getBathy(strsplit(lid, '_')[[1]][2]) + bathy = get_bathy(lid) lake_data = ddply(lake_data, 'DateTime', function(df){ if(nrow(na.omit(df)) >= 5){ diff --git a/demo/cluster_cont_calibrate_bias.R b/demo/cluster_cont_calibrate_bias.R index 7653464..2994651 100644 --- a/demo/cluster_cont_calibrate_bias.R +++ b/demo/cluster_cont_calibrate_bias.R @@ -24,8 +24,8 @@ clusterCall(c1, function(){library(devtools)}) #glmr_install = clusterCall(c1, function(){install.packages('glmtools', repos=c('http://owi.usgs.gov/R', 'http://cran.rstudio.com'))}) glmr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/GLMr_3.1.10.tar.gz'))}) glmtools_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/glmtools_0.13.0.tar.gz'))}) -lakeattr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/lakeattributes_0.7.2.tar.gz'))}) -mdalakes_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/mda.lakes_3.0.1.tar.gz'))}) +lakeattr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/lakeattributes_0.7.4.tar.gz'))}) +mdalakes_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/mda.lakes_3.0.2.tar.gz'))}) library(lakeattributes) library(mda.lakes) @@ -52,6 +52,7 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm run_dir = file.path(fastdir, site_id) + cat(run_dir, '\n') dir.create(run_dir) #rename for dplyr @@ -89,7 +90,7 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm cal.data = resample_to_field(file.path(run_dir, 'output.nc'), file.path(run_dir,'obs.tsv')) cal.data$site_id = site_id - unlink(run_dir, recursive=TRUE) + #unlink(run_dir, recursive=TRUE) return(cal.data) @@ -98,7 +99,7 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm driver_fun = function(site_id){ - nldas = read.csv(get_driver_path(paste0(site_id), driver_name = 'NLDAS'), header=TRUE) + nldas = read.csv(get_driver_path(site_id, driver_name = 'NLDAS', timestep = 'daily'), header=TRUE) drivers = driver_nldas_wind_debias(nldas) drivers = driver_add_burnin_years(drivers, nyears=2) drivers = driver_add_rain(drivers, month=7:9, rain_add=0.5) ##keep the lakes topped off @@ -109,34 +110,32 @@ driver_fun = function(site_id){ #ramdisk = clusterCall(c1, function(){file.exists('/mnt/ramdisk')}) #c1 = c1[unlist(ramdisk)] -to_run = intersect(wtemp$site_id, zmax$site_id) +to_run = unique(intersect(intersect(wtemp$site_id, zmax$site_id), secchi$site_id)) -out = clusterApplyLB(c1, to_run, run_cal, driver_function = driver_fun, nml_args=list()) -# -# groups = split(to_run, ceiling(seq_along(to_run)/100)) -# out = list() -# for(grp in groups){ -# tmp = clusterApplyLB(c1,grp, run_cal, driver_fun) -# out = c(out, tmp) -# cat('iteration\n') -# } +out = clusterApplyLB(c1, to_run, run_cal, driver_function = driver_fun, nml_args=list(), years=1980:1999) #out = clusterApplyLB(c1, to_run[1:50], run_cal) sprintf('%i lakes ran\n', sum(unlist(lapply(out, inherits, what='data.frame')))) + ##results out_df = do.call('rbind', out[unlist(lapply(out, inherits, what='data.frame'))]) +write.table(out_df, 'c:/WiLMA/results/2016-03-22_NLDAS.tsv', sep='\t', row.names=FALSE) + +rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file='2016-03-22_NLDAS.pdf', + output_dir='c:/WiLMA/results/', params=list(out_df=out_df)) + -sqrt(mean((out_df$Observed_wTemp - out_df$Modeled_wTemp)^2, na.rm=TRUE)) -mean(out_df$Observed_wTemp - out_df$Modeled_wTemp, na.rm=TRUE) +sqrt(mean((out_df$Observed_temp - out_df$Modeled_temp)^2, na.rm=TRUE)) +mean(out_df$Observed_temp - out_df$Modeled_temp, na.rm=TRUE) ################################################################################ ## ACCESS ################################################################################ driver_fun = function(site_id, gcm){ - drivers = read.csv(get_driver_path(paste0(site_id, ''), driver_name = gcm, timestep = 'daily'), header=TRUE) - nldas = read.csv(get_driver_path(paste0(site_id, ''), driver_name = 'NLDAS'), header=TRUE) + drivers = read.csv(get_driver_path(site_id, driver_name = gcm, timestep = 'daily'), header=TRUE) + nldas = read.csv(get_driver_path(site_id, driver_name = 'NLDAS', timestep = 'daily'), header=TRUE) drivers = driver_nldas_debias_airt_sw(drivers, nldas) drivers = driver_add_burnin_years(drivers, nyears=2) drivers = driver_add_rain(drivers, month=7:9, rain_add=0.5) ##keep the lakes topped off @@ -145,7 +144,19 @@ driver_fun = function(site_id, gcm){ clusterExport(c1, 'driver_fun') -clusterApplyLB(c1, to_run, run_cal, years=1980:1999, driver_function=function(site_id){driver_fun(site_id, 'GENMOM')}) +out = clusterApplyLB(c1, to_run, run_cal, years=1980:1999, driver_function=function(site_id){driver_fun(site_id, 'ACCESS')}) + +sprintf('%i lakes ran\n', sum(unlist(lapply(out, inherits, what='data.frame')))) + +##results +out_df = do.call('rbind', out[unlist(lapply(out, inherits, what='data.frame'))]) +write.table(out_df, 'c:/WiLMA/results/2016-03-19_ACCESS.tsv', sep='\t', row.names=FALSE) + +sqrt(mean((out_df$Observed_temp - out_df$Modeled_temp)^2, na.rm=TRUE)) +mean(out_df$Observed_temp - out_df$Modeled_temp, na.rm=TRUE) + +rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file='2016-03-19_ACCESS.pdf', + output_dir='c:/WiLMA/results/', params=list(out_df=out_df)) # groups = split(to_run, ceiling(seq_along(to_run)/100)) @@ -156,11 +167,4 @@ clusterApplyLB(c1, to_run, run_cal, years=1980:1999, driver_function=function(si # cat('iteration\n') # } -#out = clusterApplyLB(c1, to_run[1:50], run_cal) - -##results -out_df = do.call('rbind', out[unlist(lapply(out, inherits, what='data.frame'))]) -sqrt(mean((out_df$Observed_wTemp - out_df$Modeled_wTemp)^2, na.rm=TRUE)) -mean(out_df$Observed_wTemp - out_df$Modeled_wTemp, na.rm=TRUE) - diff --git a/demo/document_calibration_overview_template.Rmd b/demo/document_calibration_overview_template.Rmd new file mode 100644 index 0000000..792df71 --- /dev/null +++ b/demo/document_calibration_overview_template.Rmd @@ -0,0 +1,101 @@ +--- +title: "Cal/Val Summary" +author: "Luke Winslow" +date: "March 22, 2016" +output: pdf_document +params: + out_df: !r data.frame() + +--- + +Lets see how the run went. + + + +```{r, echo=FALSE, message=FALSE} +library(lubridate) +library(glmtools) +library(mda.lakes) + +#out_df = read.table('c:/WiLMA/results/2016-03-21_NLDAS.tsv', header=TRUE, sep='\t', as.is=TRUE) +Sys.setenv(tz='GMT') + +out_df$DateTime = as.POSIXct(out_df$DateTime) +out_df$month = month(out_df$DateTime) +out_df$modLessObs = out_df$Modeled_temp - out_df$Observed_temp +out_df$Depth_1 = floor(out_df$Depth/1)*1 + + +``` + +#Run and code info +Specific mda.lakes version on github [link](`r paste0('https://github.com/USGS-R/mda.lakes/tree/', system('git rev-parse HEAD', intern = TRUE))`) + +Package | Version +--------|------- +mda.lakes | `r packageVersion('mda.lakes')` +lakeattributes | `r packageVersion('lakeattributes')` +GLMr | `r packageVersion('GLMr')` +glmtools | `r packageVersion('glmtools')` + + +#Classic, general stats: + +Statistic | Value +----------|------- +n obs | `r nrow(na.omit(out_df)) ` +n lakes | `r length(unique(out_df$site_id)) ` +RMSE | `r sqrt(mean((out_df$modLessObs)^2, na.rm=TRUE)) ` +Mean error| `r mean(out_df$modLessObs, na.rm=TRUE)` + + + + + +\newpage +#Overall observed vs model: +```{r, echo=FALSE, fig.width=5, fig.height=7, warning=FALSE} + +par(mfrow=c(3,1), mar=c(1,4,0,1), oma=c(3,0,1,0)) + +plot(out_df$Observed_temp, out_df$Modeled_temp, col=rgb(0, 0, 0, 0.1), pch=16, xlim=c(0,30), ylim=c(0,30), xaxt='n', ylab='Modeled Temp') + +abline(0, 1) + +epi = calc_mod_obs_metric(out_df, 'epi.temperature') + +plot(epi$obs, epi$mod, col=rgb(0, 0, 0, 0.1), pch=16, xlim=c(0,30), ylim=c(0,30), ylab='Modeled Epi', xaxt='n') +abline(0, 1) + +hypo = calc_mod_obs_metric(out_df, 'hypo.temperature') +plot(hypo$obs, hypo$mod, col=rgb(0, 0, 0, 0.1), pch=16, xlim=c(0,30), ylim=c(0,30), ylab='Modeled Hypo', xlab='Observed') +abline(0, 1) + +``` + +Statistic | RMSE | Avg Resid +----------|-------|------ +All Temp | `r sqrt(mean((out_df$modLessObs)^2, na.rm=TRUE)) ` | `r mean(out_df$modLessObs, na.rm=TRUE)` +Epi RMSE | `r sqrt(mean((epi$mod - epi$obs)^2, na.rm=TRUE))` | `r mean(epi$mod - epi$obs, na.rm=TRUE)` +Hypo RMSE | `r sqrt(mean((hypo$mod - hypo$obs)^2, na.rm=TRUE))` | `r mean(hypo$mod - hypo$obs, na.rm=TRUE)` + + +\newpage +#Residuals across depth: + +```{r, echo=FALSE} +boxplot(modLessObs~Depth_1, out_df, ylab="Model - Observation", xlab='Depth (m)', ylim=c(-10, 10)) +abline(h=0) +``` + +\newpage +#Seasonality of residuals: + +```{r, echo=FALSE} +boxplot(modLessObs~month, out_df, ylab="Model - Observation", xlab='Month', ylim=c(-10, 10)) +abline(h=0) + +``` + + + From 7cdc70c3d4073e33d80991e7d02da4c45e4d1500 Mon Sep 17 00:00:00 2001 From: Luke Winslow Date: Fri, 25 Mar 2016 13:30:19 -0500 Subject: [PATCH 4/8] roxy update --- man/LTER_NLDAS_gapper.Rd | 2 +- man/area_light_temp_threshold.Rd | 11 +++++++---- man/area_light_threshold.Rd | 8 ++++---- man/area_temp_threshold.Rd | 9 ++++++--- man/calc_mod_obs_metric.Rd | 4 ++-- man/calc_toha.Rd | 2 +- man/calc_toha_stats.Rd | 5 ++++- man/chained.habitat.calc.kevin.Rd | 6 +++++- man/comb_output_table.Rd | 7 +++++-- man/create_irr_day_cycle.Rd | 5 ++++- man/download_helper.Rd | 2 +- man/driver_add_burnin_years.Rd | 5 ++++- man/driver_add_rain.Rd | 7 +++++-- man/driver_nldas_debias_airt_sw.Rd | 2 +- man/driver_nldas_wind_debias.Rd | 4 ++-- man/driver_save.Rd | 5 ++++- man/fix_ice_on_off.Rd | 6 +++--- man/getArea.Rd | 5 ++--- man/getBathy.Rd | 2 +- man/getCD.Rd | 2 +- man/getCanopy.Rd | 2 +- man/getClarity.Rd | 4 +--- man/getElevation.Rd | 2 +- man/getIceOff.Rd | 2 +- man/getIceOn.Rd | 2 +- man/getLatLon.Rd | 2 +- man/getPerim.Rd | 2 +- man/getResidenceTime.Rd | 3 +-- man/getSDF.Rd | 4 ++-- man/getScenarioKd.Rd | 4 ++-- man/getWstr.Rd | 2 +- man/getZmax.Rd | 2 +- man/getZmean.Rd | 2 +- man/get_driver_index.Rd | 5 ++--- man/get_driver_path.Rd | 3 +-- man/get_driver_wbic.Rd | 4 ++-- man/get_ice_onoff.Rd | 5 ++++- man/get_wtr_chained.Rd | 5 ++++- man/interp_hypso.Rd | 7 +++---- man/met_check_download_gdp.Rd | 5 ++++- man/met_drivers_start_gdp.Rd | 5 ++++- man/opti_thermal_habitat.Rd | 7 +++++-- man/populate_base_lake_nml.Rd | 4 ++-- man/prep_run_chained_glm.Rd | 16 ++++++++-------- man/prep_run_chained_glm_kd.Rd | 14 ++++++-------- man/prep_run_glm_kd.Rd | 16 +++++++--------- man/sens_seasonal_site.Rd | 4 ++-- man/set_driver_url.Rd | 15 +++++++++++++++ 48 files changed, 147 insertions(+), 100 deletions(-) create mode 100644 man/set_driver_url.Rd diff --git a/man/LTER_NLDAS_gapper.Rd b/man/LTER_NLDAS_gapper.Rd index 6cb924e..22ca977 100644 --- a/man/LTER_NLDAS_gapper.Rd +++ b/man/LTER_NLDAS_gapper.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/fit_NLDAS_LTER.R \name{LTER_NLDAS_gapper} \alias{LTER_NLDAS_gapper} diff --git a/man/area_light_temp_threshold.Rd b/man/area_light_temp_threshold.Rd index 07f1917..16b40bd 100644 --- a/man/area_light_temp_threshold.Rd +++ b/man/area_light_temp_threshold.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/volume_light_threshold.R \name{area_light_temp_threshold} \alias{area_light_temp_threshold} @@ -14,18 +14,21 @@ area_light_temp_threshold(wtr, kd, light_incident, irr_thresh = c(0, 2000), \item{light_incident}{Vector of incident light (arbitrary units but units must match threshold units).} -\item{irr_thresh}{Vector of length 2 with min and max value (in that order) for light thresholds. Note: +\item{irr_thresh}{Vector of length 2 with min and max value (in that order) for light thresholds. Note: >= and <= is used for comparison, so thresholds must be adjusted accordingly.} -\item{wtr_thresh}{Vector of length 2 with min and max value (in that order) for temperature thresholds. Note: +\item{wtr_thresh}{Vector of length 2 with min and max value (in that order) for temperature thresholds. Note: >= and <= is used for comparison, so thresholds must be adjusted accordingly.} \item{hypso}{Hypsography data.frame, with columns \code{depth} and \code{area}. From \code{\link{}}} \item{area_type}{How benthic area is to be calculated. Defaults to \code{benthic}, which tries to estimate the -slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, +slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, ignoring slope.} } +\description{ +Calculate the average benthic area within temperature and light threshold +} \author{ Luke Winslow } diff --git a/man/area_light_threshold.Rd b/man/area_light_threshold.Rd index e564462..4233150 100644 --- a/man/area_light_threshold.Rd +++ b/man/area_light_threshold.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/volume_light_threshold.R \name{area_light_threshold} \alias{area_light_threshold} @@ -12,17 +12,17 @@ area_light_threshold(kd, light_incident, irr_thresh = c(0, 2000), hypso, \item{light_incident}{Vector of incident light (arbitrary units but units must match threshold units).} -\item{irr_thresh}{Vector of length 2 with min and max value (in that order) for light thresholds. Note: +\item{irr_thresh}{Vector of length 2 with min and max value (in that order) for light thresholds. Note: >= and <= is used for comparison, so thresholds must be adjusted accordingly.} \item{hypso}{Hypsography data.frame, with columns \code{depth} and \code{area}. From \code{\link{}}} \item{area_type}{How benthic area is to be calculated. Defaults to \code{benthic}, which tries to estimate the -slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, +slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, ignoring slope.} } \description{ -Returns the average amount of benthic area that is within the optical intensity thresholds based on +Returns the average amount of benthic area that is within the optical intensity thresholds based on light attenuation, hypsograph, and the desired threshold values. } \author{ diff --git a/man/area_temp_threshold.Rd b/man/area_temp_threshold.Rd index 807ec91..d8d9354 100644 --- a/man/area_temp_threshold.Rd +++ b/man/area_temp_threshold.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/volume_light_threshold.R \name{area_temp_threshold} \alias{area_temp_threshold} @@ -10,15 +10,18 @@ area_temp_threshold(wtr, wtr_thresh = c(0, 25), hypso, \arguments{ \item{wtr}{Data frame of water temperatures. See \code{\link[glmtools]{get_temp}}} -\item{wtr_thresh}{Vector of length 2 with min and max value (in that order) for temperature thresholds. Note: +\item{wtr_thresh}{Vector of length 2 with min and max value (in that order) for temperature thresholds. Note: >= and <= is used for comparison, so thresholds must be adjusted accordingly.} \item{hypso}{Hypsography data.frame, with columns \code{depth} and \code{area}. From \code{\link{}}} \item{area_type}{How benthic area is to be calculated. Defaults to \code{benthic}, which tries to estimate the -slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, +slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, ignoring slope.} } +\description{ +Calculate the average benthic area within temperature thresholds +} \author{ Luke Winslow } diff --git a/man/calc_mod_obs_metric.Rd b/man/calc_mod_obs_metric.Rd index 5e3b9cd..1d5b843 100644 --- a/man/calc_mod_obs_metric.Rd +++ b/man/calc_mod_obs_metric.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/calc_mod_obs_metric.R \name{calc_mod_obs_metric} \alias{calc_mod_obs_metric} @@ -7,7 +7,7 @@ calc_mod_obs_metric(mod_obs_df, metric) } \description{ -Calculte aggregate metrics from a data frame with modeled and observed data. +Calculte aggregate metrics from a data frame with modeled and observed data. Metric options include all available rLakeAnalyzer metrics } \seealso{ diff --git a/man/calc_toha.Rd b/man/calc_toha.Rd index c1db22f..09c56a7 100644 --- a/man/calc_toha.Rd +++ b/man/calc_toha.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/calc_toha.R \name{calc_toha} \alias{calc_toha} diff --git a/man/calc_toha_stats.Rd b/man/calc_toha_stats.Rd index 4c78353..10874e9 100644 --- a/man/calc_toha_stats.Rd +++ b/man/calc_toha_stats.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/calc_toha_stats.R \name{calc_toha_stats} \alias{calc_toha_stats} @@ -18,4 +18,7 @@ calc_toha_stats(lakeid, width_thresh = 0.02, secchi = c(seq(0.1, 2.9, by = \item{irr_thresh}{The light intensity thresholds in W/m^2 (defaults from Lester et al 2004)} } +\description{ +Calc standard stats on TOHA for a given lake +} diff --git a/man/chained.habitat.calc.kevin.Rd b/man/chained.habitat.calc.kevin.Rd index becdbb7..2229ab7 100644 --- a/man/chained.habitat.calc.kevin.Rd +++ b/man/chained.habitat.calc.kevin.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/chained.habitat.calc.kevin.R \name{chained.habitat.calc.kevin} \alias{chained.habitat.calc.kevin} @@ -7,6 +7,10 @@ chained.habitat.calc.kevin(run.path, output.path = NULL, lakeid) } \arguments{ +\item{run.path}{} + +\item{output.path}{} + \item{lakeid}{} } \description{ diff --git a/man/comb_output_table.Rd b/man/comb_output_table.Rd index 44fd125..871f3dd 100644 --- a/man/comb_output_table.Rd +++ b/man/comb_output_table.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/comb_output_table.R \name{comb_output_table} \alias{comb_output_table} @@ -13,8 +13,11 @@ comb_output_table(pattern, ...) } \description{ Attempts to load all files matching a certain pattern and combine -them vertically (rbind). Returns the result. If no files match the +them vertically (rbind). Returns the result. If no files match the pattern, then an empty data.frame is returned. +} +\details{ + } \author{ Luke Winslow diff --git a/man/create_irr_day_cycle.Rd b/man/create_irr_day_cycle.Rd index 9674988..5b54fc3 100644 --- a/man/create_irr_day_cycle.Rd +++ b/man/create_irr_day_cycle.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/create_irr_day_cycle.R \name{create_irr_day_cycle} \alias{create_irr_day_cycle} @@ -18,4 +18,7 @@ create_irr_day_cycle(lat, lon, dates = as.POSIXct("1990-01-01"), \item{by}{Timestep to generate sequence of times, see \link{seq.POSIXt} for options} } +\description{ +Estimate a full irradiance diurnal cycle +} diff --git a/man/download_helper.Rd b/man/download_helper.Rd index 39821db..263049a 100644 --- a/man/download_helper.Rd +++ b/man/download_helper.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/download_helpers.R \name{download_helper} \alias{download_helper} diff --git a/man/driver_add_burnin_years.Rd b/man/driver_add_burnin_years.Rd index d26f57b..24c15e1 100644 --- a/man/driver_add_burnin_years.Rd +++ b/man/driver_add_burnin_years.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_add_burnin_years} \alias{driver_add_burnin_years} @@ -6,4 +6,7 @@ \usage{ driver_add_burnin_years(drivers, nyears = 2) } +\description{ +Duplicate n years of initial data +} diff --git a/man/driver_add_rain.Rd b/man/driver_add_rain.Rd index f5eacb7..d70336b 100644 --- a/man/driver_add_rain.Rd +++ b/man/driver_add_rain.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_add_rain} \alias{driver_add_rain} @@ -13,8 +13,11 @@ driver_add_rain(drivers, months = 7:9, rain_add = 1) \item{rain_add}{Amount of rain to add across the months in meters} } +\description{ +Add rain to specific month +} \details{ -This is used to artificially add rain to a met file during +This is used to artificially add rain to a met file during specific months (when it will impact heat budget the least). } diff --git a/man/driver_nldas_debias_airt_sw.Rd b/man/driver_nldas_debias_airt_sw.Rd index 86c5d49..7160dc1 100644 --- a/man/driver_nldas_debias_airt_sw.Rd +++ b/man/driver_nldas_debias_airt_sw.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_nldas_debias_airt_sw} \alias{driver_nldas_debias_airt_sw} diff --git a/man/driver_nldas_wind_debias.Rd b/man/driver_nldas_wind_debias.Rd index e68982c..7f7f283 100644 --- a/man/driver_nldas_wind_debias.Rd +++ b/man/driver_nldas_wind_debias.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_nldas_wind_debias} \alias{driver_nldas_wind_debias} @@ -10,7 +10,7 @@ driver_nldas_wind_debias(drivers, ...) \item{drivers}{A GLM drivers data.frame} } \description{ -Debias NLDAS wind based on known post-2001 NLDAS/NARR +Debias NLDAS wind based on known post-2001 NLDAS/NARR issue } diff --git a/man/driver_save.Rd b/man/driver_save.Rd index 414468b..affb94f 100644 --- a/man/driver_save.Rd +++ b/man/driver_save.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_save} \alias{driver_save} @@ -9,4 +9,7 @@ driver_save(drivers) \value{ path to saved file } +\description{ +Save a driver data.frame to a temporary file +} diff --git a/man/fix_ice_on_off.Rd b/man/fix_ice_on_off.Rd index e58b18b..b08e61c 100644 --- a/man/fix_ice_on_off.Rd +++ b/man/fix_ice_on_off.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/fix_ice_on_off.R \name{fix_ice_on_off} \alias{fix_ice_on_off} @@ -16,8 +16,8 @@ fix_ice_on_off(on_off, wtr, hypso) \description{ Calculating metrics on lakes that sometimes, but do not consistently freeze is a bear, especially with future projections which forecast more frequent -no-freeze years. This function fills in missing ice on/off dates with -the date of minimum average lake temp. Seems to be a reasonable enough +no-freeze years. This function fills in missing ice on/off dates with +the date of minimum average lake temp. Seems to be a reasonable enough choice. There is no great one. } diff --git a/man/getArea.Rd b/man/getArea.Rd index 2386b3b..4e90a47 100644 --- a/man/getArea.Rd +++ b/man/getArea.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getArea} \alias{getArea} @@ -16,7 +16,7 @@ Lake surface areas in meters^2. NA if no value available Returns the surface area for a lake with given ID } \details{ -Looks for given site_ids and returns values if availalbe. All site_ids +Looks for given site_ids and returns values if availalbe. All site_ids are coerced to character regardless of input type. } \examples{ @@ -25,7 +25,6 @@ getArea(c('10000', '6100')) #this should return NA getArea('asdf') - } \author{ Jordan Read, Luke Winslow diff --git a/man/getBathy.Rd b/man/getBathy.Rd index 1ccbcbc..b800bbd 100644 --- a/man/getBathy.Rd +++ b/man/getBathy.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getBathy} \alias{getBathy} diff --git a/man/getCD.Rd b/man/getCD.Rd index b42ce6b..d7281fb 100644 --- a/man/getCD.Rd +++ b/man/getCD.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getCD} \alias{getCD} diff --git a/man/getCanopy.Rd b/man/getCanopy.Rd index b7cf878..a706274 100644 --- a/man/getCanopy.Rd +++ b/man/getCanopy.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getCanopy} \alias{getCanopy} diff --git a/man/getClarity.Rd b/man/getClarity.Rd index 9cc7ca6..4f7c537 100644 --- a/man/getClarity.Rd +++ b/man/getClarity.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getClarity} \alias{getClarity} @@ -26,8 +26,6 @@ getClarity(c('6100', '10000', 'asdf')) #Default can be requested as well getClarity(c('6100','asdf', '10000', 'asdf'), default.if.null=TRUE) - - } \author{ Luke Winslow, Jordan Read diff --git a/man/getElevation.Rd b/man/getElevation.Rd index f00ae7c..fdb637a 100644 --- a/man/getElevation.Rd +++ b/man/getElevation.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getElevation} \alias{getElevation} diff --git a/man/getIceOff.Rd b/man/getIceOff.Rd index 01cf9b8..bcb0438 100644 --- a/man/getIceOff.Rd +++ b/man/getIceOff.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getIceOff} \alias{getIceOff} diff --git a/man/getIceOn.Rd b/man/getIceOn.Rd index f0e73ef..a840b7d 100644 --- a/man/getIceOn.Rd +++ b/man/getIceOn.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getIceOn} \alias{getIceOn} diff --git a/man/getLatLon.Rd b/man/getLatLon.Rd index 5288403..1cd44a8 100644 --- a/man/getLatLon.Rd +++ b/man/getLatLon.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getLatLon} \alias{getLatLon} diff --git a/man/getPerim.Rd b/man/getPerim.Rd index 844e474..486b923 100644 --- a/man/getPerim.Rd +++ b/man/getPerim.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getPerim} \alias{getPerim} diff --git a/man/getResidenceTime.Rd b/man/getResidenceTime.Rd index 10f4507..5addfd9 100644 --- a/man/getResidenceTime.Rd +++ b/man/getResidenceTime.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getResidenceTime} \alias{getResidenceTime} @@ -20,7 +20,6 @@ TODO } \examples{ TODO - } \author{ Luke Winslow, Jordan Read diff --git a/man/getSDF.Rd b/man/getSDF.Rd index da93e27..24c2cf2 100644 --- a/man/getSDF.Rd +++ b/man/getSDF.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getSDF} \alias{getSDF} @@ -16,7 +16,7 @@ Return a SDF (between 1 and infinity) Get the shoreline development factor (SDF) of a lake with given ID } \details{ -The ratio of a a lake's observed perimeter divided by the perimeter of a +The ratio of a a lake's observed perimeter divided by the perimeter of a circle with the same area as the lake. Cannot be less than 1. } \author{ diff --git a/man/getScenarioKd.Rd b/man/getScenarioKd.Rd index d5f5992..191e53d 100644 --- a/man/getScenarioKd.Rd +++ b/man/getScenarioKd.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getScenarioKd} \alias{getScenarioKd} @@ -13,7 +13,7 @@ getScenarioKd(WBIC, years, year.1 = 1979, year.2 = 2011, trend = 0, \item{year.1}{The numeric year bounds of the averaging (i.e., values outside of this range will not be used)} -\item{trend}{The percentage of Secchi increase per year. +\item{trend}{The percentage of Secchi increase per year. Positive is increasing secchi (e.g., 0.94 is 0.94% increase per year)} \item{default.if.null}{boolean indicating if default Kd should be used if lake has no observations} diff --git a/man/getWstr.Rd b/man/getWstr.Rd index b2caf9a..f35b3cf 100644 --- a/man/getWstr.Rd +++ b/man/getWstr.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getWstr} \alias{getWstr} diff --git a/man/getZmax.Rd b/man/getZmax.Rd index 96856aa..65461ae 100644 --- a/man/getZmax.Rd +++ b/man/getZmax.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getZmax} \alias{getZmax} diff --git a/man/getZmean.Rd b/man/getZmean.Rd index ff1c3e0..2e96911 100644 --- a/man/getZmean.Rd +++ b/man/getZmean.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getZmean} \alias{getZmean} diff --git a/man/get_driver_index.Rd b/man/get_driver_index.Rd index b8a5f5e..c5b3a37 100644 --- a/man/get_driver_index.Rd +++ b/man/get_driver_index.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/get_driver_nhd.R \name{get_driver_index} \alias{get_driver_index} @@ -12,11 +12,10 @@ get_driver_index(driver_name, loc_cache = TRUE) \item{loc_cache}{Should the locally cached version of the driver file be used if available.} } \description{ -Accesses and returns the driver file index. Can be used to get list of +Accesses and returns the driver file index. Can be used to get list of all available driver data for a given driver } \examples{ unique(get_driver_index('NLDAS')$id) - } diff --git a/man/get_driver_path.Rd b/man/get_driver_path.Rd index 34168ba..b58d4fb 100644 --- a/man/get_driver_path.Rd +++ b/man/get_driver_path.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/get_driver_path.R \name{get_driver_path} \alias{get_driver_path} @@ -29,7 +29,6 @@ get_driver_path('nhd_120052892', 'CM2.0') get_driver_path('WBIC_1881900') - } \author{ Luke Winslow diff --git a/man/get_driver_wbic.Rd b/man/get_driver_wbic.Rd index 27b0ffa..5b4a506 100644 --- a/man/get_driver_wbic.Rd +++ b/man/get_driver_wbic.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/get_driver_path.R \name{get_driver_wbic} \alias{get_driver_wbic} @@ -7,7 +7,7 @@ get_driver_wbic(fname, driver_name, loc_cache, timestep) } \description{ -Old style download for legacy WBIC +Old style download for legacy WBIC driver files } \keyword{internal} diff --git a/man/get_ice_onoff.Rd b/man/get_ice_onoff.Rd index 105e0b7..e2acb5c 100644 --- a/man/get_ice_onoff.Rd +++ b/man/get_ice_onoff.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/get_ice_onoff.R \name{get_ice_onoff} \alias{get_ice_onoff} @@ -18,4 +18,7 @@ data.frame with columns \code{c('year', 'on', 'off')} Function to estimate the ice on/off dates from a timeseries of water temperature and ice data. } +\details{ + +} diff --git a/man/get_wtr_chained.Rd b/man/get_wtr_chained.Rd index b70663a..992b733 100644 --- a/man/get_wtr_chained.Rd +++ b/man/get_wtr_chained.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/get_wtr_chained.R \name{get_wtr_chained} \alias{get_wtr_chained} @@ -6,4 +6,7 @@ \usage{ get_wtr_chained(run.dir) } +\description{ + +} diff --git a/man/interp_hypso.Rd b/man/interp_hypso.Rd index 9d6f727..346bdb3 100644 --- a/man/interp_hypso.Rd +++ b/man/interp_hypso.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/opti_thermal_habitat.R \name{interp_hypso} \alias{interp_hypso} @@ -18,8 +18,8 @@ a zero-area depth, or if the zero area depth does not fall perfectly on the \cod A hypso data.frame with columns \code{depth and area} } \description{ -Interpolate bathymetry to a specified depth interval. Includes -options to ensure validity of profile (force zero area layer, monotonically +Interpolate bathymetry to a specified depth interval. Includes +options to ensure validity of profile (force zero area layer, monotonically decreasing area) } \examples{ @@ -28,6 +28,5 @@ new_hypso = interp_hypso(hypso, dz=0.1) plot(hypso$area, hypso$depth, ylim=rev(range(new_hypso$depth)), type='o') lines(new_hypso$area, new_hypso$depth, lty=2, col='red') - } diff --git a/man/met_check_download_gdp.Rd b/man/met_check_download_gdp.Rd index 65d9788..dbdc2a4 100644 --- a/man/met_check_download_gdp.Rd +++ b/man/met_check_download_gdp.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/met_check_download_gdp.R \name{met_check_download_gdp} \alias{met_check_download_gdp} @@ -14,4 +14,7 @@ met_check_download_gdp(gdp_list, dest_path = ".") \value{ The list with finished entries removed } +\description{ + +} diff --git a/man/met_drivers_start_gdp.Rd b/man/met_drivers_start_gdp.Rd index 55ee38d..4576299 100644 --- a/man/met_drivers_start_gdp.Rd +++ b/man/met_drivers_start_gdp.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/met_drivers_start_gdp.R \name{met_drivers_start_gdp} \alias{met_drivers_start_gdp} @@ -23,6 +23,9 @@ Available services:\cr \code{regclim:genmom}\cr \code{regclim:cm2.0}\cr \code{regclim:ncep} +} +\details{ + } \author{ Luke Winslow, Jordan Read diff --git a/man/opti_thermal_habitat.Rd b/man/opti_thermal_habitat.Rd index 3cd07e2..456ec31 100644 --- a/man/opti_thermal_habitat.Rd +++ b/man/opti_thermal_habitat.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/opti_thermal_habitat.R \name{opti_thermal_habitat} \alias{opti_thermal_habitat} @@ -12,8 +12,11 @@ opti_thermal_habitat(opt_wtr, io, kd, lat, lon, hypso, irr_thresh = c(0, \item{interp_hour}{Interpolate to hourly data (and )} } \value{ -data.frame with three columns. opti_hab, therm_hab, opti_therm_hab +data.frame with three columns. opti_hab, therm_hab, opti_therm_hab for areas of each habitat type (with opti_therm_hab being the overlap of both). Units are in m^2*days. Divide by the number of days in the data to } +\description{ +Calculate optical thermal habitat using temp and light thresholds +} diff --git a/man/populate_base_lake_nml.Rd b/man/populate_base_lake_nml.Rd index 7f79e49..0899f3d 100644 --- a/man/populate_base_lake_nml.Rd +++ b/man/populate_base_lake_nml.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/populate_base_lake_nml.R \name{populate_base_lake_nml} \alias{populate_base_lake_nml} @@ -16,7 +16,7 @@ populate_base_lake_nml(site_id, kd = get_kd_avg(site_id)$kd_avg, \item{kd}{Lake clarity in m^-1} } \description{ -This creates an NML object and pre-fills it with +This creates an NML object and pre-fills it with key parameters for the site_id } diff --git a/man/prep_run_chained_glm.Rd b/man/prep_run_chained_glm.Rd index c56231f..9e39d76 100644 --- a/man/prep_run_chained_glm.Rd +++ b/man/prep_run_chained_glm.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/prep_run_chained_glm.R \name{prep_run_chained_glm} \alias{prep_run_chained_glm} @@ -8,23 +8,23 @@ prep_run_chained_glm(site_id, path, start = as.POSIXct("2008-04-01"), end = as.POSIXct("2008-06-01"), nml_args = NULL) } \arguments{ +\item{site_id}{} + \item{path}{} \item{nml_args}{} } \description{ -Pulls in the required information to do a simple GLM +Pulls in the required information to do a simple GLM run. Grabs driver data from Sciencbase and attribute data from the internal package DB. } \examples{ dir.create('~/test') -dir.create(to_run[i]) - -prep_run_chained_glm(to_run[i], path=to_run[i], - start=as.POSIXct('1979-01-01'), - end=as.POSIXct('2011-12-31')) - + dir.create(to_run[i]) + prep_run_chained_glm(to_run[i], path=to_run[i], + start=as.POSIXct('1979-01-01'), + end=as.POSIXct('2011-12-31')) } diff --git a/man/prep_run_chained_glm_kd.Rd b/man/prep_run_chained_glm_kd.Rd index 9be8cc9..27dd68a 100644 --- a/man/prep_run_chained_glm_kd.Rd +++ b/man/prep_run_chained_glm_kd.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/prep_run_chained_glm_kd.R \name{prep_run_chained_glm_kd} \alias{prep_run_chained_glm_kd} @@ -20,18 +20,16 @@ prep_run_chained_glm_kd(site_id, path, years, kd = getClarity(site_id, \item{nml_args}{Arguments for nml file to override defaults} } \description{ -Pulls in the required information to do a simple GLM +Pulls in the required information to do a simple GLM run. Grabs driver data from SB and attribute data from the internal package DB. Uses supplied Kd values } \examples{ dir.create('~/test') -dir.create(to_run[i]) - -prep_run_chained_glm(to_run[i], path=to_run[i], - start=as.POSIXct('1979-01-01'), - end=as.POSIXct('2011-12-31')) - + dir.create(to_run[i]) + prep_run_chained_glm(to_run[i], path=to_run[i], + start=as.POSIXct('1979-01-01'), + end=as.POSIXct('2011-12-31')) } diff --git a/man/prep_run_glm_kd.Rd b/man/prep_run_glm_kd.Rd index 4497648..ea584a5 100644 --- a/man/prep_run_glm_kd.Rd +++ b/man/prep_run_glm_kd.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/prep_run_glm_kd.R \name{prep_run_glm_kd} \alias{prep_run_glm_kd} @@ -12,7 +12,7 @@ prep_run_glm_kd(site_id, path, years, kd = getClarity(site_id, default.if.null \item{path}{Directy to start and run model} -\item{years}{Vector of numeric years to simulate. Will simulate from Apr 01 of the +\item{years}{Vector of numeric years to simulate. Will simulate from Apr 01 of the first year to March 01 of the last year + 1} \item{kd}{Directly supplied kd value (if different value getClarity desired)} @@ -20,19 +20,17 @@ first year to March 01 of the last year + 1} \item{nml_args}{Arguments for nml file to override defaults} } \description{ -Pulls in the required information to do a simple GLM +Pulls in the required information to do a simple GLM run. Grabs driver data from SB and attribute data from the internal package DB. Uses supplied Kd values. Does \emph{NOT} use ice on/off to break up simulation. } \examples{ dir.create('~/test') -dir.create(to_run[i]) - -prep_run_glm(to_run[i], path=to_run[i], - start=as.POSIXct('1979-01-01'), - end=as.POSIXct('2011-12-31')) - + dir.create(to_run[i]) + prep_run_glm(to_run[i], path=to_run[i], + start=as.POSIXct('1979-01-01'), + end=as.POSIXct('2011-12-31')) } diff --git a/man/sens_seasonal_site.Rd b/man/sens_seasonal_site.Rd index 433bcc0..883ed95 100644 --- a/man/sens_seasonal_site.Rd +++ b/man/sens_seasonal_site.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2: do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/sens_seasonal.R \name{sens_seasonal_site} \alias{sens_seasonal_site} @@ -17,7 +17,7 @@ sens_seasonal_site(times, data, season_i, sites_i) } \description{ This outputs all paired-value slopes for a seasonal/cross-site Sen's -slope estimator. To get the slope, calculate the median value of all +slope estimator. To get the slope, calculate the median value of all paired-value slopes. } diff --git a/man/set_driver_url.Rd b/man/set_driver_url.Rd new file mode 100644 index 0000000..d05c740 --- /dev/null +++ b/man/set_driver_url.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/get_driver_nhd.R +\name{set_driver_url} +\alias{set_driver_url} +\title{Set driver URL} +\usage{ +set_driver_url(url) +} +\arguments{ +\item{url}{New base URL to set} +} +\description{ +Sets the default URL to access driver data. +} + From b79ef72d19626d13f3fc8f367a441ecf606350cd Mon Sep 17 00:00:00 2001 From: Luke Winslow Date: Fri, 25 Mar 2016 13:30:56 -0500 Subject: [PATCH 5/8] generalize get driver function to use local endpoints --- NAMESPACE | 3 ++- R/AAA.R | 4 +++- R/get_driver_nhd.R | 25 +++++++++++++++++++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 645b40e..8b2ae37 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,4 @@ -# Generated by roxygen2: do not edit by hand +# Generated by roxygen2 (4.1.1): do not edit by hand export(LTER_NLDAS_gapper) export(area_light_temp_threshold) @@ -50,6 +50,7 @@ export(prep_run_chained_glm) export(prep_run_chained_glm_kd) export(prep_run_glm_kd) export(sens_seasonal_site) +export(set_driver_url) import(GLMr) import(glmtools) import(lakeattributes) diff --git a/R/AAA.R b/R/AAA.R index 427f77b..17d7430 100644 --- a/R/AAA.R +++ b/R/AAA.R @@ -1,2 +1,4 @@ #AAA -base_url='http://cida-test.er.usgs.gov/mda.lakes/' +pkg_info = new.env() + +pkg_info$dvr_url='http://cida-test.er.usgs.gov/mda.lakes/' diff --git a/R/get_driver_nhd.R b/R/get_driver_nhd.R index 0d9b17d..f44cd81 100644 --- a/R/get_driver_nhd.R +++ b/R/get_driver_nhd.R @@ -21,11 +21,16 @@ get_driver_nhd = function(id, driver_name, loc_cache, timestep){ #grab (and open?) Rdata files for(i in 1:length(match_i)){ fname = indx[match_i[i], 'file.name'] - driver_url = paste0(base_url, 'drivers_GLM_', driver_name, '/', fname) + driver_url = paste0(pkg_info$dvr_url, 'drivers_GLM_', driver_name, '/', fname) dest = file.path(tempdir(), driver_name, fname) - if(!download_helper(driver_url, dest)){ - stop('failure downloading ', fname, '\n') + + if(substr(driver_url, 0,7) == 'file://'){ + dest = sub('file://', '', driver_url) + }else{ + if(!download_helper(driver_url, dest)){ + stop('failure downloading ', fname, '\n') + } } load(dest, envir=driver_env) @@ -86,7 +91,7 @@ get_driver_nhd = function(id, driver_name, loc_cache, timestep){ #' @export get_driver_index = function(driver_name, loc_cache=TRUE){ #see if index file exists already - index_url = paste0(base_url, 'drivers_GLM_', driver_name, '/driver_index.tsv') + index_url = paste0(pkg_info$dvr_url, 'drivers_GLM_', driver_name, '/driver_index.tsv') dest = file.path(tempdir(), driver_name, 'driver_index.tsv') #If it exists, return without downloading @@ -101,6 +106,18 @@ get_driver_index = function(driver_name, loc_cache=TRUE){ return(read.table(dest, sep='\t', header=TRUE, as.is=TRUE)) } +#' @title Set driver URL +#' +#' @param url New base URL to set +#' +#' @description +#' Sets the default URL to access driver data. +#' +#' @export +set_driver_url = function(url){ + pkg_info$dvr_url = url +} + drivers_to_glm = function(driver_df){ ## convert and downsample wind From b1d34a246f5e1ca9f5a314fc9dc600d5c16449a3 Mon Sep 17 00:00:00 2001 From: Luke Winslow Date: Wed, 6 Apr 2016 13:07:23 -0500 Subject: [PATCH 6/8] roxy update --- man/LTER_NLDAS_gapper.Rd | 2 +- man/area_light_temp_threshold.Rd | 11 ++++------- man/area_light_threshold.Rd | 8 ++++---- man/area_temp_threshold.Rd | 9 +++------ man/calc_mod_obs_metric.Rd | 4 ++-- man/calc_toha.Rd | 2 +- man/calc_toha_stats.Rd | 5 +---- man/chained.habitat.calc.kevin.Rd | 6 +----- man/comb_output_table.Rd | 7 ++----- man/create_irr_day_cycle.Rd | 5 +---- man/download_helper.Rd | 2 +- man/driver_add_burnin_years.Rd | 5 +---- man/driver_add_rain.Rd | 7 ++----- man/driver_nldas_debias_airt_sw.Rd | 2 +- man/driver_nldas_wind_debias.Rd | 4 ++-- man/driver_save.Rd | 5 +---- man/fix_ice_on_off.Rd | 6 +++--- man/getArea.Rd | 5 +++-- man/getBathy.Rd | 2 +- man/getCD.Rd | 2 +- man/getCanopy.Rd | 4 ++-- man/getClarity.Rd | 4 +++- man/getElevation.Rd | 2 +- man/getIceOff.Rd | 2 +- man/getIceOn.Rd | 2 +- man/getLatLon.Rd | 2 +- man/getPerim.Rd | 2 +- man/getResidenceTime.Rd | 3 ++- man/getSDF.Rd | 4 ++-- man/getScenarioKd.Rd | 4 ++-- man/getWstr.Rd | 8 ++++---- man/getZmax.Rd | 2 +- man/getZmean.Rd | 2 +- man/get_driver_index.Rd | 5 +++-- man/get_driver_path.Rd | 3 ++- man/get_driver_wbic.Rd | 4 ++-- man/get_ice_onoff.Rd | 5 +---- man/get_wtr_chained.Rd | 5 +---- man/interp_hypso.Rd | 7 ++++--- man/met_check_download_gdp.Rd | 5 +---- man/met_drivers_start_gdp.Rd | 5 +---- man/opti_thermal_habitat.Rd | 7 ++----- man/populate_base_lake_nml.Rd | 4 ++-- man/prep_run_chained_glm.Rd | 16 ++++++++-------- man/prep_run_chained_glm_kd.Rd | 14 ++++++++------ man/prep_run_glm_kd.Rd | 16 +++++++++------- man/sens_seasonal_site.Rd | 4 ++-- man/set_driver_url.Rd | 2 +- man/write_error_log.Rd | 19 +++++++++++++++++++ 49 files changed, 124 insertions(+), 137 deletions(-) create mode 100644 man/write_error_log.Rd diff --git a/man/LTER_NLDAS_gapper.Rd b/man/LTER_NLDAS_gapper.Rd index 22ca977..6cb924e 100644 --- a/man/LTER_NLDAS_gapper.Rd +++ b/man/LTER_NLDAS_gapper.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/fit_NLDAS_LTER.R \name{LTER_NLDAS_gapper} \alias{LTER_NLDAS_gapper} diff --git a/man/area_light_temp_threshold.Rd b/man/area_light_temp_threshold.Rd index 16b40bd..07f1917 100644 --- a/man/area_light_temp_threshold.Rd +++ b/man/area_light_temp_threshold.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/volume_light_threshold.R \name{area_light_temp_threshold} \alias{area_light_temp_threshold} @@ -14,21 +14,18 @@ area_light_temp_threshold(wtr, kd, light_incident, irr_thresh = c(0, 2000), \item{light_incident}{Vector of incident light (arbitrary units but units must match threshold units).} -\item{irr_thresh}{Vector of length 2 with min and max value (in that order) for light thresholds. Note: +\item{irr_thresh}{Vector of length 2 with min and max value (in that order) for light thresholds. Note: >= and <= is used for comparison, so thresholds must be adjusted accordingly.} -\item{wtr_thresh}{Vector of length 2 with min and max value (in that order) for temperature thresholds. Note: +\item{wtr_thresh}{Vector of length 2 with min and max value (in that order) for temperature thresholds. Note: >= and <= is used for comparison, so thresholds must be adjusted accordingly.} \item{hypso}{Hypsography data.frame, with columns \code{depth} and \code{area}. From \code{\link{}}} \item{area_type}{How benthic area is to be calculated. Defaults to \code{benthic}, which tries to estimate the -slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, +slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, ignoring slope.} } -\description{ -Calculate the average benthic area within temperature and light threshold -} \author{ Luke Winslow } diff --git a/man/area_light_threshold.Rd b/man/area_light_threshold.Rd index 4233150..e564462 100644 --- a/man/area_light_threshold.Rd +++ b/man/area_light_threshold.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/volume_light_threshold.R \name{area_light_threshold} \alias{area_light_threshold} @@ -12,17 +12,17 @@ area_light_threshold(kd, light_incident, irr_thresh = c(0, 2000), hypso, \item{light_incident}{Vector of incident light (arbitrary units but units must match threshold units).} -\item{irr_thresh}{Vector of length 2 with min and max value (in that order) for light thresholds. Note: +\item{irr_thresh}{Vector of length 2 with min and max value (in that order) for light thresholds. Note: >= and <= is used for comparison, so thresholds must be adjusted accordingly.} \item{hypso}{Hypsography data.frame, with columns \code{depth} and \code{area}. From \code{\link{}}} \item{area_type}{How benthic area is to be calculated. Defaults to \code{benthic}, which tries to estimate the -slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, +slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, ignoring slope.} } \description{ -Returns the average amount of benthic area that is within the optical intensity thresholds based on +Returns the average amount of benthic area that is within the optical intensity thresholds based on light attenuation, hypsograph, and the desired threshold values. } \author{ diff --git a/man/area_temp_threshold.Rd b/man/area_temp_threshold.Rd index d8d9354..807ec91 100644 --- a/man/area_temp_threshold.Rd +++ b/man/area_temp_threshold.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/volume_light_threshold.R \name{area_temp_threshold} \alias{area_temp_threshold} @@ -10,18 +10,15 @@ area_temp_threshold(wtr, wtr_thresh = c(0, 25), hypso, \arguments{ \item{wtr}{Data frame of water temperatures. See \code{\link[glmtools]{get_temp}}} -\item{wtr_thresh}{Vector of length 2 with min and max value (in that order) for temperature thresholds. Note: +\item{wtr_thresh}{Vector of length 2 with min and max value (in that order) for temperature thresholds. Note: >= and <= is used for comparison, so thresholds must be adjusted accordingly.} \item{hypso}{Hypsography data.frame, with columns \code{depth} and \code{area}. From \code{\link{}}} \item{area_type}{How benthic area is to be calculated. Defaults to \code{benthic}, which tries to estimate the -slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, +slope corrected benthic area for each layer. \code{surface} just uses a surface area approximation, ignoring slope.} } -\description{ -Calculate the average benthic area within temperature thresholds -} \author{ Luke Winslow } diff --git a/man/calc_mod_obs_metric.Rd b/man/calc_mod_obs_metric.Rd index 1d5b843..5e3b9cd 100644 --- a/man/calc_mod_obs_metric.Rd +++ b/man/calc_mod_obs_metric.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/calc_mod_obs_metric.R \name{calc_mod_obs_metric} \alias{calc_mod_obs_metric} @@ -7,7 +7,7 @@ calc_mod_obs_metric(mod_obs_df, metric) } \description{ -Calculte aggregate metrics from a data frame with modeled and observed data. +Calculte aggregate metrics from a data frame with modeled and observed data. Metric options include all available rLakeAnalyzer metrics } \seealso{ diff --git a/man/calc_toha.Rd b/man/calc_toha.Rd index 09c56a7..c1db22f 100644 --- a/man/calc_toha.Rd +++ b/man/calc_toha.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/calc_toha.R \name{calc_toha} \alias{calc_toha} diff --git a/man/calc_toha_stats.Rd b/man/calc_toha_stats.Rd index 10874e9..4c78353 100644 --- a/man/calc_toha_stats.Rd +++ b/man/calc_toha_stats.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/calc_toha_stats.R \name{calc_toha_stats} \alias{calc_toha_stats} @@ -18,7 +18,4 @@ calc_toha_stats(lakeid, width_thresh = 0.02, secchi = c(seq(0.1, 2.9, by = \item{irr_thresh}{The light intensity thresholds in W/m^2 (defaults from Lester et al 2004)} } -\description{ -Calc standard stats on TOHA for a given lake -} diff --git a/man/chained.habitat.calc.kevin.Rd b/man/chained.habitat.calc.kevin.Rd index 2229ab7..becdbb7 100644 --- a/man/chained.habitat.calc.kevin.Rd +++ b/man/chained.habitat.calc.kevin.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/chained.habitat.calc.kevin.R \name{chained.habitat.calc.kevin} \alias{chained.habitat.calc.kevin} @@ -7,10 +7,6 @@ chained.habitat.calc.kevin(run.path, output.path = NULL, lakeid) } \arguments{ -\item{run.path}{} - -\item{output.path}{} - \item{lakeid}{} } \description{ diff --git a/man/comb_output_table.Rd b/man/comb_output_table.Rd index 871f3dd..44fd125 100644 --- a/man/comb_output_table.Rd +++ b/man/comb_output_table.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/comb_output_table.R \name{comb_output_table} \alias{comb_output_table} @@ -13,11 +13,8 @@ comb_output_table(pattern, ...) } \description{ Attempts to load all files matching a certain pattern and combine -them vertically (rbind). Returns the result. If no files match the +them vertically (rbind). Returns the result. If no files match the pattern, then an empty data.frame is returned. -} -\details{ - } \author{ Luke Winslow diff --git a/man/create_irr_day_cycle.Rd b/man/create_irr_day_cycle.Rd index 5b54fc3..9674988 100644 --- a/man/create_irr_day_cycle.Rd +++ b/man/create_irr_day_cycle.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/create_irr_day_cycle.R \name{create_irr_day_cycle} \alias{create_irr_day_cycle} @@ -18,7 +18,4 @@ create_irr_day_cycle(lat, lon, dates = as.POSIXct("1990-01-01"), \item{by}{Timestep to generate sequence of times, see \link{seq.POSIXt} for options} } -\description{ -Estimate a full irradiance diurnal cycle -} diff --git a/man/download_helper.Rd b/man/download_helper.Rd index 263049a..39821db 100644 --- a/man/download_helper.Rd +++ b/man/download_helper.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/download_helpers.R \name{download_helper} \alias{download_helper} diff --git a/man/driver_add_burnin_years.Rd b/man/driver_add_burnin_years.Rd index 24c15e1..d26f57b 100644 --- a/man/driver_add_burnin_years.Rd +++ b/man/driver_add_burnin_years.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_add_burnin_years} \alias{driver_add_burnin_years} @@ -6,7 +6,4 @@ \usage{ driver_add_burnin_years(drivers, nyears = 2) } -\description{ -Duplicate n years of initial data -} diff --git a/man/driver_add_rain.Rd b/man/driver_add_rain.Rd index d70336b..f5eacb7 100644 --- a/man/driver_add_rain.Rd +++ b/man/driver_add_rain.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_add_rain} \alias{driver_add_rain} @@ -13,11 +13,8 @@ driver_add_rain(drivers, months = 7:9, rain_add = 1) \item{rain_add}{Amount of rain to add across the months in meters} } -\description{ -Add rain to specific month -} \details{ -This is used to artificially add rain to a met file during +This is used to artificially add rain to a met file during specific months (when it will impact heat budget the least). } diff --git a/man/driver_nldas_debias_airt_sw.Rd b/man/driver_nldas_debias_airt_sw.Rd index 7160dc1..86c5d49 100644 --- a/man/driver_nldas_debias_airt_sw.Rd +++ b/man/driver_nldas_debias_airt_sw.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_nldas_debias_airt_sw} \alias{driver_nldas_debias_airt_sw} diff --git a/man/driver_nldas_wind_debias.Rd b/man/driver_nldas_wind_debias.Rd index 7f7f283..e68982c 100644 --- a/man/driver_nldas_wind_debias.Rd +++ b/man/driver_nldas_wind_debias.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_nldas_wind_debias} \alias{driver_nldas_wind_debias} @@ -10,7 +10,7 @@ driver_nldas_wind_debias(drivers, ...) \item{drivers}{A GLM drivers data.frame} } \description{ -Debias NLDAS wind based on known post-2001 NLDAS/NARR +Debias NLDAS wind based on known post-2001 NLDAS/NARR issue } diff --git a/man/driver_save.Rd b/man/driver_save.Rd index affb94f..414468b 100644 --- a/man/driver_save.Rd +++ b/man/driver_save.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/driver_modification_functions.R \name{driver_save} \alias{driver_save} @@ -9,7 +9,4 @@ driver_save(drivers) \value{ path to saved file } -\description{ -Save a driver data.frame to a temporary file -} diff --git a/man/fix_ice_on_off.Rd b/man/fix_ice_on_off.Rd index b08e61c..e58b18b 100644 --- a/man/fix_ice_on_off.Rd +++ b/man/fix_ice_on_off.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/fix_ice_on_off.R \name{fix_ice_on_off} \alias{fix_ice_on_off} @@ -16,8 +16,8 @@ fix_ice_on_off(on_off, wtr, hypso) \description{ Calculating metrics on lakes that sometimes, but do not consistently freeze is a bear, especially with future projections which forecast more frequent -no-freeze years. This function fills in missing ice on/off dates with -the date of minimum average lake temp. Seems to be a reasonable enough +no-freeze years. This function fills in missing ice on/off dates with +the date of minimum average lake temp. Seems to be a reasonable enough choice. There is no great one. } diff --git a/man/getArea.Rd b/man/getArea.Rd index 4e90a47..2386b3b 100644 --- a/man/getArea.Rd +++ b/man/getArea.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getArea} \alias{getArea} @@ -16,7 +16,7 @@ Lake surface areas in meters^2. NA if no value available Returns the surface area for a lake with given ID } \details{ -Looks for given site_ids and returns values if availalbe. All site_ids +Looks for given site_ids and returns values if availalbe. All site_ids are coerced to character regardless of input type. } \examples{ @@ -25,6 +25,7 @@ getArea(c('10000', '6100')) #this should return NA getArea('asdf') + } \author{ Jordan Read, Luke Winslow diff --git a/man/getBathy.Rd b/man/getBathy.Rd index b800bbd..1ccbcbc 100644 --- a/man/getBathy.Rd +++ b/man/getBathy.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getBathy} \alias{getBathy} diff --git a/man/getCD.Rd b/man/getCD.Rd index d7281fb..b42ce6b 100644 --- a/man/getCD.Rd +++ b/man/getCD.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getCD} \alias{getCD} diff --git a/man/getCanopy.Rd b/man/getCanopy.Rd index a706274..4fee156 100644 --- a/man/getCanopy.Rd +++ b/man/getCanopy.Rd @@ -1,10 +1,10 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getCanopy} \alias{getCanopy} \title{Get surrounding canopy height for a given lake} \usage{ -getCanopy(site_id, default.if.null = FALSE, method = "aster") +getCanopy(site_id, default.if.null = FALSE, method = "landcover") } \arguments{ \item{site_id}{The character ID for the requested data} diff --git a/man/getClarity.Rd b/man/getClarity.Rd index 4f7c537..9cc7ca6 100644 --- a/man/getClarity.Rd +++ b/man/getClarity.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getClarity} \alias{getClarity} @@ -26,6 +26,8 @@ getClarity(c('6100', '10000', 'asdf')) #Default can be requested as well getClarity(c('6100','asdf', '10000', 'asdf'), default.if.null=TRUE) + + } \author{ Luke Winslow, Jordan Read diff --git a/man/getElevation.Rd b/man/getElevation.Rd index fdb637a..f00ae7c 100644 --- a/man/getElevation.Rd +++ b/man/getElevation.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getElevation} \alias{getElevation} diff --git a/man/getIceOff.Rd b/man/getIceOff.Rd index bcb0438..01cf9b8 100644 --- a/man/getIceOff.Rd +++ b/man/getIceOff.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getIceOff} \alias{getIceOff} diff --git a/man/getIceOn.Rd b/man/getIceOn.Rd index a840b7d..f0e73ef 100644 --- a/man/getIceOn.Rd +++ b/man/getIceOn.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getIceOn} \alias{getIceOn} diff --git a/man/getLatLon.Rd b/man/getLatLon.Rd index 1cd44a8..5288403 100644 --- a/man/getLatLon.Rd +++ b/man/getLatLon.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getLatLon} \alias{getLatLon} diff --git a/man/getPerim.Rd b/man/getPerim.Rd index 486b923..844e474 100644 --- a/man/getPerim.Rd +++ b/man/getPerim.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getPerim} \alias{getPerim} diff --git a/man/getResidenceTime.Rd b/man/getResidenceTime.Rd index 5addfd9..10f4507 100644 --- a/man/getResidenceTime.Rd +++ b/man/getResidenceTime.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getResidenceTime} \alias{getResidenceTime} @@ -20,6 +20,7 @@ TODO } \examples{ TODO + } \author{ Luke Winslow, Jordan Read diff --git a/man/getSDF.Rd b/man/getSDF.Rd index 24c2cf2..da93e27 100644 --- a/man/getSDF.Rd +++ b/man/getSDF.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getSDF} \alias{getSDF} @@ -16,7 +16,7 @@ Return a SDF (between 1 and infinity) Get the shoreline development factor (SDF) of a lake with given ID } \details{ -The ratio of a a lake's observed perimeter divided by the perimeter of a +The ratio of a a lake's observed perimeter divided by the perimeter of a circle with the same area as the lake. Cannot be less than 1. } \author{ diff --git a/man/getScenarioKd.Rd b/man/getScenarioKd.Rd index 191e53d..d5f5992 100644 --- a/man/getScenarioKd.Rd +++ b/man/getScenarioKd.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getScenarioKd} \alias{getScenarioKd} @@ -13,7 +13,7 @@ getScenarioKd(WBIC, years, year.1 = 1979, year.2 = 2011, trend = 0, \item{year.1}{The numeric year bounds of the averaging (i.e., values outside of this range will not be used)} -\item{trend}{The percentage of Secchi increase per year. +\item{trend}{The percentage of Secchi increase per year. Positive is increasing secchi (e.g., 0.94 is 0.94% increase per year)} \item{default.if.null}{boolean indicating if default Kd should be used if lake has no observations} diff --git a/man/getWstr.Rd b/man/getWstr.Rd index f35b3cf..b75af98 100644 --- a/man/getWstr.Rd +++ b/man/getWstr.Rd @@ -1,15 +1,15 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getWstr} \alias{getWstr} \title{Get wind sheltering coefficient for a given lake} \usage{ -getWstr(WBIC, method = "Markfort", canopy = NULL) +getWstr(site_id, method = "Markfort", canopy = NULL) } \arguments{ -\item{method}{The desired calculation method one of c('Markfort', 'Hondzo', )} - \item{site_id}{The character ID for the requested data} + +\item{method}{The desired calculation method one of c('Markfort', 'Hondzo', )} } \value{ The wind sheltering coefficient (between 0 and 1) diff --git a/man/getZmax.Rd b/man/getZmax.Rd index 65461ae..96856aa 100644 --- a/man/getZmax.Rd +++ b/man/getZmax.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getZmax} \alias{getZmax} diff --git a/man/getZmean.Rd b/man/getZmean.Rd index 2e96911..ff1c3e0 100644 --- a/man/getZmean.Rd +++ b/man/getZmean.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lake_attribute_functions.R \name{getZmean} \alias{getZmean} diff --git a/man/get_driver_index.Rd b/man/get_driver_index.Rd index c5b3a37..b8a5f5e 100644 --- a/man/get_driver_index.Rd +++ b/man/get_driver_index.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get_driver_nhd.R \name{get_driver_index} \alias{get_driver_index} @@ -12,10 +12,11 @@ get_driver_index(driver_name, loc_cache = TRUE) \item{loc_cache}{Should the locally cached version of the driver file be used if available.} } \description{ -Accesses and returns the driver file index. Can be used to get list of +Accesses and returns the driver file index. Can be used to get list of all available driver data for a given driver } \examples{ unique(get_driver_index('NLDAS')$id) + } diff --git a/man/get_driver_path.Rd b/man/get_driver_path.Rd index b58d4fb..34168ba 100644 --- a/man/get_driver_path.Rd +++ b/man/get_driver_path.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get_driver_path.R \name{get_driver_path} \alias{get_driver_path} @@ -29,6 +29,7 @@ get_driver_path('nhd_120052892', 'CM2.0') get_driver_path('WBIC_1881900') + } \author{ Luke Winslow diff --git a/man/get_driver_wbic.Rd b/man/get_driver_wbic.Rd index 5b4a506..27b0ffa 100644 --- a/man/get_driver_wbic.Rd +++ b/man/get_driver_wbic.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get_driver_path.R \name{get_driver_wbic} \alias{get_driver_wbic} @@ -7,7 +7,7 @@ get_driver_wbic(fname, driver_name, loc_cache, timestep) } \description{ -Old style download for legacy WBIC +Old style download for legacy WBIC driver files } \keyword{internal} diff --git a/man/get_ice_onoff.Rd b/man/get_ice_onoff.Rd index e2acb5c..105e0b7 100644 --- a/man/get_ice_onoff.Rd +++ b/man/get_ice_onoff.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get_ice_onoff.R \name{get_ice_onoff} \alias{get_ice_onoff} @@ -18,7 +18,4 @@ data.frame with columns \code{c('year', 'on', 'off')} Function to estimate the ice on/off dates from a timeseries of water temperature and ice data. } -\details{ - -} diff --git a/man/get_wtr_chained.Rd b/man/get_wtr_chained.Rd index 992b733..b70663a 100644 --- a/man/get_wtr_chained.Rd +++ b/man/get_wtr_chained.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get_wtr_chained.R \name{get_wtr_chained} \alias{get_wtr_chained} @@ -6,7 +6,4 @@ \usage{ get_wtr_chained(run.dir) } -\description{ - -} diff --git a/man/interp_hypso.Rd b/man/interp_hypso.Rd index 346bdb3..9d6f727 100644 --- a/man/interp_hypso.Rd +++ b/man/interp_hypso.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/opti_thermal_habitat.R \name{interp_hypso} \alias{interp_hypso} @@ -18,8 +18,8 @@ a zero-area depth, or if the zero area depth does not fall perfectly on the \cod A hypso data.frame with columns \code{depth and area} } \description{ -Interpolate bathymetry to a specified depth interval. Includes -options to ensure validity of profile (force zero area layer, monotonically +Interpolate bathymetry to a specified depth interval. Includes +options to ensure validity of profile (force zero area layer, monotonically decreasing area) } \examples{ @@ -28,5 +28,6 @@ new_hypso = interp_hypso(hypso, dz=0.1) plot(hypso$area, hypso$depth, ylim=rev(range(new_hypso$depth)), type='o') lines(new_hypso$area, new_hypso$depth, lty=2, col='red') + } diff --git a/man/met_check_download_gdp.Rd b/man/met_check_download_gdp.Rd index dbdc2a4..65d9788 100644 --- a/man/met_check_download_gdp.Rd +++ b/man/met_check_download_gdp.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/met_check_download_gdp.R \name{met_check_download_gdp} \alias{met_check_download_gdp} @@ -14,7 +14,4 @@ met_check_download_gdp(gdp_list, dest_path = ".") \value{ The list with finished entries removed } -\description{ - -} diff --git a/man/met_drivers_start_gdp.Rd b/man/met_drivers_start_gdp.Rd index 4576299..55ee38d 100644 --- a/man/met_drivers_start_gdp.Rd +++ b/man/met_drivers_start_gdp.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/met_drivers_start_gdp.R \name{met_drivers_start_gdp} \alias{met_drivers_start_gdp} @@ -23,9 +23,6 @@ Available services:\cr \code{regclim:genmom}\cr \code{regclim:cm2.0}\cr \code{regclim:ncep} -} -\details{ - } \author{ Luke Winslow, Jordan Read diff --git a/man/opti_thermal_habitat.Rd b/man/opti_thermal_habitat.Rd index 456ec31..3cd07e2 100644 --- a/man/opti_thermal_habitat.Rd +++ b/man/opti_thermal_habitat.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/opti_thermal_habitat.R \name{opti_thermal_habitat} \alias{opti_thermal_habitat} @@ -12,11 +12,8 @@ opti_thermal_habitat(opt_wtr, io, kd, lat, lon, hypso, irr_thresh = c(0, \item{interp_hour}{Interpolate to hourly data (and )} } \value{ -data.frame with three columns. opti_hab, therm_hab, opti_therm_hab +data.frame with three columns. opti_hab, therm_hab, opti_therm_hab for areas of each habitat type (with opti_therm_hab being the overlap of both). Units are in m^2*days. Divide by the number of days in the data to } -\description{ -Calculate optical thermal habitat using temp and light thresholds -} diff --git a/man/populate_base_lake_nml.Rd b/man/populate_base_lake_nml.Rd index 0899f3d..7f79e49 100644 --- a/man/populate_base_lake_nml.Rd +++ b/man/populate_base_lake_nml.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/populate_base_lake_nml.R \name{populate_base_lake_nml} \alias{populate_base_lake_nml} @@ -16,7 +16,7 @@ populate_base_lake_nml(site_id, kd = get_kd_avg(site_id)$kd_avg, \item{kd}{Lake clarity in m^-1} } \description{ -This creates an NML object and pre-fills it with +This creates an NML object and pre-fills it with key parameters for the site_id } diff --git a/man/prep_run_chained_glm.Rd b/man/prep_run_chained_glm.Rd index 9e39d76..c56231f 100644 --- a/man/prep_run_chained_glm.Rd +++ b/man/prep_run_chained_glm.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/prep_run_chained_glm.R \name{prep_run_chained_glm} \alias{prep_run_chained_glm} @@ -8,23 +8,23 @@ prep_run_chained_glm(site_id, path, start = as.POSIXct("2008-04-01"), end = as.POSIXct("2008-06-01"), nml_args = NULL) } \arguments{ -\item{site_id}{} - \item{path}{} \item{nml_args}{} } \description{ -Pulls in the required information to do a simple GLM +Pulls in the required information to do a simple GLM run. Grabs driver data from Sciencbase and attribute data from the internal package DB. } \examples{ dir.create('~/test') - dir.create(to_run[i]) +dir.create(to_run[i]) + +prep_run_chained_glm(to_run[i], path=to_run[i], + start=as.POSIXct('1979-01-01'), + end=as.POSIXct('2011-12-31')) + - prep_run_chained_glm(to_run[i], path=to_run[i], - start=as.POSIXct('1979-01-01'), - end=as.POSIXct('2011-12-31')) } diff --git a/man/prep_run_chained_glm_kd.Rd b/man/prep_run_chained_glm_kd.Rd index 27dd68a..9be8cc9 100644 --- a/man/prep_run_chained_glm_kd.Rd +++ b/man/prep_run_chained_glm_kd.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/prep_run_chained_glm_kd.R \name{prep_run_chained_glm_kd} \alias{prep_run_chained_glm_kd} @@ -20,16 +20,18 @@ prep_run_chained_glm_kd(site_id, path, years, kd = getClarity(site_id, \item{nml_args}{Arguments for nml file to override defaults} } \description{ -Pulls in the required information to do a simple GLM +Pulls in the required information to do a simple GLM run. Grabs driver data from SB and attribute data from the internal package DB. Uses supplied Kd values } \examples{ dir.create('~/test') - dir.create(to_run[i]) +dir.create(to_run[i]) + +prep_run_chained_glm(to_run[i], path=to_run[i], + start=as.POSIXct('1979-01-01'), + end=as.POSIXct('2011-12-31')) + - prep_run_chained_glm(to_run[i], path=to_run[i], - start=as.POSIXct('1979-01-01'), - end=as.POSIXct('2011-12-31')) } diff --git a/man/prep_run_glm_kd.Rd b/man/prep_run_glm_kd.Rd index ea584a5..4497648 100644 --- a/man/prep_run_glm_kd.Rd +++ b/man/prep_run_glm_kd.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/prep_run_glm_kd.R \name{prep_run_glm_kd} \alias{prep_run_glm_kd} @@ -12,7 +12,7 @@ prep_run_glm_kd(site_id, path, years, kd = getClarity(site_id, default.if.null \item{path}{Directy to start and run model} -\item{years}{Vector of numeric years to simulate. Will simulate from Apr 01 of the +\item{years}{Vector of numeric years to simulate. Will simulate from Apr 01 of the first year to March 01 of the last year + 1} \item{kd}{Directly supplied kd value (if different value getClarity desired)} @@ -20,17 +20,19 @@ first year to March 01 of the last year + 1} \item{nml_args}{Arguments for nml file to override defaults} } \description{ -Pulls in the required information to do a simple GLM +Pulls in the required information to do a simple GLM run. Grabs driver data from SB and attribute data from the internal package DB. Uses supplied Kd values. Does \emph{NOT} use ice on/off to break up simulation. } \examples{ dir.create('~/test') - dir.create(to_run[i]) +dir.create(to_run[i]) + +prep_run_glm(to_run[i], path=to_run[i], + start=as.POSIXct('1979-01-01'), + end=as.POSIXct('2011-12-31')) + - prep_run_glm(to_run[i], path=to_run[i], - start=as.POSIXct('1979-01-01'), - end=as.POSIXct('2011-12-31')) } diff --git a/man/sens_seasonal_site.Rd b/man/sens_seasonal_site.Rd index 883ed95..433bcc0 100644 --- a/man/sens_seasonal_site.Rd +++ b/man/sens_seasonal_site.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/sens_seasonal.R \name{sens_seasonal_site} \alias{sens_seasonal_site} @@ -17,7 +17,7 @@ sens_seasonal_site(times, data, season_i, sites_i) } \description{ This outputs all paired-value slopes for a seasonal/cross-site Sen's -slope estimator. To get the slope, calculate the median value of all +slope estimator. To get the slope, calculate the median value of all paired-value slopes. } diff --git a/man/set_driver_url.Rd b/man/set_driver_url.Rd index d05c740..f412b9e 100644 --- a/man/set_driver_url.Rd +++ b/man/set_driver_url.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get_driver_nhd.R \name{set_driver_url} \alias{set_driver_url} diff --git a/man/write_error_log.Rd b/man/write_error_log.Rd new file mode 100644 index 0000000..76208be --- /dev/null +++ b/man/write_error_log.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/write_error_log.R +\name{write_error_log} +\alias{write_error_log} +\title{Simple error log writing function} +\usage{ +write_error_log(error_list, ids, fname) +} +\arguments{ +\item{error_list}{List of error text output} + +\item{ids}{List of Lake IDs, same length as error_list} + +\item{fname}{File name to write log output} +} +\description{ + +} + From 9903979a55e9f706c0d55717e2408e562c7cc701 Mon Sep 17 00:00:00 2001 From: Luke Winslow Date: Wed, 6 Apr 2016 13:07:58 -0500 Subject: [PATCH 7/8] fix up attribute function --- DESCRIPTION | 2 +- NAMESPACE | 3 +- R/lake_attribute_functions.R | 41 ++++-------- demo/cluster_cont_calibrate_bias.R | 66 +++++++++++++------ ...document_calibration_overview_template.Rmd | 5 +- 5 files changed, 65 insertions(+), 52 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c5c8ed5..431b827 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mda.lakes Type: Package Title: Tools for combining models, data, and processing for lakes -Version: 3.0.2 +Version: 3.0.4 Date: 2015-12-03 Author: Luke Winslow, Jordan Read Maintainer: Luke Winslow diff --git a/NAMESPACE b/NAMESPACE index 8b2ae37..c747565 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,4 @@ -# Generated by roxygen2 (4.1.1): do not edit by hand +# Generated by roxygen2: do not edit by hand export(LTER_NLDAS_gapper) export(area_light_temp_threshold) @@ -51,6 +51,7 @@ export(prep_run_chained_glm_kd) export(prep_run_glm_kd) export(sens_seasonal_site) export(set_driver_url) +export(write_error_log) import(GLMr) import(glmtools) import(lakeattributes) diff --git a/R/lake_attribute_functions.R b/R/lake_attribute_functions.R index eccbba5..4de4f7a 100644 --- a/R/lake_attribute_functions.R +++ b/R/lake_attribute_functions.R @@ -122,7 +122,7 @@ getResidenceTime <- local( #' #' #' @export -getCanopy = function(site_id, default.if.null=FALSE, method="aster"){ +getCanopy = function(site_id, default.if.null=FALSE, method="landcover"){ if (tolower(method) == 'aster'){ @@ -137,28 +137,13 @@ getCanopy = function(site_id, default.if.null=FALSE, method="aster"){ return(vals$MEAN_HT) }else if (tolower(method) == "landcover"){ - - fname = system.file('supporting_files/buffers_land_cover.csv', - package=packageName()) - d = read.table(fname, header=TRUE, sep=',') - #100 urban - #110 ag - #150 grassland - #160 forest - #200 open water - #210 wetland - lc_types = data.frame(majority_cover=c(200, 160, 100, 150, 110, 210), - height= c(0.5, 11.5, 0.5, 0.65, 0.8, 0.5)) - - vals = merge(data.frame(site_id, order=1:length(site_id)), - d, by='site_id', all.x=TRUE) - - heights = merge(vals, lc_types, all.x=TRUE, by='majority_cover') - - #merge does not preserve order, re-order before returning - heights = heights[order(heights$order),] - - return(heights$height) + data(canopy) + id = site_id + d = subset(canopy, `site_id` == id & source == 'nlcd') + if(nrow(d) < 1){ + return(NA) + } + return(d$canopy_m) }else{ stop('Unidentified method ', method, ' for getCanopy [aster, landcover]') @@ -494,9 +479,9 @@ getCD <- function(site_id=NULL, Wstr=NULL, method='Hondzo'){ #' #' #'@export -getWstr <- function(WBIC, method='Markfort', canopy=NULL){ +getWstr <- function(site_id, method='Markfort', canopy=NULL){ - lkeArea <- get_area(WBIC) + lkeArea <- get_area(site_id) if(is.na(lkeArea)){ return(NA) @@ -506,7 +491,7 @@ getWstr <- function(WBIC, method='Markfort', canopy=NULL){ # Markfort et al. 2010 minWstr <- 0.0001 if (is.null(canopy)){ - hc <- max(c(getCanopy(WBIC),1)) + hc <- max(c(getCanopy(site_id),1)) } else { hc <- canopy } @@ -530,14 +515,14 @@ getWstr <- function(WBIC, method='Markfort', canopy=NULL){ # Markfort et al. 2010 minWstr <- 0.0001 if (is.null(canopy)){ - hc <- max(c(getCanopy(WBIC),1)) + hc <- max(c(getCanopy(site_id),1)) } else { hc <- canopy } Xt <- 50*hc - perim <- getPerim(WBIC) + perim <- getPerim(site_id) shelArea <- perim*hc*12.5 # 25% of Markfort, as sheltering is single direction... shelter <- (lkeArea-shelArea)/lkeArea wind.shelter <- max(c(shelter,minWstr)) diff --git a/demo/cluster_cont_calibrate_bias.R b/demo/cluster_cont_calibrate_bias.R index 2994651..a3ca6f3 100644 --- a/demo/cluster_cont_calibrate_bias.R +++ b/demo/cluster_cont_calibrate_bias.R @@ -6,12 +6,15 @@ #local_url = '192.0.2.1:4040' local_url = paste0((Sys.info()["nodename"]),':4040') +driver_url = paste0('http://', (Sys.info()["nodename"]),':4041/') + library(parallel) #lets try 50 to start -c1 = makePSOCKcluster(paste0('licon', 1:50), manual=TRUE, port=4045) +c1 = makePSOCKcluster(paste0('licon', 1:50), manual=TRUE, port=4046) clusterExport(c1, varlist = 'local_url') +clusterExport(c1, varlist = 'driver_url') #clusterCall(c1, function(){install.packages('devtools', repos='http://cran.rstudio.com')}) clusterCall(c1, function(){install.packages('rLakeAnalyzer', repos='http://cran.rstudio.com')}) @@ -24,8 +27,8 @@ clusterCall(c1, function(){library(devtools)}) #glmr_install = clusterCall(c1, function(){install.packages('glmtools', repos=c('http://owi.usgs.gov/R', 'http://cran.rstudio.com'))}) glmr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/GLMr_3.1.10.tar.gz'))}) glmtools_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/glmtools_0.13.0.tar.gz'))}) -lakeattr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/lakeattributes_0.7.4.tar.gz'))}) -mdalakes_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/mda.lakes_3.0.2.tar.gz'))}) +lakeattr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/lakeattributes_0.8.4.tar.gz'))}) +mdalakes_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/mda.lakes_3.0.3.tar.gz'))}) library(lakeattributes) library(mda.lakes) @@ -34,7 +37,7 @@ library(glmtools) ## setup run function -run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nml_args=list()){ +run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nml_args=list(), datasource=NA){ library(lakeattributes) @@ -51,7 +54,7 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm tryCatch({ - run_dir = file.path(fastdir, site_id) + run_dir = file.path(fastdir, paste0(site_id, '_', sample.int(1e9, size=1))) cat(run_dir, '\n') dir.create(run_dir) @@ -71,7 +74,7 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm driver_path = gsub('\\\\', '/', driver_path) - kds = get_kd_best(site_id, years=years) + kds = get_kd_best(site_id, years=years, datasource = datasource) kd_avg = secchi_conv/mean(kds$secchi_avg, na.rm=TRUE) @@ -90,11 +93,14 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm cal.data = resample_to_field(file.path(run_dir, 'output.nc'), file.path(run_dir,'obs.tsv')) cal.data$site_id = site_id - #unlink(run_dir, recursive=TRUE) + unlink(run_dir, recursive=TRUE) return(cal.data) - }, error=function(e){unlink(run_dir, recursive=TRUE);e}) + }, error=function(e){ + unlink(run_dir, recursive=TRUE) + return(paste(e$call, e$message, Sys.info()["nodename"])) + }) } @@ -103,6 +109,7 @@ driver_fun = function(site_id){ drivers = driver_nldas_wind_debias(nldas) drivers = driver_add_burnin_years(drivers, nyears=2) drivers = driver_add_rain(drivers, month=7:9, rain_add=0.5) ##keep the lakes topped off + #drivers$time = drivers$time - as.difftime(2, units='days') driver_save(drivers) } @@ -111,8 +118,14 @@ driver_fun = function(site_id){ #c1 = c1[unlist(ramdisk)] to_run = unique(intersect(intersect(wtemp$site_id, zmax$site_id), secchi$site_id)) +#to_run = to_run[to_run %in% read.table('~/managed_lakes_wilma_nhd.tsv', sep='\t', header=TRUE, as.is=TRUE)$id] + +run_name = '2016-03-31_cal_NLDAS' +run_comment = "Full calibration run with all available wtemp, secchi and depth" + +clusterCall(c1, function(){library(mda.lakes);set_driver_url(driver_url)}) -out = clusterApplyLB(c1, to_run, run_cal, driver_function = driver_fun, nml_args=list(), years=1980:1999) +out = clusterApplyLB(c1, to_run, run_cal, driver_function = driver_fun, nml_args=list(), years=1980:1999, datasource=NA) #out = clusterApplyLB(c1, to_run[1:50], run_cal) @@ -121,10 +134,13 @@ sprintf('%i lakes ran\n', sum(unlist(lapply(out, inherits, what='data.frame')))) ##results out_df = do.call('rbind', out[unlist(lapply(out, inherits, what='data.frame'))]) -write.table(out_df, 'c:/WiLMA/results/2016-03-22_NLDAS.tsv', sep='\t', row.names=FALSE) +write.table(out_df, paste0('c:/WiLMA/results/', run_name, '.tsv'), sep='\t', row.names=FALSE) -rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file='2016-03-22_NLDAS.pdf', - output_dir='c:/WiLMA/results/', params=list(out_df=out_df)) +out_err = out[!unlist(lapply(out, inherits, what='data.frame'))] +save(out_err, file = paste0('c:/WiLMA/results/', run_name, '.Rdata')) + +rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file=paste0(run_name,'.pdf'), + output_dir='c:/WiLMA/results/', params=list(out_df=out_df, run_message=run_comment)) sqrt(mean((out_df$Observed_temp - out_df$Modeled_temp)^2, na.rm=TRUE)) @@ -133,31 +149,39 @@ mean(out_df$Observed_temp - out_df$Modeled_temp, na.rm=TRUE) ################################################################################ ## ACCESS ################################################################################ -driver_fun = function(site_id, gcm){ - drivers = read.csv(get_driver_path(site_id, driver_name = gcm, timestep = 'daily'), header=TRUE) - nldas = read.csv(get_driver_path(site_id, driver_name = 'NLDAS', timestep = 'daily'), header=TRUE) - drivers = driver_nldas_debias_airt_sw(drivers, nldas) +driver_fun = function(site_id){ + drivers = read.csv(get_driver_path(site_id, driver_name = 'ACCESS', timestep = 'daily'), header=TRUE) + #nldas = read.csv(get_driver_path(site_id, driver_name = 'NLDAS', timestep = 'daily'), header=TRUE) + #drivers = driver_nldas_debias_airt_sw(drivers, nldas) drivers = driver_add_burnin_years(drivers, nyears=2) drivers = driver_add_rain(drivers, month=7:9, rain_add=0.5) ##keep the lakes topped off driver_save(drivers) } +run_name = '2016-03-28_ACCESS_WILMALakes' +run_comment = "Look at bias and RMSE for Notaro ACCESS drivers on WiLMA only lakes. Years are only 1980:1999" + +clusterCall(c1, function(){library(mda.lakes);set_driver_url('http://cida-test.er.usgs.gov/mda.lakes/')}) + clusterExport(c1, 'driver_fun') -out = clusterApplyLB(c1, to_run, run_cal, years=1980:1999, driver_function=function(site_id){driver_fun(site_id, 'ACCESS')}) +out = clusterApplyLB(c1, to_run, run_cal, years=1980:1999, driver_function=driver_fun, datasource=NA) + sprintf('%i lakes ran\n', sum(unlist(lapply(out, inherits, what='data.frame')))) + ##results out_df = do.call('rbind', out[unlist(lapply(out, inherits, what='data.frame'))]) -write.table(out_df, 'c:/WiLMA/results/2016-03-19_ACCESS.tsv', sep='\t', row.names=FALSE) +write.table(out_df, paste0('c:/WiLMA/results/', run_name, '.tsv'), sep='\t', row.names=FALSE) + +rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file=paste0(run_name,'.pdf'), + output_dir='c:/WiLMA/results/', params=list(out_df=out_df, run_message=run_comment)) + sqrt(mean((out_df$Observed_temp - out_df$Modeled_temp)^2, na.rm=TRUE)) mean(out_df$Observed_temp - out_df$Modeled_temp, na.rm=TRUE) -rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file='2016-03-19_ACCESS.pdf', - output_dir='c:/WiLMA/results/', params=list(out_df=out_df)) - # groups = split(to_run, ceiling(seq_along(to_run)/100)) # out = list() diff --git a/demo/document_calibration_overview_template.Rmd b/demo/document_calibration_overview_template.Rmd index 792df71..91ae02f 100644 --- a/demo/document_calibration_overview_template.Rmd +++ b/demo/document_calibration_overview_template.Rmd @@ -5,10 +5,11 @@ date: "March 22, 2016" output: pdf_document params: out_df: !r data.frame() + run_message: !r "default message" --- -Lets see how the run went. +Run description: `r params$run_message` @@ -17,6 +18,8 @@ library(lubridate) library(glmtools) library(mda.lakes) +out_df = params$out_df + #out_df = read.table('c:/WiLMA/results/2016-03-21_NLDAS.tsv', header=TRUE, sep='\t', as.is=TRUE) Sys.setenv(tz='GMT') From 7902db9590eb8cba20468649b8f4b1fe88296562 Mon Sep 17 00:00:00 2001 From: Luke Winslow Date: Mon, 11 Apr 2016 14:21:20 -0500 Subject: [PATCH 8/8] updates to run documentation #70 --- demo/cluster_cont_calibrate_bias.R | 73 ++++++---- ...document_calibration_overview_template.Rmd | 128 +++++++++++++++++- 2 files changed, 171 insertions(+), 30 deletions(-) diff --git a/demo/cluster_cont_calibrate_bias.R b/demo/cluster_cont_calibrate_bias.R index a3ca6f3..59c852b 100644 --- a/demo/cluster_cont_calibrate_bias.R +++ b/demo/cluster_cont_calibrate_bias.R @@ -28,7 +28,7 @@ clusterCall(c1, function(){library(devtools)}) glmr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/GLMr_3.1.10.tar.gz'))}) glmtools_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/glmtools_0.13.0.tar.gz'))}) lakeattr_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/lakeattributes_0.8.4.tar.gz'))}) -mdalakes_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/mda.lakes_3.0.3.tar.gz'))}) +mdalakes_install = clusterCall(c1, function(){install_url(paste0('http://', local_url,'/mda.lakes_3.0.4.tar.gz'))}) library(lakeattributes) library(mda.lakes) @@ -38,7 +38,7 @@ library(glmtools) ## setup run function run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nml_args=list(), datasource=NA){ - + library(lakeattributes) library(mda.lakes) @@ -61,9 +61,10 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm #rename for dplyr nhd_id = site_id + data(wtemp) obs = filter(wtemp, site_id == nhd_id) %>% - transmute(DateTime=date, Depth=depth, temp=wtemp) - + transmute(DateTime=date, Depth=depth, temp=wtemp) + #having a weird issue with resample_to_field, make unique obs = obs[!duplicated(obs[,1:2]), ] @@ -79,16 +80,17 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm kd_avg = secchi_conv/mean(kds$secchi_avg, na.rm=TRUE) prep_run_glm_kd(site_id=site_id, - path=run_dir, - years=years, - kd=kd_avg, - nml_args=c(list( - dt=3600, subdaily=FALSE, nsave=24, - timezone=-6, - csv_point_nlevs=0, - snow_albedo_factor=1.1, - meteo_fl=driver_path), - nml_args)) + path=run_dir, + years=years, + kd=kd_avg, + nml_args=c(list( + dt=3600, subdaily=FALSE, nsave=24, + timezone=-6, + csv_point_nlevs=0, + snow_albedo_factor=1.1, + meteo_fl=driver_path, + cd=getCD(site_id, method='Hondzo')), + nml_args)) cal.data = resample_to_field(file.path(run_dir, 'output.nc'), file.path(run_dir,'obs.tsv')) cal.data$site_id = site_id @@ -96,11 +98,11 @@ run_cal = function(site_id, years=1979:2012, driver_function=get_driver_path, nm unlink(run_dir, recursive=TRUE) return(cal.data) - + }, error=function(e){ - unlink(run_dir, recursive=TRUE) - return(paste(e$call, e$message, Sys.info()["nodename"])) - }) + unlink(run_dir, recursive=TRUE) + return(paste(e$call, e$message, Sys.info()["nodename"])) + }) } @@ -116,16 +118,16 @@ driver_fun = function(site_id){ #we want only ramdisk enabled nodes #ramdisk = clusterCall(c1, function(){file.exists('/mnt/ramdisk')}) #c1 = c1[unlist(ramdisk)] - +data(wtemp) to_run = unique(intersect(intersect(wtemp$site_id, zmax$site_id), secchi$site_id)) #to_run = to_run[to_run %in% read.table('~/managed_lakes_wilma_nhd.tsv', sep='\t', header=TRUE, as.is=TRUE)$id] -run_name = '2016-03-31_cal_NLDAS' -run_comment = "Full calibration run with all available wtemp, secchi and depth" +run_name = '2016-04-06_cal_NLDAS' +run_comment = "Markfort sheltering model for full calibration run with all available wtemp, secchi and depth. 1980-2014" clusterCall(c1, function(){library(mda.lakes);set_driver_url(driver_url)}) -out = clusterApplyLB(c1, to_run, run_cal, driver_function = driver_fun, nml_args=list(), years=1980:1999, datasource=NA) +out = clusterApplyLB(c1, to_run, run_cal, driver_function = driver_fun, nml_args=list(), years=1980:2014, datasource=NA) #out = clusterApplyLB(c1, to_run[1:50], run_cal) @@ -139,7 +141,32 @@ write.table(out_df, paste0('c:/WiLMA/results/', run_name, '.tsv'), sep='\t', row out_err = out[!unlist(lapply(out, inherits, what='data.frame'))] save(out_err, file = paste0('c:/WiLMA/results/', run_name, '.Rdata')) -rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file=paste0(run_name,'.pdf'), +rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file=paste0(run_name,'.html'), + output_dir='c:/WiLMA/results/', params=list(out_df=out_df, run_message=run_comment)) + + +sqrt(mean((out_df$Observed_temp - out_df$Modeled_temp)^2, na.rm=TRUE)) +mean(out_df$Observed_temp - out_df$Modeled_temp, na.rm=TRUE) + +run_comment = "Markfort sheltering model for full calibration run with all available wtemp, secchi and depth. 1980-2014" + +clusterCall(c1, function(){library(mda.lakes);set_driver_url(driver_url)}) + +out = clusterApplyLB(c1, to_run, run_cal, driver_function = driver_fun, nml_args=list(), years=1980:2014, datasource=NA) + +#out = clusterApplyLB(c1, to_run[1:50], run_cal) + +sprintf('%i lakes ran\n', sum(unlist(lapply(out, inherits, what='data.frame')))) + + +##results +out_df = do.call('rbind', out[unlist(lapply(out, inherits, what='data.frame'))]) +write.table(out_df, paste0('c:/WiLMA/results/', run_name, '.tsv'), sep='\t', row.names=FALSE) + +out_err = out[!unlist(lapply(out, inherits, what='data.frame'))] +save(out_err, file = paste0('c:/WiLMA/results/', run_name, '.Rdata')) + +rmarkdown::render('demo/document_calibration_overview_template.Rmd', output_file=paste0(run_name,'.html'), output_dir='c:/WiLMA/results/', params=list(out_df=out_df, run_message=run_comment)) diff --git a/demo/document_calibration_overview_template.Rmd b/demo/document_calibration_overview_template.Rmd index 91ae02f..1ccd55a 100644 --- a/demo/document_calibration_overview_template.Rmd +++ b/demo/document_calibration_overview_template.Rmd @@ -2,7 +2,7 @@ title: "Cal/Val Summary" author: "Luke Winslow" date: "March 22, 2016" -output: pdf_document +output: html_document params: out_df: !r data.frame() run_message: !r "default message" @@ -13,10 +13,11 @@ Run description: `r params$run_message` -```{r, echo=FALSE, message=FALSE} +```{r, echo=FALSE, message=FALSE, warning=FALSE} library(lubridate) library(glmtools) library(mda.lakes) +library(plyr) out_df = params$out_df @@ -28,6 +29,20 @@ out_df$month = month(out_df$DateTime) out_df$modLessObs = out_df$Modeled_temp - out_df$Observed_temp out_df$Depth_1 = floor(out_df$Depth/1)*1 +epi = calc_mod_obs_metric(out_df, 'epi.temperature') + +hypo = calc_mod_obs_metric(out_df, 'hypo.temperature') + +metric_calc_bylake = function(df){ + data.frame(rmse=sqrt(mean((df$mod - df$obs)^2, na.rm=TRUE)), bias=mean(df$mod - df$obs, na.rm=TRUE), ndates=nrow(df)) +} + + +epi_bylake = ddply(epi, 'site_id', metric_calc_bylake) +hypo_bylake = ddply(hypo, 'site_id', metric_calc_bylake) + +epi_bylake = subset(epi_bylake, ndates >=10) +hypo_bylake = subset(hypo_bylake, ndates >=10) ``` @@ -51,11 +66,24 @@ n lakes | `r length(unique(out_df$site_id)) ` RMSE | `r sqrt(mean((out_df$modLessObs)^2, na.rm=TRUE)) ` Mean error| `r mean(out_df$modLessObs, na.rm=TRUE)` +# Epi and Hypo lake-specific RMSE +These are RMSE calculated for each lake, then the 50th and 95th percentile of those per-lake values +are presented. +Layer | 50% | 95% +------|-----|----- +Epi | `r quantile(epi_bylake$rmse, probs=0.5)` | `r quantile(epi_bylake$rmse, probs=0.95)` +Hypo RMSE | `r quantile(hypo_bylake$rmse, probs=0.5)` | `r quantile(hypo_bylake$rmse, probs=0.95)` + +#Epi and Hypo lake-specific Bias stats + +Layer | 2.5% | 50% | 97.5 +------|-----|-----|------- +Epi Bias | `r quantile(epi_bylake$bias, probs=0.025)` | `r quantile(epi_bylake$bias, probs=0.5)` | `r quantile(epi_bylake$bias, probs=0.975)` +Hypo Bias | `r quantile(hypo_bylake$bias, probs=0.025)` | `r quantile(hypo_bylake$bias, probs=0.5)` | `r quantile(hypo_bylake$bias, probs=0.975)` -\newpage #Overall observed vs model: ```{r, echo=FALSE, fig.width=5, fig.height=7, warning=FALSE} @@ -65,12 +93,11 @@ plot(out_df$Observed_temp, out_df$Modeled_temp, col=rgb(0, 0, 0, 0.1), pch=16, x abline(0, 1) -epi = calc_mod_obs_metric(out_df, 'epi.temperature') plot(epi$obs, epi$mod, col=rgb(0, 0, 0, 0.1), pch=16, xlim=c(0,30), ylim=c(0,30), ylab='Modeled Epi', xaxt='n') abline(0, 1) -hypo = calc_mod_obs_metric(out_df, 'hypo.temperature') + plot(hypo$obs, hypo$mod, col=rgb(0, 0, 0, 0.1), pch=16, xlim=c(0,30), ylim=c(0,30), ylab='Modeled Hypo', xlab='Observed') abline(0, 1) @@ -83,7 +110,9 @@ Epi RMSE | `r sqrt(mean((epi$mod - epi$obs)^2, na.rm=TRUE))` | `r mean(epi$mod Hypo RMSE | `r sqrt(mean((hypo$mod - hypo$obs)^2, na.rm=TRUE))` | `r mean(hypo$mod - hypo$obs, na.rm=TRUE)` -\newpage + + + #Residuals across depth: ```{r, echo=FALSE} @@ -91,7 +120,7 @@ boxplot(modLessObs~Depth_1, out_df, ylab="Model - Observation", xlab='Depth (m)' abline(h=0) ``` -\newpage + #Seasonality of residuals: ```{r, echo=FALSE} @@ -101,4 +130,89 @@ abline(h=0) ``` +```{r, echo=FALSE} + +library(leaflet) +library(plyr) +library(lakeattributes) + +lake_stats = ddply(out_df, 'site_id', function(df){ + + rmse = sqrt(mean((df$Observed_temp - df$Modeled_temp)^2, na.rm=TRUE)) + bias = mean(df$Modeled_temp - df$Observed_temp, na.rm=TRUE) + n = nrow(df) + data.frame(rmse, bias, n) + +}) + +data(canopy) + +lake_stats = merge(lake_stats, lakeattributes::location, by='site_id') +lake_stats = merge(lake_stats, lakeattributes::area, by='site_id') +lake_stats = merge(lake_stats, lakeattributes::zmax, by='site_id') +lake_stats$secchi = 1.7/get_kd_avg(lake_stats$site_id)$kd_avg +lake_stats = merge(lake_stats, canopy, by='site_id') + +``` + +# +```{r, echo=FALSE} + +par(mfrow=c(2,1), mar=c(0,4,1,1), oma=c(4,0,0,0)) +plot((lake_stats$area_m2), lake_stats$bias, xlab='Lake area m^2', ylab='by-obs Bias', xaxt='n', log='x') +plot((lake_stats$area_m2), lake_stats$rmse, xlab='Lake area m^2', ylab='by-obs RMSE', log='x') +mtext(text='Log10(lake area m^2)', side=1, line=2) +``` + +```{r, echo=FALSE} +par(mfrow=c(2,1), mar=c(0,4,1,1), oma=c(4,0,0,0)) +plot(lake_stats$secchi, lake_stats$bias, xlab='Secchi(m)', ylab='by-obs Bias', xaxt='n') +plot(lake_stats$secchi, lake_stats$rmse, xlab='Secchi(m)', ylab='by-obs RMSE') +mtext(text='Secchi(m)', side=1, line=2) +``` + +```{r, echo=FALSE} +par(mfrow=c(2,1), mar=c(0,4,1,1), oma=c(4,0,0,0)) +plot(lake_stats$zmax_m, lake_stats$bias, log='x', xlab='Log(zmax)', ylab='by-obs Bias', xaxt='n') +plot(lake_stats$zmax_m, lake_stats$rmse, log='x', xlab='Log(zmax)', ylab='by-obs RMSE') +mtext(text='zmax', side=1, line=2) +# +# par(mfrow=c(2,1)) +# boxplot(bias~canopy_m, lake_stats) +# abline(h=0) +# height = as.numeric(names(tmp)) +# barplot(height~tmp) + + +``` + +## Map of Bias + +```{r, echo=FALSE} + +m = leaflet() %>% addTiles() %>% + addCircleMarkers(lng=lake_stats$lon, lat=lake_stats$lat, radius=4, stroke=TRUE, weight=1, + fillColor=colorNumeric(c('Blue', 'White', "Red"), (lake_stats$bias))((lake_stats$bias)), + fillOpacity=1, popup=paste0('Bias: ', lake_stats$bias, '
RMSE:', lake_stats$rmse, '
N:', + lake_stats$n, '
ID:', lake_stats$site_id)) + +m + + +``` + +## Map of RMSE + +```{r, echo=FALSE} + +m = leaflet() %>% addTiles() %>% + addCircleMarkers(lng=lake_stats$lon, lat=lake_stats$lat, radius=4, stroke=TRUE, weight=1, + fillColor=colorNumeric(c('White', "Red"), (lake_stats$rmse))((lake_stats$rmse)), + fillOpacity=1, popup=paste0('Bias: ', lake_stats$bias, '
RMSE:', lake_stats$rmse, '
N:', + lake_stats$n, '
ID:', lake_stats$site_id)) + +m + + +```