Skip to content
Snippets Groups Projects
Commit ff1da0d0 authored by Felix Kleinert's avatar Felix Kleinert
Browse files

include some basic test plots in __main__

parent 9d0ec12c
No related branches found
No related tags found
1 merge request!259Draft: Resolve "WRF-Datahandler should inherit from SingleStationDatahandler"
Pipeline #63118 passed
......@@ -393,6 +393,8 @@ if __name__ == '__main__':
def plot_map_proj(data, xlim=None, ylim=None, filename=None, point=None, radius=None, **kwargs):
cmap = kwargs.pop('cmap', plt.cm.Reds)
set_background = kwargs.pop('set_background', False)
edgecolors = kwargs.pop('edgecolors', 'face')
circle = kwargs.pop('circle', False)
crs_latlon = ccrs.PlateCarree()
if ylim is None:
......@@ -408,12 +410,14 @@ if __name__ == '__main__':
ax = plt.axes(projection=ccrs.PlateCarree())
ax.set_global()
pm = data.squeeze().plot.pcolormesh(ax=ax, transform=ccrs.PlateCarree(), x='XLONG', y='XLAT',
cmap=cmap, edgecolors=None,
cmap=cmap, edgecolors=edgecolors,
**kwargs)
ax.coastlines(resolution='50m')
##### Idea to draw circle from https://stackoverflow.com/a/58735566
#### own try:
if circle:
circle_points = Geodesic().circle(lon=lon, lat=lat,
radius=radius*1000., # radius_in_meters,
)
......@@ -427,8 +431,8 @@ if __name__ == '__main__':
plt.plot(lon, lat, '+k', markersize=7, transform=crs_latlon)
if set_background:
ax.stock_img()
plt.tight_layout()
plt.savefig(filename)
# plt.tight_layout()
plt.savefig(filename, bbox_inches='tight')
plt.close('all')
......@@ -528,47 +532,59 @@ if __name__ == '__main__':
# dummy_plot(geo_info.bearing.where(dist_xr <= radius_from_point), True, [2, 15], [45, 58])
for i, (data, xlim, ylim, kwargs) in enumerate(((wrf_new._data.T2.isel({'XTIME': 0}), [-42, 66], [23, 80], {}),
(wrf_new.geo_infos.dist, [-42, 66], [23, 80], {}),
(wrf_new.geo_infos.bearing, [-42, 66], [23, 80], {}),
for i, (data, xlim, ylim, kwargs) in enumerate(((wrf_new._data.T2.isel({'XTIME': 0}), [-42, 66], [23, 80],
{'circle': True, 'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}}),
(wrf_new._data.o3.isel({'XTIME': 0, 'bottom_top': 0}),
[-42, 66], [23, 80], {'circle': True, 'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}}),
(wrf_new.geo_infos.dist, [-42, 66], [23, 80],
{'cmap': plt.cm.get_cmap('Greys'), 'circle': True, 'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}}),
(wrf_new.geo_infos.bearing, [-42, 66], [23, 80],
{'cmap': plt.cm.get_cmap('twilight'), 'circle': True, 'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}}),
(wrf_new.geo_infos.wind_sectors, [-42, 66], [23, 80], {
'cmap': plt.cm.get_cmap('tab20'),
'set_background': True,
}
),
'cmap': plt.cm.get_cmap('tab20',16),
'circle': True,
'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}
#'set_background': True,
# 'levels': 16,
}),
(wrf_new._data.T2.isel({'XTIME': 0}).where(
windsect.is_in_sector('N', wrf_new.geo_infos['bearing'])),
[-42, 66], [23, 80], {}),
[-42, 66], [23, 80], {'circle': False, 'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}}),
(wrf_new._data.T2.isel({'XTIME': 0}).where(
wrf_new.geo_infos.dist.sel({'points': 0}).drop('points') <= radius_from_point),
[2, 15],
[45, 58], {}),
[45, 58], {'circle': False, 'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}}),
(geo_info.dist.where(
wrf_new.geo_infos.dist.sel({'points': 0}).drop('points') <= radius_from_point),
[2, 15],
[45, 58], {}),
[45, 58], {'circle': False, 'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}}),
(wrf_new.geo_infos.bearing.where(
dist_xr.sel({'points': 0}).drop('points') <= radius_from_point),
[2, 15],
[45, 58], {}),
[45, 58], {'circle': False, 'cbar_kwargs': {'orientation': 'horizontal', 'pad': 0.01}}),
(wrf_new.geo_infos.wind_sectors.where(
dist_xr.sel({'points': 0}).drop('points') <= radius_from_point),
[2, 15],
[45, 58], {'cmap': plt.cm.get_cmap('tab20', 16),
'set_background': True,
'circle': False,
'cbar_kwargs': {'orientation': 'horizontal',
'shrink': .6, 'pad': 0.01}
#'set_background': True,
}),
(wrf_new.geo_infos.dist.where(
wrf_new.geo_infos.dist.sel({'points': 0}).drop('points') <= radius_from_point).where(
windsect.is_in_sector('N', wrf_new.geo_infos['bearing'])),
[2, 15],
[45, 58], {}),
[45, 58], {'circle': False, 'cbar_kwargs': {'orientation': 'horizontal',
'fraction':.1, 'pad': 0.01}}),
)):
plot_map_proj(data, xlim=xlim,
ylim=ylim,
# point=[lat_np, lon_np],
point=[wrf_new.get_nearest_coords()['lat'][0], wrf_new.get_nearest_coords()['lon'][0]],
filename=f'Example_dist{i}.pdf',
filename=f'EEExample_dist{i}.png',
radius=radius_from_point,
# cbar_kwargs={'orientation': 'horizontal'},
**kwargs,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment