Skip to content

Commit 322ffec

Browse files
committed
initial push to repo
1 parent 4f9ae09 commit 322ffec

25 files changed

+3458
-0
lines changed

Python.gitignore

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
98+
__pypackages__/
99+
100+
# Celery stuff
101+
celerybeat-schedule
102+
celerybeat.pid
103+
104+
# SageMath parsed files
105+
*.sage.py
106+
107+
# Environments
108+
.env
109+
.venv
110+
env/
111+
venv/
112+
ENV/
113+
env.bak/
114+
venv.bak/
115+
116+
# Spyder project settings
117+
.spyderproject
118+
.spyproject
119+
120+
# Rope project settings
121+
.ropeproject
122+
123+
# mkdocs documentation
124+
/site
125+
126+
# mypy
127+
.mypy_cache/
128+
.dmypy.json
129+
dmypy.json
130+
131+
# Pyre type checker
132+
.pyre/
133+
134+
# pytype static type analyzer
135+
.pytype/
136+
137+
# Cython debug symbols
138+
cython_debug/

scatnet/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# coding=utf-8
2+
"""Deep scattering transform clustering on segmented time series."""
3+
4+
__all__ = [
5+
"display",
6+
"parse",
7+
"Network",
8+
"inventory",
9+
"signal",
10+
"wavelet",
11+
"hierarchy",
12+
]
13+
14+
from . import display
15+
from . import wavelet
16+
from . import inventory
17+
from . import signal
18+
from . import hierarchy
19+
from .io import parse
20+
from .network import Network

scatnet/cli/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# coding=utf-8
2+
"""Command-line interface tools."""
3+
4+
__all__ = ["cli"]
5+
6+
from . import cli

scatnet/cli/cli.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# coding: utf-8
2+
"""Command-line interface module.
3+
4+
The subcommands are defined in dedicated modules. Note that all subcommands
5+
share a subset of options defined in the "common.py" module. The "main"
6+
function defined here is a group for attaching all the subcommands, and it
7+
establishes the program's entry point.
8+
9+
Author: Leonard Seydoux Date: June, 2021 Email:
10+
leonard.seydoux@univ-grenoble-alpes.fr
11+
"""
12+
13+
import click
14+
15+
from .inventory import inventory
16+
from .linkage import linkage
17+
from .features import features
18+
from .transform import transform
19+
from .waveforms import waveforms
20+
21+
22+
@click.group()
23+
def main():
24+
"""Deep scattering transform on segmented time series.
25+
26+
This program contains a series of command-line tools for clustering
27+
continuous time series with a deep scattering network. The following
28+
sub-commands must be run in a specific order from the continuous data to
29+
the cluster results.
30+
31+
1. The inventorize command lists and selects the data based on usual meta
32+
parameters (sampling rate, duration, channels) and stores the relevant
33+
datapaths into an inventory file. This first command helps explore the data
34+
coverage in time, selecting appropriate time segments, and running the
35+
remaining steps on the actual data.
36+
37+
2. The transform command runs the deep scattering transform on the
38+
segmented time series and stores the scattering coefficients for later
39+
feature extraction.
40+
41+
3. With the features command, the large-dimensional scattering coefficients
42+
are reduced to a low-dimensional space which dimensions are considered
43+
features here. These features are used in the clustering step next.
44+
45+
4. The command calculates the linkage matrix that helps cluster the data
46+
based on some criteria of similarity (a metric and a method). Once this
47+
matrix is calculated, the clusters are extracted for further analyses.
48+
49+
Created in May, 2021 by Leonard Seydoux
50+
(leonard.seydoux@univ-grenoble-alpes.fr) and Randall Balestriero.
51+
52+
"""
53+
pass
54+
55+
56+
# Add subcommands
57+
main.add_command(inventory)
58+
main.add_command(transform)
59+
main.add_command(features)
60+
main.add_command(linkage)
61+
main.add_command(waveforms)

scatnet/cli/common.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# coding: utf-8
2+
"""Common subcomands options for command-line interface.
3+
4+
Authors: Leonard Seydoux and Randall Balestriero
5+
Email: leonard.seydoux@univ-grenoble-alpes.fr
6+
Date: May, 2021
7+
"""
8+
9+
10+
import click
11+
import os
12+
import functools
13+
14+
COMMON_OPTIONS = [
15+
click.option(
16+
"--savepath",
17+
default=os.environ.get("SAVEPATH", "."),
18+
show_default=".",
19+
help="output directory",
20+
type=click.Path(resolve_path=True, writable=True),
21+
),
22+
click.option(
23+
"--datapath",
24+
default=os.environ.get("DATAPATH", "."),
25+
show_default=".",
26+
help="input data path to scan",
27+
),
28+
click.option(
29+
"--figpath",
30+
default=os.environ.get("FIGPATH", "."),
31+
show_default=".",
32+
help="path to save figures",
33+
type=click.Path(resolve_path=True, writable=True),
34+
),
35+
click.option(
36+
"--start",
37+
type=click.DateTime(),
38+
default="0001-01-01 00:00:00",
39+
help="Select data after start time.",
40+
),
41+
click.option(
42+
"--end",
43+
type=click.DateTime(),
44+
default="9999-01-01 00:00:00",
45+
help="Select data after start time.",
46+
),
47+
click.option(
48+
"--channels",
49+
type=str,
50+
default="*",
51+
show_default=True,
52+
help="Channels to search for.",
53+
),
54+
click.option(
55+
"--filename_inventory",
56+
type=str,
57+
default="inventory",
58+
show_default=True,
59+
help="Basename for inventory file.",
60+
),
61+
click.option(
62+
"--filename_network",
63+
type=str,
64+
default="network",
65+
show_default=True,
66+
help="Basename for network file.",
67+
),
68+
click.option(
69+
"--filename_reduction",
70+
type=str,
71+
default="reduction_{}",
72+
show_default=True,
73+
help="Basename for network file.",
74+
),
75+
click.option(
76+
"--path_scatterings",
77+
type=str,
78+
default="scatterings",
79+
show_default=True,
80+
help="Name of scattering files directory.",
81+
),
82+
click.option(
83+
"--path_features",
84+
type=str,
85+
default="features",
86+
show_default=True,
87+
help="Name of feature files directory.",
88+
),
89+
click.option(
90+
"--path_clusters",
91+
type=str,
92+
default="clusters",
93+
show_default=True,
94+
help="Name of cluster files directory.",
95+
),
96+
click.option(
97+
"--show",
98+
is_flag=True,
99+
default=False,
100+
show_default=True,
101+
help="Excluding flag to show or calculate.",
102+
),
103+
]
104+
105+
106+
def common_options(f):
107+
return functools.reduce(lambda x, opt: opt(x), COMMON_OPTIONS, f)
108+

0 commit comments

Comments
 (0)