Project

General

Profile

« Previous | Next » 

Revision 643c7d19

Added by Benoit Parmentier over 11 years ago

Transforming validation function to allow explicit passing of arguments with calling from raster prediction function

View differences:

climate/research/oregon/interpolation/GAM_fusion_function_multisampling_validation_metrics.R
2 2

  
3 3
#The interpolation is done first at the monthly add delta.
4 4
#AUTHOR: Benoit Parmentier                                                                        
5
#DATE: 02/13/2013                                                                                 
5
#DATE: 03/12/2013                                                                                 
6 6

  
7 7
#Change this to allow explicitly arguments...
8 8
#Arguments: 
9 9
#1)list of climatology files for all models...(365*nb of models)
10 10
#2)data_s:training
11 11
#3)data_v:testing
12
#4)list of dates??
12
#4)list of dates??: index
13 13
#5)stack of covariates: not needed at this this stage
14 14
#6)dst: data at the monthly time scale
15 15

  
16 16
#Function used in the script
17 17

  
18
calculate_accuracy_metrics<-function(i){
18
calculate_accuracy_metrics<-function(i,list_param){
19 19
  
20 20
  ### Caculate accuracy metrics
21 21
  calc_val_metrics<-function(x,y){
......
62 62
  
63 63
  ## BEGIN ##
64 64
  
65
  day_list <-rast_day_yearlist[[i]] #list of prediction for the current date...
65
  #PARSING INPUT PARAMETERS
66
  day_list<- list_param$rast_day_year_list[[i]]
67
  #day_list <-rast_day_yearlist[[i]] #list of prediction for the current date...
66 68
  names_mod<-names(day_list)
67
  #this needs to be changed...this must be assigned earlier
68
#  names(day_list)<-c("mod1","mod2","mod3","mod4","mod_kr")
69
#  obj_names<-c(y_var_name,"clim","delta","data_s","sampling_dat","data_v",
70
#               ,model_name)
71
#  names(gam_fus_mod[[i]])
72
  #
73
  data_v <- gam_fus_mod[[i]]$data_v
74
  data_s <- gam_fus_mod[[i]]$data_s
69
  method_mod_obj<-list_param$method_mod_obj
70
  #Change to results_mod_obj[[i]]$data_s to make it less specific
71
  data_v <- method_mod_obj[[i]]$data_v
72
  data_s <- method_mod_obj[[i]]$data_s
73
  
74
  ## Now create the stack
75 75
  
76 76
  rast_day_mod <- stack(day_list)
77 77
  names(rast_day_mod) <- names(day_list)
......
84 84
  ns<-nrow(data_s) # some loss of data might have happened because of the averaging...
85 85
  nv<-nrow(data_v)
86 86
  
87
  sampling_dat_day<-(gam_fus_mod[[i]])$sampling_dat
87
  sampling_dat_day<-(method_mod_obj[[i]])$sampling_dat
88 88
   
89 89
  metrics_v_obj<-calc_val_metrics_rast(data_v,y_var_name,names_mod)
90 90
  metrics_s_obj<-calc_val_metrics_rast(data_s,y_var_name,names_mod)
......
158 158
}
159 159

  
160 160
## Function to display metrics by months/seasons
161
boxplot_from_tb <-function(tb_diagnostic,metric_names,out_prefix){
161
boxplot_month_from_tb <-function(tb_diagnostic,metric_names,out_prefix){
162 162
  #Add code here...
163 163
}
164 164

  

Also available in: Unified diff