From 2570349eac91d22ce39c5a994831b8433b70eb60 Mon Sep 17 00:00:00 2001
From: Impact <pascal.mouquet@ird.fr>
Date: Mon, 6 May 2019 14:32:41 +0400
Subject: [PATCH] timeseries new figure

---
 sen2chain/time_series.py | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/sen2chain/time_series.py b/sen2chain/time_series.py
index d85feb2..0c5409b 100644
--- a/sen2chain/time_series.py
+++ b/sen2chain/time_series.py
@@ -254,7 +254,7 @@ class TimeSeries:
                 self._date_max)
             df = self.data[df_name]
             plt.figure(figsize=(19.2,10.8))
-            if df_name in ['NDVI', 'NDWIGAO', 'NDVIMCF', 'MNDWI']:
+            if df_name in ['NDVI', 'NDWIGAO', 'NDWIMCF', 'MNDWI']:
                 plt.ylim((-10000,10000))
             else:
                 plt.ylim((0,10000))
@@ -279,8 +279,13 @@ class TimeSeries:
                 df_name,
                 self._date_min,
                 self._date_max)
+            png_path_nonan = out_path_folder / "{0}_plot-details-nonan_{1}_{2}_{3}.png".format(
+                self._vectors_file.stem,
+                df_name,
+                self._date_min,
+                self._date_max)
             
-            if df_name in ['NDVI', 'NDWIGAO', 'NDWMCF', 'MNDWI']:
+            if df_name in ['NDVI', 'NDWIGAO', 'NDWIMCF', 'MNDWI']:
                 ylim = [-10000, 10000]
             else:
                 ylim = [0, 10000]
@@ -305,10 +310,24 @@ class TimeSeries:
                 ax.legend(loc=0, labelspacing=0.05)
             fig.tight_layout()
             fig.suptitle(df_name, fontsize=16)
-
             plt.savefig(str(png_path))
-            plt.close()  
-            logger.info("Plot saved to png: {}".format(png_path))      
+            plt.close()
+            logger.info("Plot saved to png: {}".format(png_path)) 
+                 
+            fig, axs = plt.subplots(nrows, ncols, figsize=(19.2,10.8))
+            for (name, dfe), ax in zip(grouped, axs.flat):
+                ax.set_ylim(ylim)
+                ax.set_title(name)
+                dfe = dfe.dropna(subset = ['mean'])
+                dfe = dfe[(dfe[['nodata']] == 0).all(axis=1)]
+                dfe.plot(y=['mean'], ax=ax, yerr='std', color='black', elinewidth=0.2, legend=False)
+                dfe.plot(y=['min', 'max'], ax=ax, linewidth=0.25, color='black', legend=False)
+                ax.legend(loc=0, labelspacing=0.05)
+            fig.tight_layout()
+            fig.suptitle(df_name, fontsize=16)
+            plt.savefig(str(png_path_nonan))
+            plt.close()
+            logger.info("Plot saved to png: {}".format(png_path_nonan)) 
 
 
     def extract_ql(self, out_path: Union[str, pathlib.PosixPath] = None) -> None:
@@ -331,7 +350,7 @@ class TimeSeries:
                          'BIRNIR' : 'afmhot',
                          'BIBG' : 'bone',
                          'MNDWI' : 'BrBG'}
-            if df_name in ['NDVI', 'NDWIGAO', 'NDWMCF', 'MNDWI']:
+            if df_name in ['NDVI', 'NDWIGAO', 'NDWIMCF', 'MNDWI']:
                 vmin = -10000
                 vmax = 10000
             else:
-- 
GitLab