Revision 6099c011
Added by Benoit Parmentier over 8 years ago
climate/research/oregon/interpolation/global_product_assessment_part1_functions.R | ||
---|---|---|
672 | 672 |
} |
673 | 673 |
|
674 | 674 |
|
675 |
combine_measurements_and_predictions_df <- function(i,df_raster,df_time_series,df_ts_pix,data_var,list_selected_ID,r_ts_name,var_name,var_pred,plot_fig=T){ |
|
675 |
combine_measurements_and_predictions_df <- function(i,df_raster,df_time_series,df_ts_pix,data_var,list_selected_ID,r_ts_name,var_name,var_pred,out_dir=".",out_suffix="",plot_fig=T){
|
|
676 | 676 |
|
677 | 677 |
# Input arguments: |
678 | 678 |
# i : selected station |
... | ... | |
759 | 759 |
df_pix_ts <- merge(pix_ts,var_pix,by="date",all=T) |
760 | 760 |
#Create time series object from extract pixel time series |
761 | 761 |
|
762 |
df_pix_ts$month_str <- format(as.Date(df_pix_ts$date), "%b") ## Month, char, abbreviated |
|
763 |
df_pix_ts$year <- format(as.Date(df_pix_ts$date), "%Y") ## Year with century |
|
764 |
df_pix_ts$day <- as.numeric(format(as.Date(df_pix_ts$date), "%d")) ## numeric month |
|
765 |
|
|
766 |
#compute residuals from mosaics |
|
767 |
df_pix_ts[[paste0("res_",var_pred_tmp)]] <- df_pix_ts[[var_pred_tmp]] - df_pix_ts[[y_var_name]] |
|
768 |
|
|
769 |
id_name <- list_selected_ID[i] |
|
770 |
df_pix_ts_filename <- file.path(out_dir,paste0("df_pix_ts_",id_name,y_var_name,out_suffix,".txt")) |
|
771 |
write.table(df_pix_ts,df_pix_ts_filename,sep=",") |
|
772 |
|
|
773 |
|
|
762 | 774 |
nb_zero <- sum( df_pix_ts[[var_pred_tmp]]==0) #relevant for precip |
763 | 775 |
#nb_NA <- sum(is.na(df2$COL_SCORE)) |
764 | 776 |
nb_NA <- sum(is.na( df_pix_ts[[var_pred_tmp]])) #for ID 394 DMR it is 361 missing values for 2012!! |
... | ... | |
770 | 782 |
#Kepp number of NA for scores... |
771 | 783 |
#Summarize by season... |
772 | 784 |
## Threshold? |
773 |
station_summary_obj <- list(nb_zero,nb_NA, df_pix_ts) |
|
774 |
names(station_summary_obj) <- c("nb_zero_precip","nb_NA_var","df_pix_ts") |
|
785 |
station_summary_obj <- list(nb_zero,nb_NA, df_pix_ts,df_pix_ts_filename )
|
|
786 |
names(station_summary_obj) <- c("nb_zero_precip","nb_NA_var","df_pix_ts","df_pix_ts_filename")
|
|
775 | 787 |
return(station_summary_obj) |
776 | 788 |
} |
777 | 789 |
|
Also available in: Unified diff
fixing bugs in combining extracted predicted values and observations from assessement