Update README, zero_cross
This commit is contained in:
parent
c5f419b587
commit
db5096922f
2 changed files with 17 additions and 61 deletions
|
@ -150,3 +150,20 @@ raw_ts : liste des fichiers de données brutes de la bouée à utiliser
|
||||||
[out]
|
[out]
|
||||||
root : racine des fichiers de sortie
|
root : racine des fichiers de sortie
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Zero-cross
|
||||||
|
`zero_cross.py` permet d'obtenir les vagues les plus grosses de toutes les séries temporelles et d'obtenir la
|
||||||
|
transformée en ondelettes de la série.
|
||||||
|
|
||||||
|
```python -m processing.zero_cross [-c CONFIG] [-v]```
|
||||||
|
|
||||||
|
* `-c CONFIG` : choix d'un fichier de configuration (`.ini`)
|
||||||
|
* `-v` : verbose
|
||||||
|
|
||||||
|
```
|
||||||
|
[inp]
|
||||||
|
root : racine des fichiers d'entrée (les données brutes doivent être dans le sous-dossier `cerema/raw`)
|
||||||
|
|
||||||
|
[out]
|
||||||
|
root : racine des fichiers de sortie
|
||||||
|
```
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
import argparse
|
|
||||||
import configparser
|
|
||||||
import logging
|
|
||||||
import pathlib
|
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import numpy as np
|
|
||||||
import scipy.signal as sgl
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Pre-process time-series")
|
|
||||||
parser.add_argument("-v", "--verbose", action="count", default=0)
|
|
||||||
parser.add_argument("-c", "--config", default="config.ini")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
logging.basicConfig()
|
|
||||||
log = logging.getLogger("bathy")
|
|
||||||
log.setLevel(max((10, 20 - 10 * args.verbose)))
|
|
||||||
|
|
||||||
log.info("Starting time-series pre-processing")
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config.read(args.config)
|
|
||||||
|
|
||||||
inp_root = pathlib.Path(config.get("inp", "root"), "cerema/raw")
|
|
||||||
out_root = pathlib.Path(config.get("out", "root"))
|
|
||||||
|
|
||||||
raw_ts = []
|
|
||||||
for tsi in sorted(inp_root.glob("2017022817*.raw")):
|
|
||||||
#for tsi in sorted(inp_root.glob("*.raw")):
|
|
||||||
raw_ts.append(
|
|
||||||
np.loadtxt(
|
|
||||||
tsi,
|
|
||||||
dtype=[("state", int), ("z", float), ("y", float), ("x", float)],
|
|
||||||
delimiter=",",
|
|
||||||
max_rows=2304,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
log.debug(f"Loading <{tsi}>")
|
|
||||||
n = len(raw_ts)
|
|
||||||
raw_ts = np.concatenate(raw_ts)
|
|
||||||
log.debug(f"{raw_ts=}")
|
|
||||||
|
|
||||||
# t = np.linspace(0, 30 * 60 * n * 1e3, 2304 * n + 1)[:-1].astype("timedelta64[ms]") + np.datetime64("2017-02-28T00:00")
|
|
||||||
t = np.linspace(0, 30 * 60 * n, 2304 * n, endpoint=False)
|
|
||||||
|
|
||||||
if (errs := np.count_nonzero(raw_ts["state"])) != 0:
|
|
||||||
log.warning(f"{errs} transmission errors!")
|
|
||||||
log.debug(f"{dict(zip(*np.unique(raw_ts['state'], return_counts=True)))}")
|
|
||||||
# log.debug(f"{t[raw_ts['state'] != 0]}")
|
|
||||||
|
|
||||||
z = raw_ts["z"]
|
|
||||||
# z = np.cos(2 * np.pi * 7 * t) + sgl.gausspulse(t - 0.4, fc=2)
|
|
||||||
|
|
||||||
M = sgl.cwt(z, sgl.morlet, np.arange(1, 30 / (30 * 60 / 2304)))
|
|
||||||
print(M)
|
|
||||||
|
|
||||||
fig, ax = plt.subplots()
|
|
||||||
c = ax.imshow(M, aspect="auto", cmap="spring", vmin=0)
|
|
||||||
ax2 = ax.twinx()
|
|
||||||
ax2.plot(z, c="k")
|
|
||||||
fig.colorbar(c)
|
|
||||||
plt.show()
|
|
Loading…
Reference in a new issue