1
Fork 0

Processing: fft of swash output

This commit is contained in:
Edgar P. Burkhart 2022-04-08 13:18:55 +02:00
parent 49dec9b76e
commit 8f902fb24d
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -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")