Project

General

Profile

« Previous | Next » 

Revision 3fb08f02

Added by Benoit Parmentier almost 10 years ago

run 9 NEX, part 2 assessment of accuracy, cleaning up and adding figures

View differences:

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: 11/03/2014            
8
#MODIFIED ON: 11/17/2014            
9 9
#Version: 3
10 10
#PROJECT: Environmental Layers project     
11 11
#COMMENTS: analyses for run 5 global using 6 specific tiles
......
215 215
#in_dir1 <- "/data/project/layers/commons/NEX_data/output_run6_global_analyses_09162014/output20Deg2"
216 216
# parent output dir for the curent script analyes
217 217
#out_dir <-"/data/project/layers/commons/NEX_data/output_run3_global_analyses_06192014/" #On NCEAS Atlas
218
out_dir <-"/data/project/layers/commons/NEX_data/output_run8_global_analyses_10292014/"
218
out_dir <-"/data/project/layers/commons/NEX_data/output_run9_global_analyses_11122014/"
219 219
# input dir containing shapefiles defining tiles
220 220
#in_dir_shp <- "/data/project/layers/commons/NEX_data/output_run5_global_analyses_08252014/output/subset/shapefiles"
221 221

  
......
228 228

  
229 229
y_var_name <- "dailyTmax"
230 230
interpolation_method <- c("gam_CAI")
231
out_prefix<-"run8_global_analyses_10292014"
231
out_prefix<-"run9_global_analyses_11122014"
232 232
mosaic_plot <- FALSE
233 233

  
234 234
proj_str<- CRS_WGS84
......
622 622
  list_df_ac_mod[[i]] <- arrange(as.data.frame(ac_mod),desc(rmse))[,c("rmse","mae","tile_id")]
623 623
}
624 624

  
625
## Number of tiles with information:
626

  
627
sum(df_tile_processed$metrics_v)/nrow(df_tile_processed$metrics_v)
625 628

  
626 629
#coordinates
627 630
coordinates(summary_metrics_v) <- c("lon","lat")
628 631
summary_metrics_v$n_missing <- summary_metrics_v$n == 365
629
  
632
#summary_metrics_v$n_missing <- summary_metrics_v$n < 365
633
#summary_metrics_v$n_missing <- summary_metrics_v$n < 300
634

  
635
nb<-nrow(subset(summary_metrics_v,model_name=="mod1"))  
636
sum(subset(summary_metrics_v,model_name=="mod1")$n_missing)/nb
637

  
638
## Make this a figure...
639

  
630 640
#plot(summary_metrics_v)
631 641
p_shp <- layer(sp.polygons(reg_layer, lwd=1, col='black'))
632 642
#title("(a) Mean for 1 January")
......
634 644
p1 <- p+p_shp
635 645
print(p1)
636 646

  
647

  
637 648
######################
638 649
### Figure 7: Number of predictions: daily and monthly
639 650

  
......
658 669
table(tb$index_d)
659 670
table(subset(tb,pred_mod!="mod_kr"))
660 671
table(subset(tb,pred_mod=="mod1")$index_d)
661
aggregate()
672
#aggregate()
662 673
tb$predicted <- 1
663 674
test <- aggregate(predicted~pred_mod+tile_id,data=tb,sum)
664 675
xyplot(predicted~pred_mod | tile_id,data=subset(as.data.frame(test),
......
666 677

  
667 678
test
668 679

  
669
unique(test$tile_id) #71 tiles
670
dim(subset(test,test$predicted==365 & test$pred_mod=="mod2"))
671
histogram(subset(test, test$pred_mod=="mod2")$predicted)
672
unique(subset(test, test$pred_mod=="mod2")$predicted)
673
table((subset(test, test$pred_mod=="mod2")$predicted))
680
unique(test$tile_id) #72 tiles
681
dim(subset(test,test$predicted==365 & test$pred_mod=="mod1"))
682
histogram(subset(test, test$pred_mod=="mod1")$predicted)
683
unique(subset(test, test$pred_mod=="mod1")$predicted)
684
table((subset(test, test$pred_mod=="mod1")$predicted))
674 685

  
675
LST_avgm_min <- aggregate(LST~month,data=data_month_all,min)
686
#LST_avgm_min <- aggregate(LST~month,data=data_month_all,min)
676 687
histogram(test$predicted~test$tile_id)
677
table(tb)
688
#table(tb)
678 689
## Figure 7b
679 690
#png(filename=paste("Figure7b_number_daily_predictions_per_models","_",out_prefix,".png",sep=""),
680 691
#    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
......
691 702
######################
692 703
### Figure 9: Plot the number of stations in a processing tile
693 704

  
694
#data_tb <- merge(df_tile_processed,summary_metrics_v,by="tile_id") #keep only the common id, id tiles with pred ac
695
#data_tb <- merge(df_tile_processed,summary_metrics_v,by="tile_id",all=T) #keep all
696

  
697
mod1_data_tb <- merge(df_tile_processed,subset(summary_metrics_v,pred_mod=="mod1"),by="tile_id",all=T) #keep all
698
mod2_data_tb <- merge(df_tile_processed,subset(summary_metrics_v,pred_mod=="mod2"),by="tile_id",all=T) #keep all
699
mod_kr_data_tb <- merge(df_tile_processed,subset(summary_metrics_v,pred_mod=="mod_kr"),by="tile_id",all=T) #keep all
700

  
701
##First create an image of the tiles, use ratify?? with tile id as the raster id for the attribute table??
702
#Transform table text file into a raster image
703
#coord_names <- c("XCoord","YCoord")
704
coord_names <- c("lon.x","lat.x")
705
#l_r_ast <- rasterize_df_fun(df_tile_processed,coord_names,proj_str,out_suffix,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
706
out_suffix_str <- paste("mod1_",out_suffix)
707
mod1_l_rast <- rasterize_df_fun(mod1_data_tb,coord_names,proj_str=CRS_WGS84,out_suffix_str,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
708
mod1_stack <- stack(mod1_l_rast)
709
names(mod1_stack) <- names(mod1_data_tb)
710

  
711
out_suffix_str <- paste("mod2_",out_suffix)
712
mod2_l_rast <- rasterize_df_fun(mod2_data_tb,coord_names,proj_str=CRS_WGS84,out_suffix_str,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
713
mod2_stack <- stack(mod2_l_rast)
714
names(mod2_stack) <- names(mod2_data_tb)
715

  
716
out_suffix_str <- paste("mod_kr_",out_suffix)
717
mod_kr_l_rast <- rasterize_df_fun(mod_kr_data_tb,coord_names,proj_str=CRS_WGS84,out_suffix_str,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
718
mod_kr_stack <- stack(mod_kr_l_rast)
719
names(mod_kr_stack) <- names(mod_kr_data_tb)
720

  
721
#Number of daily predictions 
722
p0 <- levelplot(mod1_stack,layer=21,margin=F,
723
                main=paste("number_daily_predictions_for_","mod1",sep=""))
724
p<- p0+p_shp
705
# #data_tb <- merge(df_tile_processed,summary_metrics_v,by="tile_id") #keep only the common id, id tiles with pred ac
706
# #data_tb <- merge(df_tile_processed,summary_metrics_v,by="tile_id",all=T) #keep all
707
# 
708
# mod1_data_tb <- merge(df_tile_processed,subset(summary_metrics_v,pred_mod=="mod1"),by="tile_id",all=T) #keep all
709
# mod2_data_tb <- merge(df_tile_processed,subset(summary_metrics_v,pred_mod=="mod2"),by="tile_id",all=T) #keep all
710
# mod_kr_data_tb <- merge(df_tile_processed,subset(summary_metrics_v,pred_mod=="mod_kr"),by="tile_id",all=T) #keep all
711
# 
712
# ##First create an image of the tiles, use ratify?? with tile id as the raster id for the attribute table??
713
# #Transform table text file into a raster image
714
# #coord_names <- c("XCoord","YCoord")
715
# coord_names <- c("lon.x","lat.x")
716
# #l_r_ast <- rasterize_df_fun(df_tile_processed,coord_names,proj_str,out_suffix,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
717
# out_suffix_str <- paste("mod1_",out_suffix)
718
# mod1_l_rast <- rasterize_df_fun(mod1_data_tb,coord_names,proj_str=CRS_WGS84,out_suffix_str,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
719
# mod1_stack <- stack(mod1_l_rast)
720
# names(mod1_stack) <- names(mod1_data_tb)
721
# 
722
# out_suffix_str <- paste("mod2_",out_suffix)
723
# mod2_l_rast <- rasterize_df_fun(mod2_data_tb,coord_names,proj_str=CRS_WGS84,out_suffix_str,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
724
# mod2_stack <- stack(mod2_l_rast)
725
# names(mod2_stack) <- names(mod2_data_tb)
726
# 
727
# out_suffix_str <- paste("mod_kr_",out_suffix)
728
# mod_kr_l_rast <- rasterize_df_fun(mod_kr_data_tb,coord_names,proj_str=CRS_WGS84,out_suffix_str,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
729
# mod_kr_stack <- stack(mod_kr_l_rast)
730
# names(mod_kr_stack) <- names(mod_kr_data_tb)
731
# 
732
# #Number of daily predictions 
733
# p0 <- levelplot(mod1_stack,layer=21,margin=F,
734
#                 main=paste("number_daily_predictions_for_","mod1",sep=""))
735
# p<- p0+p_shp
725 736

  
726 737
###########
727 738
## Figure 9a: number of daily predictions
728 739

  
729
res_pix <- 1200
740
#res_pix <- 1200
730 741
#res_pix <- 480
731
col_mfrow <- 1
732
row_mfrow <- 1
742
#col_mfrow <- 1
743
#row_mfrow <- 1
733 744

  
734
png(filename=paste("Figure9a_raster_map_number_daily_predictions_forr_","mod1","_",out_prefix,".png",sep=""),
735
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
745
#png(filename=paste("Figure9a_raster_map_number_daily_predictions_forr_","mod1","_",out_prefix,".png",sep=""),
746
#    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
736 747

  
737
print(p)
748
#print(p)
738 749

  
739
dev.off()
750
#dev.off()
740 751

  
741 752
## Figure 9a
742
p0 <- levelplot(mod2_stack,layer=21,margin=F)
743
p <- p0+p_shp
753
#p0 <- levelplot(mod2_stack,layer=21,margin=F)
754
#p <- p0+p_shp
744 755

  
745
res_pix <- 1200
756
#res_pix <- 1200
746 757
#res_pix <- 480
747
col_mfrow <- 1
748
row_mfrow <- 1
749
png(filename=paste("Figure9a_raster_map_number_daily_predictions_for_","mod2","_",out_prefix,".png",sep=""),
750
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
758
#col_mfrow <- 1
759
#row_mfrow <- 1
760
#png(filename=paste("Figure9a_raster_map_number_daily_predictions_for_","mod2","_",out_prefix,".png",sep=""),
761
#    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
751 762

  
752
print(p)
763
#print(p)
753 764

  
754
dev.off()
765
#dev.off()
755 766

  
756 767
#plot(mod_kr_stack,y=21)
757 768

  
758 769
########
759 770
###Figure 9b: RMSE plots
760 771
##
761
p0 <- levelplot(mod1_stack,layer=10,margin=F,col.regions=matlab.like(25),
762
                main="Average RMSE for mod1")
763
p<- p0+p_shp
772
#p0 <- levelplot(mod1_stack,layer=10,margin=F,col.regions=matlab.like(25),
773
#                main="Average RMSE for mod1")
774
#p<- p0+p_shp
764 775

  
765
res_pix <- 1200
776
#res_pix <- 1200
766 777
#res_pix <- 480
767
col_mfrow <- 1
768
row_mfrow <- 1
769
png(filename=paste("Figure9b_raster_map_rmse_predictions_for_","mod1","_",out_prefix,".png",sep=""),
770
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
778
#col_mfrow <- 1
779
#row_mfrow <- 1
780
#png(filename=paste("Figure9b_raster_map_rmse_predictions_for_","mod1","_",out_prefix,".png",sep=""),
781
#    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
771 782

  
772
print(p)
783
#print(p)
773 784

  
774
dev.off()
785
#dev.off()
775 786

  
776 787
#print(p)
777
p0 <- levelplot(mod2_stack,layer=10,margin=F,col.regions=matlab.like(25),
778
                main="Average RMSE for mod2")
779
p<- p0+p_shp
788
#p0 <- levelplot(mod2_stack,layer=10,margin=F,col.regions=matlab.like(25),
789
#                main="Average RMSE for mod2")
790
#p<- p0+p_shp
780 791
#print(p)
781 792

  
782
res_pix <- 1200
793
#res_pix <- 1200
783 794
#res_pix <- 480
784
col_mfrow <- 1
785
row_mfrow <- 1
786
png(filename=paste("Figure9b_raster_map_rmse_predictions_for_","mod2","_",out_prefix,".png",sep=""),
787
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
795
#col_mfrow <- 1
796
#row_mfrow <- 1
797
#png(filename=paste("Figure9b_raster_map_rmse_predictions_for_","mod2","_",out_prefix,".png",sep=""),
798
#    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
788 799

  
789
print(p)
800
#print(p)
790 801

  
791
dev.off()
802
#dev.off()
792 803

  
793 804
#plot(mod1_stack,y=10)
794 805
#plot(mod2_stack,y=10)
......
808 819
#out_suffix <-out_prefix  
809 820

  
810 821
#first need to join x and y coord
811
date_selected <- "20100101"
812
mod_selected <- "mod1"
813
var_selected <- "rmse"
814
#test2_data_tb <- merge(df_tile_processed,test2,by="tile_id",all=T) #keep all
815

  
816
#l_date_selected <- unique(tb$date)
817
idx <- seq(as.Date('2010-01-01'), as.Date('2010-12-31'), 'day')
818
#idx <- seq(as.Date('2010-01-01'),by="day", length=365)
819

  
820
#idx <- seq(as.Date('20100101'), as.Date('20101231'), 'day')
821
#date_l <- strptime(idx[1], "%Y%m%d") # interpolation date being processed
822
l_date_selected <- format(idx, "%Y%m%d") # interpolation date being processed
823
tb_dat <- tb
824
proj_str <- CRS_WGS84
825
list_param_raster_from_tb <- list(tb_dat,df_tile_processed,l_date_selected,
826
                                  mod_selected,var_selected,out_suffix,
827
                                  proj_str,file_format,NA_value,NA_flag_val)
828

  
829
names(list_param_raster_from_tb) <- c("tb_dat","df_tile_processed","date_selected",
830
                                      "mod_selected","var_selected","out_suffix",
831
                                      "proj_str","file_format","NA_value","NA_flag_val")
832
#undebug(create_raster_from_tb_diagnostic)
833
rast <- create_raster_from_tb_diagnostic (i,list_param=list_param_raster_from_tb)
834
l_rast <- lapply(1:length(l_date_selected),FUN=create_raster_from_tb_diagnostic,list_param=list_param_raster_from_tb)
835
r_mod1_rmse <- stack(l_rast)
836
list_param_raster_from_tb$var_selected <- "n"
837
l_rast_n<- lapply(1:length(l_date_selected),FUN=create_raster_from_tb_diagnostic,list_param=list_param_raster_from_tb)
838
r_mod1_n <- stack(l_rast_n)
839

  
840
##now stack for mod2
841

  
842
list_param_raster_from_tb$mod_selected <- "mod2"
843
list_param_raster_from_tb$var_selected <- "rmse"
844
l_rast <- lapply(1:length(l_date_selected),FUN=create_raster_from_tb_diagnostic,list_param=list_param_raster_from_tb)
845
r_mod2_rmse <- stack(l_rast)
846
list_param_raster_from_tb$var_selected <- "n"
847
l_rast_n<- lapply(1:length(l_date_selected),FUN=create_raster_from_tb_diagnostic,list_param=list_param_raster_from_tb)
848
r_mod2_n <- stack(l_rast_n)
849

  
850
#r_mod2_n <- stack(list.files(pattern="r_nn_mod2.*.rst"))
851
#r_mod1_n <- stack(list.files(pattern="r_nn_mod1.*.rst"))
852

  
853
l_rast_n[[1]]
854
#"./r_nn_mod2_20101231_run7_global_analyses_10042014.rst"
855

  
856
# Create a raster stack with time series tag
857
r_mod2_rmse <- setZ(r_mod2_rmse, idx)
858
names(r_mod2_rmse) <- l_date_selected
859
r_mod2_n <- setZ(r_mod2_n, idx)
860
names(r_mod2_n) <- l_date_selected
861

  
862
writeRaster(r_mod2_n,by=F)
863

  
864
levelplot(r_mod2_rmse,layers=1:12,panel=panel.levelplot.raster, col.regions=matlab.like(25))+p_shp
865

  
866
p_hist <- histogram(r_mod2_rmse,FUN=as.yearmon)
867
p_hist2 <- p_hist
868
print(p_hist)
869
p_hist$x.limits <- rep(list(c(-2,6)),12)
870
print(p_hist)
871
p_bw <- bwplot(r_mod2_rmse,FUN=as.yearmon)
872
print(p_bw)
873
p_bw2 <- p_bw
874
p_bw2$y.limits <- c(-2,6)
875
print(p_bw2)
876
r_mod2_rmse_m <- zApply(r_mod2_rmse,by=as.yearmon,fun="mean")
877
p_lev_rmse_m <- levelplot(r_mod2_rmse_m,panel=panel.levelplot.raster,col.regions=matlab.like(25)) + p_shp
878
print(p_lev_rmse_m)
879

  
880
## analysis of the daily nmber of validation stations per tile
881
r_mod2_n_m <- zApply(r_mod2_n,by=as.yearmon,fun="mean")
882
p_lev_n_m <- levelplot(r_mod2_n_m,panel=panel.levelplot.raster,col.regions=matlab.like(25))+p_shp
883
print(p_lev_n_m)
884

  
885
p_bw_n2 <- bwplot(r_mod2_n,FUN=as.yearmon,do.out=F)
886
print(p_bw_n)
887
p_bw_n$y.limits <- c(0,16)
888
print(p_bw_n)
889
p_ho <- hovmoller(r_mod2_rmse)
890

  
891
p_lev_n <- levelplot(r_mod2_n,layers=1:12,panel=panel.levelplot.raster, col.regions=matlab.like(25))+p_shp
892

  
893
print(p_lev_n)
894

  
895
### mod1
896

  
897
#as(r_mod2_rmse)
898

  
899
#Make this a function...
900
#test <- subset(tb,pred_mod=="mod1" & date=="20100101",select=c("tile_id","n","mae","rmse","me","r","m50"))
901

  
902
plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
903
mod_selected <- "mod2"
904
plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
905
mod_selected <- "mod1"
906
date_selected  <- "20100901"
907
plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
908

  
909
list_date_selected <- c("20100101","20100901")
910
for (i in 1:length(list_date_selected)){
911
  mod_selected <- "mod1"
912
  date_selected  <- list_date_selected[i]
913
  var_selected <- "rmse"
914
  plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
915
  var_selected <- "n"
916
  plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
917
}
918

  
919
list_date_selected <- c("20100101","20100901")
920
for (i in 1:length(list_date_selected)){
921
  mod_selected <- "mod2"
922
  date_selected  <- list_date_selected[i]
923
  var_selected <- "rmse"
924
  plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
925
  var_selected <- "n"
926
  plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
927
}
928

  
929

  
930
# dd <- merge(df_tile_processed,pred_data_month_info,by="tile_id")
931
# coordinates(dd) <- c(dd$x,dd$y)
822
# date_selected <- "20100101"
823
# mod_selected <- "mod1"
824
# var_selected <- "rmse"
825
# #test2_data_tb <- merge(df_tile_processed,test2,by="tile_id",all=T) #keep all
826
# 
827
# #l_date_selected <- unique(tb$date)
828
# idx <- seq(as.Date('2010-01-01'), as.Date('2010-12-31'), 'day')
829
# #idx <- seq(as.Date('2010-01-01'),by="day", length=365)
830
# 
831
# #idx <- seq(as.Date('20100101'), as.Date('20101231'), 'day')
832
# #date_l <- strptime(idx[1], "%Y%m%d") # interpolation date being processed
833
# l_date_selected <- format(idx, "%Y%m%d") # interpolation date being processed
834
# tb_dat <- tb
835
# proj_str <- CRS_WGS84
836
# list_param_raster_from_tb <- list(tb_dat,df_tile_processed,l_date_selected,
837
#                                   mod_selected,var_selected,out_suffix,
838
#                                   proj_str,file_format,NA_value,NA_flag_val)
839
# 
840
# names(list_param_raster_from_tb) <- c("tb_dat","df_tile_processed","date_selected",
841
#                                       "mod_selected","var_selected","out_suffix",
842
#                                       "proj_str","file_format","NA_value","NA_flag_val")
843
# #undebug(create_raster_from_tb_diagnostic)
844
# rast <- create_raster_from_tb_diagnostic (i,list_param=list_param_raster_from_tb)
845
# l_rast <- lapply(1:length(l_date_selected),FUN=create_raster_from_tb_diagnostic,list_param=list_param_raster_from_tb)
846
# r_mod1_rmse <- stack(l_rast)
847
# list_param_raster_from_tb$var_selected <- "n"
848
# l_rast_n<- lapply(1:length(l_date_selected),FUN=create_raster_from_tb_diagnostic,list_param=list_param_raster_from_tb)
849
# r_mod1_n <- stack(l_rast_n)
850
# 
851
# ##now stack for mod2
852
# 
853
# list_param_raster_from_tb$mod_selected <- "mod2"
854
# list_param_raster_from_tb$var_selected <- "rmse"
855
# l_rast <- lapply(1:length(l_date_selected),FUN=create_raster_from_tb_diagnostic,list_param=list_param_raster_from_tb)
856
# r_mod2_rmse <- stack(l_rast)
857
# list_param_raster_from_tb$var_selected <- "n"
858
# l_rast_n<- lapply(1:length(l_date_selected),FUN=create_raster_from_tb_diagnostic,list_param=list_param_raster_from_tb)
859
# r_mod2_n <- stack(l_rast_n)
860
# 
861
# #r_mod2_n <- stack(list.files(pattern="r_nn_mod2.*.rst"))
862
# #r_mod1_n <- stack(list.files(pattern="r_nn_mod1.*.rst"))
863
# 
864
# l_rast_n[[1]]
865
# #"./r_nn_mod2_20101231_run7_global_analyses_10042014.rst"
866
# 
867
# # Create a raster stack with time series tag
868
# r_mod2_rmse <- setZ(r_mod2_rmse, idx)
869
# names(r_mod2_rmse) <- l_date_selected
870
# r_mod2_n <- setZ(r_mod2_n, idx)
871
# names(r_mod2_n) <- l_date_selected
872
# 
873
# writeRaster(r_mod2_n,by=F)
874
# 
875
# levelplot(r_mod2_rmse,layers=1:12,panel=panel.levelplot.raster, col.regions=matlab.like(25))+p_shp
876
# 
877
# p_hist <- histogram(r_mod2_rmse,FUN=as.yearmon)
878
# p_hist2 <- p_hist
879
# print(p_hist)
880
# p_hist$x.limits <- rep(list(c(-2,6)),12)
881
# print(p_hist)
882
# p_bw <- bwplot(r_mod2_rmse,FUN=as.yearmon)
883
# print(p_bw)
884
# p_bw2 <- p_bw
885
# p_bw2$y.limits <- c(-2,6)
886
# print(p_bw2)
887
# r_mod2_rmse_m <- zApply(r_mod2_rmse,by=as.yearmon,fun="mean")
888
# p_lev_rmse_m <- levelplot(r_mod2_rmse_m,panel=panel.levelplot.raster,col.regions=matlab.like(25)) + p_shp
889
# print(p_lev_rmse_m)
890
# 
891
# ## analysis of the daily nmber of validation stations per tile
892
# r_mod2_n_m <- zApply(r_mod2_n,by=as.yearmon,fun="mean")
893
# p_lev_n_m <- levelplot(r_mod2_n_m,panel=panel.levelplot.raster,col.regions=matlab.like(25))+p_shp
894
# print(p_lev_n_m)
895
# 
896
# p_bw_n2 <- bwplot(r_mod2_n,FUN=as.yearmon,do.out=F)
897
# print(p_bw_n)
898
# p_bw_n$y.limits <- c(0,16)
899
# print(p_bw_n)
900
# p_ho <- hovmoller(r_mod2_rmse)
901
# 
902
# p_lev_n <- levelplot(r_mod2_n,layers=1:12,panel=panel.levelplot.raster, col.regions=matlab.like(25))+p_shp
903
# 
904
# print(p_lev_n)
905
# 
906
# ### mod1
907
# 
908
# #as(r_mod2_rmse)
909
# 
910
# #Make this a function...
911
# #test <- subset(tb,pred_mod=="mod1" & date=="20100101",select=c("tile_id","n","mae","rmse","me","r","m50"))
912
# 
913
# plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
914
# mod_selected <- "mod2"
915
# plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
916
# mod_selected <- "mod1"
917
# date_selected  <- "20100901"
918
# plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
919
# 
920
# list_date_selected <- c("20100101","20100901")
921
# for (i in 1:length(list_date_selected)){
922
#   mod_selected <- "mod1"
923
#   date_selected  <- list_date_selected[i]
924
#   var_selected <- "rmse"
925
#   plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
926
#   var_selected <- "n"
927
#   plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
928
# }
929
# 
930
# list_date_selected <- c("20100101","20100901")
931
# for (i in 1:length(list_date_selected)){
932
#   mod_selected <- "mod2"
933
#   date_selected  <- list_date_selected[i]
934
#   var_selected <- "rmse"
935
#   plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
936
#   var_selected <- "n"
937
#   plot_raster_tb_diagnostic(reg_layer,tb_dat,df_tile_processed,date_selected,mod_selected,var_selected,out_suffix)
938
# }
939
# 
932 940
# 
941
# # dd <- merge(df_tile_processed,pred_data_month_info,by="tile_id")
942
# # coordinates(dd) <- c(dd$x,dd$y)
943
# # 
933 944

  
934 945
######################
935 946
### Figure 9: Plot the number of stations in a processing tile

Also available in: Unified diff