Revision e8db2d42
Added by Benoit Parmentier over 10 years ago
climate/research/oregon/interpolation/global_run_scalingup_assessment_part2.R | ||
---|---|---|
5 | 5 |
#Analyses, figures, tables and data are also produced in the script. |
6 | 6 |
#AUTHOR: Benoit Parmentier |
7 | 7 |
#CREATED ON: 03/23/2014 |
8 |
#MODIFIED ON: 05/15/2014
|
|
8 |
#MODIFIED ON: 06/01/2014
|
|
9 | 9 |
#Version: 3 |
10 |
#PROJECT: Environmental Layers project |
|
10 |
#PROJECT: Environmental Layers project |
|
11 |
#COMMENTS: analyses for run 3 global using 2 specific tiles |
|
11 | 12 |
################################################################################################# |
12 | 13 |
|
13 | 14 |
### Loading R library and packages |
... | ... | |
68 | 69 |
#on ATLAS |
69 | 70 |
#in_dir1 <- "/data/project/layers/commons/NEX_data/test_run1_03232014/output" #On Atlas |
70 | 71 |
#parent output dir : contains subset of the data produced on NEX |
71 |
in_dir1 <- "/data/project/layers/commons/NEX_data/output_run2_05122014/output/"
|
|
72 |
in_dir1 <- "/data/project/layers/commons/NEX_data/output_run3_global_analyses_05292014/output"
|
|
72 | 73 |
# parent output dir for the curent script analyes |
73 |
out_dir <-"/data/project/layers/commons/NEX_data/" #On NCEAS Atlas |
|
74 |
out_dir <-"/data/project/layers/commons/NEX_data/output_run3_global_analyses_05292014/" #On NCEAS Atlas |
|
75 |
out_dir <-"/data/project/layers/commons/NEX_data/output_run3_global_analyses_05292014/" |
|
74 | 76 |
# input dir containing shapefiles defining tiles |
75 |
in_dir_shp <- "/data/project/layers/commons/NEX_data/output_run2_05122014/output/subset/shapefiles"
|
|
77 |
in_dir_shp <- "/data/project/layers/commons/NEX_data/output_run3_global_analyses_05292014/output/subset/shapefiles"
|
|
76 | 78 |
|
77 | 79 |
#On NEX |
78 | 80 |
#contains all data from the run by Alberto |
... | ... | |
85 | 87 |
in_dir_list <- file.path(in_dir1,read.table(file.path(in_dir1,"processed.txt"))$V1) |
86 | 88 |
y_var_name <- "dailyTmax" |
87 | 89 |
interpolation_method <- c("gam_CAI") |
88 |
out_prefix<-"run2_global_analyses_05122014"
|
|
90 |
out_prefix<-"run3_global_analyses_05292014"
|
|
89 | 91 |
|
90 | 92 |
#out_dir <-paste(out_dir,"_",out_prefix,sep="") |
91 |
create_out_dir_param <- TRUE
|
|
93 |
create_out_dir_param <- FALSE
|
|
92 | 94 |
|
93 | 95 |
if(create_out_dir_param==TRUE){ |
94 | 96 |
out_dir <- create_dir_fun(out_dir,out_prefix) |
... | ... | |
105 | 107 |
|
106 | 108 |
###Table 1: Average accuracy metrics |
107 | 109 |
###Table 2: daily accuracy metrics for all tiles |
108 |
|
|
110 |
#lf_tables <- list.files(out_dir,) |
|
109 | 111 |
summary_metrics_v <- read.table(file=file.path(out_dir,paste("summary_metrics_v2_NA_",out_prefix,".txt",sep="")),sep=",") |
110 | 112 |
tb <- read.table(file=file.path(out_dir,paste("tb_diagnostic_v_NA","_",out_prefix,".txt",sep="")),sep=",") |
111 |
#df_tile_processed <- read.table(file=file.path(out_dir,paste("df_tile_processed_",out_prefix,".txt",sep="")),sep=",")
|
|
113 |
df_tile_processed <- read.table(file=file.path(out_dir,paste("df_tile_processed_",out_prefix,".txt",sep="")),sep=",") |
|
112 | 114 |
|
113 | 115 |
########################## START SCRIPT ############################## |
114 | 116 |
|
... | ... | |
128 | 130 |
shps_tiles <- vector("list",length(list_shp_reg_files)) |
129 | 131 |
#collect info: read in all shapfiles |
130 | 132 |
for(i in 1:length(list_shp_reg_files)){ |
133 |
path_to_shp <- dirname(list_shp_reg_files[[i]]) |
|
134 |
layer_name <- basename(list_shp_reg_files[[i]]) |
|
135 |
shp1 <- readOGR(path_to_shp, layer_name) |
|
131 | 136 |
shp1<-readOGR(dirname(list_shp_reg_files[[i]]),sub(".shp","",basename(list_shp_reg_files[[i]]))) |
132 | 137 |
pt <- gCentroid(shp1) |
133 | 138 |
centroids_pts[[i]] <-pt |
... | ... | |
235 | 240 |
date_selected <- "20100101" |
236 | 241 |
name_method_var <- paste(interpolation_method,"_",y_var_name,"_",sep="") |
237 | 242 |
|
238 |
pattern_str <- paste("mosaiced","_",name_method_var,".*.",date_selected,".*.tif",sep="") |
|
239 |
lf_list <- list.files(pattern=pattern_str) |
|
243 |
pattern_str <- paste("mosaiced","_",name_method_var,"predicted",".*.",date_selected,".*.tif",sep="")
|
|
244 |
lf_pred_list <- list.files(pattern=pattern_str)
|
|
240 | 245 |
|
241 |
for(i in 1:length(lf_list)){ |
|
246 |
for(i in 1:length(lf_pred_list)){
|
|
242 | 247 |
|
243 |
r_pred <- raster(lf_list[i]) |
|
248 |
r_pred <- raster(lf_pred_list[i])
|
|
244 | 249 |
|
245 | 250 |
res_pix <- 480 |
246 | 251 |
col_mfrow <- 1 |
... | ... | |
255 | 260 |
|
256 | 261 |
} |
257 | 262 |
|
263 |
## plotting of delta and clim for later scripts... |
|
264 |
|
|
258 | 265 |
#### Now combined plot... |
259 | 266 |
|
260 | 267 |
#pred_s <- stack(lf_list) #problem different extent!! |
... | ... | |
291 | 298 |
### Figure 5: plot map of average RMSE per tile at centroids |
292 | 299 |
|
293 | 300 |
#Turn summary table to a point shp |
294 |
coordinates(summary_metrics_v) <- cbind(long,lat) |
|
295 |
list_df_ac_mod <- vector("list",length=length(lf_list)) |
|
301 |
|
|
302 |
coordinates(summary_metrics_v) <- cbind(summary_metrics_v$lon,summary_metrics_v$lat) |
|
303 |
proj4string(summary_metrics_v) <- CRS_WGS84 |
|
304 |
list_df_ac_mod <- vector("list",length=length(lf_pred_list)) |
|
296 | 305 |
for (i in 1:length(lf_list)){ |
297 | 306 |
|
298 | 307 |
ac_mod <- summary_metrics_v[summary_metrics_v$pred_mod==model_name[i],] |
Also available in: Unified diff
assessment NEX run part2: debugging