Project

General

Profile

« Previous | Next » 

Revision a6e5ed01

Added by Benoit Parmentier about 10 years ago

run5 assessment NEX part3: running diagnostic for specific tiles for more in depth analyses

View differences:

climate/research/oregon/interpolation/global_run_scalingup_assessment_part1.R
548 548
lf_diagnostic_obj <- lf_diagnostic_obj[grep("lk_min",lf_diagnostic_obj,invert=T)] #remove object that have lk_min...
549 549

  
550 550
## This will be part of the raster_obj function
551
debug(create_raster_prediction_obj)
551
#debug(create_raster_prediction_obj)
552 552
out_prefix_str <- paste(basename(in_dir_list),out_prefix,sep="_") 
553 553
lf_raster_obj <- create_raster_prediction_obj(in_dir_list,interpolation_method, y_var_name,out_prefix_str,out_path_list=NULL)
554 554

  
......
576 576
  
577 577
##Quick exploration of raster object
578 578
robj1 <- load_obj(list_raster_obj_files[[2]]) #This is tile corresponding to Oregon
579
robj1 <- load_obj(lf_raster_obj[2]) #This is tile corresponding to Oregon
579 580

  
580 581
names(robj1)
581 582
names(robj1$method_mod_obj[[1]]) #for January 1, 2010
......
1117 1118
for (j in 1:length(list_tile_scp)){
1118 1119
  tile_nb <- list_tile_scp[j]
1119 1120
  #nb_mod <- 3+1 #set up earlier
1120
  date_selected <- c("20100101","20100901") #should be set up earlier
1121
  date_index <- c(1,244) #list_day??
1121
  date_selected <- c("20100101","20100102","20100103","20100103","20100901","20100902","20100903") #should be set up earlier
1122
  date_index <- c(1,2,3,244,245,246) #list_day??
1122 1123
  #tile_nb <- 1
1123 1124

  
1124 1125
  in_dir_tile <- basename(df_tile_processed$path_NEX[tile_nb])
climate/research/oregon/interpolation/global_run_scalingup_assessment_part3.R
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...

Also available in: Unified diff