Revision d95d4617
Added by Benoit Parmentier over 11 years ago
climate/research/oregon/interpolation/covariates_production_temperatures.R | ||
---|---|---|
180 | 180 |
tab_range <- strsplit(tab_range_list,",") |
181 | 181 |
tab_range <-as.data.frame(do.call(rbind, tab_range)) |
182 | 182 |
names(tab_range)<-c("varname","vmin","vmax") |
183 |
tab_range$vmin <- as.numeric(tab_range$vmin) |
|
184 |
tab_range$vmax <- as.numeric(tab_range$vmax) |
|
183 |
tab_range$vmin <- as.numeric(as.character(tab_range$vmin)) #transform to character first to avoid values being considered as factor |
|
184 |
tab_range$vmax <- as.numeric(as.character(tab_range$vmax)) |
|
185 |
tab_range$varname <- as.character(tab_range$varname) |
|
185 | 186 |
val_rst<-vector("list",nrow(tab_range)) #list of one row data.frame |
186 | 187 |
|
187 | 188 |
for (k in 1:nrow(tab_range)){ |
... | ... | |
196 | 197 |
} |
197 | 198 |
#could be taken out of function for parallelization |
198 | 199 |
s_rst_m<-stack(val_rst) #This a raster stack with valid range of values |
199 |
retained_names<-setdiff(names(r_stack),as.character(tab_range$varname))
|
|
200 |
retained_names<-setdiff(names(r_stack),tab_range$varname)
|
|
200 | 201 |
r_stack <- dropLayer(r_stack,match(tab_range$varname,names(r_stack))) |
201 | 202 |
names(r_stack) <-retained_names |
202 | 203 |
r_stack <- addLayer(r_stack,s_rst_m) #add back layers that were screened out |
... | ... | |
539 | 540 |
#covar_names<-c(rnames,lc_names,lst_names) |
540 | 541 |
names(s_raster)<-covar_names |
541 | 542 |
|
542 |
##Write function to screen data values... |
|
543 |
#add screening here... |
|
544 |
#browser() |
|
545 |
#test <-screening_val_r_stack_fun(list_val_range,s_raster) |
|
543 |
#Screen values given valid value ranges for specified variables |
|
546 | 544 |
s_raster<-screening_val_r_stack_fun(list_val_range,s_raster) |
547 | 545 |
|
548 | 546 |
#Write out stack of number of change |
climate/research/oregon/interpolation/master_script_temp.R | ||
---|---|---|
45 | 45 |
|
46 | 46 |
##SCRIPT USED FOR THE PREDICTIONS: Source or list all scripts here to avoid confusion on versions being run!!!! |
47 | 47 |
|
48 |
#source(file.path(script_path,"master_script_temp_06082013.R")) #Master script can be run directly...
|
|
48 |
#source(file.path(script_path,"master_script_temp_06272013.R")) #Master script can be run directly...
|
|
49 | 49 |
|
50 | 50 |
#CALLED FROM MASTER SCRIPT: |
51 | 51 |
|
... | ... | |
53 | 53 |
clim_script <- file.path(script_path,"climatology_05312013.py") # LST climatology python script |
54 | 54 |
grass_setting_script <- file.path(script_path,"grass-setup.R") #Set up system shell environment for python+GRASS |
55 | 55 |
source(file.path(script_path,"download_and_produce_MODIS_LST_climatology_05302013.R")) |
56 |
source(file.path(script_path,"covariates_production_temperatures_06202013.R"))
|
|
56 |
source(file.path(script_path,"covariates_production_temperatures_06272013.R"))
|
|
57 | 57 |
source(file.path(script_path,"Database_stations_covariates_processing_function_05212013.R")) |
58 | 58 |
source(file.path(script_path,"GAM_fusion_analysis_raster_prediction_multisampling_06082013.R")) |
59 | 59 |
source(file.path(script_path,"results_interpolation_date_output_analyses_06102013.R")) |
60 |
#source(file.path(script_path,"results_covariates_database_stations_output_analyses_04012013.R")) |
|
60 |
#source(file.path(script_path,"results_covariates_database_stations_output_analyses_04012013.R")) #to be completed
|
|
61 | 61 |
|
62 | 62 |
#FUNCTIONS CALLED FROM GAM ANALYSIS RASTER PREDICTION ARE FOUND IN... |
63 | 63 |
|
... | ... | |
134 | 134 |
"nobs_09","nobs_10","nobs_11","nobs_12") |
135 | 135 |
covar_names<-c(rnames,lc_names,lst_names) |
136 | 136 |
|
137 |
list_val_range <-c("lon,180,180","lat,-90,90","N,-1,1","E,-1,1","N_w,-1,1","E_w,-1,1","elev_s,0,6000","slope,0,90", |
|
137 |
list_val_range <-c("lon,-180,180","lat,-90,90","N,-1,1","E,-1,1","N_w,-1,1","E_w,-1,1","elev_s,0,6000","slope,0,90",
|
|
138 | 138 |
"aspect,0,360","DISTOC,-0,10000000","CANHEIGHT,0,255","LC1,0,100","LC3,0,100","mm_01,-15,50", |
139 | 139 |
"mm_02,-15,50","mm_03,-15,50","mm_04,-15,50","mm_05,-15,50","mm_06,-15,50","mm_07,-15,50", |
140 | 140 |
"mm_08,-15,50","mm_09,-15,50","mm_10,-15,50","mm_11,-15,50","mm_12,-15,50") |
Also available in: Unified diff
covariates, fixing screening function to remove extreme values