Project

General

Profile

« Previous | Next » 

Revision c11dd274

Added by Benoit Parmentier over 8 years ago

analyses of extremes more changes and debugging to record data

View differences:

climate/research/oregon/interpolation/global_run_scalingup_assessment_part5.R
538 538

  
539 539
  ##### Figure 3 ###
540 540
  
541
  tile_selected_extremes <- as.character(list_tb_extremes[[3]]$df_extremes$tile_id)
542
  
543
  list_fig_filename <- vector("list",length=length(tile_selected_extremes))
541 544
  
542 545
  for(i in 1:length(tile_selected_extremes)){
543
    d
544
    d
545
    d
546
      test<- subset(tb_subset,tb_subset$tile_id=="tile_14")
547
  test2 <- aggregate(rmse~date,test,min)
548
  #idx <- test2$date #transform this format...
549

  
550
  idx <- as.Date(strptime(test2$date, "%Y%m%d"))   # interpolation date being processed
551
 
546
    tile_selected <- tile_selected_extremes[i]
547
    #tb_subset$tile_id
548
    tb_tile_tmp <- subset(tb_subset,tb_subset$tile_id==tile_selected)
549
    tb_tile <- aggregate(rmse~date,tb_tile_tmp,min)
550
    #idx <- test2$date #transform this format...
551

  
552
    idx <- as.Date(strptime(tb_tile$date, "%Y%m%d"))   # interpolation date being processed
553
    d_z <- zoo(tb_tile,idx) #make a time series ...
554
    #add horizontal line...
555
    #plot(d_z[[metric_name]])
556
    
557
    fig_filename <- paste("Figure3a_time_series_extremes_tile_",model_name[j],"_",tile_selected,"_",
558
                      region_name,"_",out_suffix,".png",sep="")
559

  
560
    res_pix <- 960
561
    col_mfrow <- 1
562
    row_mfrow <- 1
563
    #only mod1 right now
564
    png(filename=fig_filename,
565
        width=col_mfrow*res_pix,height=row_mfrow*res_pix)
566

  
567
    title_str <- paste("Time series of",metric_name,"for",tile_selected,"and",region_name,sep=" ")
568
    plot(d_z$rmse,ylab=metric_name,xlab="dates")
569
    title(title_str)
570

  
571
    #length(unique(test$year_predicted))
572
    #unique(tb$year_predicted)
573
    dev.off()
574
    list_fig_filename[[i]] <- fig_filename
575
    
576
    ##Now plot the location
577
    #Take the max for now?
578
    val_selected <- max(d_z$rmse)
579
    d_z_selected <- d_z[d_z$rmse==val_selected,]
580
    date_selected <- d_z_selected$date
581
    #data_v_selected <- subset(tb_data_v,tb_data_v$date==date_selected)# & tb_data_v$tile_id==tile_selected)
582

  
583
    data_v_selected <- subset(tb_data_v,tb_data_v$date==date_selected & tb_data_v$tile_id==tile_selected)
584
    #tb_tile[,rmse==]
585

  
586
    data_s_selected <- subset(tb_data_s,tb_data_s$date==date_selected & tb_data_s$tile_id==tile_selected)
587
    
588
    fig_filename <- paste("Figure3b_data_stations_trainaing_testing_extremes_tile_",model_name[j],"_",tile_selected,"_",
589
                      region_name,"_",out_suffix,".png",sep="")
590
    coordinates(data_s_selected)<- c(data_s_selected$lon,data_s_selected$lat)
591
    coordinates(data_v_selected)<- c(data_v_selected$lon,data_v_selected$lat)
592
    
593
    res_pix <- 960
594
    col_mfrow <- 1
595
    row_mfrow <- 1
596
    #only mod1 right now
597
    png(filename=fig_filename,
598
        width=col_mfrow*res_pix,height=row_mfrow*res_pix)
552 599

  
553
  d_z <- zoo(test2,idx) #make a time series ...
554
  #add horizontal line...
555
  plot(d_z[[metric_name]])
556
  plot(d_z$rmse,ylab=metric_name,xlab="dates")
557
  title(title_str)
600
    title_str <- paste("Data stations",metric_name,"for",tile_selected,"and",region_name,sep=" ")
601
    
602
    p_shp <- spplot(reg_layer,"ISO3" ,col.regions=NA, col="black") #ok problem solved!!
603
    #title("(a) Mean for 1 January")
604
    #tb_sorted$freq_extremes2 <- tb_sorted$freq_extremes/17
605
    p <- bubble(tb_sorted,"freq_extremes",main=paste("Extremes per tile and by ",model_name[j]," for ",
606
                                                                threshold_val[i]))
558 607

  
559
  plot(test$rmse,type="b")
560
  length(unique(test$year_predicted))
561
  unique(tb$year_predicted)
608
    plot(d_z$rmse,ylab=metric_name,xlab="dates")
609
    title(title_str)
610

  
611
    #length(unique(test$year_predicted))
612
    #unique(tb$year_predicted)
613
    dev.off()
562 614

  
563 615
  }
564 616
   
617
  #Now plot the location
618
  
619
  tile_selected_extremes <- as.character(list_tb_extremes[[3]]$df_extremes$tile_id)
620
  list_fig_filename <- vector("list",length=length(tile_selected_extremes))
621
  
622
  
565 623
  ######################################################
566 624
  ##### Prepare objet to return ####
567 625

  

Also available in: Unified diff