Project

General

Profile

« Previous | Next » 

Revision ac043b28

Added by Benoit Parmentier over 9 years ago

running part2 assessment 1992 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: 07/30/2015            
8
#MODIFIED ON: 09/03/2015            
9 9
#Version: 4
10 10
#PROJECT: Environmental Layers project     
11 11
#COMMENTS: analyses for run 10 global analyses,all regions 1500x4500km with additional tiles to increase overlap 
......
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_pred_2010_testelev_07302015" #PARAM3
385
out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_pred_2010_testelev_07302015" #PARAM4
384
out_suffix <- "run10_1500x4500_global_analyses_pred_1992_09012015" #PARAM3
385
out_dir <- "/data/project/layers/commons/NEX_data/output_run10_1500x4500_global_analyses_pred_1992_09012015" #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 391

  
392
day_to_mosaic <- c("20100829","20100830","20100831",
393
                   "20100901","20100902","20100903")
392
day_to_mosaic <- c("19920101","19920102","19920103","19920104","19920105",
393
                   "19920106","19920107","19920108","19920109","19920110",
394
                   "19920111")
394 395

  
395 396
CRS_WGS84 <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84 #CONSTANT1
396 397
CRS_locs_WGS84<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
......
407 408
plot_region <- TRUE
408 409
num_cores <- 10 #PARAM 14
409 410
reg_modified <- TRUE
410
region <- c("reg5") #reference region to merge if necessary #PARAM 16
411
region <- c("reg4") #reference region to merge if necessary #PARAM 16
411 412

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

  
......
976 977

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

  
980
plot_screen_raster_val<-function(i,list_param){
981
  ##USAGE###
982
  #Screen raster list and produced plot as png.
983
  fname <-list_param$lf_raster_fname[i]
984
  screenRast <- list_param$screenRast
985
  l_dates<- list_param$l_dates
986
  out_dir_str <- list_param$out_dir_str
987
  prefix_str <-list_param$prefix_str
988
  out_suffix_str <- list_param$out_suffix_str
989
  
990
if(is.null(day_to_mosaic)){
991
  
992
  #idx <- seq(as.Date('2010-01-01'), as.Date('2010-12-31'), 'day')
993
  #idx <- seq(as.Date('20100101'), as.Date('20101231'), 'day')
994
  #date_l <- strptime(idx[1], "%Y%m%d") # interpolation date being processed
995
  #dates_l <- format(idx, "%Y%m%d") # interpolation date being processed
996
  day_to_mosaic <- dates_predicted #should be 365 days...
997
  #l_dates <- day_to_mosaic
998
}
999
  
979 1000
if(plot_region==TRUE){
980 1001
  
981 1002
  #get the files
982 1003
  l_reg_name <- unique(df_tile_processed$reg)
983
  #l_reg_name <- c("reg5")
1004
  l_reg_name <- c("reg4") #use this for the time
984 1005
  #lf_mosaics_reg5 <- mixedsort(list.files(path="/data/project/layers/commons/NEX_data/output_run10_global_analyses_11302014/mosaics/reg5",
985 1006
  #           pattern="CAI_TMAX_clim_month_.*_mod1_all.tif", full.names=T))
986 1007
  lf_mosaics_reg <- vector("list",length=length(l_reg_name))
......
1003 1024
    out_dir_str <- out_dir
1004 1025
    reg_name <- paste(l_reg_name[i],"_",tile_size,sep="") #make this automatic
1005 1026
    #lapply()
1006
    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)
1027
    #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)
1007 1028
    #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)
1008 1029
    #lf_mosaics_mask_reg[[i]] <- lapply(1:1,FUN=plot_daily_mosaics,list_param=list_param_plot_daily_mosaics)
1030
    lf_raster_fname <- lf_m
1031
    prefix_str <- "Figure10_clim_reg4_mosaics_day_"
1032
    l_dates <-day_to_mosaic
1033
    screenRast=FALSE
1034
    list_param_plot_screen_raster <- list(lf_raster_fname,screenRast,l_dates,out_dir,prefix_str,out_suffix)
1035
    names(list_param_plot_screen_raster) <- c("lf_raster_fname","screenRast","l_dates","out_dir_str","prefix_str","out_suffix_str")
1036

  
1037
    #undebug(plot_screen_raster_val)
1038

  
1039
    #world_m_list1<- plot_screen_raster_val(1,list_param_plot_screen_raster)
1040
    #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
1041
    lf_mosaics_mask_reg[[i]] <- 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
1042

  
1009 1043

  
1010
    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)
1044
    #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)
1011 1045
  }
1012 1046
}
1013 1047

  
......
1130 1164
#(subset(df_tile_processed$reg == l_reg_name[i],date)
1131 1165

  
1132 1166
for(i in 1:length(l_reg_name)){
1133
  lf_world_pred <-list.files(path=file.path(out_dir,l_reg_name[[i]]),    
1167
  lf_world_pred<-list.files(path=file.path(out_dir,l_reg_name[[i]]),    
1134 1168
           pattern=paste(".tif$",sep=""),full.names=T) 
1135 1169

  
1136 1170
  #mosaic_list_mean <- test_list 

Also available in: Unified diff