Kritikalität
Monatliche Kritikalität von Großwetterlagen
Ergebnis¶
Welche monatlichen Eigenschaften Großwetterlagen (GWL) innerhalb des Zeitraum 2015-2019 aufweisen zeigt Abb.1.: HFA im Juli ist besonders heiß, TM im Juli ist besonders feucht und NWZ im März sehr stürmig. Diese GWL liegen im Mittelfeld der Häufigkeit.
Matrix¶
Abb.1: Monatliche Charakteristik von Großwetterlagen für den Zeitraum 2015-2019: Temperatur (o.l.), Niederschlag (o.r.), Windspitzen (m.l.), Meldungen (m.r.) und Häufigkeit (u.).
- leere Felder: diese GWL sind innerhalb des Zeitraums nicht aufgetreten.
Kritikalität¶
Abb.2: Hitliste von monatlichen Großwetterlagen nach Meldungen für den Zeitraum 2015-2019. Beobachtete Änderungssignale 1961-1990 (blau) vs 1990-2019 (rot).
Code¶
Python
import sys
import numpy as N
import shapefile
import scipy.stats as stats
import pylab as P
from matplotlib.collections import PatchCollection
from pylab import Polygon
from mpl_toolkits.basemap import Basemap
import matplotlib as mpl
P.style.use('bmh')
params = {'legend.fontsize': 8,'font.family': 'serif'}
P.rcParams.update(params)
== “Reading”
tmp=N.genfromtxt('../shp/GP.csv',names=True,comments='#',delimiter=';',dtype=None,encoding='utf-8')
pds = tmp['Name']
file = '../dat/gwlneudatum.dat'
dd=N.genfromtxt(file,usecols=(0),skip_header=0,dtype="I")
mm=N.genfromtxt(file,usecols=(1),skip_header=0,dtype="I")
jj=N.genfromtxt(file,usecols=(2),skip_header=0,dtype="I")
gw=N.genfromtxt(file,usecols=(3),skip_header=0,dtype="S")
id = N.where((jj>=2015)&(jj<=2019))[0]
ni = len(id)
id = id[:ni-1]
dd = dd[id]
mm = mm[id]
jj = jj[id]
gw = gw[id]
#go = N.array(['HNA'])#,'HFZ','WA','SWA','BM','NEA','WW','HFA','SWZ','NEZ','HM','HB','HNZ','WZ','NA','SEZ','NWZ','NZ','TM','NWA','SEA','TB','TRM','HNFA','HNFZ','U','TRW','SZ','WS','SA'])
go = N.array(list(set(gw)))
ng = len(go)
mo = N.arange(1,13,1)
nm = len(mo)
filter = 'Filter1'
paras = {'tmax':[0,35,'Spectral_r'],'nied':[1,8,'YlGnBu','[]'],'wmax':[5,20,'gist_stern_r'],'bahn':[10,30,'RdPu']}
np = 34
tmax = N.zeros((np,ng,nm),float);tmax[:,:,:] = N.nan
nied = N.zeros((np,ng,nm),float);nied[:,:,:] = N.nan
wmax = N.zeros((np,ng,nm),float);wmax[:,:,:] = N.nan
bahn = N.zeros((np,ng,nm),float);bahn[:,:,:] = N.nan
gwls = N.zeros((ng,nm),float);gwls[:,:] = N.nan
m = Basemap(projection='merc',llcrnrlat=47,urcrnrlat=55.2,llcrnrlon=5,urcrnrlon=16,resolution='l')
m.readshapefile('../shp/OSS_M1_PROD_DURCH_FL_EXT_geo', 'pds',zorder=10)
px = -1
for info, shape in zip(m.pds_info, m.pds):
px = px+1
pd = info['NAME']
for para in paras:
if(para!='bahn'):
file = '../csv/obs-dwd/'+pd+'.csv'
data=N.genfromtxt(file,names=True,comments='#',delimiter=';',dtype=None,encoding='utf-8')
id = N.where((data['ja']>=2015)&(data['ja']<=2019))[0]
ni = len(id)
id = id[:ni-1]
dum = data[para][id]
for gx in range(ng):
for mx in range(nm):
jd = N.where((mm==mo[mx])&(gw==go[gx]))[0]
#gwls[gx,mx] = len(jd)
if(len(jd)>0):
gwls[gx,mx] = len(jd)/5.
if(para=='tmax'): tmax[px,gx,mx] = N.mean(dum[jd])
if(para=='nied'): nied[px,gx,mx] = N.mean(dum[jd])
if(para=='wmax'): wmax[px,gx,mx] = N.mean(dum[jd])
else:
file = '../csv/pds-uas/'+pd+'.csv'
data=N.genfromtxt(file,names=True,comments='#',delimiter=';',dtype=None,encoding='utf-8')
id = N.where((data['ja']>=2015)&(data['ja']<=2019))[0]
for gx in range(ng):
for mx in range(nm):
jd = N.where((mm==mo[mx])&(gw==go[gx]))[0]
#gwls[gx,mx] = len(jd)
if(len(jd>0)):
gwls[gx,mx] = len(jd)/5.
dum = data[filter][jd]#/20000.
#dum = []
#for ua in ['UA32','UA04','UA57','UA44','UA38','UA35','UA29']:
# xxx = data[ua][id]
# dum.append(N.sum(xxx[jd]))
#dum = N.array(dum)
#bahn[px,gx,mx] = N.sum(dum)/len(jd)
bahn[px,gx,mx] = N.max(dum)
fig = P.figure(figsize=(12,8))
gwl = N.nansum(gwls,1)
id = N.argsort(gwl)
id = id[::-1]
for para in paras:
if(para=='tmax'): ax = fig.add_subplot(3,2,1); data = N.mean(tmax[:,id,:],0)
if(para=='nied'): ax = fig.add_subplot(3,2,2); data = N.mean(nied[:,id,:],0)
if(para=='wmax'): ax = fig.add_subplot(3,2,3); data = N.mean(wmax[:,id,:],0)
if(para=='bahn'): ax = fig.add_subplot(3,2,4); data = N.sum(bahn[:,id,:],0)/34.
pc = ax.pcolor(data.T,edgecolor='k',linewidth=0.5,cmap=P.get_cmap(paras[para][2]),vmin=paras[para][0],vmax=paras[para][1],zorder=0)
cb = P.colorbar(pc,orientation='vertical',extend='both',pad=-0.0)
if(para=='bahn'): para = 'Meldungen'
cb.set_label(para,fontsize=12,weight='bold')
gg = N.arange(ng)+0.5
mm = N.arange(nm)+0.5
mo = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Okt','Nov','Dez']
P.xticks(gg,go[id],rotation=90)
P.yticks(mm,mo)
P.tick_params(direction='out')
#P.title(para,fontsize=14,weight='bold',ha='left')
ax = fig.add_subplot(3,1,3)
data = gwls[id,:]
pc = ax.pcolor(data.T,edgecolor='k',linewidth=0.5,cmap=P.get_cmap('cool'),vmin=0,vmax=5,zorder=0)
cb = P.colorbar(pc,orientation='vertical',extend='both',pad=-0.0)
cb.set_label('Anzahl',fontsize=12,weight='bold')
gg = N.arange(ng)+0.5
mm = N.arange(nm)+0.5
mo = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Okt','Nov','Dez']
P.xticks(gg,go[id],rotation=90)
P.yticks(mm,mo)
P.tick_params(direction='out')
fig.tight_layout()
fig.savefig('./img/pcolor_'+filter+'.png',dpi=240,transparent=False,bbox_inches='tight',pad_inches=0.0)
mi = N.arange(1,13,1);nm = len(mi)
for per in ['his','fut']:
for mod in ['obs','ens']:
if(mod=='ens'):
file = '../dat/ens.dat'
dd=N.genfromtxt(file,usecols=(0),skip_header=0,delimiter=';',comments='#',dtype="S")
gg=N.genfromtxt(file,usecols=(3),skip_header=0,delimiter=';',comments='#',dtype="S")
mm = []
jj = []
for id in dd:
jj.append(int(id[0:4]))
mm.append(int(id[5:7]))
mm = N.array(mm)
jj = N.array(jj)
if(per=='his'): id = N.where((jj>=1981)&(jj<=2010))[0]
if(per=='fut'): id = N.where((jj>=2061)&(jj<=2090))[0]
if(mod=='obs'):
file = '../dat/gwlneudatum.dat'
mm=N.genfromtxt(file,usecols=(1),skip_header=0,dtype="I")
jj=N.genfromtxt(file,usecols=(2),skip_header=0,dtype="I")
gg=N.genfromtxt(file,usecols=(3),skip_header=0,dtype="S")
if(per=='his'): id = N.where((jj>=1961)&(jj<=1990))[0]
if(per=='fut'): id = N.where((jj>=1990)&(jj<=2019))[0]
mm0 = mm[id]
gg0 = gg[id]
gwl = N.zeros((ng,nm),float)
for gx in range(ng):
for mx in range(nm):
jd = N.where((mm0==mi[mx])&(gg0==go[gx]))[0]
gwl[gx,mx] = len(jd)/30.
if((mod=='obs')&(per=='his')): gwl_obs_his = gwl
if((mod=='obs')&(per=='fut')): gwl_obs_fut = gwl
if((mod=='ens')&(per=='his')): gwl_ens_his = gwl
if((mod=='ens')&(per=='fut')): gwl_ens_fut = gwl
############
fig = P.figure(figsize=(7,8))
data = N.sum(bahn,0)/34.
data = N.ravel(data)
id = N.where(N.invert(N.isnan(data)))[0]
data = data[id]
mon,gwl = N.meshgrid(mo,go)
mon = N.ravel(mon)
gwl = N.ravel(gwl)
gwl_obs_his = N.ravel(gwl_obs_his)
gwl_obs_fut = N.ravel(gwl_obs_fut)
gwl_ens_his = N.ravel(gwl_ens_his)
gwl_ens_fut = N.ravel(gwl_ens_fut)
mon = mon[id]
gwl = gwl[id]
gwl_obs_his = gwl_obs_his[id]
gwl_obs_fut = gwl_obs_fut[id]
gwl_ens_his = gwl_ens_his[id]
gwl_ens_fut = gwl_ens_fut[id]
id = N.argsort(data)
id = id[::-1]
id = id[0:30][::-1]
nam = []
col = []
for i in id:
nam.append('%s-%s'%(gwl[i],mon[i]))
if((gwl[i]=='WZ')|(gwl[i]=='WA')|(gwl[i]=='NWZ')|(gwl[i]=='NZ')):
col.append('limegreen')
elif((gwl[i]=='BM')|(gwl[i]=='HM')|(gwl[i]=='HNFZ')|(gwl[i]=='SWZ')|(gwl[i]=='HNZ')|(gwl[i]=='WW')|(gwl[i]=='SEZ')|(gwl[i]=='HFZ')):
col.append('orangered')
elif((gwl[i]=='TRM')|(gwl[i]=='TRW')):
col.append('blueviolet')
else:
col.append('gray')
ii = N.arange(len(id))
P.barh(ii,data[id],0.8,color=col,alpha=0.6,edgecolor='k',linewidth=1)
j = -1
for i in id:
j = j+1
delta = gwl_obs_fut[i]-gwl_obs_his[i]
if(delta>0.5):
P.text(data[i]+1,ii[j],r'$\nearrow$',ha='left',va='center',weight='bold',fontsize=12)
elif(delta<-0.5):
P.text(data[i]+1,ii[j],r'$\searrow$',ha='left',va='center',weight='bold',fontsize=12)
else:
P.text(data[i]+1,ii[j],r'$\rightarrow$',ha='left',va='center',weight='bold',fontsize=12)
delta = gwl_ens_fut[i]-gwl_ens_his[i]
if(delta>0.5):
P.text(data[i]+3,ii[j],r'$\nearrow$',ha='left',va='center',weight='bold',fontsize=12)
elif(delta<-0.5):
P.text(data[i]+3,ii[j],r'$\searrow$',ha='left',va='center',weight='bold',fontsize=12)
else:
P.text(data[i]+3,ii[j],r'$\rightarrow$',ha='left',va='center',weight='bold',fontsize=12)
P.yticks(ii,nam)
P.xlim(0,40)
P.ylim(-1,30)
P.xlabel('max. Meldungen pro Tag',fontsize=16,weight='bold')
P.title('Kritikalitaet von Grosswetterlagen 2015-2019',weight='bold',fontsize=14)
P.legend(loc=4,shadow='true')
P.tick_params(direction='out')
fig.tight_layout()
fig.savefig('./img/bar_'+filter+'.png',dpi=240,transparent=False,bbox_inches='tight',pad_inches=0.0)