Project

General

Profile

« Previous | Next » 

Revision 4f5c2b40

Added by Benoit Parmentier over 10 years ago

run6 assessment NEX part1: first global run with specific k

View differences:

climate/research/oregon/interpolation/global_run_scalingup_assessment_part1.R
5 5
#Part 1 create summary tables and inputs for figure in part 2 and part 3.
6 6
#AUTHOR: Benoit Parmentier 
7 7
#CREATED ON: 03/23/2014  
8
#MODIFIED ON: 08/28/2014            
8
#MODIFIED ON: 09/16/2014            
9 9
#Version: 3
10 10
#PROJECT: Environmental Layers project  
11 11
#TO DO:
......
459 459

  
460 460
#in_dir1 <- "/data/project/layers/commons/NEX_data/test_run1_03232014/output" #On Atlas
461 461
#in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output10Deg/reg1/" #On NEX
462
in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output20Deg/"
462
in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output20Deg2/"
463 463

  
464 464
#/nobackupp4/aguzman4/climateLayers/output10Deg/reg1/finished.txt
465
#in_dir_list <- list.dirs(path=in_dir1,recursive=FALSE) #get the list of directories with resutls by 10x10 degree tiles
466
in_dir_list <- c(
467
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg2//-10.0_-70.0/",
468
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg4//40.0_0.0/",
469
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg4//50.0_0.0/",
470
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg6//60.0_40.0/",
471
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg6//30.0_40.0/",
472
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg8//40.0_130.0/")
465
in_dir_reg <- list.dirs(path=in_dir1,recursive=FALSE) #get the list regions processed for this run
466
in_dir_list <- list.dirs(path=in_dir_reg,recursive=FALSE) #get the list of tiles/directories with outputs 
467

  
468
#in_dir_list <- in_dir_list[grep("bak",basename(basename(in_dir_list)),invert=TRUE)] #the first one is the in_dir1
469
in_dir_subset <- in_dir_list[grep("subset",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
470
in_dir_shp <- file.path(in_dir_subset,"shapefiles")
471
#in_dir_shp <- in_dir_list[grep("shapefiles",basename(in_dir_subset),invert=FALSE)] #select directory with shapefiles...
472

  
473
#[27] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg2/outLogs"    
474
#[28] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg2/sept01"     
475
#[29] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg2/serial"     
476
#[30] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg2/subset"     
477
#[31] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg2/testFit" 
478

  
479
#in_dir_subset <- in_dir_list[grep("subset",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
480
#in_dir_subset <- in_dir_list[grep("serial",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
481
#in_dir_subset <- in_dir_list[grep("sept01",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
482
#in_dir_subset <- in_dir_list[grep("testFit",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
483

  
484
#Only 6 folders/regions contain information  
485

  
486
#[1] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg2/subset"
487
#[2] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg3/subset"
488
#[3] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg4/subset"
489
#[4] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg5/subset"
490
#[5] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg6/subset"
491
#[6] "/nobackupp4/aguzman4/climateLayers/output20Deg2//reg7/subset"
492

  
493
in_dir_reg <- dirname(in_dir_subset)
494
in_dir_list <- list.dirs(path=in_dir_reg,recursive=FALSE) #get the list of directories with resutls by 10x10 degree tiles
495
#select only directories used for predictions
496
in_dir_list <- in_dir_list[grep(".*._.*.",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
473 497

  
474 498
#Models used.
475 499
#list_models<-c("y_var ~ s(lat,lon,k=4) + s(elev_s,k=3) + s(LST,k=3)",
......
486 510
#in_dir_list <- as.list(in_dir_list[-1])
487 511
#in_dir_list <- in_dir_list[grep("bak",basename(basename(in_dir_list)),invert=TRUE)] #the first one is the in_dir1
488 512
#in_dir_shp <- in_dir_list[grep("shapefiles",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
489
in_dir_shp <- c(
490
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg2/subset/shapefiles/",
491
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg4/subset/shapefiles/",
492
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg4/subset/shapefiles/",
493
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg6/subset/shapefiles/",
494
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg6/subset/shapefiles/",
495
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg8/subset/shapefiles/")
496 513

  
497 514
#in_dir_shp <- "/nobackupp4/aguzman4/climateLayers/output10Deg/reg1/subset/shapefiles/"
498 515
#in_dir_shp <- "/nobackupp4/aguzman4/climateLayers/output20Deg/reg2/subset/shapefiles"
......
503 520
# the last directory contains shapefiles 
504 521
y_var_name <- "dailyTmax"
505 522
interpolation_method <- c("gam_CAI")
506
out_prefix<-"run5_global_analyses_08252014"
523
out_prefix<-"run6_global_analyses_09162014"
507 524

  
508 525
#out_dir<-"/data/project/layers/commons/NEX_data/" #On NCEAS Atlas
509 526
out_dir <- "/nobackup/bparmen1/" #on NEX
......
544 561
lf_covar_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="covar_obj.*.RData",full.names=T)})
545 562
lf_covar_tif <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="covar.*.tif",full.names=T)})
546 563
#diagnostics_obj_gam_fitting_dailyTmax7__08062014.RData
547
lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostics_.*.RData",full.names=T)})
548
lf_diagnostic_obj <- lf_diagnostic_obj[grep("lk_min",lf_diagnostic_obj,invert=T)] #remove object that have lk_min...
564
#lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostics_.*.RData",full.names=T)})
565
#lf_diagnostic_obj <- lf_diagnostic_obj[grep("lk_min",lf_diagnostic_obj,invert=T)] #remove object that have lk_min...
549 566

  
550 567
## This will be part of the raster_obj function
551 568
#debug(create_raster_prediction_obj)
552
out_prefix_str <- paste(basename(in_dir_list),out_prefix,sep="_") 
553
lf_raster_obj <- create_raster_prediction_obj(in_dir_list,interpolation_method, y_var_name,out_prefix_str,out_path_list=NULL)
569
#out_prefix_str <- paste(basename(in_dir_list),out_prefix,sep="_") 
570
#lf_raster_obj <- create_raster_prediction_obj(in_dir_list,interpolation_method, y_var_name,out_prefix_str,out_path_list=NULL)
554 571

  
555
lf_raster_obj <- c("/nobackupp4/aguzman4/climateLayers/output20Deg/reg2//-10.0_-70.0//raster_prediction_obj_gam_CAI_dailyTmax-10.0_-70.0_run5_global_analyses_08252014.RData"
556
  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg4//40.0_0.0//raster_prediction_obj_gam_CAI_dailyTmax40.0_0.0_run5_global_analyses_08252014.RData"   
557
  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg4//50.0_0.0//raster_prediction_obj_gam_CAI_dailyTmax50.0_0.0_run5_global_analyses_08252014.RData"
558
  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg6//60.0_40.0//raster_prediction_obj_gam_CAI_dailyTmax60.0_40.0_run5_global_analyses_08252014.RData"
559
  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg6//30.0_40.0//raster_prediction_obj_gam_CAI_dailyTmax30.0_40.0_run5_global_analyses_08252014.RData"
560
  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg8//40.0_130.0//raster_prediction_obj_gam_CAI_dailyTmax40.0_130.0_run5_global_analyses_08252014.RData")
572
#lf_raster_obj <- c("/nobackupp4/aguzman4/climateLayers/output20Deg/reg2//-10.0_-70.0//raster_prediction_obj_gam_CAI_dailyTmax-10.0_-70.0_run5_global_analyses_08252014.RData"
573
#  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg4//40.0_0.0//raster_prediction_obj_gam_CAI_dailyTmax40.0_0.0_run5_global_analyses_08252014.RData"   
574
#  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg4//50.0_0.0//raster_prediction_obj_gam_CAI_dailyTmax50.0_0.0_run5_global_analyses_08252014.RData"
575
#  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg6//60.0_40.0//raster_prediction_obj_gam_CAI_dailyTmax60.0_40.0_run5_global_analyses_08252014.RData"
576
#  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg6//30.0_40.0//raster_prediction_obj_gam_CAI_dailyTmax30.0_40.0_run5_global_analyses_08252014.RData"
577
#  ,"/nobackupp4/aguzman4/climateLayers/output20Deg/reg8//40.0_130.0//raster_prediction_obj_gam_CAI_dailyTmax40.0_130.0_run5_global_analyses_08252014.RData")#
561 578

  
562 579
########################## START SCRIPT ##############################
563 580

  
......
575 592
df_tile_processed$path_NEX <- in_dir_list
576 593
  
577 594
##Quick exploration of raster object
578
robj1 <- load_obj(list_raster_obj_files[[2]]) #This is tile corresponding to Oregon
579
robj1 <- load_obj(lf_raster_obj[2]) #This is tile corresponding to Oregon
595
robj1 <- load_obj(list_raster_obj_files[[4]]) #This is an example tile
596
#robj1 <- load_obj(lf_raster_obj[4]) #This is tile tile
580 597

  
581 598
names(robj1)
582 599
names(robj1$method_mod_obj[[1]]) #for January 1, 2010
......
587 604
#Get the number of models predicted
588 605
nb_mod <- length(unique(robj1$tb_diagnostic_v$pred_mod))
589 606

  
590
list_tb_diagnostic_v <- mclapply(lf_validation_obj,FUN=function(x){try( x<- load_obj(x)); try(extract_from_list_obj(x,"metrics_v"))},mc.preschedule=FALSE,mc.cores = 6)                           
591
names(list_tb_diagnostic_v) <- list_names_tile_id
607
#list_tb_diagnostic_v <- mclapply(lf_validation_obj,FUN=function(x){try( x<- load_obj(x)); try(extract_from_list_obj(x,"metrics_v"))},mc.preschedule=FALSE,mc.cores = 6)                           
608
#names(list_tb_diagnostic_v) <- list_names_tile_id
592 609

  
593 610
################
594 611
#### Table 1: Average accuracy metrics
595 612

  
596 613
#can use a maximum of 6 cores on the NEX Bridge
614
#For 177 tiles but only xx RData boject it takes xxx min
597 615
#summary_metrics_v_list <- mclapply(list_raster_obj_files[5:6],FUN=function(x){try( x<- load_obj(x)); try(x[["summary_metrics_v"]]$avg)},mc.preschedule=FALSE,mc.cores = 2)                           
598 616

  
599 617
summary_metrics_v_list <- mclapply(list_raster_obj_files,FUN=function(x){try( x<- load_obj(x)); try(x[["summary_metrics_v"]]$avg)},mc.preschedule=FALSE,mc.cores = 6)                           
600
summary_metrics_v_list <- lapply(summary_metrics_v_list,FUN=function(x){try(x$avg)})
618
#summary_metrics_v_list <- lapply(summary_metrics_v_list,FUN=function(x){try(x$avg)})
601 619
names(summary_metrics_v_list) <- list_names_tile_id
602 620

  
603 621
summary_metrics_v_tmp <- remove_from_list_fun(summary_metrics_v_list)$list
......
691 709
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg5/20.0_30.0//diagnostics_obj_gam_fitting_TMax_9_mod2_08062014.RData
692 710
#lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostics_.*.RData",full.names=T)})
693 711
#lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostics_obj_gam_fitting_TMax_*_mod*_08062014.RData",full.names=T)})
694
lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostics_obj_gam_fitting_TMax_.*._mod.*._08062014.RData",full.names=T)})
712
#lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostics_obj_gam_fitting_TMax_.*._mod.*._08062014.RData",full.names=T)})
695 713

  
696 714
#lf_diagnostic_obj <- lf_diagnostic_obj[grep("lk_min",lf_diagnostic_obj,invert=T)] #remove object that have lk_min...
697 715

  
698
names(lf_diagnostic_obj) <- list_names_tile_id
699
lf_diagnostic_obj_tmp <- remove_from_list_fun(lf_diagnostic_obj)$list
716
#names(lf_diagnostic_obj) <- list_names_tile_id
717
#lf_diagnostic_obj_tmp <- remove_from_list_fun(lf_diagnostic_obj)$list
700 718
#df_tile_processed$tb_diag <- remove_from_list_fun(tb_diagnostic_v_list)$valid
701 719

  
702
gam_diagnostic_tb_list <- vector("list",length=length(lf_diagnostic_obj_tmp))
703
for(i in 1:length(lf_diagnostic_obj_tmp)){
704
  l_diagnostic_obj_tmp <- lf_diagnostic_obj_tmp[[i]]
705
  tile_id_name <-  names(lf_diagnostic_obj_tmp)[i]
706
  #l_diagnostic_obj_tmp <- l_diagnostic_obj_tmp[grep("lk_min",l_diagnostic_obj_tmp,invert=T)] #remove object that have lk_min...
707
  l_diagnostic_obj_tmp_list <- lapply(l_diagnostic_obj_tmp,FUN=function(x){try(x<-load_obj(x));try(x[["df_diagnostics"]])})#,mc.preschedule=FALSE,mc.cores = 6)                            
708
  gam_diagnostic_tb <- do.call(rbind.fill,l_diagnostic_obj_tmp_list)#create a df for NA tiles with all accuracy metrics
709
  gam_diagnostic_tb$tile_id <- tile_id_name
710
  gam_diagnostic_tb_list[[i]] <- gam_diagnostic_tb    
711
}
720
#gam_diagnostic_tb_list <- vector("list",length=length(lf_diagnostic_obj_tmp))
721
#for(i in 1:length(lf_diagnostic_obj_tmp)){
722
#  l_diagnostic_obj_tmp <- lf_diagnostic_obj_tmp[[i]]
723
#  tile_id_name <-  names(lf_diagnostic_obj_tmp)[i]
724
#  #l_diagnostic_obj_tmp <- l_diagnostic_obj_tmp[grep("lk_min",l_diagnostic_obj_tmp,invert=T)] #remove object that have lk_min...
725
#  l_diagnostic_obj_tmp_list <- lapply(l_diagnostic_obj_tmp,FUN=function(x){try(x<-load_obj(x));try(x[["df_diagnostics"]])})#,mc.preschedule=FALSE,mc.cores = 6)                            
726
#  gam_diagnostic_tb <- do.call(rbind.fill,l_diagnostic_obj_tmp_list)#create a df for NA tiles with all accuracy metrics
727
#  gam_diagnostic_tb$tile_id <- tile_id_name
728
#  gam_diagnostic_tb_list[[i]] <- gam_diagnostic_tb    
729
#}
712 730

  
713
gam_diagnostic_df <- do.call(rbind.fill,gam_diagnostic_tb_list) #create a df for NA tiles with all accuracy metrics
731
#gam_diagnostic_df <- do.call(rbind.fill,gam_diagnostic_tb_list) #create a df for NA tiles with all accuracy metrics
714 732

  
715
write.table(gam_diagnostic_df,
716
            file=file.path(out_dir,paste("gam_diagnostic_df_",out_prefix,".txt",sep="")),sep=",")
733
#write.table(gam_diagnostic_df,
734
#            file=file.path(out_dir,paste("gam_diagnostic_df_",out_prefix,".txt",sep="")),sep=",")
717 735

  
718 736

  
719 737
#Now look at the 100 tiles of 10x10
720 738
#lf_test<-list.files("/nobackupp4/aguzman4/climateLayers/output10Deg/*/*/","diagnostics_obj_gam_fitting*")  
721
lf_test <-list.files("/nobackupp4/aguzman4/climateLayers/output10Deg/","diagnostics_obj_gam_fitting.*.RData",recursive=T,full.names=T)
722

  
723
gam_diagnostic_10x10tb_list <- vector("list",length=length(lf_test))
724
lf_diagnostic_obj_tmp <- lf_test  
725
for(i in 1:length( lf_diagnostic_obj_tmp)){
726
  l_diagnostic_obj_tmp <-  lf_diagnostic_obj_tmp[[i]]
727
  tile_coord <-  basename(dirname(lf_diagnostic_obj_tmp[i]))
728
  #l_diagnostic_obj_tmp <- l_diagnostic_obj_tmp[grep("lk_min",l_diagnostic_obj_tmp,invert=T)] #remove object that have lk_min...
729
  l_diagnostic_obj_tmp_list <- lapply(l_diagnostic_obj_tmp,FUN=function(x){try(x<-load_obj(x));try(x[["df_diagnostics"]])})#,mc.preschedule=FALSE,mc.cores = 6)                            
730
  gam_diagnostic_tb <- do.call(rbind.fill,l_diagnostic_obj_tmp_list)#create a df for NA tiles with all accuracy metrics
731
  gam_diagnostic_tb$tile_coord <- tile_coord
732
  gam_diagnostic_10x10tb_list[[i]] <- gam_diagnostic_tb    
733
}
739
#lf_test <-list.files("/nobackupp4/aguzman4/climateLayers/output10Deg/","diagnostics_obj_gam_fitting.*.RData",recursive=T,full.names=T)
740

  
741
#gam_diagnostic_10x10tb_list <- vector("list",length=length(lf_test))
742
#lf_diagnostic_obj_tmp <- lf_test  
743
#for(i in 1:length( lf_diagnostic_obj_tmp)){
744
#  l_diagnostic_obj_tmp <-  lf_diagnostic_obj_tmp[[i]]
745
#  tile_coord <-  basename(dirname(lf_diagnostic_obj_tmp[i]))
746
#  #l_diagnostic_obj_tmp <- l_diagnostic_obj_tmp[grep("lk_min",l_diagnostic_obj_tmp,invert=T)] #remove object that have lk_min...
747
#  l_diagnostic_obj_tmp_list <- lapply(l_diagnostic_obj_tmp,FUN=function(x){try(x<-load_obj(x));try(x[["df_diagnostics"]])})#,mc.preschedule=FALSE,mc.cores = 6)                            
748
#  gam_diagnostic_tb <- do.call(rbind.fill,l_diagnostic_obj_tmp_list)#create a df for NA tiles with all accuracy metrics
749
#  gam_diagnostic_tb$tile_coord <- tile_coord
750
#  gam_diagnostic_10x10tb_list[[i]] <- gam_diagnostic_tb    
751
#}
734 752

  
735
gam_diagnostic_10x10_df <- do.call(rbind.fill,gam_diagnostic_10x10tb_list) #create a df for NA tiles with all accuracy metrics
753
#gam_diagnostic_10x10_df <- do.call(rbind.fill,gam_diagnostic_10x10tb_list) #create a df for NA tiles with all accuracy metrics
736 754

  
737
list_tile_coord <- unique(gam_diagnostic_10x10_df$tile_coord)
738
list_tile_id <- paste("tile_",1:length(list_tile_coord),sep="")
755
#list_tile_coord <- unique(gam_diagnostic_10x10_df$tile_coord)
756
#list_tile_id <- paste("tile_",1:length(list_tile_coord),sep="")
739 757

  
740
tile_id_df <- data.frame(tile_coord=list_tile_coord,tile_id=list_tile_id)
741
gam_diagnostic_10x10_df <- merge(gam_diagnostic_10x10_df,tile_id_df,by="tile_coord")
758
#tile_id_df <- data.frame(tile_coord=list_tile_coord,tile_id=list_tile_id)
759
#gam_diagnostic_10x10_df <- merge(gam_diagnostic_10x10_df,tile_id_df,by="tile_coord")
742 760

  
743 761
# write.table(gam_diagnostic_10x10_df,
744 762
#             file=file.path(out_dir,paste("gam_diagnostic_10x10_df_",out_prefix,".txt",sep="")),sep=",")
......
794 812
######################################################
795 813
####### PART 2 CREATE MOSAIC OF PREDICTIONS PER DAY, Delta surfaces and clim ###
796 814

  
797
dates_l <- unique(robj1$tb_diagnostic_s$date) #list of dates to query tif
815
#dates_l <- unique(robj1$tb_diagnostic_s$date) #list of dates to query tif
816
#create date!!!
817
idx <- seq(as.Date('2010-01-01'), as.Date('2010-12-31'), 'day')
818
#idx <- seq(as.Date('20100101'), as.Date('20101231'), 'day')
819
#date_l <- strptime(idx[1], "%Y%m%d") # interpolation date being processed
820
dates_l <- format(idx, "%Y%m%d") # interpolation date being processed
798 821

  
799 822
## make this a function? report on number of tiles used for mosaic...
800 823

  
......
828 851
  lf_pred_tif[[i]] <- list_tif_files_dates
829 852
}
830 853

  
854
#Need to check how many dates were predicted (have tif) !!! make a table with that!! 
855

  
831 856
#Now get the clim surfaces:
832 857
month_l <- paste("clim_month_",1:12,sep="")
833
l_pattern_models <- lapply(c("_mod1_0_1.*","_mod2_0_1.*","_mod3_0_1.*","_mod_kr_0_1.*"),
858
#l_pattern_models <- lapply(c("_mod1_0_1.*","_mod2_0_1.*","_mod3_0_1.*","_mod_kr_0_1.*"),
859
#                           FUN=function(x){paste("*.",month_l,x,".*.tif",sep="")})
860
#generate this automatically!!!
861
l_pattern_models <- lapply(c("_mod1_0_1.*","_mod2_0_1.*","_mod_kr_0_1.*"),
834 862
                           FUN=function(x){paste("*.",month_l,x,".*.tif",sep="")})
863

  
864

  
835 865
#"CAI_TMAX_clim_month_11_mod2_0_145.0_-120.0.tif"
836 866
lf_clim_tif <- vector("list",length=nb_mod) #number of models is 3
837 867
for (i in 1:length(l_pattern_models)){
......
842 872
}
843 873

  
844 874
#Now get delta surfaces:
875

  
876
#mod_id <- c(1:(nb_mod-1),"_kr")
877
#pred_pattern_str <- paste(".*predicted_mod",mod_id,"_0_1.*",sep="")
878
#,".*predicted_mod2_0_1.*",".*predicted_mod3_0_1.*",".*predicted_mod_kr_0_1.*")
879
#l_pattern_models <- lapply(c(".*predicted_mod1_0_1.*",".*predicted_mod2_0_1.*",".*predicted_mod3_0_1.*",".*predicted_mod_kr_0_1.*"),
880
#                           FUN=function(x){paste(x,dates_l,".*.tif",sep="")})
881
#l_pattern_models <- lapply(pred_pattern_str,
882
                           FUN=function(x){paste(x,dates_l,".*.tif",sep="")})
883

  
845 884
date_l# <- paste("clim_month_",1:12,sep="")
846 885
#l_pattern_models <- lapply(c("_mod1_0_1.*","_mod2_0_1.*","_mod3_0_1.*","_mod_kr_0_1.*"),
847 886
#                           FUN=function(x){paste("*.",month_l,x,".*.tif",sep="")})
848
l_pattern_models <- lapply(c(".*delta_dailyTmax_mod1_del_0_1.*",".*delta_dailyTmax_mod2_del_0_1.*",".*delta_dailyTmax_mod3_del_0_1.*",".*delta_dailyTmax_mod_kr_del_0_1.*"),
887
#l_pattern_models <- lapply(c(".*delta_dailyTmax_mod1_del_0_1.*",".*delta_dailyTmax_mod2_del_0_1.*",".*delta_dailyTmax_mod3_del_0_1.*",".*delta_dailyTmax_mod_kr_del_0_1.*"),
888
#                           FUN=function(x){paste(x,dates_l,".*.tif",sep="")})
889
l_pattern_models <- lapply(c(".*delta_dailyTmax_mod1_del_0_1.*",".*delta_dailyTmax_mod2_del_0_1.*",".*delta_dailyTmax_mod_kr_del_0_1.*"),
849 890
                           FUN=function(x){paste(x,dates_l,".*.tif",sep="")})
850 891

  
851 892
lf_delta_tif <- vector("list",length=nb_mod) #number of models is 3
......
859 900

  
860 901
#### NOW create mosaic images for daily prediction
861 902

  
862
out_prefix_s <- paste(name_method,c("predicted_mod1_0_01","predicted_mod2_0_01","predicted_mod3_0_01","predicted_mod_kr_0_1"),sep="")
903
#out_prefix_s <- paste(name_method,c("predicted_mod1_0_01","predicted_mod2_0_01","predicted_mod3_0_01","predicted_mod_kr_0_1"),sep="")
904
out_prefix_s <- paste(name_method,c("predicted_mod1_0_01","predicted_mod2_0_01","predicted_mod_kr_0_1"),sep="")
905

  
863 906
dates_l #list of predicted dates
864 907
#l_out_rastnames_var <- paste(name_method,"predicted_mod1_0_01_",dates_l,sep="")
865 908
l_out_rastnames_var <- lapply(out_prefix_s,
......
1032 1075
pred_data_info <- mclapply(1:length(list_raster_obj_files[list_names_tile_id]),FUN=extract_daily_training_testing_info,list_param=list_param_training_testing_info,mc.preschedule=FALSE,mc.cores = 6)
1033 1076
#pred_data_info <- mclapply(1:length(list_raster_obj_files[list_names_tile_id][1:6]),FUN=extract_daily_training_testing_info,list_param=list_param_training_testing_info,mc.preschedule=FALSE,mc.cores = 6)
1034 1077
#pred_data_info <- lapply(1:length(list_raster_obj_files),FUN=extract_daily_training_testing_info,list_param=list_param_training_testing_info)
1035
#pred_data_info <- lapply(1:length(list_raster_obj_files[1]),FUN=extract_daily_training_testing_info,list_param=list_param_training_testing_info)
1078
pred_data_info <- lapply(1:length(list_raster_obj_files[1]),FUN=extract_daily_training_testing_info,list_param=list_param_training_testing_info)
1036 1079

  
1037 1080
pred_data_info_tmp <- remove_from_list_fun(pred_data_info)$list #remove data not predicted
1038 1081
##Add tile nanmes?? it is alreaready there
......
1072 1115
cmd_str <- paste("scp -p",filenames_NEX,paste(Atlas_hostname,Atlas_dir,sep=":"), sep=" ")
1073 1116
system(cmd_str)
1074 1117

  
1075
#system("scp -p ./*.txt parmentier@atlas.nceas.ucsb.edu:/data/project/layers/commons/NEX_data/output_run2_global_analyses_05122014")
1118
#system("scp -p ./*.txt parmentier@atlas.nceas.ucsb.edu:/data/project/layers/commons/NEX_data/output_run6_global_analyses_09162014")
1076 1119
#system("scp -p ./*.txt ./*.tif parmentier@atlas.nceas.ucsb.edu:/data/project/layers/commons/NEX_data/output_run2_global_analyses_05122014")
1077 1120

  
1078 1121
#### COPY SHAPEFILES, TIF MOSAIC, COMBINED TEXT FILES etc...
1079 1122

  
1080
#copy shapefiles defining regions
1081
Atlas_dir <- file.path("/data/project/layers/commons/NEX_data/",basename(out_dir),"output/subset/shapefiles")
1123
#Copy all shapefiles in one unique directory
1124

  
1125
Atlas_dir <- file.path("/data/project/layers/commons/NEX_data/",basename(out_dir),"shapefiles")
1082 1126
Atlas_hostname <- "parmentier@atlas.nceas.ucsb.edu"
1083 1127
lf_cp_shp <- df_tile_processed$shp_files #get all the files...
1084 1128

  
1085
layer_name <- sub(".shp","",basename(lf_cp_shp[[i]]))
1129
lf_cp_shp_pattern <- gsub(".shp","*",base_name(lf_cp_shp))
1130
lf_cp_shp_pattern <- file.path(dirname(lf_cp_shp),lf_cp_shp_pattern)
1131
filenames_NEX <- paste(lf_cp_shp_pattern,collapse=" ")  #copy raster prediction object
1132

  
1133
cmd_str <- paste("scp -p",filenames_NEX,paste(Atlas_hostname,Atlas_dir,sep=":"), sep=" ")
1134
system(cmd_str)
1086 1135

  
1136
###Copy shapefiles in the separate directories?
1087 1137
#lf_cp_shp <- list.files(in_dir_shp, ".shp",full.names=T)
1088 1138
list_tile_scp <- 1:6
1089 1139

  

Also available in: Unified diff