Time-series pre-processing
This commit is contained in:
parent
39c4b9c1ba
commit
20176f4b98
3 changed files with 44 additions and 0 deletions
|
@ -5,6 +5,7 @@ hires=bathyhires.dat
|
|||
hstru=Hstru.dat
|
||||
poro=Poro.dat
|
||||
psize=Psize.dat
|
||||
raw_ts=201702281700.raw
|
||||
hires_step=0.5
|
||||
|
||||
[out]
|
||||
|
|
1
data/data/.gitignore
vendored
1
data/data/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
*.xyz
|
||||
*.raw
|
||||
|
|
42
data/processing/ts.py
Normal file
42
data/processing/ts.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import argparse
|
||||
import configparser
|
||||
import logging
|
||||
import pathlib
|
||||
|
||||
import numpy as np
|
||||
|
||||
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(level=max((10, 20 - 10 * args.verbose)))
|
||||
log = logging.getLogger("bathy")
|
||||
|
||||
log.info("Starting time-series pre-processing")
|
||||
config = configparser.ConfigParser()
|
||||
config.read(args.config)
|
||||
|
||||
inp_root = pathlib.Path(config.get("inp", "root"))
|
||||
out_root = pathlib.Path(config.get("out", "root"))
|
||||
|
||||
inp_ts = inp_root.joinpath(config.get("inp", "raw_ts"))
|
||||
out_ts = out_root.joinpath("ts.dat")
|
||||
|
||||
raw_ts = np.loadtxt(
|
||||
inp_ts,
|
||||
dtype=[("state", int), ("z", float), ("y", float), ("x", float)],
|
||||
delimiter=",",
|
||||
max_rows=2304,
|
||||
)
|
||||
log.debug(f"{raw_ts=}")
|
||||
|
||||
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)))}")
|
||||
|
||||
t = np.linspace(0, 30 * 60, 2305)[:-1]
|
||||
log.debug(f"{t=}")
|
||||
|
||||
log.info(f"Saving timeseries to '{out_ts}'")
|
||||
np.savetxt(out_ts, np.stack((t, raw_ts["z"]), axis=1))
|
Loading…
Reference in a new issue