Skip to content

Commit f6e03a4

Browse files
authored
Merge pull request #118 from jmccreight/wavelet
wavelet touch ups
2 parents e79e01d + 28149d1 commit f6e03a4

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: rwrfhydro
22
Type: Package
33
Title: R tools for the WRF Hydro Model
4-
Version: 1.0.1
4+
Version: 1.0.2
55
Date: 2015-05-01
66
Authors@R: c(
77
person("James", "McCreight", email = "jamesmcc@ucar.edu", role = c("aut","cre")),

R/wavelet_event_timing.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ WtTimeChunks <- function(
237237
for(cc in (first_ind+1):length(chunk_list)) {
238238

239239
if(class(chunk_list[[cc]]) != "biwavelet") {
240-
# print(cc)
241240
next
242241
}
243242

@@ -327,7 +326,6 @@ WtEventTiming <- function(POSIXct, obs,
327326
"than min_ts_length. Returning.")
328327
cat(msg,'\n')
329328
cat(paste0("min_ts_length: ", min_ts_length), '\n')
330-
print(chunk_len)
331329
return(NULL)
332330
}
333331

R/wavelet_event_timing_plot.R

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
543543
library(dplyr)
544544
library(ggplot2)
545545
library(relayer) ## git hash 8a1d49e1707d9fcc1aaa83476a3d9a15448a1065
546+
library(ggplotify)
546547

547548
obs_power = get_data_plot_power(wt_event$obs$wt, wt_event$input_data)
548549
obs_t_avg_power = get_data_plot_time_avg_power(wt_event$obs$wt)
@@ -642,15 +643,15 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
642643

643644
## Merge the new and old data.
644645
pd = rbind(plot_data, wt_copy)
645-
646+
646647
## Get the standard plot
647648
gg = plot_wavelet_events(pd, do_plot=FALSE)
648-
649+
649650
## Extend the standard plot.
650651

651652
## Use annotations for units labels on the y-axes.
652653
plot_data = as.data.table(plot_data)
653-
654+
654655
y_labs =
655656
plot_data[,
656657
.(y_center=min(y, na.rm=TRUE)+.5*(max(y, na.rm=TRUE)-min(y, na.rm=TRUE)),
@@ -716,11 +717,6 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
716717
max_stats$y_var = ordered('d Period', levels=new_y_levels)
717718
max_stats$x = min(plot_data$x, na.rm=TRUE) + 3600*(max_stats$time)
718719

719-
print(max_stats$x)
720-
print(min(plot_data$x, na.rm=TRUE))
721-
print((max_stats$time))
722-
print(3600*(max_stats$time))
723-
724720
period_y_cols = c('y', 'period')
725721
period_y_map = unique(plot_data[ y_var =='d Period', ..period_y_cols ])
726722
max_stats = merge(max_stats, period_y_map, by='period')
@@ -812,7 +808,7 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
812808

813809
text_color = 'grey30'
814810
text_size = 11
815-
811+
816812
text_grob_1 = grid.text(
817813
'Streamflow (cms)', x=-1.25, y=.6, hjust=.50, vjust=-3.5, rot=-90,
818814
gp=gpar(col=text_color, fontsize=text_size))
@@ -843,7 +839,7 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
843839
t = unique(grob$layout[grepl("panel-1-4",grob$layout$name), "t"])
844840
g = gtable::gtable_add_grob(g, grobs=text_grob_3, t=t, l=ncol(g), clip='off')
845841

846-
return(g)
842+
return(as.ggplot(g))
847843
}
848844

849845

@@ -857,7 +853,8 @@ step2_figure = function(
857853
library(dplyr)
858854
library(ggplot2)
859855
library(relayer) ## git hash 8a1d49e1707d9fcc1aaa83476a3d9a15448a1065
860-
856+
library(ggplotify)
857+
861858
## Currently this is only configured to handle a single modeled timeseries.
862859
model_name = setdiff(names(wt_event), c("input_data", "obs"))
863860
if(length(model_name) > 1)
@@ -1085,11 +1082,6 @@ step2_figure = function(
10851082
max_stats$y_var = ordered('TimePer', levels=new_y_levels)
10861083
max_stats$x = min(plot_data$x, na.rm=TRUE) + 3600*(max_stats$time)
10871084

1088-
print(max_stats$x)
1089-
print(min(plot_data$x, na.rm=TRUE))
1090-
print((max_stats$time))
1091-
print(3600*(max_stats$time))
1092-
10931085
period_y_cols = c('y', 'period')
10941086
period_y_map = unique(plot_data[ y_var =='TimePer', ..period_y_cols ])
10951087
max_stats = merge(max_stats, period_y_map, by='period')
@@ -1228,7 +1220,7 @@ step2_figure = function(
12281220
guide_layout = guide_layout[c(4,1,2,3),]
12291221
colnames(guide_layout) = 1:4
12301222
g$grobs[[wh_guide_box]]$layout[1:4,] = guide_layout
1231-
return(g)
1223+
return(as.ggplot(g))
12321224
}
12331225

12341226

0 commit comments

Comments
 (0)