Revision b691ffcf
Added by Benoit Parmentier over 11 years ago
climate/research/oregon/interpolation/results_interpolation_date_output_analyses.R | ||
---|---|---|
32 | 32 |
|
33 | 33 |
##Paths to inputs and output |
34 | 34 |
#script_path<-"/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/" |
35 |
in_path <- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/input_data/" |
|
36 |
out_path<- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/output_data/" |
|
37 |
infile_covar<-"covariates__venezuela_region__VE_01292013.tif" #this is an output from covariate script |
|
38 |
date_selected<-c("20000101") ##This is for year 2000!!! |
|
35 |
#in_path <- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/input_data/"
|
|
36 |
#out_path<- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/output_data/"
|
|
37 |
#infile_covar<-"covariates__venezuela_region__VE_01292013.tif" #this is an output from covariate script
|
|
38 |
#date_selected<-c("20000101") ##This is for year 2000!!!
|
|
39 | 39 |
#raster_prediction_obj<-load_obj("raster_prediction_obj_dailyTmin_365d_GAM_fus5_all_lstd_03292013.RData") |
40 | 40 |
#out_prefix<-"_365d_GAM_fus5_all_lstd_03132013" |
41 | 41 |
#out_prefix<-"_365d_GAM_fus5_all_lstd_03142013" #User defined output prefix |
42 |
out_prefix<-"_365d_GAM_fus5_all_lstd_03292013" #User defined output prefix |
|
43 |
var<-"TMIN" |
|
42 |
#out_prefix<-"_365d_GAM_fus5_all_lstd_03292013" #User defined output prefix
|
|
43 |
#var<-"TMIN"
|
|
44 | 44 |
#gam_fus_mod<-load_obj("gam_fus_mod_365d_GAM_fus5_all_lstd_02202013.RData") |
45 |
#validation_obj<-load_obj("gam_fus_validation_mod_365d_GAM_fus5_all_lstd_02202013.RData") |
|
46 |
#clim_obj<-load_obj("gamclim_fus_mod_365d_GAM_fus5_all_lstd_02202013.RData") |
|
45 |
#validation_mod_obj<-load_obj("gam_fus_validation_mod_365d_GAM_fus5_all_lstd_02202013.RData")
|
|
46 |
#clim_method_mod_obj<-load_obj("gamclim_fus_mod_365d_GAM_fus5_all_lstd_02202013.RData")
|
|
47 | 47 |
|
48 |
rnames<-c("x","y","lon","lat","N","E","N_w","E_w","elev","slope","aspect","CANHEIGHT","DISTOC") |
|
49 |
lc_names<-c("LC1","LC2","LC3","LC4","LC5","LC6","LC7","LC8","LC9","LC10","LC11","LC12") |
|
50 |
lst_names<-c("mm_01","mm_02","mm_03","mm_04","mm_05","mm_06","mm_07","mm_08","mm_09","mm_10","mm_11","mm_12", |
|
51 |
"nobs_01","nobs_02","nobs_03","nobs_04","nobs_05","nobs_06","nobs_07","nobs_08", |
|
52 |
"nobs_09","nobs_10","nobs_11","nobs_12") |
|
53 |
covar_names<-c(rnames,lc_names,lst_names) |
|
48 |
#rnames<-c("x","y","lon","lat","N","E","N_w","E_w","elev","slope","aspect","CANHEIGHT","DISTOC")
|
|
49 |
#lc_names<-c("LC1","LC2","LC3","LC4","LC5","LC6","LC7","LC8","LC9","LC10","LC11","LC12")
|
|
50 |
#lst_names<-c("mm_01","mm_02","mm_03","mm_04","mm_05","mm_06","mm_07","mm_08","mm_09","mm_10","mm_11","mm_12",
|
|
51 |
# "nobs_01","nobs_02","nobs_03","nobs_04","nobs_05","nobs_06","nobs_07","nobs_08",
|
|
52 |
# "nobs_09","nobs_10","nobs_11","nobs_12")
|
|
53 |
#covar_names<-c(rnames,lc_names,lst_names)
|
|
54 | 54 |
|
55 |
list_param_results_analyses<-list(in_path,out_path,script_path,raster_prediction_obj,interpolation_method,infile_covar,covar_names,date_selected,var,out_prefix) |
|
56 |
names(list_param_results_analyses)<-c("in_path","out_path","script_path","raster_prediction_obj", "interpolation_method", |
|
57 |
"infile_covar","covar_names","date_selected","var","out_prefix") |
|
55 |
#list_param_results_analyses<-list(in_path,out_path,script_path,raster_prediction_obj,interpolation_method,infile_covar,covar_names,date_selected,var,out_prefix)
|
|
56 |
#names(list_param_results_analyses)<-c("in_path","out_path","script_path","raster_prediction_obj", "interpolation_method",
|
|
57 |
# "infile_covar","covar_names","date_selected","var","out_prefix")
|
|
58 | 58 |
|
59 |
setwd(in_path) |
|
59 |
#setwd(in_path)
|
|
60 | 60 |
|
61 | 61 |
## make this a script that calls several function: |
62 | 62 |
#1) covariate script |
... | ... | |
83 | 83 |
|
84 | 84 |
date_selected<-list_param$date_selected |
85 | 85 |
var<-list_param$var |
86 |
interpolation |
|
87 |
#gam_fus_mod<-load_obj("gam_fus_mod_365d_GAM_fus5_all_lstd_02202013.RData") |
|
88 |
#validation_obj<-load_obj("gam_fus_validation_mod_365d_GAM_fus5_all_lstd_02202013.RData") |
|
89 |
#clim_obj<-load_obj("gamclim_fus_mod_365d_GAM_fus5_all_lstd_02202013.RData") |
|
86 |
interpolation_method <- list_param$interpolation_method |
|
90 | 87 |
|
91 | 88 |
raster_prediction_obj<-list_param$raster_prediction_obj |
92 | 89 |
method_mod_obj<-raster_prediction_obj$method_mod_obj |
93 |
method_mod_obj<-raster_prediction_obj$gam_fus_mod #change later for any model type |
|
94 |
#validation_obj<-raster_prediction_obj$validation_obj |
|
95 |
validation_obj<-raster_prediction_obj$gam_fus_validation_mod #change later for any model type |
|
96 |
#clim_obj<-raster_prediction_obj$clim_obj |
|
97 |
clim_obj<-raster_prediction_obj$gamclim_fus_mod #change later for any model type |
|
90 |
validation_mod_obj<-raster_prediction_obj$validation_mod_obj |
|
91 |
clim_method_mod_obj <- raster_prediction_obj$clim_method_mod_obj |
|
98 | 92 |
|
99 | 93 |
if (var=="TMAX"){ |
100 | 94 |
y_var_name<-"dailyTmax" |
... | ... | |
139 | 133 |
|
140 | 134 |
#Get validation metrics, daily spdf training and testing stations, monthly spdf station input |
141 | 135 |
sampling_dat<-method_mod_obj[[index]]$sampling_dat |
142 |
metrics_v<-validation_obj[[index]]$metrics_v |
|
143 |
metrics_s<-validation_obj[[index]]$metrics_s |
|
144 |
data_v<-validation_obj[[index]]$data_v |
|
145 |
data_s<-validation_obj[[index]]$data_s |
|
146 |
data_month<-clim_obj[[index]]$data_month |
|
147 |
formulas<-clim_obj[[index]]$formulas |
|
136 |
metrics_v<-validation_mod_obj[[index]]$metrics_v
|
|
137 |
metrics_s<-validation_mod_obj[[index]]$metrics_s
|
|
138 |
data_v<-validation_mod_obj[[index]]$data_v
|
|
139 |
data_s<-validation_mod_obj[[index]]$data_s
|
|
140 |
data_month<-clim_method_mod_obj[[index]]$data_month
|
|
141 |
formulas<-clim_method_mod_obj[[index]]$formulas
|
|
148 | 142 |
|
149 | 143 |
#Adding layer LST to the raster stack of covariates |
150 | 144 |
#The names of covariates can be changed... |
... | ... | |
260 | 254 |
|
261 | 255 |
## Figure 7: delta surface and bias |
262 | 256 |
|
263 |
png(paste("Bias_delta_surface_",y_var_name,"_",sampling_dat$date[i],"_",sampling_dat$prop[i], |
|
264 |
"_",sampling_dat$run_samp[i],out_prefix,".png", sep="")) |
|
265 |
|
|
266 |
bias_rast<-stack(clim_obj[[index]]$bias) |
|
267 |
delta_rast<-raster(method_mod_obj[[index]]$delta) #only one delta image!!! |
|
268 |
names(delta_rast)<-"delta" |
|
269 |
rast_temp_date<-stack(bias_rast,delta_rast) |
|
270 |
rast_temp_date<-mask(rast_temp_date,LC_mask,file="test.tif",overwrite=TRUE) |
|
271 |
#bias_d_rast<-raster("fusion_bias_LST_20100103_30_1_10d_GAM_fus5_all_lstd_02082013.rst") |
|
272 |
plot(rast_temp_date) |
|
273 |
|
|
274 |
dev.off() |
|
257 |
if (interpolation_method=="gam_fus"){ |
|
258 |
png(paste("Bias_delta_surface_",y_var_name,"_",sampling_dat$date[i],"_",sampling_dat$prop[i], |
|
259 |
"_",sampling_dat$run_samp[i],out_prefix,".png", sep="")) |
|
260 |
|
|
261 |
bias_rast<-stack(clim_method_mod_obj[[index]]$bias) |
|
262 |
delta_rast<-raster(method_mod_obj[[index]]$delta) #only one delta image!!! |
|
263 |
names(delta_rast)<-"delta" |
|
264 |
rast_temp_date<-stack(bias_rast,delta_rast) |
|
265 |
rast_temp_date<-mask(rast_temp_date,LC_mask,file="test.tif",overwrite=TRUE) |
|
266 |
#bias_d_rast<-raster("fusion_bias_LST_20100103_30_1_10d_GAM_fus5_all_lstd_02082013.rst") |
|
267 |
plot(rast_temp_date) |
|
268 |
dev.off() |
|
269 |
} |
|
270 |
|
|
271 |
if (interpolation_method=="gam_CAI"){ |
|
272 |
png(paste("clim_surface_",y_var_name,"_",sampling_dat$date[i],"_",sampling_dat$prop[i], |
|
273 |
"_",sampling_dat$run_samp[i],out_prefix,".png", sep="")) |
|
274 |
|
|
275 |
clim_rast<-stack(clim_method_mod_obj[[index]]$clim) |
|
276 |
rast_temp_date<-stack(clim_rast,delta_rast) |
|
277 |
rast_temp_date<-mask(rast_temp_date,LC_mask,file="test.tif",overwrite=TRUE) |
|
278 |
#bias_d_rast<-raster("fusion_bias_LST_20100103_30_1_10d_GAM_fus5_all_lstd_02082013.rst") |
|
279 |
plot(rast_temp_date) |
|
280 |
|
|
281 |
dev.off() |
|
282 |
} |
|
275 | 283 |
|
276 | 284 |
#Figure 9: histogram for all images... |
277 | 285 |
|
Also available in: Unified diff
results analyses, modifications to allow for gam cai and other methods