Project

General

Profile

« Previous | Next » 

Revision d7f715b5

Added by Benoit Parmentier over 11 years ago

Master function, modification of date passing, run for tmax prediction for 2000 in Venezuela

View differences:

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: 03/12/2013                                                                                 
13
#DATE: 03/14/2013                                                                                 
14 14

  
15 15
#PROJECT: NCEAS INPLANT: Environment and Organisms --TASK#363, TASK$568--   
16 16

  
......
81 81

  
82 82
############# STAGE 3: Data preparation ###############
83 83

  
84
source(file.path(script_path,"Database_stations_covariates_processing_function_03052013.R"))
84
source(file.path(script_path,"Database_stations_covariates_processing_function_03132013.R"))
85 85

  
86 86
#Setting up input argurments for script function...
87 87

  
88 88
db.name <- "ghcn"       # name of the Postgres database
89 89
var <- "TMAX"           # name of the variables to keep: TMIN, TMAX or PRCP
90
range_years<-c("2010","2011") #right bound not included in the range!!
90
range_years<-c("2000","2001") #right bound not included in the range!!
91 91
range_years_clim<-c("2000","2011") #right bound not included in the range!!
92 92
infile1<- "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
93 93
infile2<-"/home/layers/data/climate/ghcn/v2.92-upd-2012052822/ghcnd-stations.txt"                              #This is the textfile of station locations from GHCND
94 94
infile_covariates<-"covariates__venezuela_region__VE_01292013.tif" #this is an output from covariate script and used in stage 3 and stage 4
95 95
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84: same as earlier
96 96
in_path <- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/input_data/"
97
out_prefix<-"_365d_GAM_fus5_all_lstd_03052013"                #User defined output prefix
97
out_prefix<-"_365d_GAM_fus5_all_lstd_03142013"                #User defined output prefix
98 98
#qc_flags<-    flags allowe for the query from the GHCND??
99 99

  
100 100
#The names of covariates can be changed...these names should be output/input from covar script!!!
......
112 112
names(list_param_prep)<-cnames
113 113

  
114 114
##### RUN SCRIPT TO GET STATION DATA WITH COVARIATES #####
115
list_outfiles<-database_covaratiates_preparation(list_param_prep)
115

  
116
list_outfiles<-database_covariates_preparation(list_param_prep)
116 117

  
117 118
############### STAGE 4: RASTER PREDICTION #################
118 119

  
......
125 126
infile_daily<-list_outfiles$daily_covar_ghcn_data  #outfile3 from database_covar script
126 127
infile_locs<- list_outfiles$loc_stations_ghcn #outfile2? from database covar script
127 128

  
128
list_param_data_prep<-list(infile_monthly,infile_daily,infile_locs,infile_covariates,covar_names,var,out_prefix,CRS_locs_WGS84)
129
#names(outfiles_obj)<- c("loc_stations","loc_stations_ghcn","daily_covar_ghcn_data","monthly_covar_ghcn_data")
129 130

  
131
list_param_data_prep<-list(infile_monthly,infile_daily,infile_locs,infile_covariates,covar_names,var,out_prefix,CRS_locs_WGS84)
130 132
names(list_param_data_prep)<-c("infile_monthly","infile_daily","infile_locs","infile_covariates","covar_names","var","out_prefix","CRS_locs_WGS84")
131 133

  
132 134
#Set additional parameters
......
136 138
step<-0         
137 139
constant<-0             #if value 1 then use the same samples as date one for the all set of dates
138 140
prop_minmax<-c(0.3,0.3)  #if prop_min=prop_max and step=0 then predicitons are done for the number of dates...
139
infile_dates<-"list_365_dates_04212012.txt"
141
#dates_selected<-c("20100101","20100102","20100103","20100901") # Note that the dates set must have a specific format: yyymmdd
142
dates_selected<-"" # if empty string then predict for the full year specified earlier
140 143

  
141 144
#Models to run...this can be change for each run
142 145
list_models<-c("y_var ~ s(elev_1)",
......
161 164

  
162 165
#Collect all parameters in a list
163 166
list_param_raster_prediction<-list(list_param_data_prep,
164
                                seed_number,nb_sample,step,constant,prop_minmax,infile_dates,
167
                                seed_number,nb_sample,step,constant,prop_minmax,dates_selected,
165 168
                                list_models,lst_avg,in_path,out_path,script_path,
166 169
                                interpolation_method)
167 170

  
168 171
names(list_param_raster_prediction)<-c("list_param_data_prep",
169
                                "seed_number","nb_sample","step","constant","prop_minmax","infile_dates",
172
                                "seed_number","nb_sample","step","constant","prop_minmax","dates_selected",
170 173
                                "list_models","lst_avg","in_path","out_path","script_path",
171 174
                                "interpolation_method")
172 175

  
173 176
#Source file
174
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_03122013b.R"))
177
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_03132013.R"))
175 178

  
176 179
#Make the function call
177 180
raster_prediction_gam_fus_obj <-raster_prediction_gam_fusion(list_param_raster_prediction)

Also available in: Unified diff