Project

General

Profile

« Previous | Next » 

Revision c352e9e1

Added by Benoit Parmentier almost 12 years ago

Methods comp part3-task#491- clean up, verification of results for specific dates

View differences:

climate/research/oregon/interpolation/methods_comparison_assessment_part3.R
49 49
infile6<-"OR83M_state_outline.shp"
50 50
#stat_loc<-read.table(paste(path,"/","location_study_area_OR_0602012.txt",sep=""),sep=",", header=TRUE)
51 51

  
52
out_prefix<-"methods_09262012_"
52
out_prefix<-"methods_11072012_"
53 53
#output path
54 54
path<-"/home/parmentier/Data/IPLANT_project/data_Oregon_stations_07192012_GAM"
55
path<-"/home/parmentier/Data/IPLANT_project/data_Oregon_stations_07192012_GAM"
56

  
55 57
setwd(path)
56 58

  
57 59
##### LOAD USEFUL DATA
58 60

  
59 61
obj_list<-"list_obj_08262012.txt"                                  #Results of fusion from the run on ATLAS
60
path<-"/home/parmentier/Data/IPLANT_project/methods_interpolation_comparison" #Jupiter LOCATION on Atlas for kriging                              #Jupiter Location on XANDERS
62
path<-"/home/parmentier/Data/IPLANT_project/methods_interpolation_comparison_10242012" #Jupiter LOCATION on Atlas for kriging                              #Jupiter Location on XANDERS
61 63
#path<-"/Users/benoitparmentier/Dropbox/Data/NCEAS/Oregon_covariates/"            #Local dropbox folder on Benoit's laptop
62 64
setwd(path) 
63 65
proj_str="+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m +no_defs";
......
70 72

  
71 73
filename<-sub(".shp","",infile1)             #Removing the extension from file.
72 74
ghcn<-readOGR(".", filename)                 #reading shapefile 
75
filename<-sub(".shp","",infile6)             #Removing the extension from file.
76
#reg_outline<-readOGR(".", filename)                 #reading shapefile 
77
reg_outline<-readOGR(dsn=".", layer=filename)                 #reading shapefile 
73 78

  
74 79
#CRS<-proj4string(ghcn)                       #Storing projection information (ellipsoid, datum,etc.)
75 80
lines<-read.table(paste(path,"/",inlistf,sep=""), sep="")                      #Column 1 contains the names of raster files
......
101 106
mm_01<-mask(mm_01,mask_land_NA)  #Raster image used as backround
102 107
#mention this is the last... files
103 108

  
104
################# PART 1: COMPARING RESULTS USING ALL MONTHNLY DATA AND SAMPLED FROM DAILY###################
105
######## Visualize data: USING ALL MONTHLY DATA...
109
################# PART 1: COMPARING RESULTS USING ALL MONTHNLY DATA AND SAMPLED FROM DAILY ###################
110
######## Visualize data: USING ALL MONTHLY DATA...  
106 111

  
107 112
file_pat<-glob2rx("GAMCAI_tmax_pred_predicted_mod*_365d_GAM_CAI2_all_lstd_10262012.rst")   
108 113
lf_cai_all<-list.files(pattern=file_pat)
......
269 274
savePlot("lst_climatology_OR_nobs.png",type="png")
270 275
dev.off)
271 276

  
272
#note differnces in patternin agricultural areas and 
277
#note differences in patternin agricultural areas and 
273 278
extremeValues(molst) #not yet implemented...
274 279
min_values<-cellStats(molst,"min")
275 280
max_values<-cellStats(molst,"max")
......
460 465
#legend("topleft",legend=c("fo","LST","LST_forest","LST_grass"), cex=0.8, col=c("black","blue","green","red"),
461 466
              #lty=1)
462 467
                  
463
############ PART 4: RESIDUALS ANALYSIS: ranking, plots, focus regions  ##################
464
############## EXAMINING STATION RESIDUALS ###########
465
########### CONSTANT OVER 365 AND SAMPLING OVER 365
466
#Plot daily_deltaclim_rast, bias_rast,add data_s and data_v
467
                  
468
# RANK STATION by average or median RMSE
469
# Count the number of times a station is in the extremum group of outliers...
470
# LOOK at specific date...
471
                  
472
#Examine residuals for a spciefic date...Jan, 1 using run of const_all i.e. same training over 365 dates
473
path_data_cai<-"/home/parmentier/Data/IPLANT_project/data_Oregon_stations_10242012_CAI"  #Change to constant
474
path_data_fus<-"/home/parmentier/Data/IPLANT_project/data_Oregon_stations_10242012_GAM"
475
setwd(path_data) #output data
476

  
477
#list files that contain raster tmax prediction (maps) for CAI and Fusion
478
#lf_c<-"GAM_predicted_mod7_20101231_30_1_365d_GAM_fusion_const_10172012.rst"
479
lf_cg<-list.files(pattern="GAM_predicted_mod2_.*_30_1_365d_GAM_fusion_const_10172012.rst$")    #changee to constant 
480
lf_ck<-list.files(pattern="fusion_tmax_predicted_.*_30_1_365d_GAM_fusion_const_10172012.rst$") #Fusion+Kriging
481
                  
482
#list files that contain model objects and ratingin-testing information for CAI and Fusion
483
fus1_c<-load_obj("results2_fusion_Assessment_measure_all_365d_GAM_fusion_const_10172012.RData")
484
#fus1_c<-load_obj("results2_fusion_Assessment_measure_all_365d_GAM_fusion_const_10172012.RData")
485
                  
486
gam_fus<-load_obj(file.path(path_data_fus,
487
                          "results2_fusion_Assessment_measure_all_365d_GAM_fusion_all_lstd_10242012.RData"))
488
gam_cai<-load_obj(file.path(path_dat_cai,
489
                          "results2_CAI_Assessment_measure_all_365d_GAM_CAI2_all_lstd_10262012.RData")  #This contains all the info
490
sampling_obj_cai<-load_obj(file.path(path_data_cai,
491
                                          "results2_CAI_sampling_obj_365d_GAM_CAI2_all_lstd_10262012.RData"))
492
sampling_date_list<-sampling_obj_cai$sampling_dat$date
493
                                    
494
date_selected<-"20100103"
495
                  
496
k<-match(date_selected,sampling_date_list)
497
                  
498
data_sf<-gam_fus[[k]]$data_s #object for the first date...20100103                  
499
data_vf<-gam_fus[[k]]$data_v #object for the first date...20100103                  
500
data_sc<-gam_fus[[k]]$data_s #object for the first date...20100103                  
501
data_vc<-gam_fus[[k]]$data_v #object for the first date...20100103                  
502

  
503
#Select background image for plotting
504
mod_pat<-glob2rx(paste("*",date_selected,"*",sep=""))   
505
image_file<-grep(mod_pat,lf_ck,value=TRUE) # using grep with "value" extracts the matching names         
506
raster_pred_k<-raster(image_file)
507
image_file<-grep(mod_pat,lf_cg,value=TRUE) # using grep with "value" extracts the matching names         
508
raster_pred_g<-raster(image_file)
509
plot(data_sf,add=TRUE)
510
plot(data_vf,pch=1,add=TRUE)
511
                  
512
#Create a residual table...
513
res_mod9_list<-vector("list",365)
514
res_mod2_list<-vector("list",365)
515
                  
516
tab_nv<-matrix(NA,365,1)
517
for(k in 1:365){
518
      tab_nv[k]<-length(fus1_c[[k]]$data_v$res_mod9)
519
}
520
#note that there might be some variation in the number!!!
521
                  
522
for(k in 1:365){
523
   res_mod9<-fus1_c[[k]]$data_v$res_mod9
524
   res_mod2<-fus1_c[[k]]$data_v$res_mod2
525
   res_mod9_list[[k]]<-res_mod9
526
   res_mod2_list[[k]]<-res_mod2
527
   #subset data frame? or rbind them...and reshape?? think about it
528
}
529
tab_resmod9<-do.call(rbind,res_mod9_list)
530
                  
531
data_v_list<-vector("list",365)
532
                  
533
for(k in 1:365){
534
      data_v<-as.data.frame(fus1_c[[k]]$data_v)
535
      data_v<-data_v[,c("id","res_mod9")]
536
      #subset data frame? or rbind them...and reshape?? think about it
537
      data_v_list[[k]]<-data_v
538
}
539
tab_resmod9<-do.call(rbind,data_v_list)
540
                  
541
#NOW USE RESHAPE TO CREATE TABLE....
542

  
543
#updated the analysis
468
###################### Visualization of results ######################
544 469
                  
545 470
"tmax_predicted*20100103_30_1_365d_GAM_fusion_all_lstd_10242012.rst"
546 471
oldpath<-getwd()

Also available in: Unified diff