Processing: fft of swash output
This commit is contained in:
parent
49dec9b76e
commit
8f902fb24d
1 changed files with 46 additions and 0 deletions
46
olaflow/processing/sws_wavedict.py
Normal file
46
olaflow/processing/sws_wavedict.py
Normal 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")
|
Loading…
Reference in a new issue