Project

General

Profile

« Previous | Next » 

Revision 9807a6a1

Added by Benoit Parmentier over 8 years ago

debugging part3, assessment part3 for combining yearly assessment

View differences:

climate/research/oregon/interpolation/global_run_scalingup_assessment_part3.R
7 7
#Analyses, figures, tables and data are also produced in the script.
8 8
#AUTHOR: Benoit Parmentier 
9 9
#CREATED ON: 03/23/2014  
10
#MODIFIED ON: 02/10/2016            
10
#MODIFIED ON: 04/29/2016            
11 11
#Version: 5
12 12
#PROJECT: Environmental Layers project     
13 13
#COMMENTS: Initial commit, script based on part 2 of assessment, will be modified further for overall assessment 
......
243 243

  
244 244
  ## Step 2: only read what is necessary at this stage...
245 245
  list_tb <- lapply(list_tb_fname,function(x){read.table(x,stringsAsFactors=F,sep=",")})
246

  
246 247
  tb <- do.call(rbind,list_tb)
247 248
  list_tb_s <- lapply(list_tb_s_fname,function(x){read.table(x,stringsAsFactors=F,sep=",")})
248 249
  tb_s <- do.call(rbind,list_tb_s)
......
289 290
  try(summary_metrics_v$reg <- summary_metrics_v$reg.x)  
290 291
  try(summary_metrics_v$lat <- summary_metrics_v$lat.x)
291 292
  try(summary_metrics_v$lon <- summary_metrics_v$lon.x)
292

  
293
  #browser()
294
  
293 295
  ############ PART 2: PRODUCE FIGURES ################
294 296
  
295 297
  ###########################
......
327 329
  #This is slow...make a function and use mclapply??
328 330
  #/data/project/layers/commons/NEX_data/output_run6_global_analyses_09162014/shapefiles
329 331
  
330
  in_dir_shp <- file.path(in_dir,in_dir_list[[1]],"shapefiles") #this should be set as a input parameter!!!
332
  centroids_shp_fun <- function(i,list_shp_reg_files,in_dir_shp){
333
    
334
  }
335
  in_dir_shp <- file.path(in_dir_list[[1]],"shapefiles") #this should be set as a input parameter!!!
331 336
  for(i in 1:length(list_shp_reg_files)){
332 337
    #path_to_shp <- dirname(list_shp_reg_files[[i]])
333 338
    path_to_shp <- in_dir_shp
......
384 389
    #to be able to run on NEX set font and usePolypath, maybe add option NEX?
385 390
    if(!inherits(shp1,"try-error")){
386 391
      plot(shp1,add=T,border="blue",usePolypath = FALSE) #added usePolypath following error on brige and NEX
392
      #plot(shp1,add=T,border="blue",usePolypath = FALSE) #added usePolypath following error on brige and NEX
393

  
387 394
      #plot(pt,add=T,cex=2,pch=5)
388 395
      label_id <- df_tile_processed$tile_id[i]
389 396
      text(coordinates(pt)[1],coordinates(pt)[2],labels=i,cex=1.3,font=2,col=c("red"),family="HersheySerif")
......
402 409
  ###############
403 410
  ### Figure 2: boxplot of average accuracy by model and by tiles
404 411
  
405
  tb$tile_id <- factor(tb$tile_id, levels=unique(tb$tile_id))
412
  #tb$tile_id <- factor(tb$tile_id, levels=unique(mixedsort(tb$tile_id)))#fix level ordering for plotting
413
  #fix level ordering for plotting
414
  #tb$tile_nb <- unlist(mclapply(as.character(tb$tile_id),FUN=function(x){strsplit(x,"_")[[1]][2]},mc.preschedule=FALSE,mc.cores = num_cores))
415
  #unlist(mclapply(as.character(tb$tile_id[1:10]),FUN=function(x){strsplit(x,"_")[[1]][2]},mc.preschedule=FALSE,mc.cores = num_cores))
416
  
406 417
  model_name <- as.character(unique(tb$pred_mod))
407 418
  
408 419
  ## Figure 2a
......
415 426
    png(filename=paste("Figure2a_boxplot_with_oultiers_by_tiles_",model_name[i],"_",out_suffix,".png",sep=""),
416 427
        width=col_mfrow*res_pix,height=row_mfrow*res_pix)
417 428
    
418
    boxplot(rmse~tile_id,data=subset(tb,tb$pred_mod==model_name[i]))
429
    boxplot(rmse~tile_id,data=subset(tb,tb$pred_mod==model_name[i]),las=2)
419 430
    title(paste("RMSE per ",model_name[i]))
420 431
    
421 432
    dev.off()
......
439 450
    
440 451
    model_name <- unique(tb$pred_mod)
441 452
    boxplot(rmse~tile_id,data=subset(tb,tb$pred_mod==model_name[i])
442
            ,ylim=c(0,4),outline=FALSE)
453
            ,ylim=c(0,4),outline=FALSE,las=2)
443 454
    title(paste("RMSE per ",model_name[i]))
444 455
    dev.off()
445 456
    #we already stored one figure

Also available in: Unified diff