Skip to content
Snippets Groups Projects
Commit 8f2b1be9 authored by leufen1's avatar leufen1
Browse files

added overall plot including all variables

parent ab5136ae
Branches
Tags
6 merge requests!319add all changes of dev into release v1.4.0 branch,!318Resolve "release v1.4.0",!299Draft: Merge default data handler and preprocessing support parameter use_multiprocessing....,!289include plot script restructuring,!287Resolve "periodogram for kzf",!259Draft: Resolve "WRF-Datahandler should inherit from SingleStationDatahandler"
Pipeline #65413 failed
......@@ -454,6 +454,8 @@ class PlotPeriodogram(AbstractPlotClass):
self._prepare_pgram(generator, pos)
self._plot(raw=True)
self._plot(raw=False)
self._plot_total(raw=True)
self._plot_total(raw=False)
def _prepare_pgram(self, generator, pos):
raw_data = dict()
......@@ -529,3 +531,41 @@ class PlotPeriodogram(AbstractPlotClass):
# close all open figures / plots
pdf_pages.close()
plt.close('all')
def _plot_total(self, raw=True):
plot_path = os.path.join(os.path.abspath(self.plot_folder),
f"{self.plot_name}{'_raw' if raw else ''}_{self._sampling}_total.pdf")
pdf_pages = matplotlib.backends.backend_pdf.PdfPages(plot_path)
fig, ax = plt.subplots()
res = None
for var in self.plot_data_raw.keys():
d_var = self.plot_data_raw[var][1]
res = d_var if res is None else np.concatenate((res, d_var), axis=-1)
if raw is True:
for i in range(res.shape[1]):
ax.plot(self.f_index, res[:, i], "lightblue")
ax.plot(self.f_index, res.mean(axis=1), "blue")
else:
ma = pd.DataFrame(np.vstack(res)).rolling(5, center=True, axis=0)
mean = ma.mean().mean(axis=1).values.flatten()
upper, lower = ma.max().mean(axis=1).values.flatten(), ma.min().mean(axis=1).values.flatten()
ax.plot(self.f_index, mean, "blue")
ax.fill_between(self.f_index, lower, upper, color="lightblue")
plt.yscale("log")
plt.xscale("log")
ax.set_ylabel("power", fontsize='x-large')
ax.set_xlabel("frequency $[day^{-1}$]", fontsize='x-large')
lims = ax.get_ylim()
self._add_annotation_line([1, 2, 3], 365.25, lims, "yr") # per year
self._add_annotation_line(1, 365.25 / 12, lims, "m") # per month
self._add_annotation_line(1, 7, lims, "w") # per week
self._add_annotation_line([1, 0.5], 1, lims, "d") # per day
if self._sampling == "hourly":
self._add_annotation_line(2, 1, lims, "d") # per day
self._add_annotation_line([1, 0.5], 1 / 24., lims, "h") # per hour
title = f"Periodogram (total)"
plt.title(title)
pdf_pages.savefig()
# close all open figures / plots
pdf_pages.close()
plt.close('all')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment