Project

General

Profile

« Previous | Next » 

Revision e5e3509c

Added by Benoit Parmentier over 9 years ago

assessment part2, first test for year 2003 predictions in reg5 Africa

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: 03/25/2015            
8
#MODIFIED ON: 04/15/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
......
381 381
interpolation_method <- c("gam_CAI") #PARAM2
382 382
#out_suffix<-"run10_global_analyses_01282015"
383 383
#out_suffix <- "output_run10_1000x3000_global_analyses_02102015"
384
out_suffix <- "run10_1500x4500_global_analyses_03252015" #PARAM3
385
out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_03252015" #PARAM4
384
out_suffix <- "run10_1500x4500_global_analyses_pred_2003_04102015" #PARAM3
385
out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_pred_2003_04102015" #PARAM4
386 386
create_out_dir_param <- FALSE #PARAM 5
387 387

  
388 388
mosaic_plot <- FALSE #PARAM6
389 389

  
390 390
#if daily mosaics NULL then mosaicas all days of the year
391
day_to_mosaic <- c("20100101","20100102","20100103","20100104","20100105",
392
                   "20100301","20100302","20100303","20100304","20100305",
393
                   "20100501","20100502","20100503","20100504","20100505",
394
                   "20100701","20100702","20100703","20100704","20100705",
395
                   "20100901","20100902","20100903","20100904","20100905",
396
                   "20101101","20101102","20101103","20101104","20101105") #PARAM7
391
day_to_mosaic <- c("20030101","20030102","20030103","20030104","20030105",
392
                   "20030301","20030302","20030303","20030304","20030305",
393
                   "20030501","20030502","20030503","20030504","20030505",
394
                   "20030701","20030702","20030703","20030704","20030705",
395
                   "20030901","20030902","20030903","20030904","20030905",
396
                   "20031101","20031102","20031103","20031104","20031105") #PARAM7
397 397
  
398 398
#CRS_locs_WGS84 <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
399 399
CRS_WGS84 <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 #CONSTANT1
......
408 408
mulitple_region <- TRUE #PARAM 12
409 409

  
410 410
region_name <- "world" #PARAM 13
411
plot_region <- FALSE
411
plot_region <- TRUE
412
num_cores <- 10 #PARAM 14
412 413

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

  
......
788 789
}
789 790

  
790 791
## Number of tiles with information:
791
sum(df_tile_processed$metrics_v) #188,number of tiles with raster object
792
length(df_tile_processed$metrics_v) #214,number of tiles in the region
793
sum(df_tile_processed$metrics_v)/length(df_tile_processed$metrics_v) #87.85% of tiles with info
792
sum(df_tile_processed$metrics_v) #20,number of tiles with raster object
793
length(df_tile_processed$metrics_v) #25,number of tiles in the region
794
sum(df_tile_processed$metrics_v)/length(df_tile_processed$metrics_v) #80 of tiles with info
794 795

  
795 796
#coordinates
796 797
#coordinates(summary_metrics_v) <- c("lon","lat")
......
926 927
#####################################################
927 928
#### Figure 9: plotting mosaics of regions ###########
928 929
## plot mosaics...
929
#l_reg_name <- unique(df_tile_processed$reg)
930
#lf_mosaics_reg5 <- mixedsort(list.files(path="/data/project/layers/commons/NEX_data/output_run10_global_analyses_11302014/mosaics/reg5",
931
#           pattern="CAI_TMAX_clim_month_.*_mod1_all.tif", full.names=T))
932
#lf_mosaics_reg <- vector("list",length=length(l_reg_name))
933
#for(i in 1:length(l_reg_name)){
934
#    lf_mosaics_reg[[i]] <- try(mixedsort(
935
#    list.files(
936
#    path=file.path(out_dir,"mosaics"),
937
#    #pattern="reg6_.*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",
938
#    pattern=paste(l_reg_name[i],".*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",sep=""), 
939
#    full.names=T))
940
#  )
941
#}
930

  
931
#First collect file names
932

  
933

  
942 934
#names(lf_mosaics_reg) <- l_reg_name
943 935

  
944 936
#This part should be automated...
......
957 949
#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)
958 950

  
959 951
if(plot_region==TRUE){
952
  
953
  #get the files
954
  l_reg_name <- unique(df_tile_processed$reg)
955
  #lf_mosaics_reg5 <- mixedsort(list.files(path="/data/project/layers/commons/NEX_data/output_run10_global_analyses_11302014/mosaics/reg5",
956
  #           pattern="CAI_TMAX_clim_month_.*_mod1_all.tif", full.names=T))
957
  lf_mosaics_reg <- vector("list",length=length(l_reg_name))
958
  for(i in 1:length(l_reg_name)){
959
    lf_mosaics_reg[[i]] <- try(mixedsort(
960
    list.files(
961
    path=file.path(out_dir,"mosaics"),
962
    #pattern="reg6_.*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",
963
    pattern=paste(l_reg_name[i],".*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",sep=""), 
964
    full.names=T))
965
    )
966
  }
967
  
968
  #now mask and potl
960 969
  lf_mosaics_mask_reg <- vector("list",length=length(l_reg_name))
961 970
  for(i in 1:length(l_reg_name)){
962
    d
971
    
963 972
    #
964 973
    lf_m <- lf_mosaics_reg[[i]]
965 974
    out_dir_str <- out_dir
......
967 976
    #lapply()
968 977
    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)
969 978
    #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)
979
    #lf_mosaics_mask_reg[[i]] <- lapply(1:1,FUN=plot_daily_mosaics,list_param=list_param_plot_daily_mosaics)
970 980

  
971
    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)
981
    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 = num_cores)
972 982
  }
973 983
}
974 984

  

Also available in: Unified diff