Project

General

Profile

« Previous | Next » 

Revision 8df39bf1

Added by Benoit Parmentier over 9 years ago

global assessment part1, obtaining training and testing information from global runs

View differences:

climate/research/oregon/interpolation/global_run_scalingup_assessment_part1.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: 04/24/2015            
8
#MODIFIED ON: 04/27/2015            
9 9
#Version: 4
10 10
#PROJECT: Environmental Layers project  
11 11
#TO DO:
......
90 90
CRS_locs_WGS84 <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0") #Station coords WGS84, #PARAM8
91 91

  
92 92
#day_to_mosaic <- c("20100101","20100901") #PARAM9
93
#day_to_mosaic <- c("20100101","20100102","20100103","20100104","20100105",
94
#                   "20100301","20100302","20100303","20100304","20100305",
95
#                   "20100501","20100502","20100503","20100504","20100505",
96
#                   "20100701","20100702","20100703","20100704","20100705",
97
#                   "20100901","20100902","20100903","20100904","20100905",
98
#                   "20101101","20101102","20101103","20101104","20101105")
99
day_to_mosaic <- NULL #if day to mosaic is null then mosaic all dates?
93
day_to_mosaic <- c("20100101","20100102","20100103","20100104","20100105",
94
                   "20100301","20100302","20100303","20100304","20100305",
95
                   "20100501","20100502","20100503","20100504","20100505",
96
                   "20100701","20100702","20100703","20100704","20100705",
97
                   "20100901","20100902","20100903","20100904","20100905",
98
                   "20101101","20101102","20101103","20101104","20101105")
99
#day_to_mosaic <- NULL #if day to mosaic is null then mosaic all dates?
100 100

  
101 101
file_format <- ".tif" #format for mosaiced files #PARAM10
102 102
NA_flag_val <- -9999  #No data value, #PARAM11
......
110 110
#module_path <- "/nobackupp6/aguzman4/climateLayers/sharedCode/" #PARAM14
111 111
#mosaics script #PARAM 15
112 112
#shell global mosaic script #PARAM 16
113
#gather station data
113 114

  
114 115
########################## START SCRIPT #########################################
115 116

  
......
369 370
# write.table((data_month_NAM),
370 371
#             file=file.path(out_dir,paste("data_month_s_NAM","_",out_prefix,".txt",sep="")),sep=",")
371 372

  
373
##### SPDF of daily Station info
374
#load data_month for specific tiles
375
# data_month <- extract_from_list_obj(robj1$clim_method_mod_obj,"data_month")
376
# names(data_month) #this contains LST means (mm_1, mm_2 etc.) as well as TMax and other info
377
# 
378
data_day_s_list <- mclapply(list_raster_obj_files,FUN=function(x){try(x<-load_obj(x));try(x$validation_mod_obj[["data_s"]])},mc.preschedule=FALSE,mc.cores = num_cores)    
379
data_day_v_list <- mclapply(list_raster_obj_files,FUN=function(x){try(x<-load_obj(x));try(x$validation_mod_obj[["data_v"]])},mc.preschedule=FALSE,mc.cores = num_cores)    
380

  
381
data_day_s_list <- mclapply(list_raster_obj_files[1:6],FUN=function(x){try(x<-load_obj(x));try(x$validation_mod_obj[["data_s"]])},mc.preschedule=FALSE,mc.cores = num_cores)    
382

  
383
data_day_v_list <- mclapply(list_raster_obj_files,FUN=function(x){try(x<-load_obj(x));try(extract_list_from_list_obj(x$validation_mod_obj,"data_v"))},mc.preschedule=FALSE,mc.cores = num_cores)    
384
data_day_s_list <- mclapply(list_raster_obj_files,FUN=function(x){try(x<-load_obj(x));try(extract_list_from_list_obj(x$validation_mod_obj,"data_s"))},mc.preschedule=FALSE,mc.cores = num_cores)    
385

  
386
list_data_day_v <- try(extract_list_from_list_obj(raster_obj$validation_mod_obj,"data_v"))
387
list_data_day_s <- try(extract_list_from_list_obj(raster_obj$validation_mod_obj,"data_s"))
388
sampling_dat_day <- extract_list_from_list_obj(raster_obj$method_mod_obj,"daily_dev_sampling_dat")
389
#debug(pred_data_info_fun)
390
#list_pred_data_day_s_info <- pred_data_info_fun(1,list_data=list_data_day_s,pred_mod=pred_mod,sampling_dat_info=sampling_dat_day)
391
list_pred_data_day_s_info <- lapply(1:length(sampling_dat_day),FUN=pred_data_info_fun,
392
           list_data=list_data_day_s,pred_mod=pred_mod,sampling_dat_info=sampling_dat_day)
393
list_pred_data_day_v_info <- lapply(1:length(sampling_dat_day),FUN=pred_data_info_fun,
394
           list_data=list_data_day_v,pred_mod=pred_mod,sampling_dat_info=sampling_dat_day)
395
pred_data_day_s_info <- do.call(rbind,list_pred_data_day_s_info)
396
pred_data_day_v_info <- do.call(rbind,list_pred_data_day_v_info)
397
pred_data_day_s_info$training <- rep(1,nrow(pred_data_day_s_info)) 
398
pred_data_day_v_info$training <- rep(0,nrow(pred_data_day_v_info)) 
399
pred_data_day_info <-rbind(pred_data_day_v_info,pred_data_day_s_info)
400

  
401
# 
402
 names(data_month_s_list) <- list_names_tile_id
403
# 
404
# data_month_tmp <- remove_from_list_fun(data_month_s_list)$list
405
# #df_tile_processed$metrics_v <- remove_from_list_fun(data_month_s_list)$valid
406
# 
407
# tile_id <- lapply(1:length(data_month_tmp),
408
#                   FUN=function(i,x){rep(names(x)[i],nrow(x[[i]]))},x=data_month_tmp)
409
# data_month_NAM <- do.call(rbind.fill,data_month_list) #combined data_month for "NAM" North America
410
# data_month_NAM$tile_id <- unlist(tile_id)
411
# 
412
# write.table((data_month_NAM),
413
#             file=file.path(out_dir,paste("data_month_s_NAM","_",out_prefix,".txt",sep="")),sep=",")
414

  
372 415
##### SPDF of Daily Station info
373 416

  
374 417

  
......
537 580
### SECOND mosaics globally from regional mosaics...
538 581
### Now find out how many files were predicted
539 582
# will be useful later on
583
# Transform this into a function that takes in a list of files!!! We can skip the region stage to reduce the number of files..
540 584

  
541 585
#sh /nobackupp6/aguzman4/climateLayers/sharedCode/shMergeFromFile.sh list_mosaics_20100901.txt world_mosaics_1000x3000_20100901.tif
542 586

  

Also available in: Unified diff