Skip to content

Commit 90a4a06

Browse files
authored
Add detrending methods (#16)
* update CI * WIP Porting Aryan's code * add basic detranding and window smoothing * correct changelog * update docs to reflect dynamical systems style * update doc generation to dynamical systems * actually build docs * add docstring to MAW * finish things and add to docs * update workflows * add Loess * use correct module in docs * fix all tests * make subtypes of decompo-sition * add HP filter * add it to tests * fix test call * make test project file * add delay embedding in test * fix all tests * fix docs, fix tests * fix docs?
1 parent 8331729 commit 90a4a06

28 files changed

+437
-178
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,24 @@
11
name: CompatHelper
2+
23
on:
34
schedule:
4-
- cron: 0 0 * * *
5-
workflow_dispatch:
6-
permissions:
7-
contents: write
8-
pull-requests: write
5+
- cron: '00 * * * *'
6+
97
jobs:
108
CompatHelper:
11-
runs-on: ubuntu-latest
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
julia-version: [1]
13+
julia-arch: [x86]
14+
os: [ubuntu-latest]
1215
steps:
13-
- name: Check if Julia is already available in the PATH
14-
id: julia_in_path
15-
run: which julia
16-
continue-on-error: true
17-
- name: Install Julia, but only if it is not already available in the PATH
18-
uses: julia-actions/setup-julia@v1
16+
- uses: julia-actions/setup-julia@latest
1917
with:
20-
version: '1'
21-
arch: ${{ runner.arch }}
22-
if: steps.julia_in_path.outcome != 'success'
23-
- name: "Add the General registry via Git"
24-
run: |
25-
import Pkg
26-
ENV["JULIA_PKG_SERVER"] = ""
27-
Pkg.Registry.add("General")
28-
shell: julia --color=yes {0}
29-
- name: "Install CompatHelper"
30-
run: |
31-
import Pkg
32-
name = "CompatHelper"
33-
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
34-
version = "3"
35-
Pkg.add(; name, uuid, version)
36-
shell: julia --color=yes {0}
37-
- name: "Run CompatHelper"
38-
run: |
39-
import CompatHelper
40-
CompatHelper.main()
41-
shell: julia --color=yes {0}
18+
version: ${{ matrix.julia-version }}
19+
- name: Pkg.add("CompatHelper")
20+
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
21+
- name: CompatHelper.main()
4222
env:
4323
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
45-
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
24+
run: julia -e 'using CompatHelper; CompatHelper.main()'

.github/workflows/TagBot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
- uses: JuliaRegistries/TagBot@v1
1313
with:
1414
token: ${{ secrets.GITHUB_TOKEN }}
15-
ssh: ${{ secrets.DOCUMENTER_KEY }}
15+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.github/workflows/ci.yml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ name: CI
22
on:
33
pull_request:
44
branches:
5-
- master
5+
- main
6+
- '**' # matches every branch
67
push:
78
branches:
8-
- master
9+
- main
910
tags: '*'
1011
jobs:
1112
test:
@@ -15,17 +16,25 @@ jobs:
1516
fail-fast: false
1617
matrix:
1718
version:
18-
- '1' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
19-
os: [ubuntu-latest]
19+
- '1'
20+
os: [ubuntu-latest] # adjust according to need, e.g. os: [ubuntu-latest] if testing only on linux
2021
arch:
2122
- x64
2223
steps:
24+
# Cancel ongoing CI test runs if pushing to branch again before the previous tests
25+
# have finished
26+
- name: Cancel ongoing test runs for previous commits
27+
uses: styfle/cancel-workflow-action@0.6.0
28+
with:
29+
access_token: ${{ github.token }}
30+
31+
# Do tests
2332
- uses: actions/checkout@v2
2433
- uses: julia-actions/setup-julia@v1
2534
with:
2635
version: ${{ matrix.version }}
2736
arch: ${{ matrix.arch }}
28-
- uses: actions/cache@v1
37+
- uses: actions/cache@v4
2938
env:
3039
cache-name: cache-artifacts
3140
with:
@@ -36,24 +45,9 @@ jobs:
3645
${{ runner.os }}-test-
3746
${{ runner.os }}-
3847
- uses: julia-actions/julia-buildpkg@v1
48+
3949
- uses: julia-actions/julia-runtest@v1
40-
docs:
41-
name: Documentation
42-
runs-on: ubuntu-latest
43-
steps:
44-
- uses: actions/checkout@v2
45-
- uses: julia-actions/setup-julia@v1
50+
- uses: julia-actions/julia-processcoverage@v1
51+
- uses: codecov/codecov-action@v1
4652
with:
47-
version: '1'
48-
- name: Instantiate and install dependencies
49-
run: |
50-
julia --project=docs -e '
51-
using Pkg
52-
Pkg.develop(PackageSpec(path=pwd()))
53-
Pkg.instantiate()'
54-
- name: Generate documentation and deploy
55-
env: # needed for pushing to gh-pages branch
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
58-
run:
59-
julia --project=docs docs/make.jl
53+
file: lcov.info

.github/workflows/doccleanup.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Doc Preview Cleanup
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
doc-preview-cleanup:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout gh-pages branch
12+
uses: actions/checkout@v2
13+
with:
14+
ref: gh-pages
15+
- name: Delete preview and history + push changes
16+
run: |
17+
if [ -d "previews/PR$PRNUM" ]; then
18+
git config user.name "Documenter.jl"
19+
git config user.email "documenter@juliadocs.github.io"
20+
git rm -rf "previews/PR$PRNUM"
21+
git commit -m "delete preview"
22+
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
23+
git push --force origin gh-pages-new:gh-pages
24+
fi
25+
env:
26+
PRNUM: ${{ github.event.number }}

.github/workflows/documentation.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags: '*'
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
permissions:
13+
contents: write
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: julia-actions/setup-julia@v1
18+
with:
19+
version: '1'
20+
- name: Install dependencies
21+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
22+
- name: Build and deploy
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
25+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
26+
run: julia --project=docs/ docs/make.jl

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ videos
99
plots
1010
notebooks
1111
_research
12+
docs/build_docs_with_style.jl
1213

1314
################################################################################
1415
# Julia #

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*changelog kept with respect to version 1.0*
2+
3+
# v1.2
4+
5+
- Add new functionality for the package: detrending
6+
- Add new functionality for the package: smoothing
7+
- Add new `Decompositions`: `PolynomialDetrending, NoDecomposition, MovingAverageSmoothing, LoessSmoothing, HodrickPrescott`.
8+
- Package is now part of DynamicalSystems.jl as well under the category "Nonlinear Timeseries Analysis".
9+
10+
# v1.1
11+
12+
Update to Julia 1.9, and bump dependency compatibility versions to those of Julia 1.9+.

Project.toml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SignalDecomposition"
22
uuid = "11a47235-7b84-4c7c-b885-fc3e2a9cf955"
33
authors = ["Datseris <datseris.george@gmail.com>"]
4-
version = "1.1.0"
4+
version = "1.2.0"
55

66
[deps]
77
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
@@ -10,8 +10,11 @@ DelayEmbeddings = "5732040d-69e3-5649-938a-b6b4f237613f"
1010
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
1111
LPVSpectral = "26dcc766-85df-5edc-b560-6076d5dbac63"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
13+
Loess = "4345ca2d-374a-55d4-8d30-97f9976e7612"
1314
Neighborhood = "645ca80c-8b79-4109-87ea-e1f58159d116"
15+
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
1416
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
17+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1518
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1619
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1720

@@ -20,15 +23,10 @@ BandedMatrices = "1"
2023
DelayEmbeddings = "2"
2124
FFTW = "1.2"
2225
LPVSpectral = "0.3"
26+
Loess = "0.6"
2327
Neighborhood = "0.2"
28+
Polynomials = "4"
29+
SparseArrays = "1.11"
2430
StaticArrays = "1"
2531
Statistics = "1"
2632
julia = "1.9"
27-
28-
[extras]
29-
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
30-
DynamicalSystemsBase = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
31-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
32-
33-
[targets]
34-
test = ["Test", "DelimitedFiles", "DynamicalSystemsBase"]

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
![SignalDecomposition.jl](https://github.com/JuliaDynamics/JuliaDynamics/blob/master/videos/other/signaldecomposition.gif?raw=true)
1+
[![docsdev](https://img.shields.io/badge/docs-dev-lightblue.svg)](https://juliadynamics.github.io/DynamicalSystemsDocs.jl/signaldecomposition/dev/)
2+
[![docsstable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliadynamics.github.io/DynamicalSystemsDocs.jl/signaldecomposition/stable/)
3+
[![CI](https://github.com/JuliaDynamics/SignalDecomposition.jl/workflows/CI/badge.svg)](https://github.com/JuliaDynamics/SignalDecomposition.jl/actions?query=workflow%3ACI)
4+
[![codecov](https://codecov.io/gh/JuliaDynamics/SignalDecomposition.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaDynamics/SignalDecomposition.jl)
25

3-
| **Documentation** | **Tests** | **Chat** |
4-
|:--------:|:---------------:|:-----:|
5-
|[![](https://img.shields.io/badge/docs-online-blue.svg)](https://JuliaDynamics.github.io/SignalDecomposition.jl/dev)| [![CI](https://github.com/juliadynamics/SignalDecomposition.jl/workflows/CI/badge.svg)](https://github.com/JuliaDynamics/SignalDecomposition.jl/actions) | [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/JuliaDynamics/Lobby)
6+
SignalDecomposition.jl is a Julia package providing an interface and dozens of algorithm implementations for signal decomposition.
7+
Given a signal (or timeseries), the function `decompose` splits it into two components.
8+
These may be:
69

10+
- structure and noise (de-noising or smoothing)
11+
- seasonal and residual (climatologies or anomalies)
12+
- trend and residual (de-trending)
713

8-
Decompose a signal/timeseries into structure and noise or seasonal and residual components.
9-
Further info in the docs!
14+
It can be used as a standalone package, or as part of
15+
[DynamicalSystems.jl](https://juliadynamics.github.io/DynamicalSystemsDocs.jl/dynamicalsystems/stable/).
16+
17+
To install it, run `import Pkg; Pkg.add("SignalDecomposition")`.
18+
19+
All further information is provided in the documentation, which you can either find [online](https://juliadynamics.github.io/DynamicalSystemsDocs.jl/signaldecomposition/stable/) or build locally by running the `docs/make.jl` file.

docs/Project.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
33
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
44
DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8"
5-
DynamicalSystems = "61744808-ddfa-5f27-97ff-6e42cc95d634"
6-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
5+
PredefinedDynamicalSystems = "31e2f376-db9e-427a-b76e-a14f56347a14"
76
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
87
SignalDecomposition = "11a47235-7b84-4c7c-b885-fc3e2a9cf955"
8+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
9+
10+
[compat]
11+
PredefinedDynamicalSystems = "1.4"

0 commit comments

Comments
 (0)