tuk_tbl <-read_excel(here::here("data/csv/Tuksuk Butterworth smoothing.xlsx"), skip =1)#force the time seires to be every 5 minutesideal_z<-zoo(,seq.POSIXt(from = tuk_tbl$`date&time`[1], tuk_tbl$`date&time`[nrow(tuk_tbl)],by ="5 min") %>%as.POSIXct()) #makes a ideal TStuk_z<-merge(zoo(tuk_tbl$discharge,tuk_tbl$`date&time`),ideal_z) %>%na.approx()tuk_tbl<-fortify.zoo(tuk_z)#return the information of frequency of 5 min -> 24hr * 12 times = 288tuk_ts<-ts(tuk_tbl$tuk_z,frequency =288)# tuk_dec<-decompose(tuk_ts,type="additive")tuk_dec<-stl(tuk_ts, s.window ="periodic")tuk_seasonal_component <- tuk_dec$time.series[, "seasonal"] + tuk_dec$time.series[, "remainder"]plot(tuk_dec)
2 Tide Check
To confirm previous assumptions, the tide from Imuruk Basin was obtained from here:
Where records were captued from years 2022 to 2026, this allowed to create a tidal model, which it is continuos and match the 5 minute records as inputs.
Curiously, it was found an optimal lag between the seasonal + reminder component of 28 hours (336 time steps) and the tidal model. The maximum Pearson correlation was of 0.68, which is considered as relevant.
4 Comparison between Seasonal + Reminder with the Tide Prediction
It was found that the decomposition was relevant related with the tidal estimation, when the tidal is lagged (28 hours). This proof relevance of the decomposition method as it is correlated with the tidal model with an \(R^2\) of 0.53.
To compare were scaled, which means it was subtracted the mean and divided by their respective standard deviation.
When comparing the results the values between the Butterworth and the time series decomposition seems similar in values; however, the Butterworth presents more “sinousoidal noise” on the signal.
Code
library(timetk)butter_info <-read_excel(here::here("data","csv","Tuksuk Butterworth smoothing.xlsx"), skip =1)butter_hly_z<-butter_info[,1:9] %>%tk_zoo()ts_comp_z<-merge(discharge=butter_hly_z$discharge,ts_decomposition=ts_hly_z, butter_hly_z[,-1]) plot.zoo(ts_comp_z[,1:6],yax.flip = T,main="Comparison of Time series")
When comparing the seasonal + reminder from the time series decomposition and the discharge - butterworth (400); comparing both with the tidal model, the relationship is higher with the time series decomposition; which means more data from the tide is captured from that model.
Then, it is recommended to proceed with these results instead of the Butterworth analysis.