diff --git a/olaflow/processing/sws_wavedict.py b/olaflow/processing/sws_wavedict.py new file mode 100644 index 0000000..c3c758b --- /dev/null +++ b/olaflow/processing/sws_wavedict.py @@ -0,0 +1,46 @@ +import argparse +import configparser +import logging +import pathlib + +import matplotlib.pyplot as plt +import numpy as np +from scipy import interpolate +from scipy import fft + +from .olaflow import OFModel + +parser = argparse.ArgumentParser(description="Convert swash output to olaFlow input") +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("sws_ola") + +log.info("Starting sws -> olaFlow converter") +config = configparser.ConfigParser() +config.read(args.config) + +sws_out = pathlib.Path(config.get("swash", "np_out")) + + +def data(var): + return np.load(sws_out.joinpath(f"{var}.npy")) + + +x = data("x") +t = data("t") + +watl = data("watl") + +arg_x0 = np.argmin(np.abs(x+1250)) + +wl = watl[:, arg_x0] + +f = fft.rfftfreq(t.size, np.diff(t).mean()) +w_fft = fft.rfft(wl) +amp = np.abs(w_fft) +phi = np.angle(w_fft) + +print(f, amp, phi, sep="\n")