From 0d38d280ee709ae11636811d57f75f11328fbd3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Schr=C3=B6n?= <martin.schroen@ufz.de>
Date: Wed, 21 Feb 2024 08:19:53 +0100
Subject: [PATCH] Fixed pdf plots temperature range and footprint page

---
 instantPASDy.py | 50 ++++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/instantPASDy.py b/instantPASDy.py
index 7e25a62..00f2556 100644
--- a/instantPASDy.py
+++ b/instantPASDy.py
@@ -2925,7 +2925,7 @@ def main(configfile=None, cfg_prefix=None):
                         if not data[T].isnull().all():
                             ax.plot(data.index, data[T],
                                     lw=1, color='C4', label="-")
-                            ax.set_ylim(-20,40)
+                            ax.set_ylim(-20,np.max([40,data[T].max()]))
                             ax.axhline(0.0, color="C4", ls="--", lw=1)
                             ax.set_ylabel("Air temperature (in °C)")
 
@@ -2972,7 +2972,9 @@ def main(configfile=None, cfg_prefix=None):
                     if not data[N].isnull().all():
                         with Figure(size=(10,9), layout=(3,1),
                                 **kw_fig_buff, **kw_fig_time,
-                                x_ticks_last=True) as F:
+                                x_ticks_last=True,
+                                gridspec_kw=dict(height_ratios=[3, 1, 1])
+                                ) as F:
                             
                             ax = F.axes[0]
                             ax.plot(data.index, data["correct_p"],
@@ -3241,11 +3243,11 @@ def main(configfile=None, cfg_prefix=None):
                         R.add_title("Footprint")
                         R.add_par(J.post("footprint"))
                         
-                        if not data["footprint_radius"].isnull().all():
-                            with Figure(size=(10,11), layout=(3,1),
-                                    **kw_fig_buff, **kw_fig_time,
-                                    x_ticks_last=True) as F:
-                                
+                        with Figure(size=(10,11), layout=(3,1),
+                                **kw_fig_buff, **kw_fig_time,
+                                x_ticks_last=True) as F:
+                            
+                            if not data["footprint_radius"].isnull().all():
                                 ax = F.axes[0]
                                 var = 'footprint_radius'
                                 ax.fill_between(data.index, data[var], 0,
@@ -3256,17 +3258,18 @@ def main(configfile=None, cfg_prefix=None):
                                 ax.set_ylim(0,350)
                                 ax.set_ylabel("Radius (in m)")
 
-                                ax = F.axes[1]
-                                var = 'footprint_depth'
-                                ymin = np.min([-80,-data[var].max()])
-                                ax.fill_between(data.index, -data[var], 0,
-                                                color='sienna', alpha=0.3, lw=0, step='post')
-                                ax.plot(data.index, -data[var],
-                                        color='sienna', drawstyle='steps-post', lw=2,
-                                        label="Footprint depth")
-                                ax.set_ylim(ymin,0)
-                                ax.set_ylabel("Depth (in cm)")
-
+                            ax = F.axes[1]
+                            var = 'footprint_depth'
+                            ymin = np.min([-80,-data[var].max()])
+                            ax.fill_between(data.index, -data[var], 0,
+                                            color='sienna', alpha=0.3, lw=0, step='post')
+                            ax.plot(data.index, -data[var],
+                                    color='sienna', drawstyle='steps-post', lw=2,
+                                    label="Footprint depth")
+                            ax.set_ylim(ymin,0)
+                            ax.set_ylabel("Depth (in cm)")
+
+                            if not data["footprint_volume"].isnull().all():
                                 ax = F.axes[2]
                                 var = 'footprint_volume'
                                 ax.fill_between(data.index, data[var], 0,
@@ -3277,14 +3280,15 @@ def main(configfile=None, cfg_prefix=None):
                                 ax.set_ylim(0,120)
                                 ax.set_ylabel("Volume (in 10³ m³)")
 
-                                for ax in F.axes:
-                                    ax.grid(color="k", alpha=0.1)
-                                    ax.set_xlim(date1, date2)
+                            for ax in F.axes:
+                                ax.grid(color="k", alpha=0.1)
+                                ax.set_xlim(date1, date2)
+                                if not ax.get_legend_handles_labels() == ([], []):
                                     ax.legend(loc="upper left", bbox_to_anchor=(0, 1.12),
                                             ncol=3, fancybox=False, framealpha=1, edgecolor="k",
                                             shadow=True)
-                                    if ax != F.axes[-1]:
-                                        ax.set_xticklabels([])
+                                if ax != F.axes[-1]:
+                                    ax.set_xticklabels([])
                         
                             R.add_image(F.buff)
 
-- 
GitLab