This notebook is part of the $\omega radlib$ documentation: https://docs.wradlib.org.
Copyright (c) $\omega radlib$ developers. Distributed under the MIT License. See LICENSE.txt for more info.
import wradlib as wrl
import warnings
warnings.filterwarnings('ignore')
import numpy as np
import os
import metpy
import requests
import matplotlib.pyplot as pl
import matplotlib.patheffects as pe
import matplotlib.colors
from matplotlib.colors import Normalize
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
from metpy.plots import ctables
from osgeo import osr
from datetime import timedelta, datetime
import urllib
import io
import glob
try:
get_ipython().magic("matplotlib inline")
except:
pl.ion()
from html.parser import HTMLParser
try:
import urlparse
from urllib import urlencode
except: # For Python 3
import urllib.parse as urlparse
from urllib.parse import urlencode
def ceil_dt(dt, delta):
return dt + (datetime.min - dt) % delta
now = datetime.utcnow()-timedelta(hours=0, minutes=20)
timenow_iso = now.strftime("%Y-%m-%dT%H%M00")
print(timenow_iso)
#print(ceil_dt(now, timedelta(minutes=30)))
2022-08-31T051500
import requests
from requests.structures import CaseInsensitiveDict
url = "https://partner-api.meteofrance.fr/partner/radar/europe/odyssey/1.1/realtime/composite/RAINFALL_RATE/"+timenow_iso+"Z?format=HDF5"
headers = CaseInsensitiveDict()
headers["accept"] = "application/x-hdf"
headers["apikey"] = "eyJ4NXQiOiJZV0kxTTJZNE1qWTNOemsyTkRZeU5XTTRPV014TXpjek1UVmhNbU14T1RSa09ETXlOVEE0Tnc9PSIsImtpZCI6ImdhdGV3YXlfY2VydGlmaWNhdGVfYWxpYXMiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJsdWNhLm1hdGhpYXNAY2FyYm9uLnN1cGVyIiwiYXBwbGljYXRpb24iOnsib3duZXIiOiJsdWNhLm1hdGhpYXMiLCJ0aWVyUXVvdGFUeXBlIjpudWxsLCJ0aWVyIjoiVW5saW1pdGVkIiwibmFtZSI6Ik9QRVJBIiwiaWQiOjg3OSwidXVpZCI6Ijc4YTJiOGJhLTllMjctNDZhNy1iZjE2LTIyNmZkNDhmYjE0ZCJ9LCJpc3MiOiJodHRwczpcL1wvcG9ydGFpbC1hcGkubWV0ZW9mcmFuY2UuZnI6NDQzXC9vYXV0aDJcL3Rva2VuIiwidGllckluZm8iOnsiNTBQZXJNaW4iOnsidGllclF1b3RhVHlwZSI6InJlcXVlc3RDb3VudCIsImdyYXBoUUxNYXhDb21wbGV4aXR5IjowLCJncmFwaFFMTWF4RGVwdGgiOjAsInN0b3BPblF1b3RhUmVhY2giOnRydWUsInNwaWtlQXJyZXN0TGltaXQiOjAsInNwaWtlQXJyZXN0VW5pdCI6InNlYyJ9fSwia2V5dHlwZSI6IlBST0RVQ1RJT04iLCJzdWJzY3JpYmVkQVBJcyI6W3sic3Vic2NyaWJlclRlbmFudERvbWFpbiI6ImNhcmJvbi5zdXBlciIsIm5hbWUiOiJSYWRhckV1bWV0bmV0IiwiY29udGV4dCI6IlwvcGFydG5lclwvcmFkYXJcL2V1cm9wZVwvb2R5c3NleVwvMS4xIiwicHVibGlzaGVyIjoiTUVURU8uRlJcL21hcnRpbmwiLCJ2ZXJzaW9uIjoiMS4xIiwic3Vic2NyaXB0aW9uVGllciI6IjUwUGVyTWluIn1dLCJleHAiOjE3NDM3NzU3NjgsImlhdCI6MTY0OTE2Nzc2OCwianRpIjoiZDI5NGE2MDAtMmQ3Zi00ZTZlLWI1YWMtMmQzNTY5MjU5MmE0In0=.aT7jM5QdhebQWiuy2JKqPTnDHTbgXgTKruY9kh2f4wokyyZsphHlqLKww3Y3qGiO5Xw69P3iZGepuFEH2erEgYdzNmDdsd7kbO6BkinFNTaHn67rYfTAvujf0rktdgwOWpz_B6YWsvPk7G9x9cmg4ET81mNn3us1cpAB9AZ-2GJEIHvKS3p4sapXAPBOZ7XDXHa9rmKoCd399ee5SySp6EwQBfuDy604FNiKBOUmNehqeAl_3Ir9QBLCZpJwdsLG3E3awgDiNBM0bX7nTuYYMdmvT4IK5ymhjE0_TyROYYJ4kGOqyP7vEjca1mH5yrJmCfNGLoDkWSNhDpHPg-NNTw=="
resp = requests.get(url, headers=headers)
print(resp.status_code)
open('/home/lmathias/Documents/wradlib/opera/sfcrr_latest.hdf5', 'wb').write(resp.content)
resp = glob.glob('/home/lmathias/Documents/wradlib/opera/sfcrr_latest.hdf5')
resp=resp[-1]
print(resp)
vol = wrl.io.hdf.read_opera_hdf5(resp)
#print(vol)
import dateutil.parser
date = vol['dataset1/what']['enddate'].decode("utf-8")
print(date)
time = vol['dataset1/what']['endtime'].decode("utf-8")
print(time)
time = date+time
print(time)
time2 = datetime.strptime(time, "%Y%m%d%H%M%S")-timedelta(hours=0, minutes=5)
print(time2)
url2 = "https://partner-api.meteofrance.fr/partner/radar/europe/odyssey/1.1/realtime/composite/REFLECTIVITY/"+timenow_iso+"Z?format=HDF5"
headers = CaseInsensitiveDict()
headers["accept"] = "application/x-hdf"
headers["apikey"] = "eyJ4NXQiOiJZV0kxTTJZNE1qWTNOemsyTkRZeU5XTTRPV014TXpjek1UVmhNbU14T1RSa09ETXlOVEE0Tnc9PSIsImtpZCI6ImdhdGV3YXlfY2VydGlmaWNhdGVfYWxpYXMiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJsdWNhLm1hdGhpYXNAY2FyYm9uLnN1cGVyIiwiYXBwbGljYXRpb24iOnsib3duZXIiOiJsdWNhLm1hdGhpYXMiLCJ0aWVyUXVvdGFUeXBlIjpudWxsLCJ0aWVyIjoiVW5saW1pdGVkIiwibmFtZSI6Ik9QRVJBIiwiaWQiOjg3OSwidXVpZCI6Ijc4YTJiOGJhLTllMjctNDZhNy1iZjE2LTIyNmZkNDhmYjE0ZCJ9LCJpc3MiOiJodHRwczpcL1wvcG9ydGFpbC1hcGkubWV0ZW9mcmFuY2UuZnI6NDQzXC9vYXV0aDJcL3Rva2VuIiwidGllckluZm8iOnsiNTBQZXJNaW4iOnsidGllclF1b3RhVHlwZSI6InJlcXVlc3RDb3VudCIsImdyYXBoUUxNYXhDb21wbGV4aXR5IjowLCJncmFwaFFMTWF4RGVwdGgiOjAsInN0b3BPblF1b3RhUmVhY2giOnRydWUsInNwaWtlQXJyZXN0TGltaXQiOjAsInNwaWtlQXJyZXN0VW5pdCI6InNlYyJ9fSwia2V5dHlwZSI6IlBST0RVQ1RJT04iLCJzdWJzY3JpYmVkQVBJcyI6W3sic3Vic2NyaWJlclRlbmFudERvbWFpbiI6ImNhcmJvbi5zdXBlciIsIm5hbWUiOiJSYWRhckV1bWV0bmV0IiwiY29udGV4dCI6IlwvcGFydG5lclwvcmFkYXJcL2V1cm9wZVwvb2R5c3NleVwvMS4xIiwicHVibGlzaGVyIjoiTUVURU8uRlJcL21hcnRpbmwiLCJ2ZXJzaW9uIjoiMS4xIiwic3Vic2NyaXB0aW9uVGllciI6IjUwUGVyTWluIn1dLCJleHAiOjE3NDM3NzU3NjgsImlhdCI6MTY0OTE2Nzc2OCwianRpIjoiZDI5NGE2MDAtMmQ3Zi00ZTZlLWI1YWMtMmQzNTY5MjU5MmE0In0=.aT7jM5QdhebQWiuy2JKqPTnDHTbgXgTKruY9kh2f4wokyyZsphHlqLKww3Y3qGiO5Xw69P3iZGepuFEH2erEgYdzNmDdsd7kbO6BkinFNTaHn67rYfTAvujf0rktdgwOWpz_B6YWsvPk7G9x9cmg4ET81mNn3us1cpAB9AZ-2GJEIHvKS3p4sapXAPBOZ7XDXHa9rmKoCd399ee5SySp6EwQBfuDy604FNiKBOUmNehqeAl_3Ir9QBLCZpJwdsLG3E3awgDiNBM0bX7nTuYYMdmvT4IK5ymhjE0_TyROYYJ4kGOqyP7vEjca1mH5yrJmCfNGLoDkWSNhDpHPg-NNTw=="
resp2 = requests.get(url2, headers=headers)
print(resp2.status_code)
open('/home/lmathias/Documents/wradlib/opera/maxdbz_latest.hdf5', 'wb').write(resp2.content)
resp2=glob.glob('/home/lmathias/Documents/wradlib/opera/maxdbz_latest.hdf5')
resp2=resp2[-1]
print(resp2)
vol2 = wrl.io.hdf.read_opera_hdf5(resp2)
#print(vol)
import dateutil.parser
date = vol2['dataset1/what']['enddate'].decode("utf-8")
print(date)
time = vol2['dataset1/what']['endtime'].decode("utf-8")
print(time)
time = date+time
print(time)
time2 = datetime.strptime(time, "%Y%m%d%H%M%S")-timedelta(hours=0, minutes=5)
print(time2)
200 /home/lmathias/Documents/wradlib/opera/sfcrr_latest.hdf5 20220831 052000 20220831052000 2022-08-31 05:15:00 200 /home/lmathias/Documents/wradlib/opera/maxdbz_latest.hdf5 20220831 052000 20220831052000 2022-08-31 05:15:00
from pyproj import Proj,transform
import matplotlib.colors as mcolors
import numpy.ma as ma
myProj = Proj("+proj=laea +lat_0=55.0 +lon_0=10.0 +x_0=1950000.0 +y_0=-2100000.0 +units=m +ellps=WGS84")
projdef = "+proj=laea +lat_0=55.0 +lon_0=10.0 +x_0=1950000.0 +y_0=-2100000.0 +units=m +ellps=WGS84"
proj_stereo = wrl.georef.proj4_to_osr(projdef)
#print(proj_stereo)
opera_proj = Proj(projparams=projdef)
wgs_proj = Proj(init='EPSG:4326') # WGS84
LL_lon = vol['where']['LL_lon']
UL_lon = vol['where']['UL_lon']
UR_lon = vol['where']['UR_lon']
LR_lon = vol['where']['LR_lon']
LL_lat = vol['where']['LL_lat']
UL_lat = vol['where']['UL_lat']
UR_lat = vol['where']['UR_lat']
LR_lat = vol['where']['LR_lat']
x0, y0 = transform(wgs_proj, opera_proj, UL_lon, UL_lat)
x1, y1 = transform(wgs_proj, opera_proj, LR_lon, LR_lat)
xscale = 2000.0
yscale = 2000.0
x = np.linspace(x0, x1, 1900)
y = np.linspace(y0, y1, 2200)
xv, yv = np.meshgrid(x, y)
lon, lat = transform(opera_proj, wgs_proj, xv, yv)
def plot_borders2(ax):
filename = wrl.util.get_wradlib_data_file('geo/gadm36_LUX_0.shp')
filename2 = wrl.util.get_wradlib_data_file('geo/gadm36_ITA_0.shp')
filename3 = wrl.util.get_wradlib_data_file('geo/gadm36_BEL_0.shp')
filename4 = wrl.util.get_wradlib_data_file('geo/gadm36_FRA_0.shp')
filename5 = wrl.util.get_wradlib_data_file('geo/gadm36_DEU_0.shp')
filename6 = wrl.util.get_wradlib_data_file('geo/gadm36_GBR_0.shp')
filename7 = wrl.util.get_wradlib_data_file('geo/gadm36_NLD_0.shp')
filename8 = wrl.util.get_wradlib_data_file('geo/gadm36_ESP_0.shp')
filename9 = wrl.util.get_wradlib_data_file('geo/gadm36_CZE_0.shp')
filename10 = wrl.util.get_wradlib_data_file('geo/gadm36_CHE_0.shp')
filename11 = wrl.util.get_wradlib_data_file('geo/gadm36_DNK_0.shp')
filename12 = wrl.util.get_wradlib_data_file('geo/gadm36_AUT_0.shp')
filename13 = wrl.util.get_wradlib_data_file('geo/gadm36_POL_0.shp')
filename14 = wrl.util.get_wradlib_data_file('geo/gadm36_SVN_0.shp')
filename15 = wrl.util.get_wradlib_data_file('geo/gadm36_HRV_0.shp')
dataset, inLayer = wrl.io.open_vector(filename)
dataset2, inLayer2 = wrl.io.open_vector(filename2)
dataset3, inLayer3 = wrl.io.open_vector(filename3)
dataset4, inLayer4 = wrl.io.open_vector(filename4)
dataset5, inLayer5 = wrl.io.open_vector(filename5)
dataset6, inLayer6 = wrl.io.open_vector(filename6)
dataset7, inLayer7 = wrl.io.open_vector(filename7)
dataset8, inLayer8 = wrl.io.open_vector(filename8)
dataset9, inLayer9 = wrl.io.open_vector(filename9)
dataset10, inLayer10 = wrl.io.open_vector(filename10)
dataset11, inLayer11 = wrl.io.open_vector(filename11)
dataset12, inLayer12 = wrl.io.open_vector(filename12)
dataset13, inLayer13 = wrl.io.open_vector(filename13)
dataset14, inLayer14 = wrl.io.open_vector(filename14)
dataset15, inLayer15 = wrl.io.open_vector(filename15)
borders, keys = wrl.georef.get_vector_coordinates(inLayer)
borders2, keys2 = wrl.georef.get_vector_coordinates(inLayer2)
borders3, keys3 = wrl.georef.get_vector_coordinates(inLayer3)
borders4, keys4 = wrl.georef.get_vector_coordinates(inLayer4)
borders5, keys5 = wrl.georef.get_vector_coordinates(inLayer5)
borders6, keys6 = wrl.georef.get_vector_coordinates(inLayer6)
borders7, keys7 = wrl.georef.get_vector_coordinates(inLayer7)
borders8, keys8 = wrl.georef.get_vector_coordinates(inLayer8)
borders9, keys9 = wrl.georef.get_vector_coordinates(inLayer9)
borders10, keys10 = wrl.georef.get_vector_coordinates(inLayer10)
borders11, keys11 = wrl.georef.get_vector_coordinates(inLayer11)
borders12, keys12 = wrl.georef.get_vector_coordinates(inLayer12)
borders13, keys13 = wrl.georef.get_vector_coordinates(inLayer13)
borders14, keys14 = wrl.georef.get_vector_coordinates(inLayer14)
borders15, keys15 = wrl.georef.get_vector_coordinates(inLayer15)
wrl.vis.add_lines(ax, borders, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders2, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders3, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders4, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders5, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders6, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders7, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders8, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders9, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders10, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders11, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders12, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders13, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders14, color='black', lw=1.5, zorder=4)
wrl.vis.add_lines(ax, borders15, color='black', lw=1.5, zorder=4)
cmap = ctables.colortables.get_colortable('NWSStormClearReflectivity')
cmap2 = ctables.colortables.get_colortable('NWSReflectivity')
newcmap = ListedColormap(cmap(np.linspace(0.25, 0.92, 28)))
sfcrr = vol['dataset1/data1/data']
sfcdbz = 10*np.log10(200*sfcrr**(1.6))
sfcdbz = ma.masked_where(sfcdbz < 0, sfcdbz)
sfcrr = ma.masked_where(sfcrr < 0.5, sfcrr)
maxdbz = vol2['dataset1/data1/data']
maxdbz = ma.masked_where(maxdbz < 0, maxdbz)
sfcrr = ma.masked_where(sfcrr < 0.5, sfcrr)
#maxdbz_int = griddata(lon,lat, maxdbz, method='linear')
# fig = pl.figure(figsize=(15,11))
# ax = pl.subplot(111)
# pm = ax.pcolormesh(lon, lat, sfcrr, cmap=newcmap, vmin=10, vmax=70)
# cb = pl.colorbar(pm, ax=ax, shrink=0.9, ticks=[0,10,20,30,40,50,60,70],orientation='vertical')
# cb.set_label("dBZ",fontsize=16)
# cb.ax.tick_params(labelsize=14)
# pl.xlabel("Longitude ",fontsize=16)
# pl.ylabel("Latitude",fontsize=16)
# pl.title(time2.strftime("%d.%m.%Y %H:%M UTC"),fontsize=22)
# pl.xticks(fontsize=12)
# pl.yticks(fontsize=12)
# pl.grid(linewidth=0.5, color='gray', alpha=0.5, linestyle='--')
# pl.xlim(-5, 16)
# pl.ylim(42, 55)
# plot_borders2(ax)
# t = pl.gcf().text(0.135, 0.84, 'Product: Maximum Reflectivity (OPERA)\nData: EUMETNET', fontsize=10)
# t.set_bbox(dict(facecolor='white', alpha=0.9, edgecolor='black'))
# base_filename='opera_maxdbz_'
# suffix='.png'
# my_file = base_filename+time2.strftime("%Y%m%d%H%M")+suffix
# print(my_file)
# pl.savefig(my_file, bbox_inches='tight', dpi=300)
# fig = pl.figure(figsize=(15,11))
# ax = pl.subplot(111)
# pm = ax.pcolormesh(lon, lat, sfcdbz, cmap=newcmap, vmin=0, vmax=70)
# cb = pl.colorbar(pm, ax=ax, shrink=0.9, orientation='vertical')
# cb.set_label("dBZ",fontsize=16)
# cb.ax.tick_params(labelsize=14)
# pl.xlabel("Longitude ",fontsize=16)
# pl.ylabel("Latitude",fontsize=16)
# pl.title(time2.strftime("%d.%m.%Y %H:%M UTC"),fontsize=22)
# pl.xticks(fontsize=12)
# pl.yticks(fontsize=12)
# pl.grid(linewidth=0.5, color='gray', alpha=0.5, linestyle='--')
# pl.xlim(-5, 16)
# pl.ylim(42, 55)
# plot_borders2(ax)
# t = pl.gcf().text(0.135, 0.84, 'Product: Low-Level Reflectivity\nData: OPERA/EUMETNET', fontsize=10)
# t.set_bbox(dict(facecolor='white', alpha=0.9, edgecolor='black'))
# base_filename='opera_sfcrr_'
# suffix='.png'
# my_file = base_filename+time2.strftime("%Y%m%d%H%M")+suffix
# print(my_file)
# pl.savefig(my_file, bbox_inches='tight', dpi=80)
fig = pl.figure(figsize=(15,11))
ax = pl.subplot(111)
pm = ax.pcolormesh(lon, lat, sfcdbz, cmap=newcmap, vmin=0, vmax=70)
cb = pl.colorbar(pm, ax=ax, shrink=0.9, orientation='vertical')
cb.set_label("dBZ",fontsize=16)
cb.ax.tick_params(labelsize=14)
pl.xlabel("Longitude ",fontsize=16)
pl.ylabel("Latitude",fontsize=16)
pl.title(time2.strftime("%d.%m.%Y %H:%M UTC"),fontsize=22)
pl.xticks(fontsize=12)
pl.yticks(fontsize=12)
pl.grid(linewidth=0.5, color='gray', alpha=0.5, linestyle='--')
pl.xlim(3.7, 8)
pl.ylim(48.5, 51)
plot_borders2(ax)
t = pl.gcf().text(0.135, 0.84, 'Product: Low-Level Reflectivity\nData: OPERA/EUMETNET', fontsize=10)
t.set_bbox(dict(facecolor='white', alpha=0.9, edgecolor='black'))
base_filename='opera_sfcdbz_'
suffix='.jpeg'
my_file = base_filename+time2.strftime("%Y%m%d%H%M")+suffix
print(my_file)
pl.savefig(my_file, bbox_inches='tight', dpi=80)
opera_sfcdbz_202208310515.jpeg
--------------------------------------------------------------------------- MemoryError Traceback (most recent call last) File ~/.conda/envs/wradlib/lib/python3.8/site-packages/IPython/core/formatters.py:339, in BaseFormatter.__call__(self, obj) 337 pass 338 else: --> 339 return printer(obj) 340 # Finally look for special method names 341 method = get_real_method(obj, self.print_method) File ~/.conda/envs/wradlib/lib/python3.8/site-packages/IPython/core/pylabtools.py:151, in print_figure(fig, fmt, bbox_inches, base64, **kwargs) 148 from matplotlib.backend_bases import FigureCanvasBase 149 FigureCanvasBase(fig) --> 151 fig.canvas.print_figure(bytes_io, **kw) 152 data = bytes_io.getvalue() 153 if fmt == 'svg': File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/backend_bases.py:2295, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs) 2289 renderer = _get_renderer( 2290 self.figure, 2291 functools.partial( 2292 print_method, orientation=orientation) 2293 ) 2294 with getattr(renderer, "_draw_disabled", nullcontext)(): -> 2295 self.figure.draw(renderer) 2297 if bbox_inches: 2298 if bbox_inches == "tight": File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/artist.py:74, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs) 72 @wraps(draw) 73 def draw_wrapper(artist, renderer, *args, **kwargs): ---> 74 result = draw(artist, renderer, *args, **kwargs) 75 if renderer._rasterizing: 76 renderer.stop_rasterizing() File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/artist.py:51, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) 48 if artist.get_agg_filter() is not None: 49 renderer.start_filter() ---> 51 return draw(artist, renderer) 52 finally: 53 if artist.get_agg_filter() is not None: File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/figure.py:2845, in Figure.draw(self, renderer) 2842 # ValueError can occur when resizing a window. 2844 self.patch.draw(renderer) -> 2845 mimage._draw_list_compositing_images( 2846 renderer, self, artists, self.suppressComposite) 2848 for sfig in self.subfigs: 2849 sfig.draw(renderer) File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite) 130 if not_composite or not has_images: 131 for a in artists: --> 132 a.draw(renderer) 133 else: 134 # Composite any adjacent images together 135 image_group = [] File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/artist.py:51, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) 48 if artist.get_agg_filter() is not None: 49 renderer.start_filter() ---> 51 return draw(artist, renderer) 52 finally: 53 if artist.get_agg_filter() is not None: File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/axes/_base.py:3091, in _AxesBase.draw(self, renderer) 3088 a.draw(renderer) 3089 renderer.stop_rasterizing() -> 3091 mimage._draw_list_compositing_images( 3092 renderer, self, artists, self.figure.suppressComposite) 3094 renderer.close_group('axes') 3095 self.stale = False File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite) 130 if not_composite or not has_images: 131 for a in artists: --> 132 a.draw(renderer) 133 else: 134 # Composite any adjacent images together 135 image_group = [] File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/artist.py:51, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) 48 if artist.get_agg_filter() is not None: 49 renderer.start_filter() ---> 51 return draw(artist, renderer) 52 finally: 53 if artist.get_agg_filter() is not None: File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/collections.py:2175, in QuadMesh.draw(self, renderer) 2172 ys = self.convert_yunits(offsets[:, 1]) 2173 offsets = np.column_stack([xs, ys]) -> 2175 self.update_scalarmappable() 2177 if not transform.is_affine: 2178 coordinates = self._coordinates.reshape((-1, 2)) File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/collections.py:905, in Collection.update_scalarmappable(self) 903 # pcolormesh, scatter, maybe others flatten their _A 904 self._alpha = self._alpha.reshape(self._A.shape) --> 905 self._mapped_colors = self.to_rgba(self._A, self._alpha) 907 if self._face_is_mapped: 908 self._facecolors = self._mapped_colors File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/cm.py:456, in ScalarMappable.to_rgba(self, x, alpha, bytes, norm) 454 if norm: 455 x = self.norm(x) --> 456 rgba = self.cmap(x, alpha=alpha, bytes=bytes) 457 return rgba File ~/.conda/envs/wradlib/lib/python3.8/site-packages/matplotlib/colors.py:641, in Colormap.__call__(self, X, alpha, bytes) 638 else: 639 lut = self._lut.copy() # Don't let alpha modify original _lut. --> 641 rgba = np.empty(shape=xa.shape + (4,), dtype=lut.dtype) 642 lut.take(xa, axis=0, mode='clip', out=rgba) 644 if alpha is not None: MemoryError: Unable to allocate 128. MiB for an array with shape (4180000, 4) and data type float64
<Figure size 1500x1100 with 2 Axes>
fig = pl.figure(figsize=(15,11))
ax = pl.subplot(111)
pm = ax.pcolormesh(lon, lat, maxdbz, cmap=newcmap, vmin=0, vmax=70)
cb = pl.colorbar(pm, ax=ax, shrink=0.9, orientation='vertical')
cb.set_label("dBZ",fontsize=16)
cb.ax.tick_params(labelsize=14)
pl.xlabel("Longitude ",fontsize=16)
pl.ylabel("Latitude",fontsize=16)
pl.title(time2.strftime("%d.%m.%Y %H:%M UTC"),fontsize=22)
pl.xticks(fontsize=12)
pl.yticks(fontsize=12)
pl.grid(linewidth=0.5, color='gray', alpha=0.5, linestyle='--')
pl.xlim(3.7, 8)
pl.ylim(48.5, 51)
plot_borders2(ax)
t = pl.gcf().text(0.135, 0.84, 'Product: Maximum Reflectivity\nData: OPERA/EUMETNET', fontsize=10)
t.set_bbox(dict(facecolor='white', alpha=0.9, edgecolor='black'))
base_filename='opera_maxdbz_'
suffix='.jpeg'
my_file = base_filename+time2.strftime("%Y%m%d%H%M")+suffix
print(my_file)
pl.savefig(my_file, bbox_inches='tight', dpi=80)
opera_maxdbz_202208310515.jpeg