Revision 9ad802bf
Added by Benoit Parmentier over 8 years ago
climate/research/oregon/interpolation/global_product_assessment_part1.R | ||
---|---|---|
4 | 4 |
#Combining tables and figures for individual runs for years and tiles. |
5 | 5 |
#AUTHOR: Benoit Parmentier |
6 | 6 |
#CREATED ON: 05/15/2016 |
7 |
#MODIFIED ON: 09/16/2016
|
|
7 |
#MODIFIED ON: 09/17/2016
|
|
8 | 8 |
#Version: 1 |
9 | 9 |
#PROJECT: Environmental Layers project |
10 | 10 |
#COMMENTS: Initial commit, script based on part NASA biodiversity conferenc |
... | ... | |
19 | 19 |
# |
20 | 20 |
#setfacl -Rmd user:aguzman4:rwx /nobackupp8/bparmen1/output_run10_1500x4500_global_analyses_pred_1992_10052015 |
21 | 21 |
|
22 |
#COMMIT: fixing extraction function and and missing dates
|
|
22 |
#COMMIT: clean up and first testing of extraction function
|
|
23 | 23 |
|
24 | 24 |
################################################################################################# |
25 | 25 |
|
... | ... | |
518 | 518 |
|
519 | 519 |
#debug(extract_date) |
520 | 520 |
#test <- extract_date(6431,lf_mosaic_list,12) #extract item number 12 from the name of files to get the data |
521 |
list_dates_produced <- unlist(mclapply(1:length(lf_mosaic_list),FUN=extract_date,x=lf_mosaic_list,item_no=13,mc.preschedule=FALSE,mc.cores = num_cores)) |
|
521 |
#list_dates_produced <- unlist(mclapply(1:length(lf_mosaic_list),FUN=extract_date,x=lf_mosaic_list,item_no=13,mc.preschedule=FALSE,mc.cores = num_cores))
|
|
522 | 522 |
#list_dates_produced <- mclapply(1:2,FUN=extract_date,x=lf_mosaic_list,item_no=13,mc.preschedule=FALSE,mc.cores = 2) |
523 | 523 |
|
524 |
list_dates_produced_date_val <- as.Date(strptime(list_dates_produced,"%Y%m%d")) |
|
525 |
month_str <- format(list_dates_produced_date_val, "%b") ## Month, char, abbreviated |
|
526 |
year_str <- format(list_dates_produced_date_val, "%Y") ## Year with century |
|
527 |
day_str <- as.numeric(format(list_dates_produced_date_val, "%d")) ## numeric month |
|
528 |
|
|
529 |
df_produced <- data.frame(basename(lf_mosaic_list),list_dates_produced_date_val,month_str,year_str,day_str,dirname(lf_mosaic_list)) |
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
#### |
|
534 |
df_points$date <- list_dates_produced_date_val |
|
535 |
df_points$month <- month_str |
|
536 |
df_points$year <- year_str |
|
537 |
df_points$day <- day_str |
|
538 |
|
|
539 |
in_dir_mosaic <- "/data/project/layers/commons/NEX_data/climateLayers/out/reg1/mosaics/mosaic" |
|
540 |
in_dir_mosaic_rmse <- "/data/project/layers/commons/NEX_data/climateLayers/out/reg1/mosaicsRMSE/mosaic" |
|
541 |
#pattern_str <- ".*.tif" |
|
524 |
if(is.null(df_points_extracted_fname)){ |
|
525 |
|
|
526 |
in_dir_mosaic <- "/data/project/layers/commons/NEX_data/climateLayers/out/reg1/mosaics/mosaic" |
|
527 |
#in_dir_mosaic_rmse <- "/data/project/layers/commons/NEX_data/climateLayers/out/reg1/mosaicsRMSE/mosaic" |
|
528 |
pattern_str <- ".*.tif" |
|
529 |
df_points <- #this contains the location of points to be used for extraction |
|
530 |
|
|
531 |
#extract from var pred mosaic, tmax in this case: |
|
532 |
extract_obj_var_pred <- extract_from_time_series_raster_stack(df_points,date_start,date_end,lf_raster=NULL,item_no=13, |
|
533 |
num_cores=11,pattern_str=NULL,in_dir=in_dir_mosaic,out_dir=out_dir,out_suffix=out_suffix) |
|
534 |
df_points_extracted_fname <-extract_obj_var_pred$df_points_extracted_fname |
|
535 |
df_raster_fname <- extract_obj_var_pred$df_raster_fname |
|
536 |
df_time_series_fname <- extract_obj_var_pred$df_time_series_fname |
|
542 | 537 |
|
543 |
extract_from_time_series_raster_stack(df_points,date_start,date_end,lf_raster,item_no=13,num_cores=4,pattern_str=NULL,in_dir=NULL,out_dir=".",out_suffix="") |
|
544 |
# |
|
538 |
df_raster <- read.table(df_points_extracted_fname,sep=",") |
|
539 |
df_time_series <- read.table( df_time_series,sep=",") |
|
540 |
df_points_extracted <- read.table(df_points_extracted_fname,sep=",") |
|
545 | 541 |
|
546 | 542 |
|
547 | 543 |
}else{ |
548 | 544 |
df_points_day_extracted <- read.table(df_points_extracted_fname,sep=",") |
545 |
df_time_series <- read.table( df_time_series,sep=",") |
|
546 |
df_points_extracted <- read.table(df_points_extracted_fname,sep=",") |
|
549 | 547 |
} |
550 | 548 |
|
551 |
df_points_day_extracted |
|
552 |
names(df_points_day_extracted)[1:10] |
|
553 |
(df_points_day_extracted$ID)[1:10] |
|
554 |
|
|
555 |
df_points_day_extracted_tmp <- df_points_day_extracted |
|
556 |
df_points_extracted <- cbind(df_points_day,df_points_day_extracted_tmp) |
|
557 |
#df_points_extracted$id <- df_points_day$id |
|
558 |
|
|
549 |
################################################################################################# |
|
550 |
###################### PART 5: combine stations data and extracted values ############################ |
|
559 | 551 |
#### Now combined with the station data extracted from the assessment stage |
560 |
combine |
|
552 |
|
|
553 |
#combine |
|
561 | 554 |
data_stations_var_pred |
562 | 555 |
|
563 | 556 |
##write function to combine data!!! |
Also available in: Unified diff
moving more functions, quick small test for extraction function, listing date produced and missing for mosaics