5 |
5 |
#Analyses, figures, tables and data are also produced in the script.
|
6 |
6 |
#AUTHOR: Benoit Parmentier
|
7 |
7 |
#CREATED ON: 05/21/2014
|
8 |
|
#MODIFIED ON: 06/01/2014
|
|
8 |
#MODIFIED ON: 09/07/2014
|
9 |
9 |
#Version: 1
|
10 |
10 |
#PROJECT: Environmental Layers project
|
11 |
11 |
#################################################################################################
|
... | ... | |
42 |
42 |
function_analyses_paper1 <- "contribution_of_covariates_paper_interpolation_functions_05212014.R" #first interp paper
|
43 |
43 |
function_analyses_paper2 <- "multi_timescales_paper_interpolation_functions_05052014.R"
|
44 |
44 |
function_assessment_by_tile <- "results_interpolation_date_output_analyses_05212014.R"
|
45 |
|
#source(file.path(script_path,"results_interpolation_date_output_analyses_08052013.R"))
|
|
45 |
source(file.path(script_path,"results_interpolation_date_output_analyses_08052013.R"))
|
46 |
46 |
|
47 |
47 |
load_obj <- function(f)
|
48 |
48 |
{
|
... | ... | |
80 |
80 |
|
81 |
81 |
#in_dir1 <- "/data/project/layers/commons/NEX_data/test_run1_03232014/output" #On Atlas
|
82 |
82 |
#parent output dir : contains subset of the data produced on NEX
|
83 |
|
in_dir1 <- "/data/project/layers/commons/NEX_data/output_run3_global_analyses_05292014/output/"
|
|
83 |
in_dir1 <- "/data/project/layers/commons/NEX_data/output_run5_global_analyses_08252014/output20Deg/"
|
84 |
84 |
# parent output dir for the curent script analyes
|
85 |
|
out_dir <- "/data/project/layers/commons/NEX_data/output_run3_global_analyses_05292014/" #On NCEAS Atlas
|
|
85 |
out_dir <- "/data/project/layers/commons/NEX_data/output_run5_global_analyses_08252014/" #On NCEAS Atlas
|
86 |
86 |
# input dir containing shapefiles defining tiles
|
87 |
|
in_dir_shp <- "/data/project/layers/commons/NEX_data/output_run3_global_analyses_05292014/output/subset/shapefiles"
|
|
87 |
in_dir_shp <- "/data/project/layers/commons/NEX_data/output_run5_global_analyses_08252014/output20Deg/subset/shapefiles"
|
88 |
88 |
|
89 |
89 |
#On NEX
|
90 |
90 |
#contains all data from the run by Alberto
|
... | ... | |
95 |
95 |
|
96 |
96 |
y_var_name <- "dailyTmax"
|
97 |
97 |
interpolation_method <- c("gam_CAI")
|
98 |
|
out_prefix<-"run3_global_analyses_05292014"
|
|
98 |
out_prefix<-"run5_global_analyses_08252014"
|
99 |
99 |
|
100 |
100 |
#out_dir <-paste(out_dir,"_",out_prefix,sep="")
|
101 |
101 |
create_out_dir_param <- FALSE
|
... | ... | |
109 |
109 |
setwd(out_dir)
|
110 |
110 |
|
111 |
111 |
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
|
112 |
|
region_name <- "USA"
|
|
112 |
region_name <- "World"
|
113 |
113 |
|
114 |
114 |
###Table 1: Average accuracy metrics
|
115 |
115 |
###Table 2: daily accuracy metrics for all tiles
|
... | ... | |
124 |
124 |
|
125 |
125 |
#Now add things here...
|
126 |
126 |
#
|
127 |
|
#selected_tiles <- c("45.0_-120.0","35.0_-115.0")
|
128 |
|
selected_tiles <- c("40.0_-120.0","35.0_-115.0")
|
|
127 |
selected_tiles <- df_tile_processed$tile_coord #selecting tiles 4 and 5
|
|
128 |
|
|
129 |
#selected_tiles <- c("40.0_-120.0","35.0_-115.0")
|
129 |
130 |
|
130 |
131 |
##raster_prediction object : contains testing and training stations with RMSE and model object
|
131 |
132 |
in_dir_list <- list.files(path=in_dir1,full.names=T)
|
... | ... | |
146 |
147 |
###############
|
147 |
148 |
|
148 |
149 |
##Quick interactive exploration of raster object to check possible errors
|
149 |
|
robj1 <- load_obj(list_raster_obj_files[[1]]) #This is tile in CA
|
150 |
|
|
151 |
|
names(robj1)
|
152 |
|
names(robj1$method_mod_obj[[1]]) #for January 1, 2010
|
153 |
|
names(robj1$method_mod_obj[[1]]$dailyTmax) #for January
|
154 |
|
|
155 |
|
names(robj1$clim_method_mod_obj[[1]]$data_month) #for January
|
156 |
|
names(robj1$validation_mod_month_obj[[1]]$data_s) #for January with predictions
|
|
150 |
#robj1 <- load_obj(list_raster_obj_files[[1]]) #This is tile in CA
|
|
151 |
#names(robj1)
|
|
152 |
#names(robj1$method_mod_obj[[1]]) #for January 1, 2010
|
|
153 |
# names(robj1$method_mod_obj[[1]]$dailyTmax) #for January
|
|
154 |
#names(robj1$clim_method_mod_obj[[1]]$data_month) #for January
|
|
155 |
#names(robj1$validation_mod_month_obj[[1]]$data_s) #for January with predictions
|
157 |
156 |
#Get the number of models predicted
|
158 |
|
nb_mod <- length(unique(robj1$tb_diagnostic_v$pred_mod))
|
|
157 |
#nb_mod <- length(unique(robj1$tb_diagnostic_v$pred_mod))
|
159 |
158 |
|
160 |
159 |
### Figure 1: plot location of the study area with tiles processed
|
161 |
160 |
|
... | ... | |
165 |
164 |
##Quick exploration of raster object
|
166 |
165 |
|
167 |
166 |
date_selected_results <- c("20100101")
|
168 |
|
raster_prediction_obj <- list_raster_obj_files[[1]]
|
169 |
|
in_path_tile <- in_dir_list[[1]] #Oregon tile
|
170 |
|
#in_path_tile <- NULL # set to NULL if the script is run on the NEX node as part of job
|
171 |
|
covar_obj <- lf_covar_obj[[1]]
|
|
167 |
date_selected_results <- c("20100901")
|
172 |
168 |
|
|
169 |
#robj1 <- load_obj(list_raster_obj_files[[2]])
|
|
170 |
in_path_tile <- in_dir_list[[2]] #Oregon tile
|
|
171 |
#in_path_tile <- NULL # set to NULL if the script is run on the NEX node as part of job
|
|
172 |
covar_obj <- load_obj(lf_covar_obj[[2]])
|
|
173 |
out_prefix_str <- paste(out_prefix,"_",basename(dirname(list_raster_obj_files[[2]][2])),sep="")
|
173 |
174 |
var <- "TMAX"
|
174 |
|
list_param_results_analyses<-list(out_dir,in_path_tile,script_path,raster_prediction_obj,interpolation_method,
|
175 |
|
covar_obj,date_selected_results,var,out_prefix)
|
|
175 |
list_param_results_analyses <- list(out_dir,in_path_tile,script_path,list_raster_obj_files[[2]][2],interpolation_method,
|
|
176 |
covar_obj,date_selected_results,var,out_prefix_str)
|
176 |
177 |
names(list_param_results_analyses)<-c("out_path","in_path_tile","script_path","raster_prediction_obj","interpolation_method",
|
177 |
178 |
"covar_obj","date_selected_results","var","out_prefix")
|
178 |
179 |
#list_param <- list_param_results_analyses
|
... | ... | |
180 |
181 |
#Run modified code from stage 5...
|
181 |
182 |
#plots_assessment_by_date<-function(j,list_param){
|
182 |
183 |
#Use lapply or mclapply
|
183 |
|
#debug(plots_assessment_by_date)
|
184 |
|
summary_v_day <- plots_assessment_by_date(1,list_param_results_analyses)
|
|
184 |
debug(plots_assessment_by_date)
|
|
185 |
#summary_v_day <- plots_assessment_by_date(1,list_param_results_analyses)
|
|
186 |
summary_v_day <- plots_assessment_by_date(244,list_param_results_analyses)
|
|
187 |
|
185 |
188 |
#Call as function...
|
186 |
189 |
|
187 |
190 |
#Boxplots...etc...
|
run5 assessment NEX part3: running diagnostic for specific tiles for more in depth analyses