Project

General

Profile

« Previous | Next » 

Revision 41bab185

Added by Benoit Parmentier almost 9 years ago

part2 assessment figure production, for testing on bridge

View differences:

climate/research/oregon/interpolation/global_run_scalingup_assessment_part2.R
850 850

  
851 851
#CALLED FROM MASTER SCRIPT:
852 852

  
853
# script_path <- "/nobackupp8/bparmen1/env_layers_scripts" #path to script
854
# function_assessment_part1_functions <- "global_run_scalingup_assessment_part1_functions_02112015.R" #PARAM12
855
# function_assessment_part1a <-"global_run_scalingup_assessment_part1a_01042016.R"
856
# function_assessment_part2 <- "global_run_scalingup_assessment_part2_01062016.R"
857
# function_assessment_part2_functions <- "global_run_scalingup_assessment_part2_functions_01032016.R"
858
# source(file.path(script_path,function_assessment_part1_functions)) #source all functions used in this script 
859
# source(file.path(script_path,function_assessment_part1a)) #source all functions used in this script 
860
# source(file.path(script_path,function_assessment_part2)) #source all functions used in this script 
861
# source(file.path(script_path,function_assessment_part2_functions)) #source all functions used in this script 
862
# 
863
# ### Parameters and arguments ###
864
#   
865
# var<-"TMAX" # variable being interpolated
866
# if (var == "TMAX") {
867
#   y_var_name <- "dailyTmax"
868
#   y_var_month <- "TMax"
869
# }
870
# if (var == "TMIN") {
871
#   y_var_name <- "dailyTmin"
872
#   y_var_month <- "TMin"
873
# }
874
# 
875
# #interpolation_method<-c("gam_fusion") #other otpions to be added later
876
# interpolation_method<-c("gam_CAI")
877
# CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs";
878
# #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";
879
# CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
880
# 
881
# out_region_name<-""
882
# list_models<-c("y_var ~ s(lat,lon,k=5) + s(elev_s,k=3) + s(LST,k=3)")
883
# 
884
# #reg1 (North Am), reg2(Europe),reg3(Asia), reg4 (South Am), reg5 (Africa), reg6 (Australia-Asia)
885
# #master directory containing the definition of tile size and tiles predicted
886
# in_dir1 <- "/nobackupp6/aguzman4/climateLayers/out/"
887
# #/nobackupp6/aguzman4/climateLayers/out_15x45/1982
888
# 
889
# #region_names <- c("reg23","reg4") #selected region names, #PARAM2
890
# region_name <- c("reg4") #run assessment by region, this is a unique region only
891
# #region_names <- c("reg1","reg2","reg3","reg4","reg5","reg6") #selected region names, #PARAM2
892
# interpolation_method <- c("gam_CAI") #PARAM4
893
# out_prefix <- "run_global_analyses_pred_12282015" #PARAM5
894
# #out_dir <- "/nobackupp8/bparmen1/" #PARAM6
895
# out_dir <- "/nobackupp8/bparmen1/output_run_global_analyses_pred_12282015"
896
# #out_dir <-paste(out_dir,"_",out_prefix,sep="")
897
# create_out_dir_param <- FALSE #PARAM7
898
# 
899
# #CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs";
900
# #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";
901
# CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
902
# 
903
# #list_year_predicted <- 1984:2004
904
# list_year_predicted <- c("2014")
905
# #year_predicted <- list_year_predicted[1]
906
# 
907
# file_format <- ".tif" #format for mosaiced files #PARAM10
908
# NA_flag_val <- -9999  #No data value, #PARAM11
909
# num_cores <- 6 #number of cores used #PARAM13
910
# plotting_figures <- TRUE #running part2 of assessment to generate figures...
911
#   
912
# ##Additional parameters used in part 2, some these may be removed as code is simplified
913
# mosaic_plot <- FALSE #PARAM14
914
# day_to_mosaic <- c("19920102","19920103","19920103") #PARAM15
915
# multiple_region <- TRUE #PARAM16
916
# countries_shp <- "/nobackupp8/bparmen1/NEX_data/countries.shp" #PARAM17
917
# #countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #Atlas
918
# plot_region <- TRUE  #PARAM18
919
# threshold_missing_day <- c(367,365,300,200)#PARAM19
920
# 
921
# year_predicted <- list_year_predicted[1]
922
# in_dir <- out_dir #PARAM 0
923
# #y_var_name <- "dailyTmax" #PARAM1 , already set
924
# #interpolation_method <- c("gam_CAI") #PARAM2, already set
925
# out_suffix <- out_prefix #PARAM3
926
# #out_dir <-  #PARAM4, already set
927
# create_out_dir_param <- FALSE #PARAM 5, already created and set
928
# #mosaic_plot <- FALSE #PARAM6
929
# #if daily mosaics NULL then mosaicas all days of the year
930
# #day_to_mosaic <- c("19920101","19920102","19920103") #PARAM7
931
# #CRS_locs_WGS84 already set
932
# proj_str <- CRS_locs_WGS84 #PARAM 8 #check this parameter
933
# #file_format <- ".rst" #PARAM 9, already set
934
# #NA_flag_val <- -9999 #PARAM 11, already set
935
# #multiple_region <- TRUE #PARAM 12
936
# #countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #PARAM 13, copy this on NEX too
937
# #plot_region <- TRUE
938
# #num_cores <- 6 #PARAM 14, already set
939
# #region_name <- c("reg4") #reference region to merge if necessary, if world all the regions are together #PARAM 16
940
# #use previous files produced in step 1a and stored in a data.frame
941
# df_assessment_files_name <- "df_assessment_files_reg4_2014_run_global_analyses_pred_12282015.txt"# #PARAM 17, set in the script
942
# df_assessment_files <- read.table(df_assessment_files_name,stringsAsFactors=F,sep=",")
943
# #threshold_missing_day <- c(367,365,300,200) #PARM18
944
# 
945
# list_param_run_assessment_plotting <-list(
946
#     in_dir,y_var_name, interpolation_method, out_suffix,
947
#     out_dir, create_out_dir_param, mosaic_plot, proj_str, file_format, NA_flag_val,
948
#     multiple_region, countries_shp, plot_region, num_cores,
949
#     region_name, df_assessment_files_name, threshold_missing_day,year_predicted
950
#   )
951
# 
952
# names(list_param_run_assessment_plotting) <- c(
953
#     "in_dir","y_var_name","interpolation_method","out_suffix",
954
#     "out_dir","create_out_dir_param","mosaic_plot","proj_str","file_format","NA_flag_val",
955
#     "multiple_region","countries_shp","plot_region","num_cores",
956
#     "region_name","df_assessment_files_name","threshold_missing_day","year_predicted"
957
#   )
958
# 
959
# #function_assessment_part2 <- "global_run_scalingup_assessment_part2_01032016.R"
960
# #source(file.path(script_path,function_assessment_part2)) #source all functions used in this script
961
# 
962
# debug(run_assessment_plotting_prediction_fun)
963
# df_assessment_figures_files <-
964
#   run_assessment_plotting_prediction_fun(list_param_run_assessment_plotting)
853
script_path <- "/nobackupp8/bparmen1/env_layers_scripts" #path to script
854
function_assessment_part1_functions <- "global_run_scalingup_assessment_part1_functions_02112015.R" #PARAM12
855
function_assessment_part1a <-"global_run_scalingup_assessment_part1a_01042016.R"
856
function_assessment_part2 <- "global_run_scalingup_assessment_part2_01062016.R"
857
function_assessment_part2_functions <- "global_run_scalingup_assessment_part2_functions_01032016.R"
858
source(file.path(script_path,function_assessment_part1_functions)) #source all functions used in this script 
859
source(file.path(script_path,function_assessment_part1a)) #source all functions used in this script 
860
source(file.path(script_path,function_assessment_part2)) #source all functions used in this script 
861
source(file.path(script_path,function_assessment_part2_functions)) #source all functions used in this script 
862

  
863
### Parameters and arguments ###
864
  
865
var<-"TMAX" # variable being interpolated
866
if (var == "TMAX") {
867
  y_var_name <- "dailyTmax"
868
  y_var_month <- "TMax"
869
}
870
if (var == "TMIN") {
871
  y_var_name <- "dailyTmin"
872
  y_var_month <- "TMin"
873
}
874

  
875
#interpolation_method<-c("gam_fusion") #other otpions to be added later
876
interpolation_method<-c("gam_CAI")
877
CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs";
878
#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";
879
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
880

  
881
out_region_name<-""
882
list_models<-c("y_var ~ s(lat,lon,k=5) + s(elev_s,k=3) + s(LST,k=3)")
883

  
884
#reg1 (North Am), reg2(Europe),reg3(Asia), reg4 (South Am), reg5 (Africa), reg6 (Australia-Asia)
885
#master directory containing the definition of tile size and tiles predicted
886
in_dir1 <- "/nobackupp6/aguzman4/climateLayers/out/"
887
#/nobackupp6/aguzman4/climateLayers/out_15x45/1982
888

  
889
#region_names <- c("reg23","reg4") #selected region names, #PARAM2
890
region_name <- c("reg4") #run assessment by region, this is a unique region only
891
#region_names <- c("reg1","reg2","reg3","reg4","reg5","reg6") #selected region names, #PARAM2
892
interpolation_method <- c("gam_CAI") #PARAM4
893
out_prefix <- "run_global_analyses_pred_12282015" #PARAM5
894
#out_dir <- "/nobackupp8/bparmen1/" #PARAM6
895
out_dir <- "/nobackupp8/bparmen1/output_run_global_analyses_pred_12282015"
896
#out_dir <-paste(out_dir,"_",out_prefix,sep="")
897
create_out_dir_param <- FALSE #PARAM7
898

  
899
#CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs";
900
#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";
901
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
902

  
903
#list_year_predicted <- 1984:2004
904
list_year_predicted <- c("2014")
905
#year_predicted <- list_year_predicted[1]
906

  
907
file_format <- ".tif" #format for mosaiced files #PARAM10
908
NA_flag_val <- -9999  #No data value, #PARAM11
909
num_cores <- 6 #number of cores used #PARAM13
910
plotting_figures <- TRUE #running part2 of assessment to generate figures...
911
  
912
##Additional parameters used in part 2, some these may be removed as code is simplified
913
mosaic_plot <- FALSE #PARAM14
914
day_to_mosaic <- c("19920102","19920103","19920103") #PARAM15
915
multiple_region <- TRUE #PARAM16
916
countries_shp <- "/nobackupp8/bparmen1/NEX_data/countries.shp" #PARAM17
917
#countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #Atlas
918
plot_region <- TRUE  #PARAM18
919
threshold_missing_day <- c(367,365,300,200)#PARAM19
920

  
921
year_predicted <- list_year_predicted[1]
922
in_dir <- out_dir #PARAM 0
923
#y_var_name <- "dailyTmax" #PARAM1 , already set
924
#interpolation_method <- c("gam_CAI") #PARAM2, already set
925
out_suffix <- out_prefix #PARAM3
926
#out_dir <-  #PARAM4, already set
927
create_out_dir_param <- FALSE #PARAM 5, already created and set
928
#mosaic_plot <- FALSE #PARAM6
929
#if daily mosaics NULL then mosaicas all days of the year
930
#day_to_mosaic <- c("19920101","19920102","19920103") #PARAM7
931
#CRS_locs_WGS84 already set
932
proj_str <- CRS_locs_WGS84 #PARAM 8 #check this parameter
933
#file_format <- ".rst" #PARAM 9, already set
934
#NA_flag_val <- -9999 #PARAM 11, already set
935
#multiple_region <- TRUE #PARAM 12
936
#countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #PARAM 13, copy this on NEX too
937
#plot_region <- TRUE
938
#num_cores <- 6 #PARAM 14, already set
939
#region_name <- c("reg4") #reference region to merge if necessary, if world all the regions are together #PARAM 16
940
#use previous files produced in step 1a and stored in a data.frame
941
df_assessment_files_name <- "df_assessment_files_reg4_2014_run_global_analyses_pred_12282015.txt"# #PARAM 17, set in the script
942
df_assessment_files <- read.table(df_assessment_files_name,stringsAsFactors=F,sep=",")
943
#threshold_missing_day <- c(367,365,300,200) #PARM18
944

  
945
list_param_run_assessment_plotting <-list(
946
    in_dir,y_var_name, interpolation_method, out_suffix,
947
    out_dir, create_out_dir_param, mosaic_plot, proj_str, file_format, NA_flag_val,
948
    multiple_region, countries_shp, plot_region, num_cores,
949
    region_name, df_assessment_files_name, threshold_missing_day,year_predicted
950
  )
951

  
952
names(list_param_run_assessment_plotting) <- c(
953
    "in_dir","y_var_name","interpolation_method","out_suffix",
954
    "out_dir","create_out_dir_param","mosaic_plot","proj_str","file_format","NA_flag_val",
955
    "multiple_region","countries_shp","plot_region","num_cores",
956
    "region_name","df_assessment_files_name","threshold_missing_day","year_predicted"
957
  )
958

  
959
#function_assessment_part2 <- "global_run_scalingup_assessment_part2_01032016.R"
960
#source(file.path(script_path,function_assessment_part2)) #source all functions used in this script
961

  
962
debug(run_assessment_plotting_prediction_fun)
963
df_assessment_figures_files <-
964
  run_assessment_plotting_prediction_fun(list_param_run_assessment_plotting)
965 965

  
966 966

  
967 967

  

Also available in: Unified diff