[2022 Fall] Final Exam - Question 4¶
Course: AP3021
In [1]:
Copied!
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
In [2]:
Copied!
stnno,yyyymmddhh,Pressure,Rain,Temp,Wind = np.loadtxt("./data/ground_station_data.txt",unpack="true")
stnno,yyyymmddhh,Pressure,Rain,Temp,Wind = np.loadtxt("./data/ground_station_data.txt",unpack="true")
In [3]:
Copied!
fig = plt.figure(figsize=(16,12))
plt.plot(Temp)
plt.title("Month Temperature")
plt.ylabel("Temperature")
plt.xlabel("Data_perhour")
plt.legend(['Original'])
plt.grid()
plt.show()
fig = plt.figure(figsize=(16,12))
plt.plot(Temp)
plt.title("Month Temperature")
plt.ylabel("Temperature")
plt.xlabel("Data_perhour")
plt.legend(['Original'])
plt.grid()
plt.show()
The given data is the hourly surface data of February 2019. Please apply FFT to remove the diurnal component of this data set.¶
In [4]:
Copied!
from scipy.fft import fft, fftfreq, ifft
from scipy.fft import fft, fftfreq, ifft
Temperature¶
In [5]:
Copied!
xs = np.arange(0, 672, 0.1)
Y = np.fft.fft(Temp)
fig = plt.figure(figsize=(16,12))
plt.plot(Temp)
plt.plot(Y)
plt.title("Month Temperature")
plt.ylabel("Temperature")
plt.xlabel("Data_perhour")
plt.legend(['Original', 'with FFT'])
plt.grid()
plt.show()
xs = np.arange(0, 672, 0.1)
Y = np.fft.fft(Temp)
fig = plt.figure(figsize=(16,12))
plt.plot(Temp)
plt.plot(Y)
plt.title("Month Temperature")
plt.ylabel("Temperature")
plt.xlabel("Data_perhour")
plt.legend(['Original', 'with FFT'])
plt.grid()
plt.show()
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/matplotlib/cbook/__init__.py:1340: ComplexWarning: Casting complex values to real discards the imaginary part return np.asarray(x, float)
Pressure¶
In [6]:
Copied!
xs = np.arange(0, 672, 1)
ys = Pressure[xs]
Y = np.fft.fft((ys))
fig = plt.figure(figsize=(16,12))
plt.plot(xs, ys)
plt.plot(Y)
plt.title("Month Pressure")
plt.ylabel("Pressure")
plt.xlabel("Data_perhour")
plt.legend(['Original', 'with FFT'])
plt.grid()
plt.show()
xs = np.arange(0, 672, 1)
ys = Pressure[xs]
Y = np.fft.fft((ys))
fig = plt.figure(figsize=(16,12))
plt.plot(xs, ys)
plt.plot(Y)
plt.title("Month Pressure")
plt.ylabel("Pressure")
plt.xlabel("Data_perhour")
plt.legend(['Original', 'with FFT'])
plt.grid()
plt.show()
Rain¶
In [7]:
Copied!
xs = np.arange(0, 672, 1)
ys = Rain[xs]
Y = np.fft.fft((ys))
fig = plt.figure(figsize=(16,12))
plt.plot(xs, ys)
plt.plot(Y)
plt.title("Month Rain")
plt.ylabel("Rain")
plt.xlabel("Data_perhour")
plt.legend(['Original', 'with FFT'])
plt.grid()
plt.show()
xs = np.arange(0, 672, 1)
ys = Rain[xs]
Y = np.fft.fft((ys))
fig = plt.figure(figsize=(16,12))
plt.plot(xs, ys)
plt.plot(Y)
plt.title("Month Rain")
plt.ylabel("Rain")
plt.xlabel("Data_perhour")
plt.legend(['Original', 'with FFT'])
plt.grid()
plt.show()
Wind¶
In [8]:
Copied!
xs = np.arange(0, 672, 1)
ys = Wind[xs]
Y = np.fft.fft((ys))
fig = plt.figure(figsize=(16,12))
plt.plot(xs, ys)
plt.plot(Y)
plt.title("Month Wind")
plt.ylabel("Wind")
plt.xlabel("Data_perhour")
plt.legend(['Original', 'with FFT'])
plt.grid()
plt.show()
xs = np.arange(0, 672, 1)
ys = Wind[xs]
Y = np.fft.fft((ys))
fig = plt.figure(figsize=(16,12))
plt.plot(xs, ys)
plt.plot(Y)
plt.title("Month Wind")
plt.ylabel("Wind")
plt.xlabel("Data_perhour")
plt.legend(['Original', 'with FFT'])
plt.grid()
plt.show()
In [ ]:
Copied!
Last update:
2024-04-27