Project

General

Profile

« Previous | Next » 

Revision ea216ab1

Added by Benoit Parmentier over 9 years ago

adding plot function to assess the mosaicing

View differences:

climate/research/oregon/interpolation/global_run_scalingup_mosaicing.R
189 189
save(mosaic_unweighted_20100831_obj,file=file.path(out_dir,paste(mosaic_method,"_","mosaic_obj_",
190 190
                                                           "20100831_",out_suffix,".RData",sep="")))
191 191

  
192
r2_unweighted <-raster(mosaic_unweighted_20100901_obj$mean_mosaic)
193
r2_edge <-raster(mosaic_edge_20100901_obj$mean_mosaic)
192
#r2_unweighted <-raster(mosaic_unweighted_20100901_obj$mean_mosaic)
193
#r2_edge <-raster(mosaic_edge_20100901_obj$mean_mosaic)
194 194

  
195
r1_unweighted <-raster(mosaic_unweighted_20100831_obj$mean_mosaic)
196
r1_edge <-raster(mosaic_edge_20100831_obj$mean_mosaic)
197
plot(r1_edge)
195
#r1_unweighted <-raster(mosaic_unweighted_20100831_obj$mean_mosaic)
196
#r1_edge <-raster(mosaic_edge_20100831_obj$mean_mosaic)
197
#plot(r1_edge)
198 198

  
199 199
#####################
200 200
###### PART 2: Analysis and figures for the outputs of mosaic function #####
201 201

  
202 202
#### compute and aspect and slope with figures
203
list_mosaic_unweighted <- list(mosaic_unweighted_20100831_obj,mosaic_edge_20100831_obj)
204
list_mosaic_edge <- list(mosaic_unweighted_20100901_obj,mosaic_edge_20100901_obj)
205 203

  
206
list_mosaiced_files <- c(list_mosaiced_files,r_m_mean_unweighted)
207
names(list_mosaiced_files2) <- c(names(list_mosaiced_files),"unweighted")
208

  
209
plot_mosaic(list_)
210
plot_mosaic <- function(f_mosaic,method,out_dir,out_stuffix){
211

  
212
  method_str <- method
213
  r_mosaic <- raster(f_mosaiced)
204
lf_mosaic_obj1 <- list.files(path=out_dir,pattern="*20100831_.*.RData")
205
lf_mosaic_obj2 <- list.files(path=out_dir,pattern="*20100901_20100901.*.RData")
206
lf_mosaic_obj <- unlist(list(lf_mosaic_obj1,lf_mosaic_obj2))
207
lf_mean_mosaic1 <- unlist(lapply(lf_mosaic_obj2,function(x){load_obj(x)[["mean_mosaic"]]}))
208
l_method_mosaic <- unlist(lapply(lf_mosaic_obj,function(x){load_obj(x)[["method"]]}))
209

  
210
out_suffix_tmp <- paste(c("edge","unweighted"),"20100831",sep="_")
211
#list_mosaic_unweighted <- list(mosaic_unweighted_20100831_obj,mosaic_edge_20100831_obj)
212
#list_mosaic_edge <- list(mosaic_unweighted_20100901_obj,mosaic_edge_20100901_obj)
213

  
214
#list_mosaiced_files <- c(list_mosaiced_files,r_m_mean_unweighted)
215
#names(list_mosaiced_files2) <- c(names(list_mosaiced_files),"unweighted")
216

  
217
#debug(plot_mosaic)
218
#lf_mean_mosaic1[1]
219
#plot_mosaic(lf_mean_mosaic1[1],method="edge",out_suffix="20100831")
220
list_param_plot_mosaic <- list(lf_mosaic=lf_mean_mosaic1,method=c("edge","unweighted"),out_suffix=c("20100831","20100831"))
221
#l_png_files <- lapply(1:length(lf_mean_mosaic1),FUN=plot_mosaic,list_param= list_param_plot_mosaic)
222
l_png_files <- mclapply(1:length(lf_mean_mosaic1),FUN=plot_mosaic,list_param= list_param_plot_mosaic,
223
                        mc.preschedule=FALSE,mc.cores = num_cores)
224

  
225
plot_mosaic <- function(i,list_param){
226
  #Plot for mosaic list assess via slope as well
227
  #Inputs:
228
  #
229
  
230
  method_str <- list_param$method[i]
231
  f_mosaic <- list_param$lf_mosaic[i]
232
  out_suffix_str <- list_param$out_suffix[i]
233
  
234
  r_mosaic <- raster(f_mosaic)
214 235

  
215 236
  r_mosaic_terrain <- terrain(r_mosaic,opt=c("slope","aspect"),unit="degrees")
216 237

  
217 238
  res_pix <- 1200
218 239
  col_mfrow <- 1 
219 240
  row_mfrow <- 0.8
220

  
221
  png(filename=paste("Figure2_mosaic_mean_",method_str,"_",out_suffix,".png",sep=""),
241
  
242
  out_file1 <- paste("Figure2_mosaic_mean_",method_str,"_",out_suffix_str,".png",sep="")
243
  png(filename= out_file1,
222 244
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
223 245

  
224 246
  plot(r_mosaic,main=paste("mosaic mean ",method_str,sep=""))
......
230 252
  col_mfrow <- 1 
231 253
  row_mfrow <- 0.8
232 254

  
233
  png(filename=paste("Figure2_slope_mean_",method_str,"_",out_suffix,".png",sep=""),
255
  out_file2 <- paste("Figure2_slope_mean_",method_str,"_",out_suffix_str,".png",sep="")
256
  png(filename= out_file2,
234 257
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
235 258

  
236 259
  plot(r_mosaic_terrain,y=1,main=paste("slope mosaic mean ",method_str,sep=""))
237 260

  
238 261
  dev.off()
239 262

  
240
  png(filename=paste("Figure2_aspect_mean_",method_str,"_",out_suffix,".png",sep=""),
263
  out_file3 <- paste("Figure2_aspect_mean_",method_str,"_",out_suffix_str,".png",sep="")
264
  png(filename= out_file3,
241 265
    width=col_mfrow*res_pix,height=row_mfrow*res_pix)
242 266

  
243 267
  plot(r_mosaic_terrain,y=2,main=paste("aspect mean ",method_str,sep=""))
244 268

  
245 269
  dev.off()
270
  
271
  l_out_files <- list(out_file1,out_file2,out_file3)
272
  return(l_out_files)
246 273
}
247 274

  
248 275
####################

Also available in: Unified diff