Project

General

Profile

« Previous | Next » 

Revision 48863fb9

Added by Benoit Parmentier about 10 years ago

run4 assessment NEX gam fitting with different k plots

View differences:

climate/research/oregon/interpolation/global_run_scalingup_assessment_part1.R
315 315
#in_dir1 <- "/data/project/layers/commons/NEX_data/test_run1_03232014/output" #On Atlas
316 316
#in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output10Deg/reg1/" #On NEX
317 317
in_dir1 <- "/nobackupp4/aguzman4/climateLayers/output20Deg/"
318
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg5/20.0_0.0/
319
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg3/-20.0_-70.0/
320
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg5/20.0_30.0/
321
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg4/40.0_0.0/
322
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg5/20.0_-10.0/
323
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg4/50.0_0.0/
324
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg6/60.0_40.0/
325
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg6/30.0_40.0/
326

  
327 318

  
328 319
#/nobackupp4/aguzman4/climateLayers/output10Deg/reg1/finished.txt
329 320
#in_dir_list <- list.dirs(path=in_dir1,recursive=FALSE) #get the list of directories with resutls by 10x10 degree tiles
......
345 336
#in_dir_list <- file.path(in_dir1,read.table(file.path(in_dir1,"processed.txt"))$V1)
346 337
#in_dir_list <- as.list(in_dir_list[-1])
347 338
#in_dir_list <- in_dir_list[grep("bak",basename(basename(in_dir_list)),invert=TRUE)] #the first one is the in_dir1
348
in_dir_shp <- in_dir_list[grep("shapefiles",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
339
#in_dir_shp <- in_dir_list[grep("shapefiles",basename(in_dir_list),invert=FALSE)] #select directory with shapefiles...
349 340
in_dir_shp <- c(
350 341
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg3/subset/shapefiles/",
351 342
"/nobackupp4/aguzman4/climateLayers/output20Deg/reg5/subset/shapefiles/",
......
403 394

  
404 395
lf_covar_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="covar_obj.*.RData",full.names=T)})
405 396
lf_covar_tif <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="covar.*.tif",full.names=T)})
406
lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostic.*.RData",full.names=T)})
397
#diagnostics_obj_gam_fitting_dailyTmax7__08062014.RData
398
lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostics_.*.RData",full.names=T)})
399
lf_diagnostic_obj <- lf_diagnostic_obj[grep("lk_min",lf_diagnostic_obj,invert=T)] #remove object that have lk_min...
407 400

  
408 401
########################## START SCRIPT ##############################
409 402

  
......
486 479
write.table((tb_diagnostic_v_NA),
487 480
            file=file.path(out_dir,paste("tb_diagnostic_v_NA","_",out_prefix,".txt",sep="")),sep=",")
488 481

  
482
####### process gam fitting diagnostic info
483

  
484
#/nobackupp4/aguzman4/climateLayers/output20Deg/reg5/20.0_30.0//diagnostics_obj_gam_fitting_TMax_9_mod2_08062014.RData
485
#lf_diagnostic_obj <- lapply(in_dir_list,FUN=function(x){list.files(path=x,pattern="diagnostics_.*.RData",full.names=T)})
486
#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)})
487
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)})
488

  
489
#lf_diagnostic_obj <- lf_diagnostic_obj[grep("lk_min",lf_diagnostic_obj,invert=T)] #remove object that have lk_min...
490

  
491
names(lf_diagnostic_obj) <- list_names_tile_id
492
lf_diagnostic_obj_tmp <- remove_from_list_fun(lf_diagnostic_obj)$list
493
#df_tile_processed$tb_diag <- remove_from_list_fun(tb_diagnostic_v_list)$valid
494

  
495
gam_diagnostic_tb_list <- vector("list",length=length(lf_diagnostic_obj_tmp))
496
for(i in 1:length(lf_diagnostic_obj_tmp)){
497
  l_diagnostic_obj_tmp <- lf_diagnostic_obj_tmp[[i]]
498
  tile_id_name <-  names(lf_diagnostic_obj_tmp)[i]
499
  #l_diagnostic_obj_tmp <- l_diagnostic_obj_tmp[grep("lk_min",l_diagnostic_obj_tmp,invert=T)] #remove object that have lk_min...
500
  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)                            
501
  gam_diagnostic_tb <- do.call(rbind.fill,l_diagnostic_obj_tmp_list)#create a df for NA tiles with all accuracy metrics
502
  gam_diagnostic_tb$tile_id <- tile_id_name
503
  gam_diagnostic_tb_list[[i]] <- gam_diagnostic_tb    
504
}
505

  
506
gam_diagnostic_df <- do.call(rbind.fill,gam_diagnostic_tb_list) #create a df for NA tiles with all accuracy metrics
507

  
508
write.table(gam_diagnostic_df,
509
            file=file.path(out_dir,paste("gam_diagnostic_df_",out_prefix,".txt",sep="")),sep=",")
510

  
489 511
#################
490 512
###Table 3: monthly station information with predictions for all tiles
491 513

  

Also available in: Unified diff