From 3e90b2896ff8cd50c3a62169d6e7a15c56eee46a Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 4 Dec 2023 01:59:51 +0100 Subject: meteogram --- config.yaml | 3 +++ plotter/meteogram.py | 27 ++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/config.yaml b/config.yaml index 5ba023a..d9e5d45 100644 --- a/config.yaml +++ b/config.yaml @@ -18,6 +18,9 @@ aggregator: - pmsl - t_2m - relhum_2m + - hbas_con + - htop_con + - htop_dc pressure_levels: [1000, 950, 925, 900, 875, 850, 825, 800, 775, 700, 600, 500, 400, 300, 250, 200, 150, 100] steps: [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48] plotter: diff --git a/plotter/meteogram.py b/plotter/meteogram.py index ee8c7ea..790714e 100755 --- a/plotter/meteogram.py +++ b/plotter/meteogram.py @@ -2,6 +2,8 @@ import os import json +import numpy as np + import matplotlib.pyplot as plt import xarray as xr @@ -51,14 +53,29 @@ def _plot(data, output, name, lat, lon): ax.invert_yaxis() - ### Second plot - + ### Temp + Dewpoint ax2 = fig.add_subplot(5,1,3,sharex=ax) ax2.plot(data.valid_time, data.t2m.metpy.convert_units('degC').transpose(), color='red', label='Temperature (2m)') ax2.plot(data.valid_time, mpcalc.dewpoint_from_relative_humidity(data.t2m, data.r2).transpose(), color='blue', label='Dewpoint (2m)') ax2.set_ylabel('Temperature [degC]') ax2.legend(loc='lower right') + ## MSLP + ax3 = fig.add_subplot(5,1,4,sharex=ax) + ax3.plot(data.valid_time, data.prmsl.metpy.convert_units('hPa').transpose(), color='black', label='Temperature (2m)') + ax3.set_ylabel('Mean Sea Level Pressure [hPa]') + #ax3.legend(loc='lower right') + # TODO: ADD HBAS_CON, HTOP_CON + # If none: -500m + + ax4 = ax3.twinx() + ax4.set_ylim(0, 14) + ax4.set_ylabel('Convective Clouds Height [km]') + ax4.bar(data.valid_time, + bottom=data.HBAS_CON.metpy.convert_units('km').transpose(), + height=(data.hcct.metpy.convert_units('km')-data.HBAS_CON.metpy.convert_units('km')).transpose(), + align='edge', width=np.timedelta64(3, 'h')) + ### Info Lines info_lines = [] @@ -71,10 +88,10 @@ def _plot(data, output, name, lat, lon): if '_description' in data.attrs: info_lines.append(data.attrs['_description']) - ax = fig.add_subplot(5, 1, 4) - ax.text(0, 0, '\n'.join(info_lines), ha='left', va='center', + ax_text = fig.add_subplot(5, 1, 5) + ax_text.text(0, 0, '\n'.join(info_lines), ha='left', va='center', size=10, fontfamily='monospace') - ax.axis("off") + ax_text.axis("off") ### Output -- cgit v1.2.3