Project

General

Profile

« Previous | Next » 

Revision f640fd05

Added by Benoit Parmentier almost 10 years ago

NEX assessment part2 for 1000x3000km, dropping 3b region

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: 01/28/2015            
8
#MODIFIED ON: 02/10/2015            
9 9
#Version: 4
10 10
#PROJECT: Environmental Layers project     
11 11
#COMMENTS: analyses for run 10 global analyses, Europe, Australia, 1000x300km
......
321 321

  
322 322
y_var_name <- "dailyTmax"
323 323
interpolation_method <- c("gam_CAI")
324
out_prefix<-"run10_global_analyses_01282015"
324
#out_prefix<-"run10_global_analyses_01282015"
325
#out_prefix <- "output_run10_1000x3000_global_analyses_02102015"
326
out_prefix <- "run10_1000x3000_global_analyses_02102015"
327

  
325 328
mosaic_plot <- FALSE
326 329

  
327 330
day_to_mosaic <- c("20100101","20100102","20100103","20100104","20100105",
......
342 345

  
343 346
#out_dir <-paste(out_dir,"_",out_prefix,sep="")
344 347
create_out_dir_param <- FALSE
345
out_dir <-"/data/project/layers/commons/NEX_data/output_run10_global_analyses_01282015/"
346

  
348
#out_dir <-"/data/project/layers/commons/NEX_data/output_run10_global_analyses_01282015/"
349
out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1000x3000_global_analyses_02102015"
347 350
if(create_out_dir_param==TRUE){
348 351
  out_dir <- create_dir_fun(out_dir,out_prefix)
349 352
  setwd(out_dir)
......
362 365
###Table 2: daily accuracy metrics for all tiles
363 366

  
364 367
summary_metrics_v <- read.table(file=file.path(out_dir,paste("summary_metrics_v2_NA_",out_prefix,".txt",sep="")),sep=",")
368
#fname <- file.path(out_dir,paste("summary_metrics_v2_NA_",out_prefix,".txt",sep=""))
365 369
tb <- read.table(file=file.path(out_dir,paste("tb_diagnostic_v_NA","_",out_prefix,".txt",sep="")),sep=",")
366 370
#tb_diagnostic_s_NA_run10_global_analyses_11302014.txt
367 371
tb_s <- read.table(file=file.path(out_dir,paste("tb_diagnostic_s_NA","_",out_prefix,".txt",sep="")),sep=",")
......
387 391
  
388 392
}
389 393

  
394
###
395
"/data/project/layers/commons/NEX_data/output_run8_global_analyses_10212014/tb_diagnostic_v_NA_run8_global_analyses_10212014.txt"
396

  
397
#drop 3b
398
tb_all <- tb
399
tb <- subset(tb,reg!="reg3b")
400

  
401
summary_metrics_v_all <- summary_metrics_v 
402

  
403
tb <- read.table(file=file.path(out_dir,paste("tb_diagnostic_v_NA","_",out_prefix,".txt",sep="")),sep=",")
404
#tb_diagnostic_s_NA_run10_global_analyses_11302014.txt
405
tb_s <- read.table(file=file.path(out_dir,paste("tb_diagnostic_s_NA","_",out_prefix,".txt",sep="")),sep=",")
406

  
407
tb_month_s <- read.table(file=file.path(out_dir,paste("tb_month_diagnostic_s_NA","_",out_prefix,".txt",sep="")),sep=",")
408
pred_data_month_info <- read.table(file=file.path(out_dir,paste("pred_data_month_info_",out_prefix,".txt",sep="")),sep=",")
409
pred_data_day_info <- read.table(file=file.path(out_dir,paste("pred_data_day_info_",out_prefix,".txt",sep="")),sep=",")
410
df_tile_processed <- read.table(file=file.path(out_dir,paste("df_tile_processed_",out_prefix,".txt",sep="")),sep=",")
390 411

  
391 412
###############
392 413
### Figure 1: plot location of the study area with tiles processed
......
423 444
#collect info: read in all shapfiles
424 445
#This is slow...make a function and use mclapply??
425 446
#/data/project/layers/commons/NEX_data/output_run6_global_analyses_09162014/shapefiles
447

  
426 448
for(i in 1:length(list_shp_reg_files)){
427 449
  #path_to_shp <- dirname(list_shp_reg_files[[i]])
428 450
  path_to_shp <- file.path(out_dir,"/shapefiles")
......
436 458
      pt <- gCentroid(shp1)
437 459
      centroids_pts[[i]] <- pt
438 460
  }else{
439
    centroids <- shp1
461
    pt <- shp1
462
    centroids_pts[[i]] <- pt
440 463
  }
441 464
  shps_tiles[[i]] <- shp1
465
  #centroids_pts[[i]] <- centroids
442 466
}
443 467

  
468
#fun <- function(i,list_shp_files)
444 469
#coord_names <- c("lon","lat")
445
#l_rast <- rasterize_df_fun(test,coord_names,proj_str,out_suffix=out_prefix,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
470
#l_ras#t <- rasterize_df_fun(test,coord_names,proj_str,out_suffix=out_prefix,out_dir=".",file_format,NA_flag_val,tolerance_val=0.000120005)
446 471

  
447 472
#remove try-error polygons...we loose three tiles because they extend beyond -180 deg
448 473
tmp <- shps_tiles
449 474
shps_tiles <- remove_errors_list(shps_tiles) #[[!inherits(shps_tiles,"try-error")]]
450 475
#shps_tiles <- tmp
476
length(tmp)-length(shps_tiles) #number of tiles with error message
451 477

  
452 478
tmp_pts <- centroids_pts 
453 479
centroids_pts <- remove_errors_list(centroids_pts) #[[!inherits(shps_tiles,"try-error")]]
......
484 510
###############
485 511
### Figure 2: boxplot of average accuracy by model and by tiles
486 512

  
513

  
487 514
tb$tile_id <- factor(tb$tile_id, levels=unique(tb$tile_id))
488 515

  
489 516
model_name <- as.character(unique(tb$pred_mod))
......
803 830

  
804 831

  
805 832
##########################################################
806
##### Figure 8: Breaking down accuaracy by regions!! #####
833
##### Figure 8: Breaking down accuracy by regions!! #####
807 834

  
808 835
summary_metrics_v <- merge(summary_metrics_v,df_tile_processed,by="tile_id")
809 836
table(summary_metrics_v$reg)
......
840 867
#           pattern="CAI_TMAX_clim_month_.*_mod1_all.tif", full.names=T))
841 868
lf_mosaics_reg <- vector("list",length=length(l_reg_name))
842 869
for(i in 1:length(l_reg_name)){
843
  lf_mosaics_reg[[i]] <- mixedsort(list.files(
844
  path=file.path(out_dir,"mosaics"),
845
           #pattern="reg6_.*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",
846
           pattern=paste(l_reg_name[i],".*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",sep=""), 
847
           full.names=T))
870
    lf_mosaics_reg[[i]] <- try(mixedsort(
871
    list.files(
872
    path=file.path(out_dir,"mosaics"),
873
    #pattern="reg6_.*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",
874
    pattern=paste(l_reg_name[i],".*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",sep=""), 
875
    full.names=T))
876
  )
848 877
}
849 878

  
850 879
#This part should be automated...

Also available in: Unified diff