Revision c8cfad3e
Added by Benoit Parmentier over 9 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/27/2015
|
|
8 |
#MODIFIED ON: 06/03/2015
|
|
9 | 9 |
#Version: 4 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 | 11 |
#COMMENTS: analyses for run 10 global analyses,all regions 1500x4500km and other tiles |
... | ... | |
312 | 312 |
|
313 | 313 |
y_var_name <- "dailyTmax" #PARAM1 |
314 | 314 |
interpolation_method <- c("gam_CAI") #PARAM2 |
315 |
out_suffix <- "mosaic_run10_1500x4500_global_analyses_05272015" #PARAM3
|
|
315 |
out_suffix <- "mosaic_run10_1500x4500_global_analyses_06032015" #PARAM3
|
|
316 | 316 |
out_dir <- in_dir #PARAM4 |
317 | 317 |
create_out_dir_param <- TRUE #PARAM 5 |
318 | 318 |
|
... | ... | |
334 | 334 |
tile_size <- "1500x4500" #PARAM 11 |
335 | 335 |
mulitple_region <- TRUE #PARAM 12 |
336 | 336 |
|
337 |
region_name <- "reg1" #PARAM 13 #reg1 is North America
|
|
337 |
region_name <- "reg5" #PARAM 13 #reg1 is North America, Africa Region 5
|
|
338 | 338 |
plot_region <- FALSE |
339 | 339 |
|
340 | 340 |
########################## START SCRIPT ############################## |
... | ... | |
353 | 353 |
|
354 | 354 |
setwd(out_dir) |
355 | 355 |
|
356 |
|
|
357 | 356 |
lf_mosaic <-list.files(path=file.path(in_dir), |
358 | 357 |
pattern=paste(".*.",day_to_mosaic[2],".*.tif$",sep=""),full.names=T) #choosing date 2...20100901 |
359 |
|
|
358 |
lf_mosaic <- lf_mosaic[1:20] |
|
360 | 359 |
r1 <- raster(lf_mosaic[1]) |
361 | 360 |
r2 <- raster(lf_mosaic[2]) |
362 | 361 |
|
... | ... | |
450 | 449 |
## Create raster image for original predicted images with matching resolution and extent to the mosaic (reference image) |
451 | 450 |
|
452 | 451 |
rast_ref <- file.path(out_dir,"avg.tif") #this is a the ref |
453 |
|
|
452 |
r_ref <- raster(rast_ref) |
|
453 |
plot(r_ref) |
|
454 | 454 |
|
455 | 455 |
### First match weights from linear option |
456 | 456 |
lf_files <- unlist(list_linear_r_weights) |
... | ... | |
470 | 470 |
num_cores <-11 |
471 | 471 |
list_linear_weights_prod_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores) |
472 | 472 |
|
473 |
|
|
474 | 473 |
### Second match wegihts from sine option |
475 | 474 |
|
476 | 475 |
lf_files <- unlist(list_sine_r_weights) |
... | ... | |
569 | 568 |
r_diff_mean_linear <- r_m_mean - r_m_linear_weighted_mean |
570 | 569 |
r_diff_mean_sine <- r_m_mean - r_m_sine_weighted_mean |
571 | 570 |
|
571 |
r_m_mean_terrain <- terrain(r_m_mean,opt=c("slope","aspect"),unit="degrees") |
|
572 |
r_m_sine_weighted_mean_terrain <- terrain(r_m_sine_weighted_mean,opt=c("slope","aspect"),unit="degrees") |
|
573 |
r_m_linear_weighted_mean_terrain <- terrain(r_m_linear_weighted_mean,opt=c("slope","aspect"),unit="degrees") |
|
574 |
|
|
572 | 575 |
##################### |
573 | 576 |
###### PART 5: Now plot of the weighted mean and unweighted mean with the mosaic function ##### |
574 | 577 |
|
... | ... | |
638 | 641 |
|
639 | 642 |
dev.off() |
640 | 643 |
|
644 |
|
|
645 |
#### plot terrain to emphasize possible edges.. |
|
646 |
res_pix <- 1200 |
|
647 |
col_mfrow <- 1 |
|
648 |
row_mfrow <- 0.8 |
|
649 |
|
|
650 |
png(filename=paste("Figure2_slope_mean_linear_for_region_",region_name,"_",out_suffix,".png",sep=""), |
|
651 |
width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
|
652 |
|
|
653 |
plot(r_m_linear_weighted_mean_terrain,y=1) |
|
654 |
|
|
655 |
dev.off() |
|
656 |
|
|
657 |
png(filename=paste("Figure2_aspect_mean_linear_for_region_",region_name,"_",out_suffix,".png",sep=""), |
|
658 |
width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
|
659 |
|
|
660 |
plot(r_m_linear_weighted_mean_terrain,y=2) |
|
661 |
|
|
662 |
dev.off() |
|
663 |
|
|
664 |
png(filename=paste("Figure2_slope_mean_sine_for_region_",region_name,"_",out_suffix,".png",sep=""), |
|
665 |
width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
|
666 |
|
|
667 |
plot(r_m_sine_weighted_mean_terrain,y=1) |
|
668 |
|
|
669 |
dev.off() |
|
670 |
|
|
671 |
png(filename=paste("Figure2_aspect_mean_sine_for_region_",region_name,"_",out_suffix,".png",sep=""), |
|
672 |
width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
|
673 |
|
|
674 |
plot(r_m_sine_weighted_mean_terrain,y=2) |
|
675 |
|
|
676 |
dev.off() |
|
677 |
|
|
678 |
png(filename=paste("Figure2_slope_mean_for_region_",region_name,"_",out_suffix,".png",sep=""), |
|
679 |
width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
|
680 |
|
|
681 |
plot(r_m_mean_terrain,y=1) |
|
682 |
|
|
683 |
dev.off() |
|
684 |
|
|
685 |
png(filename=paste("Figure2_aspect_mean_for_region_",region_name,"_",out_suffix,".png",sep=""), |
|
686 |
width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
|
687 |
|
|
688 |
plot(r_m_mean_terrain,y=2) |
|
689 |
|
|
690 |
dev.off() |
|
691 |
|
|
641 | 692 |
##################### END OF SCRIPT ###################### |
642 | 693 |
|
643 | 694 |
################################################# |
Also available in: Unified diff
mosaicing test region 1, North America adding figures for two methods