This notebook illustrates how the toolbox_runner can be used to apply Fourier transformations to any kind of timeseries data. The tool is following the Tool Specification and builds on the SciPy FFT implementation
from toolbox_runner import list_tools
from pprint import pprint
fft = list_tools(as_dict=True).get('fft')
print(fft.title)
print(fft.description)
pprint(fft.parameters)
Discrete Fast Fourier Transformation Perform a discrete fast Fourier transformation on numerical data. The data is accepted as a single-column dat file, or as a CSV file. The tool will automatically ignore all non-numeric columns. Note that the functions implemented here were almost entirely written by chatGPT as a test. All produced functions needed some human refactoring to get inputs and outputs right. {'data': {'description': 'Either a single-column dat or a CSV file of a ' 'timeseries', 'type': 'file'}, 'timestep': {'description': 'The timestep between measurements. If not given, ' 'a sampling rate of 1 Hz is assumed.', 'optional': True, 'type': 'integer'}}
There is sample data downloaded from the CDC server of the Deutscher Wetterdienst (DWD), containing temperature and air humidity data from the station in Chemnitz, Germany
import pandas as pd
df = pd.read_csv('in/series.csv', parse_dates=True, index_col=[0])['19550101':'19600101']
df.temperature.plot(c='red')
<AxesSubplot:xlabel='date'>
step = fft.run(result_path='./test', data=df, timestep=3600)
step.outputs
['STDERR.log', 'STDOUT.log', 'discrete_fft.csv', 'fft_plot.html', 'fft_plot.plotly.json']
import plotly.offline as py
import plotly.graph_objects as go
py.init_notebook_mode(connected=True)
# extract the plotly.json file
plot = step.get('fft_plot.plotly.json')
# create the figure and show
fig = go.Figure(plot).update_layout(legend=dict(orientation='h'))
py.iplot(fig)