10 |
10 |
#STAGE 5: Output analyses: assessment of results for specific dates...
|
11 |
11 |
#
|
12 |
12 |
#AUTHOR: Benoit Parmentier
|
13 |
|
#DATE: 06/07/2013
|
|
13 |
#DATE: 06/08/2013
|
14 |
14 |
|
15 |
15 |
#PROJECT: NCEAS INPLANT: Environment and Organisms --TASK#363, TASK$568--
|
16 |
16 |
|
... | ... | |
48 |
48 |
|
49 |
49 |
##SCRIPT USED FOR THE PREDICTIONS: Source or list all scripts here to avoid confusion on versions being run!!!!
|
50 |
50 |
|
51 |
|
#source(file.path(script_path,"master_script_temp_06032013.R")) #Master script can be run directly...
|
|
51 |
#source(file.path(script_path,"master_script_temp_06082013.R")) #Master script can be run directly...
|
52 |
52 |
|
53 |
53 |
#CALLED FROM MASTER SCRIPT:
|
54 |
54 |
|
55 |
55 |
modis_download_script <- file.path(script_path,"modis_download_05142013.py") # LST modis download python script
|
56 |
|
clim_script <- file.path(script_path,"climatology_05142013.py") # LST climatology python script
|
|
56 |
clim_script <- file.path(script_path,"climatology_05312013.py") # LST climatology python script
|
57 |
57 |
grass_setting_script <- file.path(script_path,"grass-setup.R") #Set up system shell environment for python+GRASS
|
58 |
58 |
source(file.path(script_path,"download_and_produce_MODIS_LST_climatology_05302013.R"))
|
59 |
59 |
source(file.path(script_path,"covariates_production_temperatures_06072013.R"))
|
60 |
60 |
source(file.path(script_path,"Database_stations_covariates_processing_function_05212013.R"))
|
61 |
|
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_06052013.R"))
|
62 |
|
source(file.path(script_path,"results_interpolation_date_output_analyses_05062013.R"))
|
|
61 |
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_06082013.R"))
|
|
62 |
source(file.path(script_path,"results_interpolation_date_output_analyses_06102013.R"))
|
63 |
63 |
#source(file.path(script_path,"results_covariates_database_stations_output_analyses_04012013.R"))
|
64 |
64 |
|
65 |
65 |
#FUNCTIONS CALLED FROM GAM ANALYSIS RASTER PREDICTION ARE FOUND IN...
|
66 |
66 |
|
67 |
67 |
source(file.path(script_path,"sampling_script_functions_03122013.R"))
|
68 |
68 |
source(file.path(script_path,"GAM_fusion_function_multisampling_05212013.R")) #Include GAM_CAI
|
69 |
|
source(file.path(script_path,"interpolation_method_day_function_multisampling_06052013.R")) #Include GAM_day
|
|
69 |
source(file.path(script_path,"interpolation_method_day_function_multisampling_06082013.R")) #Include GAM_day
|
70 |
70 |
source(file.path(script_path,"GAM_fusion_function_multisampling_validation_metrics_05062013.R"))
|
71 |
71 |
|
72 |
72 |
#stages_to_run<-c(1,2,3,4,5) #May decide on antoher strategy later on...
|
73 |
73 |
stages_to_run<-c(0,2,3,4,5) #May decide on antoher strategy later on...
|
74 |
74 |
|
75 |
75 |
var<-"TMAX" # variable being interpolated
|
76 |
|
#out_prefix<-"_365d_kriging_day_lst_06072013" #User defined output prefix
|
77 |
|
out_prefix<-"_365d_GAM_CAI_all_lst_06072013" #User defined output prefix
|
78 |
|
out_suffix<-"_VE_06072013"
|
79 |
|
#out_suffix_modis <-"_05302013" #use tiles produce previously
|
80 |
|
out_suffix_modis <-"_05242013" #use tiles produce previously
|
|
76 |
out_prefix<-"_365d_gwr_day_lst_06082013" #User defined output prefix
|
|
77 |
out_suffix<-"_OR_06082013"
|
|
78 |
out_suffix_modis <-"_05302013" #use tiles produce previously
|
81 |
79 |
|
82 |
80 |
#interpolation_method<-c("gam_fusion","gam_CAI","gam_daily") #other otpions to be added later
|
83 |
|
interpolation_method<-c("gam_CAI") #other otpions to be added later
|
|
81 |
#interpolation_method<-c("gam_CAI") #other otpions to be added later
|
84 |
82 |
#interpolation_method<-c("gam_fusion") #other otpions to be added later
|
85 |
83 |
#interpolation_method<-c("gam_daily") #other otpions to be added later
|
86 |
84 |
#interpolation_method<-c("kriging_daily") #other otpions to be added later
|
|
85 |
interpolation_method<-c("gwr_daily") #other otpions to be added later
|
87 |
86 |
|
88 |
|
out_path <-"/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/output_data"
|
89 |
|
#out_path<-"/home/parmentier/Data/IPLANT_project/Oregon_interpolation/Oregon_03142013/output_data"
|
|
87 |
#out_path <- paste("/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/output_data",
|
|
88 |
# out_prefix,"/",sep="")
|
|
89 |
out_path<-"/home/parmentier/Data/IPLANT_project/Oregon_interpolation/Oregon_03142013/output_data"
|
90 |
90 |
out_path <-paste(out_path,out_prefix,sep="")
|
91 |
91 |
|
92 |
92 |
if (!file.exists(out_path)){
|
... | ... | |
104 |
104 |
#infile_reg_outline<- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/outline_venezuela_region__VE_01292013.shp"
|
105 |
105 |
#infile_covariates<-"/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/covariates__venezuela_region_TMIN__VE_03192013.tif" #covariates stack for TMIN
|
106 |
106 |
#infile_covariates<- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/covariates_Oregon_region_TMAX__OR_04052013.tif" #Oregon covar TMAX from earlier codes...for continuity
|
107 |
|
infile_reg_outline="" #input region outline defined by polygon: none for Venezuela
|
|
107 |
#infile_reg_outline="" #input region outline defined by polygon: none for Venezuela
|
108 |
108 |
#This is the shape file of outline of the study area #It is an input/output of the covariate script
|
109 |
|
#infile_reg_outline <- "/home/parmentier/Data/IPLANT_project/Oregon_interpolation/Oregon_03142013/OR83M_state_outline.shp" #input region outline defined by polygon: Oregon
|
|
109 |
infile_reg_outline <- "/home/parmentier/Data/IPLANT_project/Oregon_interpolation/Oregon_03142013/OR83M_state_outline.shp" #input region outline defined by polygon: Oregon
|
110 |
110 |
#infile_reg_outline <-"OR83M_state_outline.shp" #remove this parameter!!!
|
111 |
|
ref_rast_name<-"" #local raster name defining resolution, exent, local projection--. set on the fly??
|
|
111 |
#ref_rast_name<-"" #local raster name defining resolution, exent, local projection--. set on the fly??
|
112 |
112 |
#this may be redundant with infile_reg_outline
|
113 |
|
#ref_rast_name<-"/home/parmentier/Data/IPLANT_project/Oregon_interpolation/Oregon_03142013/mean_day244_rescaled.rst" #local raster name defining resolution, exent: oregon
|
|
113 |
ref_rast_name<-"/home/parmentier/Data/IPLANT_project/Oregon_interpolation/Oregon_03142013/mean_day244_rescaled.rst" #local raster name defining resolution, exent: oregon
|
114 |
114 |
|
115 |
115 |
#covar_names see stage 2
|
116 |
116 |
|
117 |
|
list_tiles_modis <- c("h11v08,h11v07,h12v07,h12v08,h10v07,h10v08") #tile for Venezuela and surrounding area
|
118 |
|
#list_tiles_modis <- c("h08v04,h09v04") #tiles for Oregon
|
|
117 |
#list_tiles_modis <- c("h11v08,h11v07,h12v07,h12v08,h10v07,h10v08") #tile for Venezuela and surrounding area
|
|
118 |
list_tiles_modis <- c("h08v04,h09v04") #tiles for Oregon
|
119 |
119 |
|
120 |
|
CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs";
|
121 |
|
#CRS_interp <-"+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m +no_defs";
|
|
120 |
#CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs";
|
|
121 |
CRS_interp <-"+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m +no_defs";
|
122 |
122 |
#"+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80"
|
123 |
123 |
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
|
124 |
|
out_region_name<-"_venezuela_region" #generated on the fly
|
125 |
|
#out_region_name<-"_oregon_region" #generated on the fly
|
|
124 |
#out_region_name<-"_venezuela_region" #generated on the fly
|
|
125 |
out_region_name<-"_oregon_region" #generated on the fly
|
126 |
126 |
|
127 |
127 |
#The names of covariates can be changed...these names should be output/input from covar script!!!
|
128 |
128 |
rnames<-c("x","y","lon","lat","N","E","N_w","E_w","elev_s","slope","aspect","CANHEIGHT","DISTOC")
|
... | ... | |
187 |
187 |
range_years<-c("2010","2011") #right bound not included in the range!!
|
188 |
188 |
range_years_clim<-c("2000","2011") #right bound not included in the range!!
|
189 |
189 |
infile_ghncd_data <-"/home/layers/data/climate/ghcn/v2.92-upd-2012052822/ghcnd-stations.txt" #This is the textfile of station locations from GHCND
|
190 |
|
qc_flags_stations<-c("0","S") #flags allowed for screening after the query from the GHCND??
|
191 |
|
#qc_flags_stations<-c("0") #flags allowed for screening after the query from the GHCND??
|
|
190 |
#qc_flags_stations<-c("0","S") #flags allowed for screening after the query from the GHCND??
|
|
191 |
qc_flags_stations<-c("0") #flags allowed for screening after the query from the GHCND??
|
192 |
192 |
|
193 |
193 |
#infile_covariates and infile_reg_outline defined in stage 2 or at the start of script...
|
194 |
194 |
|
... | ... | |
230 |
230 |
|
231 |
231 |
#Models to run...this can be change for each run
|
232 |
232 |
|
233 |
|
list_models<-c("y_var ~ s(elev_s)",
|
234 |
|
"y_var ~ s(LST)",
|
235 |
|
"y_var ~ s(elev_s,LST)",
|
236 |
|
"y_var ~ s(lat) + s(lon)+ s(elev_s)",
|
237 |
|
"y_var ~ s(lat,lon,elev_s)",
|
238 |
|
"y_var ~ s(lat,lon) + s(elev_s) + s(N_w,E_w) + s(LST)",
|
239 |
|
"y_var ~ s(lat,lon) + s(elev_s) + s(N_w,E_w) + s(LST) + s(LC2)",
|
240 |
|
"y_var ~ s(lat,lon) + s(elev_s) + s(N_w,E_w) + s(LST) + s(LC6)",
|
241 |
|
"y_var ~ s(lat,lon) + s(elev_s) + s(N_w,E_w) + s(LST) + s(DISTOC)")
|
242 |
|
#krmod2<-autoKrige(tmax~x_OR83M+y_OR83M,input_data=data_s,new_data=s_sgdf,data_variogram=data_s)
|
243 |
|
#list_models<-c("y_var ~ 1",
|
244 |
|
# "y_var ~ x + y",
|
245 |
|
# "y_var ~ x + y + elev_s",
|
246 |
|
# "y_var ~ x + y + DISTOC",
|
247 |
|
# "y_var ~ x + y + elev_s + DISTOC",
|
248 |
|
# "y_var ~ x + y + N_w + E_w",
|
249 |
|
# "y_var ~ LST",
|
250 |
|
# "y_var ~ x + y + LST",
|
251 |
|
# "y_var ~ x + y + elev_s + LST")
|
|
233 |
list_models<-c("y_var ~ elev_s",
|
|
234 |
"y_var ~ LST",
|
|
235 |
"y_var ~ elev_s*LST")
|
|
236 |
# "y_var ~ lat + lon + elev_s",
|
|
237 |
# "y_var ~ lat*lon*elev_s",
|
|
238 |
# "y_var ~ lat*lon + elev_s + N_w*E_w + LST",
|
|
239 |
# "y_var ~ lat*lon + elev_s + N_w*E_w + LST + LC2",
|
|
240 |
# "y_var ~ lat*lon + elev_s + N_w*E_w + LST + LC6",
|
|
241 |
# "y_var ~ lat*lon + elev_s + N_w*E_w + LST + DISTOC")
|
|
242 |
|
|
243 |
#list_models<-c("y_var~ lat + lon + elev_",
|
|
244 |
# "y_var~ I(lat*lon) + elev_s",
|
|
245 |
# "y_var~ lat + lon + elev_s + N + E + DISTOC",
|
|
246 |
# "y_var~ I(lat*lon) + elev_s + I(N*E) + DISTOC + LST",
|
|
247 |
# "y_var~ lat + lon + ELEV_SRTM + N_w + E_w + DISTOC + LST",
|
|
248 |
# "y_var~ lat + lon + ELEV_SRTM + N_w + E_w + DISTOC + LST + LC2",
|
|
249 |
# "y_var~ lat + lon + ELEV_SRTM + Northness_w + Eastness_w + DISTOC + LST + LC6",
|
|
250 |
# "y_var~ lat + lon + ELEV_SRTM + Northness_w + Eastness_w + DISTOC + LST + I(LST*LC2)",
|
252 |
251 |
|
253 |
252 |
#Default name of LST avg to be matched
|
254 |
253 |
lst_avg<-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")
|
adding GWR daily method, test in Oregon