Project

General

Profile

« Previous | Next » 

Revision 3fd24f79

Added by Benoit Parmentier over 11 years ago

master script set up call to covariate production function

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/18/2013                                                                                 
13
#DATE: 03/21/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
49 49

  
50
#master_script_temp_03052013.R
50
#master_script_temp_03192013.R
51 51

  
52
#IN MASTER SCRIPT:
52
#CALLED FROM MASTER SCRIPT:
53 53

  
54
#/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/climatology_01252013b.py
55
#/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/covariates_production_temperatures_02062013.R
56

  
57
#source(file.path(script_path,"Database_stations_covariates_processing_function_03052013.R"))
58
#source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_03052013.R"))
59
#source(file.path(script_path,"results_interpolation_date_output_analyses_03052013.R"))
54
#/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/climatology_03192013.py
55
source(file.path(script_path,"covariates_production_temperatures_03212013.R"))
56
source(file.path(script_path,"Database_stations_covariates_processing_function_03132013.R"))
57
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_03182013.R"))
58
source(file.path(script_path,"results_interpolation_date_output_analyses_03182013.R"))
60 59

  
61 60
#CALLED FROM GAM FUSION ANALYSIS RASTER PREDICTION
62 61

  
63
#source(file.path(script_path,"sampling_script_functions_03052013.R"))
64
#source(file.path(script_path,"GAM_fusion_function_multisampling_03052013.R")) #Include GAM_CAI
65
#source(file.path(script_path,"GAM_fusion_function_multisampling_validation_metrics_02262013.R"))
62
source(file.path(script_path,"sampling_script_functions_03122013.R"))
63
source(file.path(script_path,"GAM_fusion_function_multisampling_03142013.R")) #Include GAM_CAI
64
source(file.path(script_path,"GAM_fusion_function_multisampling_validation_metrics_03182013.R"))
66 65

  
67 66

  
68 67
############ STAGE 1: LST Climatology ###############
69 68

  
70 69
if (stages_to_run[1]==1){
71 70
  #Call run through python
72
  #/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/climatology_01252013b.py
71
  #/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/climatology_03182013.py
73 72
}
74 73

  
75 74
############ STAGE 2: Covariate production ################
76 75

  
76
##Paths to inputs and output
77
var<-"TMIN"
78
in_path <- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/input_data/"
79
out_path<- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/output_data/"
80

  
81
lc_path<-"/home/layers/data/land-cover/lc-consensus-global"
82
infile_modis_grid<-"modis_sinusoidal_grid_world.shp"
83
infile_elev<-"/home/layers/data/terrain/dem-cgiar-srtm-1km-tif/srtm_1km.tif"  #this is the global file: replace later with the input produced by the DEM team
84
infile_canheight<-"Simard_Pinto_3DGlobalVeg_JGR.tif"              #Canopy height
85
list_tiles_modis = c('h11v08','h11v07','h12v07','h12v08','h10v07','h10v08') #tile for Venezuel and surrounding area
86
infile_reg_outline=""  #input region outline defined by polygon
87
CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs";
88
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
89
out_region_name<-"_venezuela_region" #generated on the fly
90
out_suffix<-"_VE_03192013"
91
ref_rast_name<-""  #local raster name defining resolution, exent, local projection--. set on the fly??
92
#The names of covariates can be changed...these names should be output/input from covar script!!!
93
rnames<-c("x","y","lon","lat","N","E","N_w","E_w","elev","slope","aspect","CANHEIGHT","DISTOC")
94
lc_names<-c("LC1","LC2","LC3","LC4","LC5","LC6","LC7","LC8","LC9","LC10","LC11","LC12")
95
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",
96
             "nobs_01","nobs_02","nobs_03","nobs_04","nobs_05","nobs_06","nobs_07","nobs_08",
97
             "nobs_09","nobs_10","nobs_11","nobs_12")
98
covar_names<-c(rnames,lc_names,lst_names)
99

  
100
list_param_covar_production<-list(var,in_path,out_path,lc_path,infile_modis_grid,infile_elev,infile_canheight,
101
                                  list_tiles_modis,infile_reg_outline,CRS_interp,CRS_locs_WGS84,out_region_name,
102
                                  out_suffix,ref_rast_name,covar_names) 
103

  
104
names(list_param_covar_production)<-c("var","in_path","out_path","lc_path","infile_modis_grid","infile_elev","infile_canheight",
105
                                      "list_tiles_modis","infile_reg_outline","CRS_interp","CRS_locs_WGS84","out_region_name",
106
                                      "out_suffix","ref_rast_name","covar_names") 
107

  
77 108
if (stages_to_run[2]==2){
78 109
  #Transform into function...
79
  #/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/covariates_production_temperatures_02062013.R
110
  #/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/covariates_production_temperatures_03212013.R
111
  infile_covar_brick<-covariates_production_temperature(list_param_covar_production)
80 112
}
81 113

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

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

  
86 117
#Setting up input argurments for script function...
118
#set up earlier
119
infile_covariates<-"covariates__venezuela_region__VE_01292013.tif" #this is an output from covariate script and used in stage 3 and stage 4
120
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84: same as earlier
121
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
122
#covar_names see stage 2
123
var <- "TMAX"           # name of the variables to keep: TMIN, TMAX or PRCP
87 124

  
125
#specific to this stage
88 126
db.name <- "ghcn"       # name of the Postgres database
89
var <- "TMAX"           # name of the variables to keep: TMIN, TMAX or PRCP
90 127
range_years<-c("2000","2001") #right bound not included in the range!!
91 128
range_years_clim<-c("1980","2011") #right bound not included in the range!!
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 129
infile2<-"/home/layers/data/climate/ghcn/v2.92-upd-2012052822/ghcnd-stations.txt"                              #This is the textfile of station locations from GHCND
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
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84: same as earlier
96 130
in_path <- "/home/parmentier/Data/IPLANT_project/Venezuela_interpolation/Venezuela_01142013/input_data/"
97 131
out_prefix<-"_365d_GAM_fus5_all_lstd_03182013"                #User defined output prefix
98 132
#qc_flags<-    flags allowe for the query from the GHCND??
99 133

  
100
#The names of covariates can be changed...these names should be output/input from covar script!!!
101
rnames<-c("x","y","lon","lat","N","E","N_w","E_w","elev","slope","aspect","CANHEIGHT","DISTOC")
102
lc_names<-c("LC1","LC2","LC3","LC4","LC5","LC6","LC7","LC8","LC9","LC10","LC11","LC12")
103
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",
104
             "nobs_01","nobs_02","nobs_03","nobs_04","nobs_05","nobs_06","nobs_07","nobs_08",
105
             "nobs_09","nobs_10","nobs_11","nobs_12")
106
covar_names<-c(rnames,lc_names,lst_names)
107 134

  
108 135
#list of 11 parameters for input in the function...
109 136

  
......
174 201
                                "interpolation_method")
175 202

  
176 203
#Source file
177
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_03182013.R"))
178 204

  
179 205
#Make the function call
180 206
raster_prediction_gam_fus_obj <-raster_prediction_gam_fusion(list_param_raster_prediction)
......
182 208

  
183 209
############## STAGE 5: OUTPUT ANALYSES ##################
184 210

  
185
source(file.path(script_path,"results_interpolation_date_output_analyses_03052013.R"))
186

  
211
#source(file.path(script_path,"results_interpolation_date_output_analyses_03052013.R"))
212
#Call as function...
187 213

  
188 214
###############   END OF SCRIPT   ###################
189 215
#####################################################

Also available in: Unified diff