Project

General

Profile

« Previous | Next » 

Revision 8ead75c3

Added by Benoit Parmentier almost 9 years ago

slidify presentation using input assessment figure table from stage 6

View differences:

climate/research/oregon/interpolation/global_run_scalingup_assessment_part2_functions.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: 09/23/2015            
9
#Version: 4
8
#MODIFIED ON: 01/03/2016            
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 
12 12
#TODO:
......
47 47

  
48 48
#### FUNCTION USED IN SCRIPT
49 49

  
50
function_analyses_paper1 <-"contribution_of_covariates_paper_interpolation_functions_07182014.R" #first interp paper
51
function_analyses_paper2 <-"multi_timescales_paper_interpolation_functions_08132014.R"
50
#function_analyses_paper1 <-"contribution_of_covariates_paper_interpolation_functions_07182014.R" #first interp paper
51
#function_analyses_paper2 <-"multi_timescales_paper_interpolation_functions_08132014.R"
52 52

  
53 53
load_obj <- function(f)
54 54
{
......
358 358

  
359 359
}
360 360

  
361
############################################
362
#### Parameters and constants  
363

  
364
#on ATLAS
365
#in_dir1 <- "/data/project/layers/commons/NEX_data/test_run1_03232014/output" #On Atlas
366
#parent output dir : contains subset of the data produced on NEX
367
#in_dir1 <- "/data/project/layers/commons/NEX_data/output_run6_global_analyses_09162014/output20Deg2"
368
# parent output dir for the curent script analyes
369
#out_dir <-"/data/project/layers/commons/NEX_data/output_run3_global_analyses_06192014/" #On NCEAS Atlas
370
# input dir containing shapefiles defining tiles
371
#in_dir_shp <- "/data/project/layers/commons/NEX_data/output_run5_global_analyses_08252014/output/subset/shapefiles"
372

  
373
#On NEX
374
#contains all data from the run by Alberto
375
#in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output4" #On NEX
376
#parent output dir for the current script analyes
377
#out_dir <- "/nobackup/bparmen1/" #on NEX
378
#in_dir_shp <- "/nobackupp4/aguzman4/climateLayers/output4/subset/shapefiles/"
379

  
380
y_var_name <- "dailyTmax" #PARAM1
381
interpolation_method <- c("gam_CAI") #PARAM2
382
#out_suffix<-"run10_global_analyses_01282015"
383
#out_suffix <- "output_run10_1000x3000_global_analyses_02102015"
384
out_suffix <- "run10_1500x4500_global_analyses_pred_1982_09152015" #PARAM3
385
out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_pred_1982_09152015" #PARAM4
386
create_out_dir_param <- FALSE #PARAM 5
387

  
388
mosaic_plot <- FALSE #PARAM6
389

  
390
#if daily mosaics NULL then mosaicas all days of the year
391

  
392
day_to_mosaic <- c("19820101","19820102","19820103","19820104","19820105",
393
                   "19820106","19820107","19820108","19820109","19820110",
394
                   "1982011")
395

  
396
CRS_WGS84 <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 #CONSTANT1
397
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
398

  
399
proj_str<- CRS_WGS84 #PARAM 8 #check this parameter
400
file_format <- ".rst" #PARAM 9
401
NA_value <- -9999 #PARAM10
402
NA_flag_val <- NA_value
403
                                   
404
tile_size <- "1500x4500" #PARAM 11
405
multiple_region <- TRUE #PARAM 12
406

  
407
region_name <- "world" #PARAM 13
408
plot_region <- TRUE
409
num_cores <- 6 #PARAM 14
410
reg_modified <- TRUE
411
region <- c("reg4") #reference region to merge if necessary #PARAM 16
412

  
413
########################## START SCRIPT ##############################
414

  
415

  
416
####### PART 1: Read in data ########
417

  
418
if(create_out_dir_param==TRUE){
419
  out_dir <- create_dir_fun(out_dir,out_suffix)
420
  setwd(out_dir)
421
}else{
422
  setwd(out_dir) #use previoulsy defined directory
423
}
424

  
425
setwd(out_dir)
426

  
427
###Table 1: Average accuracy metrics
428
###Table 2: daily accuracy metrics for all tiles
429

  
430
summary_metrics_v <- read.table(file=file.path(out_dir,paste("summary_metrics_v2_NA_",out_suffix,".txt",sep="")),sep=",")
431
#fname <- file.path(out_dir,paste("summary_metrics_v2_NA_",out_suffix,".txt",sep=""))
432
tb <- read.table(file=file.path(out_dir,paste("tb_diagnostic_v_NA","_",out_suffix,".txt",sep="")),sep=",")
433
#tb_diagnostic_s_NA_run10_global_analyses_11302014.txt
434
tb_s <- read.table(file=file.path(out_dir,paste("tb_diagnostic_s_NA","_",out_suffix,".txt",sep="")),sep=",")
435

  
436
tb_month_s <- read.table(file=file.path(out_dir,paste("tb_month_diagnostic_s_NA","_",out_suffix,".txt",sep="")),sep=",")
437
pred_data_month_info <- read.table(file=file.path(out_dir,paste("pred_data_month_info_",out_suffix,".txt",sep="")),sep=",")
438
pred_data_day_info <- read.table(file=file.path(out_dir,paste("pred_data_day_info_",out_suffix,".txt",sep="")),sep=",")
439
df_tile_processed <- read.table(file=file.path(out_dir,paste("df_tile_processed_",out_suffix,".txt",sep="")),sep=",")
440

  
441
#add column for tile size later on!!!
442

  
443
tb$pred_mod <- as.character(tb$pred_mod)
444
summary_metrics_v$pred_mod <- as.character(summary_metrics_v$pred_mod)
445
summary_metrics_v$tile_id <- as.character(summary_metrics_v$tile_id)
446
df_tile_processed$tile_id <- as.character(df_tile_processed$tile_id)
447

  
448
tb_month_s$pred_mod <- as.character(tb_month_s$pred_mod)
449
tb_month_s$tile_id<- as.character(tb_month_s$tile_id)
450
tb_s$pred_mod <- as.character(tb_s$pred_mod)
451
tb_s$tile_id <- as.character(tb_s$tile_id)
452

  
453

  
454
#multiple regions?
455
if(multiple_region==TRUE){
456
  df_tile_processed$reg <- basename(dirname(as.character(df_tile_processed$path_NEX)))
457
  
458
  tb <- merge(tb,df_tile_processed,by="tile_id")
459
  tb_s <- merge(tb_s,df_tile_processed,by="tile_id")
460
  tb_month_s<- merge(tb_month_s,df_tile_processed,by="tile_id")
461
  summary_metrics_v <- merge(summary_metrics_v,df_tile_processed,by="tile_id")
462

  
463
}
464

  
465
tb_all <- tb
466

  
467
summary_metrics_v_all <- summary_metrics_v 
468
#deal with additional tiles...
469
# if(reg_modified==T){
470
#   
471
#   summary_metrics_v_tmp <- summary_metrics_v
472
#   #summary_metrics_v_tmp$reg[summary_metrics_v_tmp$reg=="reg_1b"] <- "reg1"
473
#   #summary_metrics_v_tmp$reg[summary_metrics_v_tmp$reg=="reg_1c"] <- "reg1"
474
#   #summary_metrics_v_tmp$reg[summary_metrics_v_tmp$reg=="reg_3b"] <- "reg3"
475
#   summary_metrics_v_tmp$reg[summary_metrics_v_tmp$reg=="reg5b"] <- "reg5"
476
# 
477
#   summary_metrics_v_tmp$reg_all <- summary_metrics_v$reg
478
#   ###
479
#   summary_metrics_v<- summary_metrics_v_tmp
480
#   
481
#   ###
482
#   tb_tmp <- tb
483
#   #tb_tmp$reg[tb_tmp$reg=="reg_1b"] <- "reg1"
484
#   #tb_tmp$reg[tb_tmp$reg=="reg_1c"] <- "reg1"
485
#   #tb_tmp$reg[tb_tmp$reg=="reg_3b"] <- "reg3"
486
#   tb_tmp$reg[tb_tmp$reg=="reg5b"] <- "reg5"
487
# 
488
#   ###
489
#   tb <- tb_tmp
490
# }
491

  
492
table(summary_metrics_v_all$reg)
493
table(summary_metrics_v$reg)
494
table(tb_all$reg)
495
table(tb$reg)
496

  
497
############ PART 2: PRODUCE FIGURES ################
498

  
499
###########################
500
### Figure 1: plot location of the study area with tiles processed
501

  
502
#df_tiled_processed <- na.omit(df_tile_processed) #remove other list of folders irrelevant
503
#list_shp_reg_files <- df_tiled_processed$shp_files
504
list_shp_reg_files<- as.character(df_tile_processed$shp_files)
505
#list_shp_reg_files <- file.path("/data/project/layers/commons/NEX_data/",out_dir,
506
#          as.character(df_tile_processed$tile_coord),"shapefiles",basename(list_shp_reg_files))
507
list_shp_reg_files <- file.path("/data/project/layers/commons/NEX_data/",out_dir,
508
          "shapefiles",basename(list_shp_reg_files))
509

  
510
#table(summary_metrics_v$reg)
511
#table(summary_metrics_v$reg)
512

  
513
### Potential function starts here:
514
#function(in_dir,out_dir,list_shp_reg_files,title_str,region_name,num_cores,out_suffix,out_suffix)
515

  
516
### First get background map to display where study area is located
517
#can make this more general later on..should have this already in a local directory on Atlas or NEX!!!!
518

  
519
if (region_name=="USA"){
520
  usa_map <- getData('GADM', country='USA', level=1) #Get US map
521
  #usa_map <- getData('GADM', country=region_name,level=1) #Get US map, this is not working right now
522
  usa_map <- usa_map[usa_map$NAME_1!="Alaska",] #remove Alaska
523
  reg_layer <- usa_map[usa_map$NAME_1!="Hawaii",] #remove Hawai 
524
}
525

  
526
if (region_name=="world"){
527
  #http://www.diva-gis.org/Data
528
  countries_shp <-"/data/project/layers/commons/NEX_data/countries.shp"
529
  path_to_shp <- dirname(countries_shp)
530
  layer_name <- sub(".shp","",basename(countries_shp))
531
  reg_layer <- readOGR(path_to_shp, layer_name)
532
  #proj4string(reg_layer) <- CRS_locs_WGS84
533
  #reg_shp<-readOGR(dirname(list_shp_reg_files[[i]]),sub(".shp","",basename(list_shp_reg_files[[i]])))
534
}
535

  
536
centroids_pts <- vector("list",length(list_shp_reg_files))
537
shps_tiles <- vector("list",length(list_shp_reg_files))
538
#collect info: read in all shapfiles
539
#This is slow...make a function and use mclapply??
540
#/data/project/layers/commons/NEX_data/output_run6_global_analyses_09162014/shapefiles
541
  
542
for(i in 1:length(list_shp_reg_files)){
543
  #path_to_shp <- dirname(list_shp_reg_files[[i]])
544
  path_to_shp <- file.path(out_dir,"/shapefiles")
545
  layer_name <- sub(".shp","",basename(list_shp_reg_files[[i]]))
546
  shp1 <- try(readOGR(path_to_shp, layer_name)) #use try to resolve error below
547
  #shp_61.0_-160.0
548
  #Geographical CRS given to non-conformant data: -186.331747678
549
 
550
  #shp1<-readOGR(dirname(list_shp_reg_files[[i]]),sub(".shp","",basename(list_shp_reg_files[[i]])))
551
  if (!inherits(shp1,"try-error")) {
552
      pt <- gCentroid(shp1)
553
      centroids_pts[[i]] <- pt
554
  }else{
555
    pt <- shp1
556
    centroids_pts[[i]] <- pt
557
  }
558
  shps_tiles[[i]] <- shp1
559
  #centroids_pts[[i]] <- centroids
560
}
561

  
562
#fun <- function(i,list_shp_files)
563
#coord_names <- c("lon","lat")
564
#l_ras#t <- rasterize_df_fun(test,coord_names,proj_str,out_suffix=out_suffix,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
565

  
566
#remove try-error polygons...we loose three tiles because they extend beyond -180 deg
567
tmp <- shps_tiles
568
shps_tiles <- remove_errors_list(shps_tiles) #[[!inherits(shps_tiles,"try-error")]]
569
#shps_tiles <- tmp
570
length(tmp)-length(shps_tiles) #number of tiles with error message
571

  
572
tmp_pts <- centroids_pts 
573
centroids_pts <- remove_errors_list(centroids_pts) #[[!inherits(shps_tiles,"try-error")]]
574
#centroids_pts <- tmp_pts 
575
  
576
#plot info: with labels
577
res_pix <-1200
578
col_mfrow <- 1 
579
row_mfrow <- 1
580

  
581
png(filename=paste("Figure1_tile_processed_region_",region_name,"_",out_suffix,".png",sep=""),
582
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
583

  
584
plot(reg_layer)
585
#Add polygon tiles...
586
for(i in 1:length(shps_tiles)){
587
  shp1 <- shps_tiles[[i]]
588
  pt <- centroids_pts[[i]]
589
  if(!inherits(shp1,"try-error")){
590
    plot(shp1,add=T,border="blue")
591
    #plot(pt,add=T,cex=2,pch=5)
592
    label_id <- df_tile_processed$tile_id[i]
593
    text(coordinates(pt)[1],coordinates(pt)[2],labels=i,cex=1.3,font=2,col=c("red"))
594
  }
595
}
596
#title(paste("Tiles ", tile_size,region_name,sep=""))
597

  
598
dev.off()
599
      
600
#unique(summaty_metrics$tile_id)
601
#text(lat-shp,)
602
#union(list_shp_reg_files[[1]],list_shp_reg_files[[2]])
603

  
604
###############
605
### Figure 2: boxplot of average accuracy by model and by tiles
606

  
607

  
608
tb$tile_id <- factor(tb$tile_id, levels=unique(tb$tile_id))
609

  
610
model_name <- as.character(unique(tb$pred_mod))
611

  
612

  
613
## Figure 2a
614

  
615
for(i in  1:length(model_name)){
616
  
617
  res_pix <- 480
618
  col_mfrow <- 1
619
  row_mfrow <- 1
620

  
621
  png(filename=paste("Figure2a_boxplot_with_oultiers_by_tiles_",model_name[i],"_",out_suffix,".png",sep=""),
622
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
623
  
624
  boxplot(rmse~tile_id,data=subset(tb,tb$pred_mod==model_name[i]))
625
  title(paste("RMSE per ",model_name[i]))
626
  
627
  dev.off()
628
}
629

  
630
## Figure 2b
631
#wtih ylim and removing trailing...
632
for(i in  1:length(model_name)){
633

  
634
  res_pix <- 480
635
  col_mfrow <- 1
636
  row_mfrow <- 1
637
  png(filename=paste("Figure2b_boxplot_scaling_by_tiles","_",model_name[i],"_",out_suffix,".png",sep=""),
638
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
639

  
640
  model_name <- unique(tb$pred_mod)
641
  boxplot(rmse~tile_id,data=subset(tb,tb$pred_mod==model_name[i])
642
          ,ylim=c(0,4),outline=FALSE)
643
  title(paste("RMSE per ",model_name[i]))
644
  dev.off()
645
}
646
#bwplot(rmse~tile_id, data=subset(tb,tb$pred_mod=="mod1"))
647

  
648
###############
649
### Figure 3: boxplot of average RMSE by model acrosss all tiles
650

  
651
## Figure 3a
652
res_pix <- 480
653
col_mfrow <- 1
654
row_mfrow <- 1
655

  
656
png(filename=paste("Figure3a_boxplot_overall_region_with_oultiers_",model_name[i],"_",out_suffix,".png",sep=""),
657
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
658

  
659
boxplot(rmse~pred_mod,data=tb)#,names=tb$pred_mod)
660
title("RMSE per model over all tiles")
661

  
662
dev.off()
663

  
664
## Figure 3b
665
png(filename=paste("Figure3b_boxplot_overall_region_scaling_",model_name[i],"_",out_suffix,".png",sep=""),
666
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
667

  
668
boxplot(rmse~pred_mod,data=tb,ylim=c(0,5),outline=FALSE)#,names=tb$pred_mod)
669
title("RMSE per model over all tiles")
670

  
671
dev.off()
672

  
673

  
674
################ 
675
### Figure 4: plot predicted tiff for specific date per model
676

  
677
#y_var_name <-"dailyTmax"
678
#index <-244 #index corresponding to Sept 1
679

  
680
# if (mosaic_plot==TRUE){
681
#   index  <- 1 #index corresponding to Jan 1
682
#   date_selected <- "20100901"
683
#   name_method_var <- paste(interpolation_method,"_",y_var_name,"_",sep="")
684
# 
685
#   pattern_str <- paste("mosaiced","_",name_method_var,"predicted",".*.",date_selected,".*.tif",sep="")
686
#   lf_pred_list <- list.files(pattern=pattern_str)
687
# 
688
#   for(i in 1:length(lf_pred_list)){
689
#     
690
#   
691
#     r_pred <- raster(lf_pred_list[i])
692
#   
693
#     res_pix <- 480
694
#     col_mfrow <- 1
695
#     row_mfrow <- 1
696
#   
697
#     png(filename=paste("Figure4_models_predicted_surfaces_",model_name[i],"_",name_method_var,"_",data_selected,"_",out_suffix,".png",sep=""),
698
#        width=col_mfrow*res_pix,height=row_mfrow*res_pix)
699
#   
700
#     plot(r_pred)
701
#     title(paste("Mosaiced",model_name[i],name_method_var,date_selected,sep=" "))
702
#     dev.off()
703
#   }
704
#   #Plot Delta and clim...
705
# 
706
#    ## plotting of delta and clim for later scripts...
707
# 
708
# }
709

  
710

  
711
######################
712
### Figure 5: plot accuracy ranked 
713

  
714
#Turn summary table to a point shp
715

  
716
list_df_ac_mod <- vector("list",length=length(model_name))
717
for (i in 1:length(model_name)){
718
  
719
  ac_mod <- summary_metrics_v[summary_metrics_v$pred_mod==model_name[i],]
720
  ### Ranking by tile...
721
  df_ac_mod <- arrange(as.data.frame(ac_mod),desc(rmse))[,c("pred_mod","rmse","mae","tile_id")]
722
  list_df_ac_mod[[i]] <- arrange(as.data.frame(ac_mod),desc(rmse))[,c("rmse","mae","tile_id")]
723
  
724
  res_pix <- 480
725
  col_mfrow <- 1
726
  row_mfrow <- 1
727

  
728
  png(filename=paste("Figure5_ac_metrics_ranked_",model_name[i],"_",out_suffix,".png",sep=""),
729
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
730
  x<- as.character(df_ac_mod$tile_id)
731
  barplot(df_ac_mod$rmse, names.arg=x)
732
  #plot(ac_mod1,cex=sqrt(ac_mod1$rmse),pch=1,add=T)
733
  #plot(ac_mod1,cex=(ac_mod1$rmse1)*2,pch=1,add=T)
734
  title(paste("RMSE ranked by tile for ",model_name[i],sep=""))
735

  
736
  dev.off()
737
  
738
}
739

  
740
######################
741
### Figure 6: plot map of average RMSE per tile at centroids
742

  
743
#Turn summary table to a point shp
744

  
745
# coordinates(summary_metrics_v) <- cbind(summary_metrics_v$lon,summary_metrics_v$lat)
746
# proj4string(summary_metrics_v) <- CRS_WGS84
747
# #lf_list <- lf_pred_list
748
# list_df_ac_mod <- vector("list",length=length(lf_pred_list))
749
# for (i in 1:length(lf_list)){
750
#   
751
#   ac_mod <- summary_metrics_v[summary_metrics_v$pred_mod==model_name[i],]
752
#   r_pred <- raster(lf_list[i])
753
#   
754
#   res_pix <- 480
755
#   col_mfrow <- 1
756
#   row_mfrow <- 1
757
# 
758
#   png(filename=paste("Figure6_ac_metrics_map_centroids_tile_",model_name[i],"_",out_suffix,".png",sep=""),
759
#     width=col_mfrow*res_pix,height=row_mfrow*res_pix)
760
# 
761
#   plot(r_pred)  
762
#   
763
#   #plot(ac_mod1,cex=sqrt(ac_mod1$rmse),pch=1,add=T)
764
#   plot(ac_mod,cex=(ac_mod$rmse^2)/10,pch=1,add=T)
765
#   #plot(ac_mod1,cex=(ac_mod1$rmse1)*2,pch=1,add=T)
766
#   title(paste("Averrage RMSE per tile and by ",model_name[i]))
767
# 
768
#   dev.off()
769
#   
770
#   ### Ranking by tile...
771
#   #df_ac_mod <- 
772
#   list_df_ac_mod[[i]] <- arrange(as.data.frame(ac_mod),desc(rmse))[,c("rmse","mae","tile_id")]
773
# }
774
  
775
#quick kriging...
776
#autokrige(rmse~1,r2,)
777

  
778

  
779
### Without 
780

  
781
#list_df_ac_mod <- vector("list",length=length(lf_pred_list))
782
list_df_ac_mod <- vector("list",length=2)
783

  
784
for (i in 1:length(model_name)){
785
  
786
  ac_mod <- summary_metrics_v[summary_metrics_v$pred_mod==model_name[i],]
787
  #r_pred <- raster(lf_list[i])
788
  
789
  res_pix <- 1200
790
  #res_pix <- 480
791

  
792
  col_mfrow <- 1
793
  row_mfrow <- 1
794

  
795
  png(filename=paste("Figure6_ac_metrics_map_centroids_tile_",model_name[i],"_",out_suffix,".png",sep=""),
796
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
797

  
798
  #plot(r_pred)  
799
  #plot(reg_layer)
800
  #plot(ac_mod1,cex=sqrt(ac_mod1$rmse),pch=1,add=T)
801
  #plot(ac_mod,cex=(ac_mod$rmse^2)/10,pch=1,col="red",add=T)
802

  
803
  #coordinates(ac_mod) <- ac_mod[,c("lon","lat")] 
804
  coordinates(ac_mod) <- ac_mod[,c("lon.x","lat.x")] #solve this later
805
  p_shp <- layer(sp.polygons(reg_layer, lwd=1, col='black'))
806
  #title("(a) Mean for 1 January")
807
  p <- bubble(ac_mod,"rmse",main=paste("Averrage RMSE per tile and by ",model_name[i]))
808
  p1 <- p+p_shp
809
  print(p1)
810
  #plot(ac_mod1,cex=(ac_mod1$rmse1)*2,pch=1,add=T)
811
  #title(paste("Averrage RMSE per tile and by ",model_name[i]))
812

  
813
  dev.off()
814
  
815
  ### Ranking by tile...
816
  #df_ac_mod <- 
817
  list_df_ac_mod[[i]] <- arrange(as.data.frame(ac_mod),desc(rmse))[,c("rmse","mae","tile_id")]
818
}
819

  
820
## Number of tiles with information:
821
sum(df_tile_processed$metrics_v) #26,number of tiles with raster object
822
length(df_tile_processed$metrics_v) #26,number of tiles in the region
823
sum(df_tile_processed$metrics_v)/length(df_tile_processed$metrics_v) #80 of tiles with info
824

  
825
#coordinates
826
#coordinates(summary_metrics_v) <- c("lon","lat")
827
coordinates(summary_metrics_v) <- c("lon.y","lat.y")
828

  
829
threshold_missing_day <- c(367,365,300,200)
830

  
831
nb<-nrow(subset(summary_metrics_v,model_name=="mod1"))  
832
sum(subset(summary_metrics_v,model_name=="mod1")$n_missing)/nb #33/35
833

  
834
## Make this a figure...
835

  
836
#plot(summary_metrics_v)
837
#Make this a function later so that we can explore many thresholds...
838

  
839
j<-1 #for model name 1
840
for(i in 1:length(threshold_missing_day)){
841
  
842
  #summary_metrics_v$n_missing <- summary_metrics_v$n == 365
843
  #summary_metrics_v$n_missing <- summary_metrics_v$n < 365
844
  summary_metrics_v$n_missing <- summary_metrics_v$n < threshold_missing_day[i]
845
  summary_metrics_v_subset <- subset(summary_metrics_v,model_name=="mod1")
846

  
847
  #res_pix <- 1200
848
  res_pix <- 960
849

  
850
  col_mfrow <- 1
851
  row_mfrow <- 1
852

  
853
  png(filename=paste("Figure7a_ac_metrics_map_centroids_tile_",model_name[j],"_","missing_day_",threshold_missing_day[i],
854
                     "_",out_suffix,".png",sep=""),
855
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
856
  
857
  model_name[j]
858
  
859
  p_shp <- layer(sp.polygons(reg_layer, lwd=1, col='black'))
860
  #title("(a) Mean for 1 January")
861
  p <- bubble(summary_metrics_v_subset,"n_missing",main=paste("Missing per tile and by ",model_name[j]," for ",
862
                                                              threshold_missing_day[i]))
863
  p1 <- p+p_shp
864
  print(p1)
865
  #plot(ac_mod1,cex=(ac_mod1$rmse1)*2,pch=1,add=T)
866
  #title(paste("Averrage RMSE per tile and by ",model_name[i]))
867

  
868
  dev.off()
869
}
870

  
871
######################
872
### Figure 7: Number of predictions: daily and monthly
873

  
874
#xyplot(rmse~pred_mod | tile_id,data=subset(as.data.frame(summary_metrics_v),
875
#                                           pred_mod!="mod_kr"),type="b")
876

  
877
#xyplot(n~pred_mod | tile_id,data=subset(as.data.frame(summary_metrics_v),
878
#                                           pred_mod!="mod_kr"),type="h")
879

  
880
#cor
881

  
882
# 
883
## Figure 7a
884
png(filename=paste("Figure7a_number_daily_predictions_per_models","_",out_suffix,".png",sep=""),
885
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
886

  
887
xyplot(n~pred_mod | tile_id,data=subset(as.data.frame(summary_metrics_v),
888
                                           pred_mod!="mod_kr"),type="h")
889
dev.off()
890

  
891
table(tb$pred_mod)
892
table(tb$index_d)
893
table(subset(tb,pred_mod!="mod_kr"))
894
table(subset(tb,pred_mod=="mod1")$index_d)
895
#aggregate()
896
tb$predicted <- 1
897
test <- aggregate(predicted~pred_mod+tile_id,data=tb,sum)
898
xyplot(predicted~pred_mod | tile_id,data=subset(as.data.frame(test),
899
                                           pred_mod!="mod_kr"),type="h")
900

  
901
test
902

  
903
as.character(unique(test$tile_id)) #141 tiles
904

  
905
dim(subset(test,test$predicted==365 & test$pred_mod=="mod1"))
906
histogram(subset(test, test$pred_mod=="mod1")$predicted)
907
unique(subset(test, test$pred_mod=="mod1")$predicted)
908
table((subset(test, test$pred_mod=="mod1")$predicted))
909

  
910
#LST_avgm_min <- aggregate(LST~month,data=data_month_all,min)
911
histogram(test$predicted~test$tile_id)
912
#table(tb)
913
## Figure 7b
914
#png(filename=paste("Figure7b_number_daily_predictions_per_models","_",out_suffix,".png",sep=""),
915
#    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
916

  
917
#xyplot(n~month | tile_id + pred_mod,data=subset(as.data.frame(tb_month_s),
918
#                                           pred_mod!="mod_kr"),type="h")
919
#xyplot(n~month | tile_id,data=subset(as.data.frame(tb_month_s),
920
#                                           pred_mod="mod_1"),type="h")
921
#test=subset(as.data.frame(tb_month_s),pred_mod="mod_1")
922
#table(tb_month_s$month)
923
#dev.off()
924
#
925

  
926

  
927
##########################################################
928
##### Figure 8: Breaking down accuracy by regions!! #####
929

  
930
#summary_metrics_v <- merge(summary_metrics_v,df_tile_processed,by="tile_id")
931

  
932
## Figure 8a
933
res_pix <- 480
934
col_mfrow <- 1
935
row_mfrow <- 1
936

  
937
png(filename=paste("Figure8a_boxplot_overall_separated_by_region_with_oultiers_",model_name[i],"_",out_suffix,".png",sep=""),
938
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
939

  
940
p<- bwplot(rmse~pred_mod | reg, data=tb,
941
           main="RMSE per model and region over all tiles")
942
print(p)
943
dev.off()
944

  
945
## Figure 8b
946
png(filename=paste("Figure8b_boxplot_overall_separated_by_region_scaling_",model_name[i],"_",out_suffix,".png",sep=""),
947
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
948

  
949
boxplot(rmse~pred_mod,data=tb,ylim=c(0,5),outline=FALSE)#,names=tb$pred_mod)
950
title("RMSE per model over all tiles")
951
p<- bwplot(rmse~pred_mod | reg, data=tb,ylim=c(0,5),
952
           main="RMSE per model and region over all tiles")
953
print(p)
954
dev.off()
955

  
956
#####################################################
957
#### Figure 9: plotting mosaics of regions ###########
958
## plot mosaics...
959

  
960
#First collect file names
961

  
962

  
963
#names(lf_mosaics_reg) <- l_reg_name
964

  
965
#This part should be automated...
966
#plot Australia
967
#lf_m <- lf_mosaics_reg[[2]]
968
#out_dir_str <- out_dir
969
#reg_name <- "reg6_1000x3000"
970
#lapply()
971
#list_param_plot_daily_mosaics <- list(lf_m=lf_m,reg_name=reg_name,out_dir_str=out_dir_str,out_suffix=out_suffix)
972
#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)
973

  
974
#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)
975
#debug(plot_daily_mosaics)
976
#lf_m_mask_reg6_1000x3000 <- plot_daily_mosaics(1,list_param=list_param_plot_daily_mosaics)
977

  
978
#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)
979

  
980

  
981
################## WORLD MOSAICS NEEDS MAJOR CLEAN UP OF CODE HERE
982
##make functions!!
983
###Combine mosaics with modified code from Alberto
984

  
985
#use list from above!!
986

  
987
# test_list <-list.files(path=file.path(out_dir,"mosaics"),    
988
#            pattern=paste("^world_mosaics.*.tif$",sep=""), 
989
# )
990
# #world_mosaics_mod1_output1500x4500_km_20101105_run10_1500x4500_global_analyses_03112015.tif
991
# 
992
# #test_list<-lapply(1:30,FUN=function(i){lapply(1:x[[i]]},x=lf_mosaics_mask_reg)
993
# #test_list<-unlist(test_list)
994
# #mosaic_list_mean <- vector("list",length=1)
995
# mosaic_list_mean <- test_list 
996
# out_rastnames <- "world_test_mosaic_20100101"
997
# out_path <- out_dir
998
# 
999
# list_param_mosaic<-list(mosaic_list_mean,out_path,out_rastnames,file_format,NA_flag_val,out_suffix)
1000
# names(list_param_mosaic)<-c("mosaic_list","out_path","out_rastnames","file_format","NA_flag_val","out_suffix")
1001
# #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
1002
# 
1003
# lf <- mosaic_m_raster_list(1,list_param_mosaic)
1004
# 
1005
# debug(mosaic_m_raster_list)
1006
# mosaic_list<-list_param$mosaic_list
1007
# out_path<-list_param$out_path
1008
# out_names<-list_param$out_rastnames
1009
# file_format <- list_param$file_format
1010
# NA_flag_val <- list_param$NA_flag_val
1011
# out_suffix <- list_param$out_suffix
1012

  
1013
##Now mosaic for mean: should reorder files!!
1014
#out_rastnames_mean<-paste("_",lst_pat,"_","mean",out_suffix,sep="")
1015
#list_date_names<-c("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
1016
#mosaic_list<-split(tmp_str1,list_date_names)
1017
#new_list<-vector("list",length(mosaic_list))
1018
# for (i in 1:length(list_date_names)){
1019
#    j<-grep(list_date_names[i],mosaic_list,value=FALSE)
1020
#    names(mosaic_list)[j]<-list_date_names[i]
1021
#    new_list[i]<-mosaic_list[j]
1022
#  }
1023
#  mosaic_list_mean <-new_list #list ready for mosaicing
1024
#  out_rastnames_mean<-paste(list_date_names,out_rastnames_mean,sep="")
1025
  
1026
  ### Now mosaic tiles...Note that function could be improved to use less memory
1027

  
1028

  
1029
################## PLOTTING WORLD MOSAICS ################
1030

  
1031
#lf_world_pred <-list.files(path=file.path(out_dir,"mosaics"),    
1032
#           pattern=paste("^world_mosaics.*.tif$",sep=""),full.names=T) 
1033

  
1034
lf_world_pred <-list.files(path=file.path(out_dir,"mosaics"),    
1035
           pattern=paste("^reg5.*.",".tif$",sep=""),full.names=T) 
1036
l_reg_name <- unique(df_tile_processed$reg)
1037
lf_world_pred <-list.files(path=file.path(out_dir,l_reg_name[[i]]),    
1038
           pattern=paste(".tif$",sep=""),full.names=T) 
1039

  
1040
#mosaic_list_mean <- test_list 
1041
#out_rastnames <- "world_test_mosaic_20100101"
1042
#out_path <- out_dir
1043

  
1044
#lf_world_pred <- list.files(pattern="world.*2010090.*.tif$")
1045
#lf_raster_fname <- list.files(pattern="world.*2010*.*02162015.tif$",full.names=T)
1046
lf_raster_fname <- lf_world_pred
1047
prefix_str <- "Figure10_clim_world_mosaics_day_"
1048
l_dates <-day_to_mosaic
1049
screenRast=FALSE
1050
list_param_plot_screen_raster <- list(lf_raster_fname,screenRast,l_dates,out_dir,prefix_str,out_suffix)
1051
names(list_param_plot_screen_raster) <- c("lf_raster_fname","screenRast","l_dates","out_dir_str","prefix_str","out_suffix_str")
1052

  
1053
debug(plot_screen_raster_val)
1054

  
1055
world_m_list1<- plot_screen_raster_val(1,list_param_plot_screen_raster)
1056
#world_m_list <- mclapply(11:30, list_param=list_param_plot_screen_raster, plot_screen_raster_val,mc.preschedule=FALSE,mc.cores = num_cores) #This is the end bracket from mclapply(...) statement
1057
world_m_list <- mclapply(1:length(l_dates), list_param=list_param_plot_screen_raster, plot_screen_raster_val,mc.preschedule=FALSE,mc.cores = num_cores) #This is the end bracket from mclapply(...) statement
1058

  
1059
s_pred <- stack(lf_raster_fname)
1060

  
1061
res_pix <- 1500
1062
col_mfrow <- 3 
1063
row_mfrow <- 2
1064

  
1065
png(filename=paste("Figure10_levelplot_combined_",region_name,"_",out_suffix,".png",sep=""),
1066
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
1067

  
1068
levelplot(s_pred,layers=1:6,col.regions=rev(terrain.colors(255)),cex=4)
1069

  
1070
dev.off()
1071

  
1072
#   blues<- designer.colors(6, c( "blue", "white") )
1073
# reds <- designer.colors(6, c( "white","red")  )
1074
# colorTable<- c( blues[-6], reds)
1075
# breaks with a gap of 10 to 17 assigned the white color
1076
# brks<- c(seq( 1, 10,,6), seq( 17, 25,,6)) 
1077
# image.plot( x,y,z,breaks=brks, col=colorTable)
1078
#
1079

  
1080
#lf_world_mask_reg <- vector("list",length=length(lf_world_pred))
1081
#for(i in 1:length(lf_world_pred)){
1082
  #
1083
#  lf_m <- lf_mosaics_reg[i]
1084
#  out_dir_str <- out_dir
1085
  #reg_name <- paste(l_reg_name[i],"_",tile_size,sep="") #make this automatic
1086
  #lapply()
1087
#  list_param_plot_daily_mosaics <- list(lf_m=lf_m,reg_name=tile_size,out_dir_str=out_dir_str,out_suffix=out_suffix,l_dates=day_to_mosaic)
1088
  #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)
1089

  
1090
  #lf_world_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)
1091
}
1092

  
1093
############# NEW MASK AND DATA
1094
## Plot areas and day predicted as first check
1095
  
1096
l_reg_name <- unique(df_tile_processed$reg)
1097
#(subset(df_tile_processed$reg == l_reg_name[i],date)
1098

  
1099
for(i in 1:length(l_reg_name)){
1100
  lf_world_pred<-list.files(path=file.path(out_dir,l_reg_name[[i]]),    
1101
           pattern=paste(".tif$",sep=""),full.names=T) 
1102

  
1103
  #mosaic_list_mean <- test_list 
1104
  #out_rastnames <- "world_test_mosaic_20100101"
1105
  #out_path <- out_dir
1106

  
1107
  #lf_world_pred <- list.files(pattern="world.*2010090.*.tif$")
1108
  #lf_raster_fname <- list.files(pattern="world.*2010*.*02162015.tif$",full.names=T)
1109
  lf_raster_fname <- lf_world_pred
1110
  prefix_str <- paste("Figure10_",l_reg_name[i],sep="")
1111

  
1112
  l_dates <- basename(lf_raster_fname)
1113
  tmp_name <- gsub(".tif","",l_dates)
1114
  tmp_name <- gsub("gam_CAI_dailyTmax_predicted_mod1_0_1_","",tmp_name)
1115
  #l_dates <- tmp_name
1116
  l_dates <- paste(l_reg_name[i],"_",tmp_name,sep="")
1117

  
1118
  screenRast=TRUE
1119
  list_param_plot_screen_raster <- list(lf_raster_fname,screenRast,l_dates,out_dir,prefix_str,out_suffix)
1120
  names(list_param_plot_screen_raster) <- c("lf_raster_fname","screenRast","l_dates","out_dir_str","prefix_str","out_suffix_str")
1121

  
1122
  #undebug(plot_screen_raster_val)
1123

  
1124
  #world_m_list1<- plot_screen_raster_val(1,list_param_plot_screen_raster)
1125
  #world_m_list <- mclapply(11:30, list_param=list_param_plot_screen_raster, plot_screen_raster_val,mc.preschedule=FALSE,mc.cores = num_cores) #This is the end bracket from mclapply(...) statement
1126
  world_m_list <- mclapply(1:length(l_dates), list_param=list_param_plot_screen_raster, plot_screen_raster_val,mc.preschedule=FALSE,mc.cores = num_cores) #This is the end bracket from mclapply(...) statement
1127

  
1128
  #s_pred <- stack(lf_raster_fname)
1129

  
1130
  #res_pix <- 1500
1131
  #col_mfrow <- 3 
1132
  #row_mfrow <- 2
1133

  
1134
  #png(filename=paste("Figure10_levelplot_combined_",region_name,"_",out_suffix,".png",sep=""),
1135
  #  width=col_mfrow*res_pix,height=row_mfrow*res_pix)
1136

  
1137
  #levelplot(s_pred,layers=1:6,col.regions=rev(terrain.colors(255)),cex=4)
1138

  
1139
  #dev.off()
1140
}
1141

  
1142

  
1143 361
  
1144 362
##################### END OF SCRIPT ######################
climate/research/oregon/interpolation/presentation_summary_world.Rmd
1 1
---
2
title       : Summary for year 1992, region 4 -Africa
2
title       : Summary for year 1982, region 4 -Africa
3 3
subtitle    : Global assessment interpolation
4 4
author      : Benoit Parmentier and Alberto Guzman
5 5
job         : NEX job world
......
11 11
knit        : slidify::knit2slides
12 12
---
13 13

  
14
```{r,echo=F}
14
```{r,echo=FALSE}
15 15

  
16 16
#First let's set up the input parameters for the script in R:
17

  
18
in_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_pred_1992_09012015"
19

  
20
#region_name <- "world" #PARAM 13 #reg4 South America, Africa reg5,Europe reg2, North America reg1, Asia reg3
21
#mosaicing_method <- c("unweighted","use_edge_weights")
22
out_suffix <- paste(region_name,"_","pred_1992_09032015",sep="") 
23
#_mosaic_run10_1500x4500_global_analyses_06212015
17
in_dir <- "/data/project/layers/commons/NEX_data/output_run_global_analyses_pred_12282015"
18
df_assessment_figures_files_names<-"df_assessment_figures_files_reg4_20014_run_global_analyses_pred_12282015.txt"   
19
df_assessment_figures_files <- read.table(file.path(in_dir,df_assessment_figures_files_names),stringsAsFactors=F,sep=",")
20
df_assessment_files_names <- ""#to be added
21
#setwd(indir)
22
#in_dir <- "/home/bparmentier/Dropbox/Data/NCEAS/env_layers_documents/output_run10_1500x4500_g#lobal_analyses_pred_1982_09152015"
23
#region_name <- "reg4" #PARAM 13 #reg4 South America, Africa reg5,Europe reg2, North America reg1, Asia reg3
24
#out_suffix <- paste(region_name,"_","pred_1992_09032015",sep="") 
25
#out_suffix <- "pred_1982_09152015"
24 26
#day_to_mosaic <- c("20100831",
25 27
#                   "20100901") #PARAM7
26 28

  
......
28 30

  
29 31
## Tiles of 1500x4500 km
30 32

  
31
There were 43 tiles for region 4 (Africa)
33

  
34
There were 28 tiles for region 4 (South America)
32 35

  
33 36
1. Tiles were run for 365 days.
34
2. Year tested was 1992.
35
3. Assessment of number of days predicted and accuracy was carried out.
37
2. Year tested was 1982.
38
3. Assessments for the number of days predicted and accuracy were carried out.
36 39

  
37 40

  
38 41
--- .class #id 
......
46 49
</style>
47 50
 
48 51

  
49

  
50 52
# Tiles of 1500x4500km global run 
51 53

  
52 54
```{r, echo=FALSE}
53 55
#image_file1 <- file.path(in_dir,"Figure9_clim_mosaics_day_test_unweighted_20100831_world_mosaic_07092015")
54 56

  
55
fname <- paste("Figure1_tile_processed_region_world_run10_1500x4500_global_analyses_pred_1992_09012015.png")
56

  
57
fname <- basename(df_assessment_figures_files$filename[1])
58
#fname <- "Figure1_tile_processed_region_world_run10_1500x4500_global_analyses_pred_1982_09152015.#png"
57 59
image_file1 <- file.path(in_dir,fname)
58 60

  
59 61
```
60 62

  
61 63
```{r image_file1, echo = F, results = 'asis'}
62
#| I am text to the left  | ![Flowers](/flowers.jpeg) |
63
#md_str <- paste('\n|        |![](',image_file1,')\n',sep="") 
64
#md_str <- paste('\n->![alt text](',image_file1,'),<-\n',sep="")
65
#<center>![Alt test](http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png)</center>
66 64
md_str <- paste('\n<center>![](',image_file1,')<center>\n',sep="")
67
#md_str <- paste('\n![](',image_file1,'#center)\n',sep="")
68
#fig.align = "center"
65

  
69 66
cat(md_str)
70 67
```
71 68

  
72 69
---
73 70

  
74
# ACCUARY PER TILES FOR MODEL 1
71
# ACCURACY PER TILES FOR MODEL 1
75 72

  
76 73
```{r, echo=FALSE}
77
#image_file2 <- file.path(in_dir,"Figure9_clim_mosaics_day_test_edge_weighted_20100831_world_mosaic_07092015.png")
78

  
79 74

  
80
fname <- paste("Figure2a_boxplot_with_oultiers_by_tiles_mod1_run10_1500x4500_global_analyses_pred_1992_09012015.png")
75
fname <- basename(df_assessment_figures_files$filename[2])
76
#fname <- paste("Figure2a_boxplot_with_oultiers_by_tiles_mod1_run10_1500x4500_global_analyses_",ou#t_suffix,".png",sep="")
81 77
image_file2 <- file.path(in_dir,fname)
82 78

  
83
fname <- paste("Figure2b_boxplot_scaling_by_tiles_mod1_run10_1500x4500_global_analyses_pred_1992_09012015.png")
79
fname <- basename(df_assessment_figures_files$filename[3])
80
#fname <- paste("Figure2b_boxplot_scaling_by_tiles_mod1_run10_1500x4500_global_analyses_",out_suff#ix,".png",sep="")
84 81
image_file3 <- file.path(in_dir,fname)
85 82

  
86 83
```
87 84

  
88 85

  
89
```{r image_file2, echo = F, results = 'asis', fig.show = 'hold', out.width = '50%',out.extra='style=""'}
86
```{r image_file2, image_file3 , echo = F, results = 'asis', fig.show = 'hold', out.width = '50%',out.extra='style=""'}
90 87

  
91 88
md_str <- paste('\n![](',image_file2,') ','![](',image_file3,')\n',sep="") 
92 89
cat(md_str)
90

  
91
#![alt-text-1](image1.png "title-1") ![alt-text-2](image2.png "title-2")
92

  
93

  
94
```
95

  
96
---
97

  
98
# ACCURACY OVERALL FOR MODEL 1
99

  
100
```{r, echo=FALSE}
101
#image_file2 <- file.path(in_dir,"Figure9_clim_mosaics_day_test_edge_weighted_20100831_world_mosaic_07092015.png")
102

  
103
fname <- basename(df_assessment_figures_files$filename[4])
104
#fname <- paste("Figure3a_boxplot_overall_region_with_oultiers_mod_kr_run10_1500x4500_global_analy#ses_",out_suffix,".png",sep="")
105
image_file4 <- file.path(in_dir,fname)
106

  
107
fname <- basename(df_assessment_figures_files$filename[5])
108
#fname <- paste("Figure3b_boxplot_overall_region_scaling_mod_kr_run10_1500x4500_global_analyses_",#out_suffix,".png",sep="")
109
image_file5 <- file.path(in_dir,fname)
110

  
111
```
112

  
113

  
114
```{r image_file4,image_file5, echo = F, results = 'asis', fig.show = 'hold', out.width = '50%',out.extra='style=""'}
115

  
116
md_str <- paste('\n![](',image_file4,') ','![](',image_file5,')\n',sep="") 
117
cat(md_str)
93 118
#md_str <- paste('\n![](',image_file2,')\n',sep="") 
94 119
#cat(md_str)
95 120

  
96 121
#![alt-text-1](image1.png "title-1") ![alt-text-2](image2.png "title-2")
97 122

  
123
cat("Mod1: tmax <- s(lat,long,k=5) + s(elev_s,k=5)")
98 124

  
99 125
```
100 126

  
101
# ACCUARY OVERALL FOR MODEL 1
127
---
128

  
129
# AVERAGE ACCURACY RANKED BY TILES 
102 130

  
103 131
```{r, echo=FALSE}
104 132
#image_file2 <- file.path(in_dir,"Figure9_clim_mosaics_day_test_edge_weighted_20100831_world_mosaic_07092015.png")
105 133

  
134
fname <- basename(df_assessment_figures_files$filename[10])
135
#fname <- paste("Figure5_ac_metrics_ranked_mod1_run10_1500x4500_global_analyses_",out_suffix,".png#",sep="")
136
image_file6 <- file.path(in_dir,fname)
106 137

  
107
fname <- paste("Figure3a_boxplot_overall_region_with_oultiers_mod_kr_run10_1500x4500_global_analyses_pred_1992_09012015.png")
108
image_file2 <- file.path(in_dir,fname)
109

  
110
fname <- paste("Figure3b_boxplot_overall_region_scaling_mod_kr_run10_1500x4500_global_analyses_pred_1992_09012015.png")
111
image_file3 <- file.path(in_dir,fname)
138
fname <- basename(df_assessment_figures_files$filename[11])
139
#fname <- paste("Figure5_ac_metrics_ranked_mod_kr_run10_1500x4500_global_analyses_",out_suffix,sep#="")
140
image_file7 <- file.path(in_dir,fname)
112 141

  
113 142
```
114 143

  
115 144

  
116
```{r image_file2, echo = F, results = 'asis', fig.show = 'hold', out.width = '50%',out.extra='style=""'}
145
```{r image_file6,image_file7, echo = F, results = 'asis', fig.show = 'hold', out.width = '50%',out.extra='style=""'}
117 146

  
118
md_str <- paste('\n![](',image_file2,') ','![](',image_file3,')\n',sep="") 
147
md_str <- paste('\n![](',image_file6,') ','![](',image_file7,')\n',sep="") 
119 148
cat(md_str)
120 149
#md_str <- paste('\n![](',image_file2,')\n',sep="") 
121 150
#cat(md_str)
......
123 152
#![alt-text-1](image1.png "title-1") ![alt-text-2](image2.png "title-2")
124 153

  
125 154

  
155

  
126 156
```
127 157

  
158
---
159

  
160
# Averae RMSE mod1 for 1500x4500km 
161

  
162
```{r, echo=FALSE}
163
#image_file1 <- file.path(in_dir,"Figure9_clim_mosaics_day_test_unweighted_20100831_world_mosaic_07092015")
164

  
165
fname <- basename(df_assessment_figures_files$filename[12])
166
#fname <- paste("Figure6_ac_metrics_map_centroids_tile_mod1_run10_1500x4500_global_analyses_",out_#suffix,".png",sep="")
167

  
168
image_file8 <- file.path(in_dir,fname)
169

  
170
```
171

  
172
```{r image_file8, echo = F, results = 'asis'}
173
#| I am text to the left  | ![Flowers](/flowers.jpeg) |
174
#md_str <- paste('\n|        |![](',image_file1,')\n',sep="") 
175
#md_str <- paste('\n->![alt text](',image_file1,'),<-\n',sep="")
176
#<center>![Alt test](http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png)</center>
177
md_str <- paste('\n<center>![](',image_file8,')<center>\n',sep="")
178
#md_str <- paste('\n![](',image_file1,'#center)\n',sep="")
179
#fig.align = "center"
180
cat(md_str)
181
```
182

  
183
---
184

  
185
# Predicted tiles for 1982
186

  
187
```{r, echo=FALSE}
188
#image_file1 <- file.path(in_dir,"Figure9_clim_mosaics_day_test_unweighted_20100831_world_mosaic_07092015")
189

  
190
fname <- basename(df_assessment_figures_files$filename[14])
191
#fname <- paste("Figure7a_ac_metrics_map_centroids_tile_mod1_missing_day_367_run10_1500x4500_globa#l_analyses_",out_suffix,".png",sep="")
192

  
193
image_file9 <- file.path(in_dir,fname)
194

  
195
```
196

  
197
```{r image_file9, echo = F, results = 'asis'}
198
#| I am text to the left  | ![Flowers](/flowers.jpeg) |
199
#md_str <- paste('\n|        |![](',image_file1,')\n',sep="") 
200
#md_str <- paste('\n->![alt text](',image_file1,'),<-\n',sep="")
201
#<center>![Alt test](http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png)</center>
202
md_str <- paste('\n<center>![](',image_file9,')<center>\n',sep="")
203
#md_str <- paste('\n![](',image_file1,'#center)\n',sep="")
204
#fig.align = "center"
205
cat(md_str)
206
```
128 207

  
129 208
---
130 209

  
210
# Predicted less than 365, at least one missing day
211

  
212
```{r, echo=FALSE}
213
#image_file1 <- file.path(in_dir,"Figure9_clim_mosaics_day_test_unweighted_20100831_world_mosaic_07092015")
214

  
215
fname <- basename(df_assessment_figures_files$filename[15])
216
#fname <- paste("Figure7a_ac_metrics_map_centroids_tile_mod1_missing_day_365_run10_1500x4500_globa#l_analyses_",out_suffix,".png",sep="")
217

  
218
image_file10 <- file.path(in_dir,fname)
219

  
220
```
221

  
222
```{r image_file10, echo = F, results = 'asis'}
223
#| I am text to the left  | ![Flowers](/flowers.jpeg) |
224
#md_str <- paste('\n|        |![](',image_file1,')\n',sep="") 
225
#md_str <- paste('\n->![alt text](',image_file1,'),<-\n',sep="")
226
#<center>![Alt test](http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png)</center>
227
md_str <- paste('\n<center>![](',image_file10,')<center>\n',sep="")
228
#md_str <- paste('\n![](',image_file1,'#center)\n',sep="")
229
#fig.align = "center"
230
cat(md_str)
231
```
232
---
233

  
234
---
235
# Missing days
236

  
237
```{r echo = F}
238

  
239
#tb <- read.table(file.path(in_dir,"tb_diagnostic_v_NA_run10_1500x4500_global_analyses_pred#_1992_09012015.txt"),sep=",")
240
#tb_diagnostic_v_NA_run10_1500x4500_global_analyses_pred_1982_09152015.txt
241
tb <- read.table(file=file.path(in_dir,paste("tb_diagnostic_v_NA_run10_1500x4500_global_analyses","_",out_suffix,".txt",sep="")),sep=",")
242

  
243

  
244
#table(tb$pred_mod)
245
#table(tb$index_d)
246
#table(subset(tb,pred_mod!="mod_kr"))
247
#table(subset(tb,pred_mod=="mod1")$index_d)
248
#aggregate()
249
tb$predicted <- 1
250
test <- aggregate(predicted~pred_mod+tile_id,data=tb,sum)
251
#as.character(unique(test$tile_id)) #141 tiles
252
#dim(subset(test,test$predicted==365 & test$pred_mod=="mod1"))
253
#histogram(subset(test, test$pred_mod=="mod1")$predicted)
254
#unique(subset(test, test$pred_mod=="mod1")$predicted)
255
summary_predicted <-table((subset(test, test$pred_mod=="mod1")$predicted))
256

  
257
```
258

  
259
```{r summary_predicted, echo = F}
260

  
261
barplot(summary_predicted,main="Frequency of number of days predicted")
262
print(summary_predicted)
263

  
264
```
265

  
266
---
267

  
268

  
269
---
131 270

  
132 271
#########

Also available in: Unified diff