Revision dbc09684
Added by Benoit Parmentier about 10 years ago
climate/research/oregon/interpolation/global_run_scalingup_assessment_part1.R | ||
---|---|---|
5 | 5 |
#Part 1 create summary tables and inputs for figure in part 2 and part 3. |
6 | 6 |
#AUTHOR: Benoit Parmentier |
7 | 7 |
#CREATED ON: 03/23/2014 |
8 |
#MODIFIED ON: 10/29/2014
|
|
8 |
#MODIFIED ON: 11/13/2014
|
|
9 | 9 |
#Version: 3 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 | 11 |
#TO DO: |
... | ... | |
171 | 171 |
} |
172 | 172 |
|
173 | 173 |
### Function: |
174 |
pred_data_info_fun <- function(k,list_data,pred_mod,sampling_dat_info){
|
|
174 |
pred_data_info_fun <- function(k,list_data,pred_mod,sampling_dat_info){ |
|
175 | 175 |
#Summarizing input info from sampling and df used in training/testing |
176 | 176 |
|
177 |
data <- list_data[[k]] |
|
178 |
sampling_dat <- sampling_dat_info[[k]] |
|
179 |
if(data!="try-error"){ |
|
180 |
n <- nrow(data) |
|
181 |
n_mod <- vector("numeric",length(pred_mod)) |
|
182 |
for(j in 1:length(pred_mod)){ |
|
183 |
n_mod[j] <- sum(!is.na(data[[pred_mod[j]]])) |
|
184 |
} |
|
185 |
n <- rep(n,length(pred_mod)) |
|
186 |
sampling_dat <- sampling_dat[rep(seq_len(nrow(sampling_dat)), each=length(pred_mod)),] |
|
187 |
row.names(sampling_dat) <- NULL |
|
188 |
df_n <- data.frame(n,n_mod,pred_mod) |
|
189 |
df_n <- cbind(df_n,sampling_dat) |
|
190 |
}else{ |
|
191 |
n <- rep(NA,length(pred_mod)) |
|
192 |
n_mod <- vector("numeric",length(pred_mod)) |
|
193 |
n_mod <- rep(NA,length(pred_mod)) |
|
194 |
df_n <- data.frame(n,n_mod,pred_mod) |
|
195 |
sampling_dat <- sampling_dat[rep(seq_len(nrow(sampling_dat)), each=length(pred_mod)),] |
|
196 |
row.names(sampling_dat) <- NULL |
|
197 |
df_n <- data.frame(n,n_mod,pred_mod) |
|
198 |
df_n <- cbind(df_n,sampling_dat) |
|
199 |
|
|
177 |
data <- list_data[[k]] |
|
178 |
sampling_dat <- sampling_dat_info[[k]] |
|
179 |
if(data!="try-error"){ |
|
180 |
n <- nrow(data) |
|
181 |
n_mod <- vector("numeric",length(pred_mod)) |
|
182 |
for(j in 1:length(pred_mod)){ |
|
183 |
n_mod[j] <- sum(!is.na(data[[pred_mod[j]]])) |
|
200 | 184 |
} |
201 |
|
|
202 |
return(df_n) |
|
203 |
} |
|
185 |
n <- rep(n,length(pred_mod)) |
|
186 |
sampling_dat <- sampling_dat[rep(seq_len(nrow(sampling_dat)), each=length(pred_mod)),] |
|
187 |
row.names(sampling_dat) <- NULL |
|
188 |
df_n <- data.frame(n,n_mod,pred_mod) |
|
189 |
df_n <- cbind(df_n,sampling_dat) |
|
190 |
}else{ |
|
191 |
n <- rep(NA,length(pred_mod)) |
|
192 |
n_mod <- vector("numeric",length(pred_mod)) |
|
193 |
n_mod <- rep(NA,length(pred_mod)) |
|
194 |
df_n <- data.frame(n,n_mod,pred_mod) |
|
195 |
sampling_dat <- sampling_dat[rep(seq_len(nrow(sampling_dat)), each=length(pred_mod)),] |
|
196 |
row.names(sampling_dat) <- NULL |
|
197 |
df_n <- data.frame(n,n_mod,pred_mod) |
|
198 |
df_n <- cbind(df_n,sampling_dat) |
|
199 |
|
|
200 |
} |
|
201 |
return(df_n) |
|
202 |
} |
|
204 | 203 |
|
205 | 204 |
extract_daily_training_testing_info <- function(i,list_param){ |
206 | 205 |
#This function extracts training and testing information from the raster object produced for each tile |
... | ... | |
457 | 456 |
############################## |
458 | 457 |
#### Parameters and constants |
459 | 458 |
|
460 |
#in_dir1 <- "/data/project/layers/commons/NEX_data/test_run1_03232014/output" #On Atlas |
|
461 |
#in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output20Deg2/" |
|
462 |
#in_dir1 <-"/nobackupp4/aguzman4/climateLayers/output20Deg_75overlap/reg4" |
|
463 |
in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output1000x3000_km/" |
|
459 |
#in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output1000x3000_km/" |
|
460 |
in_dir1 <- "/nobackupp6/aguzman4/climateLayers/output1000x3000_km/" |
|
464 | 461 |
#/nobackupp4/aguzman4/climateLayers/output10Deg/reg1/finished.txt |
465 | 462 |
in_dir_list <- list.dirs(path=in_dir1,recursive=FALSE) #get the list regions processed for this run |
463 |
in_dir_list <- in_dir_list[c(3,4)] #get the list regions processed for this run |
|
464 |
|
|
466 | 465 |
#if(basename(in_dir_list)[[1]]=="reg?") #add later |
467 | 466 |
in_dir_list_all <- lapply(in_dir_list,function(x){list.dirs(path=x,recursive=F)}) |
468 | 467 |
#in_dir_list_all <- in_dir_list |
... | ... | |
486 | 485 |
|
487 | 486 |
#in_dir_list <- file.path(in_dir1,read.table(file.path(in_dir1,"processed.txt"))$V1) |
488 | 487 |
#in_dir_list <- as.list(in_dir_list[-1]) |
489 |
#in_dir_list <- in_dir_list[grep("bak",basename(basename(in_dir_list)),invert=TRUE)] #the first one is the in_dir1
|
|
488 |
in_dir_list <- in_dir_list[grep("bak",basename(basename(in_dir_list)),invert=TRUE)] #the first one is the in_dir1 |
|
490 | 489 |
#in_dir_shp <- in_dir_list[grep("shapefiles",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles... |
490 |
in_dir_shp <- in_dir_shp[grep("subset_bak",basename(dirname(in_dir_shp)),invert=TRUE)] #the first one is the in_dir1 |
|
491 | 491 |
|
492 | 492 |
#in_dir_shp <- "/nobackupp4/aguzman4/climateLayers/output10Deg/reg1/subset/shapefiles/" |
493 | 493 |
#in_dir_shp <- "/nobackupp4/aguzman4/climateLayers/output20Deg/reg2/subset/shapefiles" |
... | ... | |
498 | 498 |
# the last directory contains shapefiles |
499 | 499 |
y_var_name <- "dailyTmax" |
500 | 500 |
interpolation_method <- c("gam_CAI") |
501 |
out_prefix<-"run8_global_analyses_10292014"
|
|
501 |
out_prefix<-"run9_global_analyses_11122014"
|
|
502 | 502 |
|
503 | 503 |
#out_dir<-"/data/project/layers/commons/NEX_data/" #On NCEAS Atlas |
504 | 504 |
out_dir <- "/nobackup/bparmen1/" #on NEX |
Also available in: Unified diff
run 9 NEX assessment, 75% overlap 10x30 early modifications