Revision 4963bd95
Added by Benoit Parmentier almost 9 years ago
climate/research/oregon/interpolation/global_run_scalingup_assessment_part2.R | ||
---|---|---|
1 |
############################## INTERPOLATION OF TEMPERATURES #######################################
|
|
1 |
############################## INTERPOLATION OF TEMPERATURES ####################################### |
|
2 | 2 |
####################### Script for assessment of scaling up on NEX : part2 ############################## |
3 | 3 |
#This script uses the worklfow code applied to the globe. Results currently reside on NEX/PLEIADES NASA. |
4 | 4 |
#Accuracy methods are added in the the function scripts to evaluate results. |
5 | 5 |
#Analyses, figures, tables and data are also produced in the script. |
6 | 6 |
#AUTHOR: Benoit Parmentier |
7 | 7 |
#CREATED ON: 03/23/2014 |
8 |
#MODIFIED ON: 01/06/2016
|
|
8 |
#MODIFIED ON: 01/12/2016
|
|
9 | 9 |
#Version: 5 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 | 11 |
#COMMENTS: analyses for run 10 global analyses,all regions 1500x4500km with additional tiles to increase overlap |
... | ... | |
18 | 18 |
#Resolved call issues from R. |
19 | 19 |
#source /nobackupp6/aguzman4/climateLayers/sharedModules2/etc/environ.sh |
20 | 20 |
# |
21 |
#setfacl -Rmd user:aguzman4:rwx /nobackupp8/bparmen1/output_run10_1500x4500_global_analyses_pred_1992_10052015 |
|
22 |
|
|
21 | 23 |
################################################################################################# |
22 | 24 |
|
23 | 25 |
#### FUNCTION USED IN SCRIPT |
... | ... | |
103 | 105 |
#15) region_name #<- c("reg4"), world if full assessment #reference region to merge if necessary #PARAM 16 |
104 | 106 |
#16) df_assessment_files #PARAM 16 |
105 | 107 |
#17) threshold_missing_day #PARM18 |
106 |
# |
|
108 |
#18) year_predicted
|
|
107 | 109 |
|
108 | 110 |
### Loading R library and packages |
109 | 111 |
#library used in the workflow production: |
... | ... | |
570 | 572 |
} |
571 | 573 |
counter_fig <- counter_fig+length(threshold_missing_day) #currently 4 days... |
572 | 574 |
|
575 |
### Potential |
|
573 | 576 |
png(filename=paste("Figure7b_number_daily_predictions_per_models","_",out_suffix,".png",sep=""), |
574 | 577 |
width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
575 | 578 |
|
... | ... | |
784 | 787 |
|
785 | 788 |
##################### END OF SCRIPT ###################### |
786 | 789 |
|
790 |
#### Run on the bridge: |
|
791 |
|
|
792 |
#args<-commandArgs(TRUE) |
|
793 |
#script_path<-"/nobackupp6/aguzman4/climateLayers/finalCode/environmental-layers/climate/research/oregon/interpolation" |
|
794 |
#dataHome<-"/nobackupp6/aguzman4/climateLayers/interp/testdata/" |
|
795 |
#script_path2<-"/nobackupp6/aguzman4/climateLayers/finalCode/environmental-layers/climate/research/world/interpolation" |
|
796 |
|
|
797 |
#CALLED FROM MASTER SCRIPT: |
|
798 |
|
|
799 |
script_path <- "/nobackupp8/bparmen1/env_layers_scripts" #path to script |
|
800 |
function_assessment_part1_functions <- "global_run_scalingup_assessment_part1_functions_02112015.R" #PARAM12 |
|
801 |
function_assessment_part1a <-"global_run_scalingup_assessment_part1a_01042016.R" |
|
802 |
function_assessment_part2 <- "global_run_scalingup_assessment_part2_01062016.R" |
|
803 |
function_assessment_part2_functions <- "global_run_scalingup_assessment_part2_functions_01032016.R" |
|
804 |
source(file.path(script_path,function_assessment_part1_functions)) #source all functions used in this script |
|
805 |
source(file.path(script_path,function_assessment_part1a)) #source all functions used in this script |
|
806 |
source(file.path(script_path,function_assessment_part2)) #source all functions used in this script |
|
807 |
source(file.path(script_path,function_assessment_part2_functions)) #source all functions used in this script |
|
808 |
|
|
809 |
### Parameters and arguments ### |
|
810 |
|
|
811 |
var<-"TMAX" # variable being interpolated |
|
812 |
if (var == "TMAX") { |
|
813 |
y_var_name <- "dailyTmax" |
|
814 |
y_var_month <- "TMax" |
|
815 |
} |
|
816 |
if (var == "TMIN") { |
|
817 |
y_var_name <- "dailyTmin" |
|
818 |
y_var_month <- "TMin" |
|
819 |
} |
|
820 |
|
|
821 |
#interpolation_method<-c("gam_fusion") #other otpions to be added later |
|
822 |
interpolation_method<-c("gam_CAI") |
|
823 |
CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"; |
|
824 |
#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"; |
|
825 |
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 |
|
826 |
|
|
827 |
out_region_name<-"" |
|
828 |
list_models<-c("y_var ~ s(lat,lon,k=5) + s(elev_s,k=3) + s(LST,k=3)") |
|
829 |
|
|
830 |
#reg1 (North Am), reg2(Europe),reg3(Asia), reg4 (South Am), reg5 (Africa), reg6 (Australia-Asia) |
|
831 |
#master directory containing the definition of tile size and tiles predicted |
|
832 |
in_dir1 <- "/nobackupp6/aguzman4/climateLayers/out/" |
|
833 |
#/nobackupp6/aguzman4/climateLayers/out_15x45/1982 |
|
834 |
|
|
835 |
#region_names <- c("reg23","reg4") #selected region names, #PARAM2 |
|
836 |
region_name <- c("reg4") #run assessment by region, this is a unique region only |
|
837 |
#region_names <- c("reg1","reg2","reg3","reg4","reg5","reg6") #selected region names, #PARAM2 |
|
838 |
interpolation_method <- c("gam_CAI") #PARAM4 |
|
839 |
out_prefix <- "run_global_analyses_pred_12282015" #PARAM5 |
|
840 |
#out_dir <- "/nobackupp8/bparmen1/" #PARAM6 |
|
841 |
out_dir <- "/nobackupp8/bparmen1/output_run_global_analyses_pred_12282015" |
|
842 |
#out_dir <-paste(out_dir,"_",out_prefix,sep="") |
|
843 |
create_out_dir_param <- FALSE #PARAM7 |
|
844 |
|
|
845 |
#CRS_interp<-"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"; |
|
846 |
#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"; |
|
847 |
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 |
|
848 |
|
|
849 |
#list_year_predicted <- 1984:2004 |
|
850 |
list_year_predicted <- c("2014") |
|
851 |
#year_predicted <- list_year_predicted[1] |
|
852 |
|
|
853 |
file_format <- ".tif" #format for mosaiced files #PARAM10 |
|
854 |
NA_flag_val <- -9999 #No data value, #PARAM11 |
|
855 |
num_cores <- 6 #number of cores used #PARAM13 |
|
856 |
plotting_figures <- TRUE #running part2 of assessment to generate figures... |
|
857 |
|
|
858 |
##Additional parameters used in part 2, some these may be removed as code is simplified |
|
859 |
mosaic_plot <- FALSE #PARAM14 |
|
860 |
day_to_mosaic <- c("19920102","19920103","19920103") #PARAM15 |
|
861 |
multiple_region <- TRUE #PARAM16 |
|
862 |
countries_shp <- "/nobackupp8/bparmen1/NEX_data/countries.shp" #PARAM17 |
|
863 |
#countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #Atlas |
|
864 |
plot_region <- TRUE #PARAM18 |
|
865 |
threshold_missing_day <- c(367,365,300,200)#PARAM19 |
|
866 |
|
|
867 |
year_predicted <- list_year_predicted[1] |
|
868 |
in_dir <- out_dir #PARAM 0 |
|
869 |
#y_var_name <- "dailyTmax" #PARAM1 , already set |
|
870 |
#interpolation_method <- c("gam_CAI") #PARAM2, already set |
|
871 |
out_suffix <- out_prefix #PARAM3 |
|
872 |
#out_dir <- #PARAM4, already set |
|
873 |
create_out_dir_param <- FALSE #PARAM 5, already created and set |
|
874 |
#mosaic_plot <- FALSE #PARAM6 |
|
875 |
#if daily mosaics NULL then mosaicas all days of the year |
|
876 |
#day_to_mosaic <- c("19920101","19920102","19920103") #PARAM7 |
|
877 |
#CRS_locs_WGS84 already set |
|
878 |
proj_str <- CRS_locs_WGS84 #PARAM 8 #check this parameter |
|
879 |
#file_format <- ".rst" #PARAM 9, already set |
|
880 |
#NA_flag_val <- -9999 #PARAM 11, already set |
|
881 |
#multiple_region <- TRUE #PARAM 12 |
|
882 |
#countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp" #PARAM 13, copy this on NEX too |
|
883 |
#plot_region <- TRUE |
|
884 |
#num_cores <- 6 #PARAM 14, already set |
|
885 |
#region_name <- c("reg4") #reference region to merge if necessary, if world all the regions are together #PARAM 16 |
|
886 |
#use previous files produced in step 1a and stored in a data.frame |
|
887 |
df_assessment_files_name <- "df_assessment_files_reg4_2014_run_global_analyses_pred_12282015.txt"# #PARAM 17, set in the script |
|
888 |
df_assessment_files <- read.table(df_assessment_files_name,stringsAsFactors=F,sep=",") |
|
889 |
#threshold_missing_day <- c(367,365,300,200) #PARM18 |
|
890 |
|
|
891 |
list_param_run_assessment_plotting <-list( |
|
892 |
in_dir,y_var_name, interpolation_method, out_suffix, |
|
893 |
out_dir, create_out_dir_param, mosaic_plot, proj_str, file_format, NA_flag_val, |
|
894 |
multiple_region, countries_shp, plot_region, num_cores, |
|
895 |
region_name, df_assessment_files_name, threshold_missing_day,year_predicted |
|
896 |
) |
|
897 |
|
|
898 |
names(list_param_run_assessment_plotting) <- c( |
|
899 |
"in_dir","y_var_name","interpolation_method","out_suffix", |
|
900 |
"out_dir","create_out_dir_param","mosaic_plot","proj_str","file_format","NA_flag_val", |
|
901 |
"multiple_region","countries_shp","plot_region","num_cores", |
|
902 |
"region_name","df_assessment_files_name","threshold_missing_day","year_predicted" |
|
903 |
) |
|
904 |
|
|
905 |
#function_assessment_part2 <- "global_run_scalingup_assessment_part2_01032016.R" |
|
906 |
#source(file.path(script_path,function_assessment_part2)) #source all functions used in this script |
|
907 |
|
|
908 |
debug(run_assessment_plotting_prediction_fun) |
|
909 |
df_assessment_figures_files <- |
|
910 |
run_assessment_plotting_prediction_fun(list_param_run_assessment_plotting) |
|
911 |
|
|
912 |
|
|
913 |
|
|
914 |
|
|
915 |
|
|
916 |
|
|
917 |
|
|
918 |
|
|
919 |
|
|
920 |
|
|
921 |
|
|
922 |
|
|
923 |
|
|
924 |
|
|
925 |
|
|
926 |
|
|
927 |
|
|
928 |
|
|
929 |
|
|
930 |
|
|
931 |
|
|
932 |
|
|
933 |
|
|
934 |
|
|
935 |
|
|
936 |
|
|
937 |
|
|
938 |
|
|
939 |
|
|
940 |
|
|
941 |
|
|
942 |
|
|
943 |
#### CURRENT ERROR ON NEX |
|
944 |
|
|
787 | 945 |
# #comments #figure_no #region #models |
788 | 946 |
# tile processed for the region figure_1 reg4 NA |
789 | 947 |
# boxplot with outlier figure_2a reg4 mod1 |
Also available in: Unified diff
part2 assessment figure production tested and debugged on bridge