Revision 8d184742
Added by Benoit Parmentier over 8 years ago
climate/research/oregon/interpolation/global_run_scalingup_mosaicing.R | ||
---|---|---|
5 | 5 |
#Analyses, figures, tables and data are also produced in the script. |
6 | 6 |
#AUTHOR: Benoit Parmentier |
7 | 7 |
#CREATED ON: 04/14/2015 |
8 |
#MODIFIED ON: 05/01/2016
|
|
8 |
#MODIFIED ON: 05/31/2016
|
|
9 | 9 |
#Version: 6 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 | 11 |
#COMMENTS: analyses run for reg4 1991 for test of mosaicing using 1500x4500km and other tiles |
... | ... | |
204 | 204 |
|
205 | 205 |
### Read in assessment and accuracy files |
206 | 206 |
df_assessment_files <- read.table(df_assessment_files_name,stringsAsFactors=F,sep=",") |
207 |
|
|
207 |
#browser() |
|
208 | 208 |
tb_v_accuracy_name <- df_assessment_files$files[2] |
209 | 209 |
tb_s_accuracy_name <- df_assessment_files$files[4] |
210 | 210 |
tb_s_month_accuracy_name <- df_assessment_files$files[3] |
... | ... | |
226 | 226 |
|
227 | 227 |
#this part needs to be improve make this a function and use multicore to loop through files... |
228 | 228 |
#give a range of dates to run... |
229 |
#browser() |
|
229 | 230 |
|
230 | 231 |
if(is.null(day_to_mosaic_range)){ |
231 | 232 |
# start_date <- #first date |
... | ... | |
311 | 312 |
#raster_created_obj <- create_accuracy_metric_raster(1, list_param_accuracy_metric_raster) |
312 | 313 |
|
313 | 314 |
#Extract list of files for rmse and date 1 (19920101), there should be 28 raster images |
314 |
lf_accuracy_raster <- lapply(1:length(list_raster_created_obj),FUN=function(i){unlist(list_raster_created_obj[[i]]$list_raster_name)}) |
|
315 |
lf_accuracy_testing_raster <- lapply(1:length(list_raster_created_obj),FUN=function(i){unlist(list_raster_created_obj[[i]]$list_raster_name)})
|
|
315 | 316 |
|
316 | 317 |
#Plot as quick check |
317 | 318 |
#r1 <- raster(lf_mosaic[[1]][1]) |
... | ... | |
320 | 321 |
|
321 | 322 |
} |
322 | 323 |
|
324 |
#### Add option for ac training here |
|
325 |
|
|
326 |
|
|
323 | 327 |
#################################### |
324 | 328 |
###Depending on value of layers_option, create accuracy surfaces based on testing residuals... |
325 |
|
|
329 |
#browser() |
|
326 | 330 |
if(layers_option=="res_testing"){ |
327 | 331 |
#This part took 19 minutes and 45 seconds |
328 | 332 |
|
... | ... | |
460 | 464 |
#loop to dates..., make this a function... |
461 | 465 |
#This is a loop but uses multicores when calling the mosaic function |
462 | 466 |
list_mosaic_obj <- vector("list",length=length(day_to_mosaic)) |
467 |
#browser() |
|
468 |
|
|
463 | 469 |
for(i in 1:length(day_to_mosaic)){ |
464 | 470 |
# |
465 | 471 |
|
... | ... | |
494 | 500 |
#runs in 15-16 minutes for 3 dates and mosaicing of 28 tiles... |
495 | 501 |
list_mosaic_obj[[i]] <- mosaic_obj |
496 | 502 |
} |
503 |
#browser() |
|
497 | 504 |
|
498 | 505 |
if(layers_option=="ac_testing"){ |
499 | 506 |
## Now accuracy based on center of centroids |
500 | 507 |
mosaic_method <- "use_edge_weights" #this is distance from edge |
501 | 508 |
#Adding metric name in the name... |
502 | 509 |
out_suffix_tmp <- paste(interpolation_method,metric_name,day_to_mosaic[i],out_suffix,sep="_") |
503 |
|
|
504 |
#debug(mosaicFiles) |
|
510 |
|
|
511 |
#Can modify here....add creation of data for the specific date here rather than beforehand!!!! |
|
512 |
|
|
513 |
## To be inserted... |
|
514 |
|
|
515 |
#undebug(mosaicFiles) |
|
505 | 516 |
#can also loop through methods!!! |
506 |
mosaic_obj <- mosaicFiles(lf_accuracy_raster[[i]], |
|
517 |
#browser() |
|
518 |
mosaic_obj <- mosaicFiles(lf_accuracy_testing_raster[[i]], |
|
507 | 519 |
mosaic_method="use_edge_weights", |
508 | 520 |
num_cores=num_cores, |
509 | 521 |
r_mask_raster_name=infile_mask, |
510 | 522 |
python_bin=python_bin, |
511 | 523 |
mosaic_python=mosaic_python, |
512 | 524 |
algorithm=algorithm, |
525 |
match_extent = match_extent, |
|
513 | 526 |
df_points=NULL, |
514 | 527 |
NA_flag=NA_flag_val, |
515 | 528 |
file_format=file_format, |
... | ... | |
523 | 536 |
list_mosaic_obj[[i]] <- mosaic_obj |
524 | 537 |
} |
525 | 538 |
|
539 |
if(layers_option=="ac_training"){ |
|
540 |
## Now accuracy based on center of centroids |
|
541 |
mosaic_method <- "use_edge_weights" #this is distance from edge |
|
542 |
#Adding metric name in the name... |
|
543 |
out_suffix_tmp <- paste(interpolation_method,metric_name,day_to_mosaic[i],out_suffix,sep="_") |
|
544 |
|
|
545 |
#Can modify here....add creation of data for the specific date here rather than beforehand!!!! |
|
546 |
|
|
547 |
## To be inserted... |
|
548 |
|
|
549 |
#undebug(mosaicFiles) |
|
550 |
#can also loop through methods!!! |
|
551 |
#browser() |
|
552 |
mosaic_obj <- mosaicFiles(lf_accuracy_training_raster[[i]], |
|
553 |
mosaic_method="use_edge_weights", |
|
554 |
num_cores=num_cores, |
|
555 |
r_mask_raster_name=infile_mask, |
|
556 |
python_bin=python_bin, |
|
557 |
mosaic_python=mosaic_python, |
|
558 |
algorithm=algorithm, |
|
559 |
match_extent = match_extent, |
|
560 |
df_points=NULL, |
|
561 |
NA_flag=NA_flag_val, |
|
562 |
file_format=file_format, |
|
563 |
out_suffix=out_suffix_tmp, |
|
564 |
out_dir=out_dir, |
|
565 |
tmp_files=tmp_files, |
|
566 |
data_type=data_type, |
|
567 |
scaling=scaling, |
|
568 |
values_range=values_range) |
|
569 |
##Took 29 minutes for 28 tiles and one date...!!! |
|
570 |
list_mosaic_obj[[i]] <- mosaic_obj |
|
571 |
} |
|
572 |
|
|
526 | 573 |
#list_mosaic_obj[[i]] <- list(prediction=mosaic_edge_obj_prediction,accuracy=mosaic_edge_obj_accuracy) |
527 | 574 |
|
528 | 575 |
### produce residuals mosaics |
Also available in: Unified diff
debugging errors in accuracy layers and adding accuracy based on training data