Revision b459ce4a
Added by Benoit Parmentier almost 9 years ago
climate/research/oregon/interpolation/global_run_scalingup_assessment_part1a.R | ||
---|---|---|
5 | 5 |
#Part 1 create summary tables and inputs files for figure in part 2 and part 3. |
6 | 6 |
#AUTHOR: Benoit Parmentier |
7 | 7 |
#CREATED ON: 03/23/2014 |
8 |
#MODIFIED ON: 01/03/2016
|
|
8 |
#MODIFIED ON: 01/04/2016
|
|
9 | 9 |
#Version: 5 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 | 11 |
#TO DO: |
... | ... | |
433 | 433 |
FUN=function(i,x){try(rep(names(x)[i],nrow(x[[i]])))},x=data_month_v_subsampling_tmp) |
434 | 434 |
data_month_v_subsmapling_NAM <- do.call(rbind.fill,ddata_month_v_subsampling_tmp) #combined data_month for "NAM" North America |
435 | 435 |
data_month_v_subsampling_NAM$tile_id <- unlist(tile_id) |
436 |
data_month_v_subsampling_NAM$reg <- reg |
|
436 |
data_month_v_subsampling_NAM$reg <- region_name
|
|
437 | 437 |
data_month_v_subsampling_NAM$year_predicted <- year_predicted |
438 | 438 |
|
439 | 439 |
write.table((data_month_v_subsampling_NAM), |
... | ... | |
508 | 508 |
list_outfiles[[10]] <- file.path(out_dir,paste("pred_data_month_info_",year_predicted,"_",out_prefix,".txt",sep="")) |
509 | 509 |
list_outfiles[[11]] <- file.path(out_dir,paste("pred_data_day_info_",year_predicted,"_",out_prefix,".txt",sep="")) |
510 | 510 |
|
511 |
#browser() #debugging on 01/042016 |
|
512 |
|
|
511 | 513 |
###################################################### |
512 | 514 |
####### PART 4: Get shapefiles defining region tiling with centroids ### |
513 | 515 |
|
... | ... | |
537 | 539 |
long<- as.numeric(lapply(1:length(tx),function(i,x){x[[i]][2]},x=tx)) |
538 | 540 |
df_tile_processed$lat <- lat |
539 | 541 |
df_tile_processed$lon <- long |
540 |
|
|
541 | 542 |
|
542 | 543 |
#put that list in the df_processed and also the centroids!! |
543 | 544 |
write.table(df_tile_processed, |
... | ... | |
550 | 551 |
|
551 | 552 |
#Copy to local home directory on NAS-NEX |
552 | 553 |
dir.create(file.path(out_dir,"shapefiles")) |
553 |
file.copy(list_shp_world,file.path(out_dir,"shapefiles")) |
|
554 |
#list_shp_world_dbf <- gsub(".shp",".*",basename(list_shp_world)) #remove shp extension, did not owork with file.copy |
|
555 |
#list_shp_world_dbf <- gsub(".shp",".dbf",basename(list_shp_world)) #remove shp extension |
|
556 |
#list_shp_world_prj <- gsub(".shp",".dbf",basename(list_shp_world)) #remove shp extension |
|
557 |
#list_shp_world_tmp <- file.path(dirname(list_shp_world), list_shp_world_tmp) |
|
558 |
list_shp_all <- list.files(path=in_dir_shp,full.names=T)#need all the files!!! including .dbf etc. |
|
559 |
file.copy(list_shp_all,file.path(out_dir,"shapefiles")) |
|
554 | 560 |
|
555 | 561 |
#save a list of all files... |
556 | 562 |
write.table(df_tiles_all, |
... | ... | |
574 | 580 |
write.table(df_assessment_files, |
575 | 581 |
file=df_assessment_files_name,sep=",") |
576 | 582 |
|
583 |
#with reg4 prediction 2014, it took 1h36minutes to reach this point in the code. |
|
584 |
#this was processed using the bridge1 with 6 cores... |
|
585 |
|
|
577 | 586 |
###################################################### |
578 | 587 |
####### PART 5: run plotting functions to produce figures |
579 | 588 |
|
589 |
#browser() #debugging on 01/042016 |
|
590 |
#out_dir <- "/nobackupp8/bparmen1/output_run_global_analyses_pred_12282015" |
|
580 | 591 |
in_dir <- out_dir #PARAM 0 |
581 | 592 |
#y_var_name <- "dailyTmax" #PARAM1 , already set |
582 | 593 |
#interpolation_method <- c("gam_CAI") #PARAM2, already set |
... | ... | |
596 | 607 |
#num_cores <- 6 #PARAM 14, already set |
597 | 608 |
#region_name <- c("reg4") #reference region to merge if necessary, if world all the regions are together #PARAM 16 |
598 | 609 |
#use previous files produced in step 1a and stored in a data.frame |
599 |
#df_assessment_files_name <- "df_assessment_files_reg4_1984_run_global_analyses_pred_12282015.txt"# #PARAM 17, set in the script |
|
610 |
#df_assessment_files_name <- "df_assessment_files_reg4_2014_run_global_analyses_pred_12282015.txt"# #PARAM 17, set in the script |
|
611 |
#df_assessment_files <- read.table(df_assessment_files_name,stringsAsFactors=F,sep=",") |
|
600 | 612 |
#threshold_missing_day <- c(367,365,300,200) #PARM18 |
601 | 613 |
|
602 | 614 |
list_param_run_assessment_plotting <- list(in_dir,y_var_name, interpolation_method, out_suffix, |
603 |
out_dir, create_out_dir_param, mosaic_plot, proj_str, file_format, NA_value,
|
|
615 |
out_dir, create_out_dir_param, mosaic_plot, proj_str, file_format, NA_flag_val,
|
|
604 | 616 |
multiple_region, countries_shp, plot_region, num_cores, |
605 |
region_name, df_assessment_files_name, threshold_missing_day) |
|
617 |
region_name, df_assessment_files_name, threshold_missing_day,year_predicted)
|
|
606 | 618 |
|
607 | 619 |
names(list_param_run_assessment_plotting) <- c("in_dir","y_var_name","interpolation_method","out_suffix", |
608 |
"out_dir","create_out_dir_param","mosaic_plot","proj_str","file_format","NA_value",
|
|
620 |
"out_dir","create_out_dir_param","mosaic_plot","proj_str","file_format","NA_flag_val",
|
|
609 | 621 |
"multiple_region","countries_shp","plot_region","num_cores", |
610 |
"region_name","df_assessment_files_name","threshold_missing_day") |
|
622 |
"region_name","df_assessment_files_name","threshold_missing_day","year_predicted")
|
|
611 | 623 |
|
612 | 624 |
#function_assessment_part2 <- "global_run_scalingup_assessment_part2_01032016.R" |
613 | 625 |
#source(file.path(script_path,function_assessment_part2)) #source all functions used in this script |
Also available in: Unified diff
assessment part1 call to figure plot assessment debug for shapefiles not read in