diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2023-12-04 01:59:51 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2023-12-04 01:59:51 +0100 |
commit | 3e90b2896ff8cd50c3a62169d6e7a15c56eee46a (patch) | |
tree | 56331ebe038a17724c8ff323aa12e3f5d98ce0fd /plotter | |
parent | 293b33715c3656fc54bab70ec49c04912655444f (diff) | |
download | meteo_toolbox-3e90b2896ff8cd50c3a62169d6e7a15c56eee46a.tar.gz |
meteogram
Diffstat (limited to 'plotter')
-rwxr-xr-x | plotter/meteogram.py | 27 |
1 files changed, 22 insertions, 5 deletions
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 |