-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* draft of paper v0.1 * figures of paper and code for it * correct path for paper.pdf * minor modifications (mostly figures) * change ylabel of fig 2 * affiliation George Co-authored-by: George Datseris <[email protected]> * most changes from 1st review of George * funding George Co-authored-by: George Datseris <[email protected]> * draft of paper v0.2 * add ref to timeseriessurro * add TransitionsInTimeseries.jl * replace "time series" by "timeseries" * shorten and correct minors * reformulation of versatility section * typo --------- Co-authored-by: George Datseris <[email protected]>
- Loading branch information
1 parent
6f1b357
commit abde970
Showing
9 changed files
with
608 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
on: [push] | ||
|
||
jobs: | ||
paper: | ||
runs-on: ubuntu-latest | ||
name: Paper Draft | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Build draft PDF | ||
uses: openjournals/openjournals-draft-action@master | ||
with: | ||
journal: joss | ||
# This should be the path to the paper within your repo. | ||
paper-path: paper/paper.md | ||
- name: Upload | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: paper | ||
# This is the output path where Pandoc will write the compiled | ||
# PDF. Note, this should be the same directory as the input | ||
# paper.md | ||
path: paper/paper.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[deps] | ||
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" | ||
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" | ||
TransitionsInTimeseries = "5f5b98ec-1183-43e0-887a-12fdc55c52f7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import time | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import ewstools | ||
from ewstools.models import simulate_ricker | ||
|
||
# Set seed for reproducibility | ||
np.random.seed(0) | ||
|
||
# Initialize time series and spectrum computation | ||
series = simulate_ricker(tmax=1000, F=[0,2.7]) | ||
ts = ewstools.TimeSeries(data=series, transition=860) | ||
ts.detrend(method='Lowess', span=0.2) | ||
ts.state[['state','smoothing']].plot() | ||
ts.compute_spectrum(rolling_window=0.5, ham_length=40) | ||
|
||
# Initialize parameters for timing functions | ||
rw = 0.5 | ||
n = 100 | ||
t_elapsed = np.zeros(10) | ||
|
||
# Time functions (in a not very elegant way) | ||
t0 = time.time() | ||
for i in range(n): | ||
ts.compute_var(rolling_window=rw) | ||
t_elapsed[0] = time.time() - t0 | ||
|
||
t0 = time.time() | ||
for i in range(n): | ||
ts.compute_cv() | ||
t_elapsed[1] = time.time() - t0 | ||
|
||
t0 = time.time() | ||
for i in range(n): | ||
ts.compute_skew(rolling_window=rw) | ||
t_elapsed[2] = time.time() - t0 | ||
|
||
t0 = time.time() | ||
for i in range(n): | ||
ts.compute_kurt() | ||
t_elapsed[3] = time.time() - t0 | ||
|
||
t0 = time.time() | ||
for i in range(n): | ||
ts.compute_auto(rolling_window=rw, lag=1) | ||
t_elapsed[4] = time.time() - t0 | ||
|
||
t0 = time.time() | ||
for i in range(n): | ||
ts.compute_smax() | ||
t_elapsed[5] = time.time() - t0 | ||
|
||
t0 = time.time() | ||
for i in range(n): | ||
ts.compute_ktau() | ||
t_elapsed[6] = time.time() - t0 | ||
|
||
t0 = time.time() | ||
surro = ewstools.core.block_bootstrap(ts.state.residuals, n, bs_type='Stationary', block_size=10) | ||
t_elapsed[7] = time.time() - t0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using TransitionsInTimeseries, DelimitedFiles, CairoMakie, Random | ||
|
||
x = readdlm("ewstools-tuto-1.csv", ',')[:, end] | ||
t = eachindex(x) | ||
|
||
# Choose the indicators and how to measure their change over time | ||
indicators = (var, ar1_whitenoise) | ||
change_metrics = (kendalltau, kendalltau) | ||
config = SegmentedWindowConfig(indicators, change_metrics, [t[1]], [t[end]]; | ||
width_ind = length(x) ÷ 2, whichtime = last, min_width_cha = 50) | ||
results = estimate_indicator_changes(config, x, t) | ||
signif = SurrogatesSignificance(n = 1000, tail = [:right, :right], rng = Xoshiro(1995)) | ||
flags = significant_transitions(results, signif) | ||
fig = plot_changes_significance(results, signif) | ||
ylims!(contents(fig[2, 1])[2], (0.037, 0.045)) | ||
save("../figures/figure1.png", fig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using TransitionsInTimeseries, DelimitedFiles, CairoMakie, Random | ||
|
||
coefficient_of_variation(x) = std(x) / mean(x) | ||
|
||
function main() | ||
x = readdlm("ewstools-tuto-1.csv", ',')[:, end] | ||
t = eachindex(x) | ||
|
||
# Choose the indicators and how to measure their change over time | ||
indicators = (var, coefficient_of_variation, skewness, kurtosis, | ||
ar1_whitenoise, LowfreqPowerSpectrum()) | ||
stride = [1, 1, 1, 1, 1, 40] | ||
n, m = 100, length(indicators) | ||
t_elapsed = zeros(m+2) | ||
|
||
|
||
for (i, ind) in enumerate(indicators) | ||
# Build configuration with adequate parameters of the sliding window | ||
config = SegmentedWindowConfig((ind, ind), (nothing, nothing), [t[1]], [t[end]]; | ||
width_ind = length(x) ÷ 2, stride_ind = stride[i], whichtime = last, | ||
min_width_cha = 1) | ||
|
||
t0 = time() | ||
for i in 1:n | ||
# Compute the metrics over sliding windows and their significance | ||
results = estimate_indicator_changes(config, x, t) | ||
end | ||
t_elapsed[i] = (time() - t0) / 2 | ||
end | ||
|
||
config = SegmentedWindowConfig((nothing, nothing), (kendalltau, kendalltau), [t[1]], [t[end]]; | ||
width_ind = length(x) ÷ 2, stride_ind = 1, whichtime = last, min_width_cha = 1) | ||
t0 = time() | ||
for i in 1:n | ||
results = estimate_indicator_changes(config, x, t) | ||
end | ||
t_elapsed[m+1] = (time() - t0) / 2 | ||
|
||
sgen = surrogenerator(x, BlockShuffle(), Xoshiro(1995)) | ||
t0 = time() | ||
for i in 1:n | ||
s = sgen() | ||
end | ||
t_elapsed[m+2] = time() - t0 | ||
|
||
return t_elapsed | ||
end | ||
|
||
t_tt = main() | ||
t_et = [0.03840542, 0.05554581, 0.03895116, 0.04029274, 7.96556187, | ||
2.73067856, 0.39529872, 0.02751493] | ||
|
||
# [0.04681492, 8.13679838, 0.04035759, 0.09219241] | ||
inds = eachindex(t_et) | ||
w = 0.4 | ||
|
||
fig, ax = barplot(inds .- 0.5*w, t_et, label = L"ewstools $\,$", width = w, | ||
fillto = 1e-5) | ||
barplot!(ax, inds .+ 0.5*w, t_tt, label = L"TransitionsInTimeseries.jl $\,$", | ||
width = w, fillto = 1e-5) | ||
ax.yscale = log10 | ||
ax.xticks = (1:8, [L"Variance $\,$", L"Coeff. of variation $\,$", L"Skewness $\,$", | ||
L"Kurtosis $\,$", L"Lag-1 autocorr. $\,$", L"Spectral $\,$", | ||
L"Kendall $\tau$ corr. coeff.", L"Block bootstrap $\,$"]) | ||
ax.ylabel = L"Run time (s) of 100 computations on Ricker model data $\,$" | ||
ax.yticks = (10.0 .^ (-5:1), [L"10^{%$e}" for e in -5:1]) | ||
ax.xgridvisible = false | ||
ax.ygridvisible = false | ||
ax.xticklabelrotation = π / 4 | ||
axislegend(ax, position = :lt) | ||
save("../figures/figure2.png", fig) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.