Project

General

Profile

« Previous | Next » 

Revision 3d5c8553

Added by Benoit Parmentier about 10 years ago

NEX assessment part1, region 2 assessment with mosaics

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: 11/30/2014            
8
#MODIFIED ON: 12/15/2014            
9 9
#Version: 3
10 10
#PROJECT: Environmental Layers project  
11 11
#TO DO:
......
457 457
#### Parameters and constants  
458 458

  
459 459
#in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output1000x3000_km/"
460
in_dir1 <- "/nobackupp6/aguzman4/climateLayers/output1500x4500_km/"
460
#in_dir1 <- "/nobackupp6/aguzman4/climateLayers/output1500x4500_km/"
461
in_dir1 <- "/nobackupp6/aguzman4/climateLayers/output1000x3000_km/reg2"
461 462
#/nobackupp4/aguzman4/climateLayers/output10Deg/reg1/finished.txt
462 463
in_dir_list <- list.dirs(path=in_dir1,recursive=FALSE) #get the list regions processed for this run
463 464
#in_dir_list <- in_dir_list[c(3,4)] #get the list regions processed for this run
464 465

  
465 466
#if(basename(in_dir_list)[[1]]=="reg?") #add later
466
in_dir_list_all  <- lapply(in_dir_list,function(x){list.dirs(path=x,recursive=F)})
467
#in_dir_list_all  <- lapply(in_dir_list,function(x){list.dirs(path=x,recursive=F)})
467 468
#in_dir_list_all <- in_dir_list
468 469
#in_dir_list <- list.dirs(path=in_dir_reg,recursive=FALSE) #get the list of tiles/directories with outputs 
469 470
#in_dir_list <- unlist(in_dir_list_all[c(2)]) #only region 3 has informatation at this stage
470
in_dir_list <- unlist(in_dir_list_all) #[c(2)]) #only region 3 has informatation at this stage
471
#in_dir_list <- unlist(in_dir_list_all) #[c(2)]) #only region 3 has informatation at this stage
471 472

  
472 473
#in_dir_list <- in_dir_list[grep("bak",basename(basename(in_dir_list)),invert=TRUE)] #the first one is the in_dir1
473 474
in_dir_subset <- in_dir_list[grep("subset",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
......
498 499
# the last directory contains shapefiles 
499 500
y_var_name <- "dailyTmax"
500 501
interpolation_method <- c("gam_CAI")
501
out_prefix<-"run10_global_analyses_11302014"
502
out_prefix<-"run10_global_analyses_12152014"
502 503

  
503 504
#out_dir<-"/data/project/layers/commons/NEX_data/" #On NCEAS Atlas
504 505
out_dir <- "/nobackup/bparmen1/" #on NEX
......
560 561
df_tile_processed$path_NEX <- in_dir_list
561 562
  
562 563
##Quick exploration of raster object
563
robj1 <- load_obj(list_raster_obj_files[[20]]) #This is an example tile
564
robj1 <- load_obj(list_raster_obj_files[[3]]) #This is an example tile
564 565
#robj1 <- load_obj(lf_raster_obj[4]) #This is tile tile
565 566

  
566 567
names(robj1)
......
1010 1011
#for i in 1:length(df_tiled_processed$tile_coord)
1011 1012
#output_atlas_dir <- "/data/project/layers/commons/NEX_data/output_run3_global_analyses_06192014/output10Deg/reg1"
1012 1013
#output_atlas_dir <- "/data/project/layers/commons/NEX_data/output_run5_global_analyses_08252014/output20Deg"
1013
output_atlas_dir <- "/data/project/layers/commons/NEX_data/output_run10_global_analyses_11302014"
1014
output_atlas_dir <- "/data/project/layers/commons/NEX_data/output_run10_global_analyses_12152014"
1014 1015
#Make directories on ATLAS
1015 1016
#for (i in 1:length(df_tile_processed$tile_coord)){
1016 1017
#  create_dir_fun(file.path(output_atlas_dir,as.character(df_tile_processed$tile_coord[i])),out_suffix=NULL)
......
1158 1159
}
1159 1160

  
1160 1161
##################### END OF SCRIPT ######################
1162

  
1163

  
1164
###Mosaic ...
1165
#MODULEPATH=$MODULEPATH:/nex/modules/files
1166
#module load pythonkits/gdal_1.10.0_python_2.7.3_nex
1167

  
1168

  
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: 11/30/2014            
8
#MODIFIED ON: 12/15/2014            
9 9
#Version: 3
10 10
#PROJECT: Environmental Layers project     
11 11
#COMMENTS: analyses for run 5 global using 6 specific tiles
......
215 215
#in_dir1 <- "/data/project/layers/commons/NEX_data/output_run6_global_analyses_09162014/output20Deg2"
216 216
# parent output dir for the curent script analyes
217 217
#out_dir <-"/data/project/layers/commons/NEX_data/output_run3_global_analyses_06192014/" #On NCEAS Atlas
218
out_dir <-"/data/project/layers/commons/NEX_data/output_run10_global_analyses_11302014/"
218
out_dir <-"/data/project/layers/commons/NEX_data/output_run10_global_analyses_12152014/"
219 219
# input dir containing shapefiles defining tiles
220 220
#in_dir_shp <- "/data/project/layers/commons/NEX_data/output_run5_global_analyses_08252014/output/subset/shapefiles"
221 221

  
......
228 228

  
229 229
y_var_name <- "dailyTmax"
230 230
interpolation_method <- c("gam_CAI")
231
out_prefix<-"run10_global_analyses_11302014"
231
out_prefix<-"run10_global_analyses_12152014"
232 232
mosaic_plot <- FALSE
233 233

  
234 234
#CRS_locs_WGS84 <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84
......
274 274
#gam_diagnostic_df <- read.table(file=file.path(out_dir,"gam_diagnostic_df_run4_global_analyses_08142014.txt"),sep=",")
275 275

  
276 276
########################## START SCRIPT ##############################
277
tb$pred_mod <- as.character(tb$pred_mod)
278
summary_metrics_v$pred_mod <- as.character(summary_metrics_v$pred_mod)
277 279

  
278
mulitple_region <- TRUE
280
mulitple_region <- FALSE
279 281

  
280 282
#multiple regions?
281 283
if(mulitple_region==TRUE){
......
283 285
}
284 286

  
285 287
#This part is specifically related to this run : dropping model with elev
286
tb <- merge(tb,df_tile_processed,by="tile_id")
287
tb$pred_mod <- as.character(tb$pred_mod)
288
tb_tmp_reg5 <- subset(tb,reg=="reg5")
289
tb_tmp_reg4 <- subset(tb,reg=="reg4")
290
tb_tmp_reg4 <- subset(tb_tmp_reg4,pred_mod!="mod1") #remove mod1 because it is not in reg5
291
tb_tmp_reg4$pred_mod <- replace(tb_tmp_reg4$pred_mod, tb_tmp_reg4$pred_mod=="mod2", "mod1")
292
tb <- rbind(tb_tmp_reg4,tb_tmp_reg5)
288
#tb <- merge(tb,df_tile_processed,by="tile_id")
289

  
290
#tb_tmp_reg5 <- subset(tb,reg=="reg5")
291
#tb_tmp_reg4 <- subset(tb,reg=="reg4")
292
#tb_tmp_reg4 <- subset(tb_tmp_reg4,pred_mod!="mod1") #remove mod1 because it is not in reg5
293
#tb_tmp_reg4$pred_mod <- replace(tb_tmp_reg4$pred_mod, tb_tmp_reg4$pred_mod=="mod2", "mod1")
294
#tb <- rbind(tb_tmp_reg4,tb_tmp_reg5)
293 295

  
294 296
#ac_mod <- summary_metrics_v[summary_metrics_v$pred_mod==model_name[i],]
295
summary_metrics_v <- merge(summary_metrics_v,df_tile_processed,by="tile_id")
296
table(summary_metrics_v$reg)
297
#summary_metrics_v <- merge(summary_metrics_v,df_tile_processed,by="tile_id")
298
#table(summary_metrics_v$reg)
297 299

  
298
summary_metrics_v$pred_mod <- as.character(summary_metrics_v$pred_mod)
299
summary_metrics_v_reg5 <- subset(summary_metrics_v,reg=="reg5")
300
summary_metrics_v_reg4 <- subset(summary_metrics_v,reg=="reg4")
301
summary_metrics_v_reg4 <- subset(summary_metrics_v_reg4,pred_mod!="mod1") #remove mod1 because it is not in reg5
302
summary_metrics_v_reg4$pred_mod <- replace(summary_metrics_v_reg4$pred_mod, 
303
                                           summary_metrics_v_reg4$pred_mod=="mod2", "mod1")
304
summary_metrics_v <- rbind(summary_metrics_v_reg4,summary_metrics_v_reg5)
300
#summary_metrics_v_reg5 <- subset(summary_metrics_v,reg=="reg5")
301
#summary_metrics_v_reg4 <- subset(summary_metrics_v,reg=="reg4")
302
#summary_metrics_v_reg4 <- subset(summary_metrics_v_reg4,pred_mod!="mod1") #remove mod1 because it is not in reg5
303
#summary_metrics_v_reg4$pred_mod <- replace(summary_metrics_v_reg4$pred_mod, 
304
#                                           summary_metrics_v_reg4$pred_mod=="mod2", "mod1")
305
#summary_metrics_v <- rbind(summary_metrics_v_reg4,summary_metrics_v_reg5)
305 306

  
306 307
###############
307 308
### Figure 1: plot location of the study area with tiles processed
......
640 641
  #plot(ac_mod1,cex=sqrt(ac_mod1$rmse),pch=1,add=T)
641 642
  #plot(ac_mod,cex=(ac_mod$rmse^2)/10,pch=1,col="red",add=T)
642 643

  
643
  #coordinates(ac_mod) <- ac_mod[,c("lon","lat")] 
644
  coordinates(ac_mod) <- ac_mod[,c("lon","lat")] 
644 645
  #coordinates(ac_mod) <- ac_mod[,c("lon.x","lat.x")] #solve this later
645 646
  p_shp <- layer(sp.polygons(reg_layer, lwd=1, col='black'))
646 647
  #title("(a) Mean for 1 January")
......
662 663
sum(df_tile_processed$metrics_v)/length(df_tile_processed$metrics_v) #81.40%
663 664

  
664 665
#coordinates
665
#coordinates(summary_metrics_v) <- c("lon","lat")
666
coordinates(summary_metrics_v) <- c("lon.y","lat.y")
666
coordinates(summary_metrics_v) <- c("lon","lat")
667
#coordinates(summary_metrics_v) <- c("lon.y","lat.y")
667 668

  
668 669
summary_metrics_v$n_missing <- summary_metrics_v$n == 365
669 670
summary_metrics_v$n_missing <- summary_metrics_v$n < 365

Also available in: Unified diff