Revision 58b48212
Added by Benoit Parmentier almost 9 years ago
climate/research/oregon/interpolation/global_run_scalingup_assessment_part3.R | ||
---|---|---|
1 | 1 |
############################## INTERPOLATION OF TEMPERATURES ####################################### |
2 | 2 |
####################### Script for assessment of scaling up on NEX : part3 ############################## |
3 | 3 |
#This script uses the worklfow code applied to the globe. Results currently reside on NEX/PLEIADES NASA. |
4 |
#This script complement part1 and part2 of the accuracy assessment and group tables and outputs |
|
4 |
#Combining tables and figures for individual runs for years and tiles. |
|
5 |
#This script complements part1 and part2 of the accuracy assessment and group tables and outputs |
|
5 | 6 |
#from run of accuracy assessement generated earlier. |
6 | 7 |
#Analyses, figures, tables and data are also produced in the script. |
7 | 8 |
#AUTHOR: Benoit Parmentier |
8 | 9 |
#CREATED ON: 03/23/2014 |
9 |
#MODIFIED ON: 02/05/2016
|
|
10 |
#MODIFIED ON: 02/07/2016
|
|
10 | 11 |
#Version: 5 |
11 | 12 |
#PROJECT: Environmental Layers project |
12 | 13 |
#COMMENTS: Initial commit, script based on part 2 of assessment, will be modified further for overall assessment |
... | ... | |
48 | 49 |
#out_dir <- "/nobackup/bparmen1/" #on NEX |
49 | 50 |
#in_dir_shp <- "/nobackupp4/aguzman4/climateLayers/output4/subset/shapefiles/" |
50 | 51 |
|
51 |
in_dir <- "/data/project/layers/commons/NEX_data"
|
|
52 |
#in_dir <- "/data/project/layers/commons/NEX_data/reg4_assessment"
|
|
52 | 53 |
#list_in_dir_run <- |
53 | 54 |
#in_dir_list <- c("output_run_global_analyses_pred_2009_reg4","output_run_global_analyses_pred_2010_reg4", |
54 | 55 |
# "output_run_global_analyses_pred_2011_reg4","output_run_global_analyses_pred_2012_reg4", |
55 | 56 |
# "output_run_global_analyses_pred_2013_reg4","output_run_global_analyses_pred_2014_reg4") |
56 |
in_dir_list_filename <- "/data/project/layers/commons/NEX_data/regions_input_files/stage6_in_dir_list_02052016.txt"
|
|
57 |
#in_dir_list_filename <- "/data/project/layers/commons/NEX_data/reg4_assessment/stage6_reg4_in_dir_list_02072016.txt"
|
|
57 | 58 |
#in_dir <- "" #PARAM 0 |
58 | 59 |
#y_var_name <- "dailyTmax" #PARAM1 |
59 | 60 |
#interpolation_method <- c("gam_CAI") #PARAM2 |
60 |
out_suffix <- "global_analyses_overall_assessment_reg4_01272016"
|
|
61 |
#out_suffix <- "global_analyses_overall_assessment_reg4_02072016"
|
|
61 | 62 |
#out_suffix <- "output_run10_1000x3000_global_analyses_02102015" |
62 | 63 |
#out_suffix <- "run10_1500x4500_global_analyses_pred_1992_10052015" #PARAM3 |
63 | 64 |
#out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_pred_1992_10052015" #PARAM4 |
64 |
create_out_dir_param <- TRUE #PARAM 5 |
|
65 |
#create_out_dir_param <- TRUE #PARAM 5
|
|
65 | 66 |
#mosaic_plot <- FALSE #PARAM6 |
66 | 67 |
#if daily mosaics NULL then mosaicas all days of the year |
67 | 68 |
#day_to_mosaic <- c("19920101","19920102","19920103") #PARAM7 |
68 | 69 |
#CRS_WGS84 <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 #CONSTANT1 |
69 | 70 |
#CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 |
70 | 71 |
#proj_str<- CRS_WGS84 #PARAM 8 #check this parameter |
71 |
file_format <- ".rst" #PARAM 9 |
|
72 |
NA_value <- -9999 #PARAM10 |
|
73 |
NA_flag_val <- NA_value |
|
72 |
#file_format <- ".rst" #PARAM 9
|
|
73 |
#NA_value <- -9999 #PARAM10
|
|
74 |
#NA_flag_val <- NA_value
|
|
74 | 75 |
#multiple_region <- TRUE #PARAM 12 |
75 | 76 |
#region_name <- "world" #PARAM 13 |
76 |
countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #PARAM 13, copy this on NEX too |
|
77 |
#countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #PARAM 13, copy this on NEX too
|
|
77 | 78 |
#plot_region <- TRUE |
78 | 79 |
#num_cores <- 6 #PARAM 14 |
79 |
region_name <- c("reg4") #reference region to merge if necessary, if world all the regions are together #PARAM 16 |
|
80 |
#region_name <- c("reg4") #reference region to merge if necessary, if world all the regions are together #PARAM 16
|
|
80 | 81 |
#use previous files produced in step 1a and stored in a data.frame |
81 | 82 |
#df_assessment_files <- "df_assessment_files_reg4_1984_run_global_analyses_pred_12282015.txt" #PARAM 17 |
82 |
threshold_missing_day <- c(367,365,300,200) #PARM18 |
|
83 |
#threshold_missing_day <- c(367,365,300,200) #PARM18
|
|
83 | 84 |
|
84 | 85 |
#list_param_run_assessment_plottingin_dir <- list(in_dir,y_var_name, interpolation_method, out_suffix, |
85 | 86 |
# out_dir, create_out_dir_param, mosaic_plot, proj_str, file_format, NA_value, |
... | ... | |
845 | 846 |
|
846 | 847 |
##################### END OF SCRIPT ###################### |
847 | 848 |
|
848 |
#### Run on the bridge: |
|
849 |
|
|
850 |
#args<-commandArgs(TRUE) |
|
851 |
#script_path<-"/nobackupp6/aguzman4/climateLayers/finalCode/environmental-layers/climate/research/oregon/interpolation" |
|
852 |
#dataHome<-"/nobackupp6/aguzman4/climateLayers/interp/testdata/" |
|
853 |
#script_path2<-"/nobackupp6/aguzman4/climateLayers/finalCode/environmental-layers/climate/research/world/interpolation" |
|
854 |
|
|
855 |
#CALLED FROM MASTER SCRIPT: |
|
856 |
|
|
857 |
script_path <- "/nobackupp8/bparmen1/env_layers_scripts" #path to script |
|
858 |
function_assessment_part1_functions <- "global_run_scalingup_assessment_part1_functions_02112015.R" #PARAM12 |
|
859 |
function_assessment_part1a <-"global_run_scalingup_assessment_part1a_01042016.R" |
|
860 |
function_assessment_part2 <- "global_run_scalingup_assessment_part2_01062016.R" |
|
861 |
function_assessment_part2_functions <- "global_run_scalingup_assessment_part2_functions_01032016.R" |
|
862 |
source(file.path(script_path,function_assessment_part1_functions)) #source all functions used in this script |
|
863 |
source(file.path(script_path,function_assessment_part1a)) #source all functions used in this script |
|
864 |
source(file.path(script_path,function_assessment_part2)) #source all functions used in this script |
|
865 |
source(file.path(script_path,function_assessment_part2_functions)) #source all functions used in this script |
|
866 |
|
|
867 |
### Parameters and arguments ### |
|
868 |
|
|
869 |
var<-"TMAX" # variable being interpolated |
|
870 |
if (var == "TMAX") { |
|
871 |
y_var_name <- "dailyTmax" |
|
872 |
y_var_month <- "TMax" |
|
873 |
} |
|
874 |
if (var == "TMIN") { |
|
875 |
y_var_name <- "dailyTmin" |
|
876 |
y_var_month <- "TMin" |
|
877 |
} |
|
878 |
|
|
879 |
#interpolation_method<-c("gam_fusion") #other otpions to be added later |
|
880 |
interpolation_method<-c("gam_CAI") |
|
881 |
CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"; |
|
882 |
#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"; |
|
883 |
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 |
|
884 |
|
|
885 |
out_region_name<-"" |
|
886 |
list_models<-c("y_var ~ s(lat,lon,k=5) + s(elev_s,k=3) + s(LST,k=3)") |
|
887 |
|
|
888 |
#reg1 (North Am), reg2(Europe),reg3(Asia), reg4 (South Am), reg5 (Africa), reg6 (Australia-Asia) |
|
889 |
#master directory containing the definition of tile size and tiles predicted |
|
890 |
in_dir1 <- "/nobackupp6/aguzman4/climateLayers/out/" |
|
891 |
#/nobackupp6/aguzman4/climateLayers/out_15x45/1982 |
|
892 |
|
|
893 |
#region_names <- c("reg23","reg4") #selected region names, #PARAM2 |
|
894 |
region_name <- c("reg4") #run assessment by region, this is a unique region only |
|
895 |
#region_names <- c("reg1","reg2","reg3","reg4","reg5","reg6") #selected region names, #PARAM2 |
|
896 |
interpolation_method <- c("gam_CAI") #PARAM4 |
|
897 |
out_prefix <- "run_global_analyses_pred_12282015" #PARAM5 |
|
898 |
#out_dir <- "/nobackupp8/bparmen1/" #PARAM6 |
|
899 |
out_dir <- "/nobackupp8/bparmen1/output_run_global_analyses_pred_12282015" |
|
900 |
#out_dir <-paste(out_dir,"_",out_prefix,sep="") |
|
901 |
create_out_dir_param <- FALSE #PARAM7 |
|
902 |
|
|
903 |
#CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"; |
|
904 |
#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"; |
|
905 |
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 |
|
906 |
|
|
907 |
#list_year_predicted <- 1984:2004 |
|
908 |
list_year_predicted <- c("2014") |
|
909 |
#year_predicted <- list_year_predicted[1] |
|
910 |
|
|
911 |
file_format <- ".tif" #format for mosaiced files #PARAM10 |
|
912 |
NA_flag_val <- -9999 #No data value, #PARAM11 |
|
913 |
num_cores <- 6 #number of cores used #PARAM13 |
|
914 |
plotting_figures <- TRUE #running part2 of assessment to generate figures... |
|
915 |
|
|
916 |
##Additional parameters used in part 2, some these may be removed as code is simplified |
|
917 |
mosaic_plot <- FALSE #PARAM14 |
|
918 |
day_to_mosaic <- c("19920102","19920103","19920103") #PARAM15 |
|
919 |
multiple_region <- TRUE #PARAM16 |
|
920 |
countries_shp <- "/nobackupp8/bparmen1/NEX_data/countries.shp" #PARAM17 |
|
921 |
#countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #Atlas |
|
922 |
plot_region <- TRUE #PARAM18 |
|
923 |
threshold_missing_day <- c(367,365,300,200)#PARAM19 |
|
924 |
|
|
925 |
year_predicted <- list_year_predicted[1] |
|
926 |
in_dir <- out_dir #PARAM 0 |
|
927 |
#y_var_name <- "dailyTmax" #PARAM1 , already set |
|
928 |
#interpolation_method <- c("gam_CAI") #PARAM2, already set |
|
929 |
out_suffix <- out_prefix #PARAM3 |
|
930 |
#out_dir <- #PARAM4, already set |
|
931 |
create_out_dir_param <- FALSE #PARAM 5, already created and set |
|
932 |
#mosaic_plot <- FALSE #PARAM6 |
|
933 |
#if daily mosaics NULL then mosaicas all days of the year |
|
934 |
#day_to_mosaic <- c("19920101","19920102","19920103") #PARAM7 |
|
935 |
#CRS_locs_WGS84 already set |
|
936 |
proj_str <- CRS_locs_WGS84 #PARAM 8 #check this parameter |
|
937 |
#file_format <- ".rst" #PARAM 9, already set |
|
938 |
#NA_flag_val <- -9999 #PARAM 11, already set |
|
939 |
#multiple_region <- TRUE #PARAM 12 |
|
940 |
#countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #PARAM 13, copy this on NEX too |
|
941 |
#plot_region <- TRUE |
|
942 |
#num_cores <- 6 #PARAM 14, already set |
|
943 |
#region_name <- c("reg4") #reference region to merge if necessary, if world all the regions are together #PARAM 16 |
|
944 |
#use previous files produced in step 1a and stored in a data.frame |
|
945 |
df_assessment_files_name <- "df_assessment_files_reg4_2014_run_global_analyses_pred_12282015.txt"# #PARAM 17, set in the script |
|
946 |
df_assessment_files <- read.table(df_assessment_files_name,stringsAsFactors=F,sep=",") |
|
947 |
#threshold_missing_day <- c(367,365,300,200) #PARM18 |
|
948 |
|
|
949 |
list_param_run_assessment_plotting <-list( list_param_run_assessment_plotting, |
|
950 |
in_dir,y_var_name, interpolation_method, out_suffix, |
|
951 |
out_dir, create_out_dir_param, mosaic_plot, proj_str, file_format, NA_flag_val, |
|
952 |
multiple_region, countries_shp, plot_region, num_cores, |
|
953 |
region_name, df_assessment_files_name, threshold_missing_day,year_predicted |
|
954 |
) |
|
955 |
|
|
956 |
names(list_param_run_assessment_plotting) <- c("list_param_run_assessment_plotting$in_dir_list_filename #PARAM 0" |
|
957 |
"in_dir","y_var_name","interpolation_method","out_suffix", |
|
958 |
"out_dir","create_out_dir_param","mosaic_plot","proj_str","file_format","NA_flag_val", |
|
959 |
"multiple_region","countries_shp","plot_region","num_cores", |
|
960 |
"region_name","df_assessment_files_name","threshold_missing_day","year_predicted" |
|
961 |
) |
|
962 |
|
|
963 |
#function_assessment_part2 <- "global_run_scalingup_assessment_part2_01032016.R" |
|
964 |
#source(file.path(script_path,function_assessment_part2)) #source all functions used in this script |
|
965 |
|
|
966 |
debug(run_assessment_plotting_prediction_fun) |
|
967 |
df_assessment_figures_files <- |
|
968 |
run_assessment_plotting_prediction_fun(list_param_run_assessment_plotting) |
|
969 |
|
|
970 |
|
|
971 |
|
|
972 |
|
|
973 |
|
|
974 | 849 |
|
975 | 850 |
|
976 | 851 |
|
Also available in: Unified diff
reading list of dir from files and clean up in assessment part3