From 9be1af17ace1e73a1c008336ede17b0c3bbf28ae Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Wed, 29 Nov 2023 17:35:59 +0100 Subject: [PATCH] Fix plots --- isimip_qa/plots/dayofyear.py | 3 ++- isimip_qa/plots/monthofyear.py | 3 ++- isimip_qa/tests/test_plots.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/isimip_qa/plots/dayofyear.py b/isimip_qa/plots/dayofyear.py index ca69f33..6878ba9 100644 --- a/isimip_qa/plots/dayofyear.py +++ b/isimip_qa/plots/dayofyear.py @@ -15,7 +15,8 @@ class DayOfYearPlot(FigurePlotMixin, GridPlotMixin, Plot): def get_df(self, dataset): extraction = self.extraction_class(dataset, self.region, self.period) df = extraction.read() - return (df.groupby(lambda x: x.dayofyear).mean() - df.mean()) / df.std() + mean, std = df.mean().values, df.std().values + return (df.groupby(lambda x: x.dayofyear).mean() - mean) / (std if std > 0 else 1.0) def get_attrs(self, dataset): return AttrsExtraction(dataset, self.region, self.period).read() diff --git a/isimip_qa/plots/monthofyear.py b/isimip_qa/plots/monthofyear.py index ea40df1..fb89b4a 100644 --- a/isimip_qa/plots/monthofyear.py +++ b/isimip_qa/plots/monthofyear.py @@ -15,7 +15,8 @@ class MonthOfYearPlot(FigurePlotMixin, GridPlotMixin, Plot): def get_df(self, dataset): extraction = self.extraction_class(dataset, self.region, self.period) df = extraction.read() - return (df.groupby(lambda x: x.month).mean() - df.mean()) / df.std() + mean, std = df.mean().values, df.std().values + return (df.groupby(lambda x: x.month).mean() - mean) / (std if std > 0 else 1.0) def get_attrs(self, dataset): return AttrsExtraction(dataset, self.region, self.period).read() diff --git a/isimip_qa/tests/test_plots.py b/isimip_qa/tests/test_plots.py index 343c7d1..ba775e7 100644 --- a/isimip_qa/tests/test_plots.py +++ b/isimip_qa/tests/test_plots.py @@ -53,4 +53,4 @@ def test_plot(settings, dataset_path, extraction_class, plot_class): similarity = ssim(img, template_img, data_range=template_img.max() - template_img.min()) - assert similarity == 1.0 + assert similarity > 0.999999