Project

General

Profile

« Previous | Next » 

Revision a418b80a

Added by Benoit Parmentier about 9 years ago

modifying and removing plot screen mosaic functions that carashed atlas

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: 09/21/2015            
8
#MODIFIED ON: 09/22/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 
......
406 406

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

  
......
977 977

  
978 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 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
  
1000
if(plot_region==TRUE){
1001
  
1002
  #get the files
1003
  l_reg_name <- unique(df_tile_processed$reg)
1004
  l_reg_name <- c("reg4") #use this for the time
1005
  #lf_mosaics_reg5 <- mixedsort(list.files(path="/data/project/layers/commons/NEX_data/output_run10_global_analyses_11302014/mosaics/reg5",
1006
  #           pattern="CAI_TMAX_clim_month_.*_mod1_all.tif", full.names=T))
1007
  lf_mosaics_reg <- vector("list",length=length(l_reg_name))
1008
  for(i in 1:length(l_reg_name)){
1009
    lf_mosaics_reg[[i]] <- try(mixedsort(
1010
    list.files(
1011
    path=file.path(out_dir,"mosaics"),
1012
    #pattern="reg6_.*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",
1013
    pattern=paste(l_reg_name[i],".*._CAI_TMAX_clim_month_.*._mod1_all_mean.tif",sep=""), 
1014
    full.names=T))
1015
    )
1016
  }
1017
  
1018
  #now mask and potl
1019
  lf_mosaics_mask_reg <- vector("list",length=length(l_reg_name))
1020
  for(i in 1:length(l_reg_name)){
1021
    
1022
    #
1023
    lf_m <- lf_mosaics_reg[[i]]
1024
    out_dir_str <- out_dir
1025
    reg_name <- paste(l_reg_name[i],"_",tile_size,sep="") #make this automatic
1026
    #lapply()
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)
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)
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

  
1043

  
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)
1045
  }
1046
}
1047 980

  
1048 981
################## WORLD MOSAICS NEEDS MAJOR CLEAN UP OF CODE HERE
1049 982
##make functions!!
......
1099 1032
#           pattern=paste("^world_mosaics.*.tif$",sep=""),full.names=T) 
1100 1033

  
1101 1034
lf_world_pred <-list.files(path=file.path(out_dir,"mosaics"),    
1102
           pattern=paste("^reg4.*.",".tif$",sep=""),full.names=T) 
1035
           pattern=paste("^reg5.*.",".tif$",sep=""),full.names=T) 
1103 1036
l_reg_name <- unique(df_tile_processed$reg)
1104 1037
lf_world_pred <-list.files(path=file.path(out_dir,l_reg_name[[i]]),    
1105 1038
           pattern=paste(".tif$",sep=""),full.names=T) 
......
1113 1046
lf_raster_fname <- lf_world_pred
1114 1047
prefix_str <- "Figure10_clim_world_mosaics_day_"
1115 1048
l_dates <-day_to_mosaic
1116
screenRast=TRUE
1049
screenRast=FALSE
1117 1050
list_param_plot_screen_raster <- list(lf_raster_fname,screenRast,l_dates,out_dir,prefix_str,out_suffix)
1118 1051
names(list_param_plot_screen_raster) <- c("lf_raster_fname","screenRast","l_dates","out_dir_str","prefix_str","out_suffix_str")
1119 1052

  
1120
#undebug(plot_screen_raster_val)
1053
debug(plot_screen_raster_val)
1121 1054

  
1122
#world_m_list1<- plot_screen_raster_val(1,list_param_plot_screen_raster)
1055
world_m_list1<- plot_screen_raster_val(1,list_param_plot_screen_raster)
1123 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
1124 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
1125 1058

  

Also available in: Unified diff