Revision 5c60138a
Added by Benoit Parmentier over 9 years ago
climate/research/oregon/interpolation/global_run_scalingup_assessment_part2.R | ||
---|---|---|
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: 03/07/2015
|
|
8 |
#MODIFIED ON: 03/11/2015
|
|
9 | 9 |
#Version: 4 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 | 11 |
#COMMENTS: analyses for run 10 global analyses,all regions 1500x4500km and other tiles |
... | ... | |
328 | 328 |
interpolation_method <- c("gam_CAI") #PARAM2 |
329 | 329 |
#out_suffix<-"run10_global_analyses_01282015" |
330 | 330 |
#out_suffix <- "output_run10_1000x3000_global_analyses_02102015" |
331 |
out_suffix <- "run10_1500x4500_global_analyses_03052015" #PARAM3
|
|
332 |
out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_03052015" #PARAM4
|
|
331 |
out_suffix <- "run10_1500x4500_global_analyses_03112015" #PARAM3
|
|
332 |
out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_03112015" #PARAM4
|
|
333 | 333 |
create_out_dir_param <- FALSE #PARAM 5 |
334 | 334 |
|
335 | 335 |
mosaic_plot <- FALSE #PARAM6 |
... | ... | |
509 | 509 |
text(coordinates(pt)[1],coordinates(pt)[2],labels=i,cex=1.3,font=2,col=c("red")) |
510 | 510 |
} |
511 | 511 |
} |
512 |
title(paste("Tiles 1000x3000 ", region_name,sep=""))
|
|
512 |
title(paste("Tiles ", tile_size,region_name,sep=""))
|
|
513 | 513 |
|
514 | 514 |
dev.off() |
515 | 515 |
|
... | ... | |
716 | 716 |
#plot(ac_mod1,cex=sqrt(ac_mod1$rmse),pch=1,add=T) |
717 | 717 |
#plot(ac_mod,cex=(ac_mod$rmse^2)/10,pch=1,col="red",add=T) |
718 | 718 |
|
719 |
#coordinates(ac_mod) <- ac_mod[,c("lon","lat")]
|
|
720 |
coordinates(ac_mod) <- ac_mod[,c("lon.x","lat.x")] #solve this later |
|
719 |
coordinates(ac_mod) <- ac_mod[,c("lon","lat")] |
|
720 |
#coordinates(ac_mod) <- ac_mod[,c("lon.x","lat.x")] #solve this later
|
|
721 | 721 |
p_shp <- layer(sp.polygons(reg_layer, lwd=1, col='black')) |
722 | 722 |
#title("(a) Mean for 1 January") |
723 | 723 |
p <- bubble(ac_mod,"rmse",main=paste("Averrage RMSE per tile and by ",model_name[i])) |
... | ... | |
739 | 739 |
sum(df_tile_processed$metrics_v)/length(df_tile_processed$metrics_v) #87.85% of tiles with info |
740 | 740 |
|
741 | 741 |
#coordinates |
742 |
#coordinates(summary_metrics_v) <- c("lon","lat")
|
|
743 |
coordinates(summary_metrics_v) <- c("lon.y","lat.y") |
|
742 |
coordinates(summary_metrics_v) <- c("lon","lat") |
|
743 |
#coordinates(summary_metrics_v) <- c("lon.y","lat.y")
|
|
744 | 744 |
|
745 | 745 |
threshold_missing_day <- c(367,365,300,200) |
746 | 746 |
|
... | ... | |
902 | 902 |
|
903 | 903 |
#lf_m_mask_reg6_1000x3000 <- mclapply(1:length(lf_m),FUN=plot_daily_mosaics,list_param=list_param_plot_daily_mosaics,mc.preschedule=FALSE,mc.cores = 10) |
904 | 904 |
|
905 |
lf_mosaics_mask_reg <- vector("list",length=length(l_reg_name)) |
|
906 |
for(i in 1:length(l_reg_name)){ |
|
907 |
# |
|
908 |
lf_m <- lf_mosaics_reg[[i]] |
|
909 |
out_dir_str <- out_dir |
|
910 |
reg_name <- paste(l_reg_name[i],"_",tile_size,sep="") #make this automatic |
|
911 |
#lapply() |
|
912 |
list_param_plot_daily_mosaics <- list(lf_m=lf_m,reg_name=reg_name,out_dir_str=out_dir_str,out_suffix=out_suffix,l_dates=day_to_mosaic) |
|
913 |
#lf_m_mask_reg4_1500x4500 <- mclapply(1:2,FUN=plot_daily_mosaics,list_param=list_param_plot_daily_mosaics,mc.preschedule=FALSE,mc.cores = 6) |
|
914 |
|
|
915 |
lf_mosaics_mask_reg[[i]] <- mclapply(1:length(lf_m),FUN=plot_daily_mosaics,list_param=list_param_plot_daily_mosaics,mc.preschedule=FALSE,mc.cores = 10) |
|
905 |
if(plot_region==TRUE){ |
|
906 |
lf_mosaics_mask_reg <- vector("list",length=length(l_reg_name)) |
|
907 |
for(i in 1:length(l_reg_name)){ |
|
908 |
d |
|
909 |
# |
|
910 |
lf_m <- lf_mosaics_reg[[i]] |
|
911 |
out_dir_str <- out_dir |
|
912 |
reg_name <- paste(l_reg_name[i],"_",tile_size,sep="") #make this automatic |
|
913 |
#lapply() |
|
914 |
list_param_plot_daily_mosaics <- list(lf_m=lf_m,reg_name=reg_name,out_dir_str=out_dir_str,out_suffix=out_suffix,l_dates=day_to_mosaic) |
|
915 |
#lf_m_mask_reg4_1500x4500 <- mclapply(1:2,FUN=plot_daily_mosaics,list_param=list_param_plot_daily_mosaics,mc.preschedule=FALSE,mc.cores = 6) |
|
916 |
|
|
917 |
lf_mosaics_mask_reg[[i]] <- mclapply(1:length(lf_m),FUN=plot_daily_mosaics,list_param=list_param_plot_daily_mosaics,mc.preschedule=FALSE,mc.cores = 10) |
|
918 |
} |
|
916 | 919 |
} |
917 | 920 |
|
918 | 921 |
################## WORLD MOSAICS NEEDS MAJOR CLEAN UP OF CODE HERE |
... | ... | |
921 | 924 |
|
922 | 925 |
#use list from above!! |
923 | 926 |
|
924 |
test_list <-list.files(path=out_dir, |
|
925 |
pattern=paste("reg.*._CAI_TMAX_clim_month_20100101_mod1_all_mean.tif",sep=""), |
|
926 |
) |
|
927 |
|
|
928 |
test_list<-lapply(1:30,FUN=function(i){lapply(1:x[[i]]},x=lf_mosaics_mask_reg) |
|
929 |
test_list<-unlist(test_list) |
|
930 |
mosaic_list_mean <- vector("list",length=1) |
|
931 |
mosaic_list_mean[[1]] <- test_list |
|
932 |
out_rastnames <- "world_test_mosaic_20100101" |
|
933 |
out_path <- out_dir |
|
934 |
|
|
935 |
list_param_mosaic<-list(mosaic_list_mean,out_path,out_rastnames,file_format,NA_flag_val,out_suffix) |
|
936 |
names(list_param_mosaic)<-c("mosaic_list","out_path","out_rastnames","file_format","NA_flag_val","out_suffix") |
|
937 |
#mean_m_list <-mclapply(1:12, list_param=list_param_mosaic, mosaic_m_raster_list,mc.preschedule=FALSE,mc.cores = 6) #This is the end bracket from mclapply(...) statement |
|
938 |
|
|
939 |
lf <- mosaic_m_raster_list(1,list_param_mosaic) |
|
940 |
|
|
941 |
debug(mosaic_m_raster_list) |
|
942 |
mosaic_list<-list_param$mosaic_list |
|
943 |
out_path<-list_param$out_path |
|
944 |
out_names<-list_param$out_rastnames |
|
945 |
file_format <- list_param$file_format |
|
946 |
NA_flag_val <- list_param$NA_flag_val |
|
947 |
out_suffix <- list_param$out_suffix |
|
927 |
# test_list <-list.files(path=file.path(out_dir,"mosaics"), |
|
928 |
# pattern=paste("^world_mosaics.*.tif$",sep=""), |
|
929 |
# ) |
|
930 |
# #world_mosaics_mod1_output1500x4500_km_20101105_run10_1500x4500_global_analyses_03112015.tif |
|
931 |
# |
|
932 |
# #test_list<-lapply(1:30,FUN=function(i){lapply(1:x[[i]]},x=lf_mosaics_mask_reg) |
|
933 |
# #test_list<-unlist(test_list) |
|
934 |
# #mosaic_list_mean <- vector("list",length=1) |
|
935 |
# mosaic_list_mean <- test_list |
|
936 |
# out_rastnames <- "world_test_mosaic_20100101" |
|
937 |
# out_path <- out_dir |
|
938 |
# |
|
939 |
# list_param_mosaic<-list(mosaic_list_mean,out_path,out_rastnames,file_format,NA_flag_val,out_suffix) |
|
940 |
# names(list_param_mosaic)<-c("mosaic_list","out_path","out_rastnames","file_format","NA_flag_val","out_suffix") |
|
941 |
# #mean_m_list <-mclapply(1:12, list_param=list_param_mosaic, mosaic_m_raster_list,mc.preschedule=FALSE,mc.cores = 6) #This is the end bracket from mclapply(...) statement |
|
942 |
# |
|
943 |
# lf <- mosaic_m_raster_list(1,list_param_mosaic) |
|
944 |
# |
|
945 |
# debug(mosaic_m_raster_list) |
|
946 |
# mosaic_list<-list_param$mosaic_list |
|
947 |
# out_path<-list_param$out_path |
|
948 |
# out_names<-list_param$out_rastnames |
|
949 |
# file_format <- list_param$file_format |
|
950 |
# NA_flag_val <- list_param$NA_flag_val |
|
951 |
# out_suffix <- list_param$out_suffix |
|
948 | 952 |
|
949 | 953 |
##Now mosaic for mean: should reorder files!! |
950 | 954 |
#out_rastnames_mean<-paste("_",lst_pat,"_","mean",out_suffix,sep="") |
... | ... | |
964 | 968 |
|
965 | 969 |
################## PLOTTING WORLD MOSAICS ################ |
966 | 970 |
|
967 |
lf_world_pred <- list.files(pattern="world.*2010090.*.tif$") |
|
968 |
lf_raster_fname <- list.files(pattern="world.*2010*.*02162015.tif$",full.names=T) |
|
971 |
lf_world_pred <-list.files(path=file.path(out_dir,"mosaics"), |
|
972 |
pattern=paste("^world_mosaics.*.tif$",sep=""),full.names=T) |
|
973 |
) |
|
974 |
|
|
975 |
#mosaic_list_mean <- test_list |
|
976 |
#out_rastnames <- "world_test_mosaic_20100101" |
|
977 |
#out_path <- out_dir |
|
969 | 978 |
|
979 |
#lf_world_pred <- list.files(pattern="world.*2010090.*.tif$") |
|
980 |
#lf_raster_fname <- list.files(pattern="world.*2010*.*02162015.tif$",full.names=T) |
|
981 |
lf_raster_fname <- lf_world_pred |
|
970 | 982 |
prefix_str <- "Figure10_clim_world_mosaics_day_" |
971 | 983 |
l_dates <-day_to_mosaic |
972 | 984 |
screenRast=TRUE |
973 | 985 |
list_param_plot_screen_raster <- list(lf_raster_fname,screenRast,l_dates,out_dir,prefix_str,out_suffix) |
974 | 986 |
names(list_param_plot_screen_raster) <- c("lf_raster_fname","screenRast","l_dates","out_dir_str","prefix_str","out_suffix_str") |
975 | 987 |
|
976 |
#debug(plot_screen_raster_val)
|
|
988 |
undebug(plot_screen_raster_val)
|
|
977 | 989 |
|
978 |
#plot_screen_raster_val(1,list_param_plot_screen_raster) |
|
979 |
world_m_list <- mclapply(1:10, list_param=list_param_plot_screen_raster, plot_screen_raster_val,mc.preschedule=FALSE,mc.cores = 5) #This is the end bracket from mclapply(...) statement |
|
980 |
world_m_list <- mclapply(11:30, list_param=list_param_plot_screen_raster, plot_screen_raster_val,mc.preschedule=FALSE,mc.cores = 7) #This is the end bracket from mclapply(...) statement
|
|
990 |
#world_m_list1<- plot_screen_raster_val(1,list_param_plot_screen_raster)
|
|
991 |
#world_m_list <- mclapply(1:10, list_param=list_param_plot_screen_raster, plot_screen_raster_val,mc.preschedule=FALSE,mc.cores = 5) #This is the end bracket from mclapply(...) statement
|
|
992 |
world_m_list <- mclapply(1:30, list_param=list_param_plot_screen_raster, plot_screen_raster_val,mc.preschedule=FALSE,mc.cores = 7) #This is the end bracket from mclapply(...) statement |
|
981 | 993 |
|
982 | 994 |
plot_screen_raster_val<-function(i,list_param){ |
983 | 995 |
##USAGE### |
Also available in: Unified diff
1500x4500km, part 2 global assessment run10 - production of global mosaics and modifications to code