Revision b24654b2
Added by Benoit Parmentier over 8 years ago
climate/research/oregon/interpolation/global_run_scalingup_assessment_part3.R | ||
---|---|---|
196 | 196 |
###Table 1: Average accuracy metrics |
197 | 197 |
###Table 2: daily accuracy metrics for all tiles |
198 | 198 |
|
199 |
in_dir_list <- as.list(read.table(in_dir_list_filename,stringsAsFactors=F)[,1]) |
|
200 |
|
|
199 |
if(!is.null(in_dir_list_filename)){ |
|
200 |
in_dir_list <- as.list(read.table(in_dir_list_filename,stringsAsFactors=F)[,1]) |
|
201 |
}else{ |
|
202 |
pattern_str <- paste0("^output_",region_name,".*.") |
|
203 |
in_dir_list_all <- list.dirs(path=in_dir,recursive = T) |
|
204 |
in_dir_list <- in_dir_list_all[grep(pattern_str,basename(in_dir_list_all),invert=FALSE)] #select directory with shapefiles... |
|
205 |
#in_dir_shp <- file.path(in_dir_list_all,"shapefiles") |
|
206 |
} |
|
207 |
#pattern_str <- file.path(in_dir,paste0("output_",region_name,".*.")) |
|
208 |
#test <- Sys.glob(pattern_str,FALSE) |
|
209 |
# searchStr = paste(in_dir_tiles_tmp,"/*/",year_processed,"/gam_CAI_dailyTmax_predicted_",pred_mod_name,"*",day_to_mosaic[i],"*.tif",sep="") |
|
210 |
# #print(searchStr) |
|
211 |
# Sys.glob(searchStr)}) |
|
212 |
|
|
213 |
#lf_mosaic <- lapply(1:length(day_to_mosaic),FUN=function(i){ |
|
214 |
# searchStr = paste(in_dir_tiles_tmp,"/*/",year_processed,"/gam_CAI_dailyTmax_predicted_",pred_mod_name,"*",day_to_mosaic[i],"*.tif",sep="") |
|
215 |
# #print(searchStr) |
|
216 |
# Sys.glob(searchStr)}) |
|
217 |
|
|
201 | 218 |
##Read in data list from in_dir_list |
202 |
list_tb_fname <- list.files(path=file.path(in_dir,in_dir_list),"tb_diagnostic_v_NA_.*.txt",full.names=T) |
|
203 |
list_df_fname <- list.files(path=file.path(in_dir,in_dir_list),"df_tile_processed_.*..txt",full.names=T) |
|
204 |
list_summary_metrics_v_fname <- list.files(path=file.path(in_dir,in_dir_list),"summary_metrics_v2_NA_.*.txt",full.names=T) |
|
205 |
list_tb_s_fname <- list.files(path=file.path(in_dir,in_dir_list),"tb_diagnostic_s_NA.*.txt",full.names=T) |
|
206 |
list_tb_month_s_fname <- list.files(path=file.path(in_dir,in_dir_list),"tb_month_diagnostic_s.*.txt",full.names=T) |
|
207 |
list_data_month_s_fname <- list.files(path=file.path(in_dir,in_dir_list),"data_month_s.*.txt",full.names=T) |
|
208 |
list_data_s_fname <- list.files(path=file.path(in_dir,in_dir_list),"data_day_s.*.txt",full.names=T) |
|
209 |
list_data_v_fname <- list.files(path=file.path(in_dir,in_dir_list),"data_day_v.*.txt",full.names=T) |
|
210 |
list_pred_data_month_info_fname <- list.files(path=file.path(in_dir,in_dir_list),"pred_data_month_info.*.txt",full.names=T) |
|
211 |
list_pred_data_day_info_fname <- list.files(path=file.path(in_dir,in_dir_list),"pred_data_day_info.*.txt",full.names=T) |
|
219 |
#list_tb_fname <- list.files(path=file.path(in_dir,in_dir_list),"tb_diagnostic_v_NA_.*.txt",full.names=T) |
|
220 |
#list_df_fname <- list.files(path=file.path(in_dir,in_dir_list),"df_tile_processed_.*..txt",full.names=T) |
|
221 |
#list_summary_metrics_v_fname <- list.files(path=file.path(in_dir,in_dir_list),"summary_metrics_v2_NA_.*.txt",full.names=T) |
|
222 |
#list_tb_s_fname <- list.files(path=file.path(in_dir,in_dir_list),"tb_diagnostic_s_NA.*.txt",full.names=T) |
|
223 |
#list_tb_month_s_fname <- list.files(path=file.path(in_dir,in_dir_list),"tb_month_diagnostic_s.*.txt",full.names=T) |
|
224 |
#list_data_month_s_fname <- list.files(path=file.path(in_dir,in_dir_list),"data_month_s.*.txt",full.names=T) |
|
225 |
#list_data_s_fname <- list.files(path=file.path(in_dir,in_dir_list),"data_day_s.*.txt",full.names=T) |
|
226 |
#list_data_v_fname <- list.files(path=file.path(in_dir,in_dir_list),"data_day_v.*.txt",full.names=T) |
|
227 |
#list_pred_data_month_info_fname <- list.files(path=file.path(in_dir,in_dir_list),"pred_data_month_info.*.txt",full.names=T) |
|
228 |
#list_pred_data_day_info_fname <- list.files(path=file.path(in_dir,in_dir_list),"pred_data_day_info.*.txt",full.names=T) |
|
229 |
|
|
230 |
list_tb_fname <- list.files(path=in_dir_list,"tb_diagnostic_v_NA_.*.txt",full.names=T) |
|
231 |
list_df_fname <- list.files(path=in_dir_list,"df_tile_processed_.*..txt",full.names=T) |
|
232 |
list_summary_metrics_v_fname <- list.files(path=in_dir_list,"summary_metrics_v2_NA_.*.txt",full.names=T) |
|
233 |
list_tb_s_fname <- list.files(path=in_dir_list,"tb_diagnostic_s_NA.*.txt",full.names=T) |
|
234 |
list_tb_month_s_fname <- list.files(path=in_dir_list,"tb_month_diagnostic_s.*.txt",full.names=T) |
|
235 |
list_data_month_s_fname <- list.files(path=in_dir_list,"data_month_s.*.txt",full.names=T) |
|
236 |
list_data_s_fname <- list.files(path=in_dir_list,"data_day_s.*.txt",full.names=T) |
|
237 |
list_data_v_fname <- list.files(path=in_dir_list,"data_day_v.*.txt",full.names=T) |
|
238 |
list_pred_data_month_info_fname <- list.files(path=in_dir_list,"pred_data_month_info.*.txt",full.names=T) |
|
239 |
list_pred_data_day_info_fname <- list.files(path=in_dir_list,"pred_data_day_info.*.txt",full.names=T) |
|
212 | 240 |
|
213 | 241 |
#need to fix this !! has all of the files in one list (for a region) |
214 | 242 |
#list_shp <- list.files(path=file.path(in_dir,file.path(in_dir_list,"shapefiles")),"*.shp",full.names=T) |
... | ... | |
219 | 247 |
list_tb_s <- lapply(list_tb_s_fname,function(x){read.table(x,stringsAsFactors=F,sep=",")}) |
220 | 248 |
tb_s <- do.call(rbind,list_tb_s) |
221 | 249 |
|
250 |
#summary_metrics_v_list <- mclapply(list_raster_obj_files,FUN=function(x){try( x<- load_obj(x)); try(x[["summary_metrics_v"]]$avg)},mc.preschedule=FALSE,mc.cores = num_cores) |
|
251 |
|
|
222 | 252 |
list_df_tile_processed <- lapply(list_df_fname,function(x){read.table(x,stringsAsFactors=F,sep=",")}) |
223 | 253 |
df_tile_processed <- do.call(rbind,list_df_tile_processed) |
224 | 254 |
list_summary_metrics_v <- lapply(list_summary_metrics_v_fname,function(x){read.table(x,stringsAsFactors=F,sep=",")}) |
... | ... | |
246 | 276 |
#multiple regions? #this needs to be included in the previous script!!! |
247 | 277 |
#if(multiple_region==TRUE){ |
248 | 278 |
df_tile_processed$reg <- as.character(df_tile_processed$reg) |
279 |
#1.05pm... very slow |
|
249 | 280 |
tb <- merge(tb,df_tile_processed,by="tile_id") |
250 | 281 |
tb_s <- merge(tb_s,df_tile_processed,by="tile_id") |
251 | 282 |
tb_month_s<- merge(tb_month_s,df_tile_processed,by="tile_id") |
Also available in: Unified diff
scaling assessment part3, functions to combine yearly assessment used in stage 8