Revision a14b03e1
Added by Benoit Parmentier over 11 years ago
climate/research/oregon/interpolation/master_script_temp.R | ||
---|---|---|
10 | 10 |
#STAGE 5: Output analyses-visualization of results for specific dates... |
11 | 11 |
# |
12 | 12 |
#AUTHOR: Benoit Parmentier |
13 |
#DATE: 05/17/2013
|
|
13 |
#DATE: 05/23/2013
|
|
14 | 14 |
|
15 | 15 |
#PROJECT: NCEAS INPLANT: Environment and Organisms --TASK#363, TASK$568-- |
16 | 16 |
|
... | ... | |
47 | 47 |
|
48 | 48 |
##SCRIPT USED FOR THE PREDICTIONS: Source or list all scripts here to avoid confusion on versions being run!!!! |
49 | 49 |
|
50 |
#source(file.path(script_path,"master_script_temp_05162013.R")) #Master script can be run directly...
|
|
50 |
#source(file.path(script_path,"master_script_temp_05212013.R")) #Master script can be run directly...
|
|
51 | 51 |
|
52 | 52 |
#CALLED FROM MASTER SCRIPT: |
53 | 53 |
|
54 | 54 |
modis_download_script <- file.path(script_path,"modis_download_05142013.py") # LST modis download python script |
55 | 55 |
clim_script <- file.path(script_path,"climatology_05142013.py") # LST climatology python script |
56 | 56 |
grass_setting_script <- file.path(script_path,"grass-setup.R") #Set up system shell environment for python+GRASS |
57 |
source(file.path(script_path,"download_and_produce_MODIS_LST_climatology_05162013.R")) |
|
57 |
#source(file.path(script_path,"download_and_produce_MODIS_LST_climatology_05162013.R"))
|
|
58 | 58 |
source(file.path(script_path,"covariates_production_temperatures_05132013.R")) |
59 |
source(file.path(script_path,"Database_stations_covariates_processing_function_05062013.R"))
|
|
60 |
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_05062013.R"))
|
|
59 |
source(file.path(script_path,"Database_stations_covariates_processing_function_05212013.R"))
|
|
60 |
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_05212013.R"))
|
|
61 | 61 |
source(file.path(script_path,"results_interpolation_date_output_analyses_05062013.R")) |
62 | 62 |
#source(file.path(script_path,"results_covariates_database_stations_output_analyses_04012013.R")) |
63 | 63 |
|
... | ... | |
71 | 71 |
stages_to_run<-c(0,0,3,4,5) #May decide on antoher strategy later on... |
72 | 72 |
|
73 | 73 |
var<-"TMAX" # variable being interpolated |
74 |
out_prefix<-"_365d_GAM_CAI_all_lst_05172013" #User defined output prefix
|
|
74 |
out_prefix<-"_365d_GAM_fus_all_lst_05212013" #User defined output prefix
|
|
75 | 75 |
#interpolation_method<-c("gam_fusion","gam_CAI") #other otpions to be added later |
76 |
interpolation_method<-c("gam_CAI") #other otpions to be added later |
|
77 |
#interpolation_method<-c("gam_fusion") #other otpions to be added later
|
|
76 |
#interpolation_method<-c("gam_CAI") #other otpions to be added later
|
|
77 |
interpolation_method<-c("gam_fusion") #other otpions to be added later |
|
78 | 78 |
|
79 | 79 |
#Change input path?? for LST stage ?? |
80 | 80 |
in_path <- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/input_data/" |
... | ... | |
94 | 94 |
list_tiles_modis <- c("h11v08,h11v07,h12v07,h12v08,h10v07,h10v08") #tile for Venezuela and surrounding area |
95 | 95 |
#list_tiles_modis <- c("h08v04","h09v04") #tiles for Oregon |
96 | 96 |
|
97 |
infile_reg_outline="" #input region outline defined by polygon: none for Venezuel |
|
97 |
infile_reg_outline="" #input region outline defined by polygon: none for Venezuela
|
|
98 | 98 |
#infile_reg_outline <- "OR83M_state_outline.shp" #input region outline defined by polygon: Oregon |
99 | 99 |
|
100 | 100 |
CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"; |
101 | 101 |
#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"; |
102 | 102 |
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 |
103 | 103 |
out_region_name<-"_venezuela_region" #generated on the fly |
104 |
out_suffix<-"_VE_05172013"
|
|
104 |
out_suffix<-"_VE_05232013"
|
|
105 | 105 |
ref_rast_name<-"" #local raster name defining resolution, exent, local projection--. set on the fly?? |
106 | 106 |
#ref_rast_name<-"mean_day244_rescaled.rst" #local raster name defining resolution, exent: oregon |
107 | 107 |
|
... | ... | |
125 | 125 |
hdfdir = '/home/parmentier/Data/IPLANT_project/MOD11A1_tiles' |
126 | 126 |
download=1 |
127 | 127 |
clim_calc=0 |
128 |
out_suffix_modis="_05132013"
|
|
128 |
out_suffix_modis="_0522013"
|
|
129 | 129 |
#end_month= "12" |
130 | 130 |
#start_month= "1" |
131 | 131 |
|
... | ... | |
161 | 161 |
}else{ |
162 | 162 |
#Provide brick of covariates if stage 2 is not run |
163 | 163 |
infile_covariates<-"/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/covariates__venezuela_region__VE_01292013.tif" #this is an output from covariate script and used in stage 3 and stage 4 |
164 |
infile_reg_outline<- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/outline_venezuela_region__VE_01292013.shp" |
|
164 | 165 |
#infile_covariates<-"/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/covariates__venezuela_region_TMIN__VE_03192013.tif" #covariates stack for TMIN |
165 | 166 |
#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 |
166 | 167 |
} |
167 | 168 |
|
168 | 169 |
############# STAGE 3: Data preparation ############### |
169 | 170 |
|
170 |
infile1<- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/outline_venezuela_region__VE_01292013.shp" #This is the shape file of outline of the study area #It is an input/output of the covariate script |
|
171 |
#infile_reg_outline="" #input region outline defined by polygon: none for Venezuela |
|
172 |
#This is the shape file of outline of the study area #It is an input/output of the covariate script |
|
171 | 173 |
#infile_reg_outline <- "OR83M_state_outline.shp" #input region outline defined by polygon: Oregon |
172 |
#infile1 <-"OR83M_state_outline.shp" #remove this parameter!!!
|
|
174 |
#infile_reg_outline <-"OR83M_state_outline.shp" #remove this parameter!!!
|
|
173 | 175 |
#covar_names see stage 2 |
174 | 176 |
|
175 | 177 |
#specific to this stage |
176 | 178 |
db.name <- "ghcn" # name of the Postgres database |
177 | 179 |
range_years<-c("2010","2011") #right bound not included in the range!! |
178 | 180 |
range_years_clim<-c("2000","2011") #right bound not included in the range!! |
179 |
infile2<-"/home/layers/data/climate/ghcn/v2.92-upd-2012052822/ghcnd-stations.txt" #This is the textfile of station locations from GHCND
|
|
181 |
infile_ghncd_data <-"/home/layers/data/climate/ghcn/v2.92-upd-2012052822/ghcnd-stations.txt" #This is the textfile of station locations from GHCND
|
|
180 | 182 |
qc_flags_stations<-c("0","S") #flags allowed for screening after the query from the GHCND?? |
181 | 183 |
|
182 | 184 |
#list of 12 parameters for input in the function... |
183 | 185 |
|
184 |
list_param_prep<-list(db.name,var,range_years,range_years_clim,infile1,infile2,infile_covariates,CRS_locs_WGS84,in_path,out_path,covar_names,qc_flags_stations,out_prefix)
|
|
185 |
cnames<-c("db.name","var","range_years","range_years_clim","infile1","infile2","infile_covariates","CRS_locs_WGS84","in_path","out_path","covar_names","qc_flags_stations","out_prefix")
|
|
186 |
list_param_prep<-list(db.name,var,range_years,range_years_clim,infile_reg_outline,infile_ghncd_data,infile_covariates,CRS_locs_WGS84,in_path,out_path,covar_names,qc_flags_stations,out_prefix)
|
|
187 |
cnames<-c("db.name","var","range_years","range_years_clim","infile_reg_outline","infile_ghncd_data","infile_covariates","CRS_locs_WGS84","in_path","out_path","covar_names","qc_flags_stations","out_prefix")
|
|
186 | 188 |
names(list_param_prep)<-cnames |
187 | 189 |
|
188 | 190 |
##### RUN SCRIPT TO GET STATION DATA WITH COVARIATES ##### |
... | ... | |
216 | 218 |
dates_selected<-"" # if empty string then predict for the full year specified earlier |
217 | 219 |
|
218 | 220 |
#Models to run...this can be change for each run |
219 |
list_models<-c("y_var ~ s(elev_s)",
|
|
221 |
list_models<-c("y_var ~ s(x,y)",
|
|
220 | 222 |
"y_var ~ s(LST)", |
221 |
"y_var ~ s(elev_s,LST)", |
|
222 |
"y_var ~ s(lat) + s(lon)+ s(elev_s)", |
|
223 |
"y_var ~ s(lat,lon,elev_s)", |
|
223 |
"y_var ~ s(x,y,LST)", |
|
224 |
"y_var ~ s(LST,elev_s)", |
|
224 | 225 |
"y_var ~ s(lat,lon) + s(elev_s) + s(N_w,E_w) + s(LST)", |
225 | 226 |
"y_var ~ s(lat,lon) + s(elev_s) + s(N_w,E_w) + s(LST) + s(LC2)", |
226 | 227 |
"y_var ~ s(lat,lon) + s(elev_s) + s(N_w,E_w) + s(LST) + s(LC6)") |
Also available in: Unified diff
master script, gam fusion additional models using s(x,y), s(x,y,LST)