Skip to content

Anomalien

Monatsanomalien

Abb.: Anomalien der Monatsmittel der Temperatur (links, ±5K) und der Monatssumme des Niederschlags (rechts, ±50mm) von 1971-2100 gegenüber 1971-2000 für ein regionales Klimamodellensemble (RCP85).

Wärmeanomalien vs Kälteanomalien

Code

Importing

import sys
import matplotlib
matplotlib.use('Agg')

import numpy as N
import matplotlib.pyplot as P
from scipy import stats as S
from mpl_toolkits.basemap import Basemap
import statsmodels.api as sm
from netCDF4 import Dataset,num2date
import shapefile as shp
import matplotlib.path as mpath
import matplotlib.patches as mpatches
from sklearn.preprocessing import scale
from matplotlib.offsetbox import AnchoredText

P.style.use('bmh')

P.rcParams["font.family"] = "serif"

def ma(a,n=3):
    ret=N.cumsum(a,dtype=float)
    ret[n:]=ret[n:]-ret[:-n]
    return ret[n-1:]/n

Plotting

ort = sys.argv[1]

mods = ['obs-dwd','cnr-clm','ece-clm','had-clm','mpi-clm','mpi-rca','cnr-rca','nor-rca','ips-rca','ece-rca','had-rca','cnr-hir','had-hir','ece-hir','nor-hir','cnr-rac','had-rac','ece-rac']
nr = len(mods)

jo = N.arange(1971,2100,1)
nj = len(jo)
nd = 365

mo = N.arange(1,14,1)
nm = len(mo)

ens = N.zeros((nj,nm,nr,2),float)
ens[:,:,:,:] = N.nan

P.figure(figsize=(6,5))

r = -1

for mod in mods:

    r = r+1

    print (mod)

    file = '../../data/csv/rcp85/%s/%sbasz.txt'%(mod,ort)

    dat = N.genfromtxt(file,names=True,dtype=None)

    tmit = N.zeros((nj,nd),float);tmit[:,:] = N.nan

    for j in range(nj):

        for m in range(nm):

            id = N.where((dat['jahr']==jo[j])&(dat['mo']==mo[m]))[0]

            if(len(id)>0):

                 ens[j,m,r,0] = N.nanmean(dat['tas'][id])     
                 ens[j,m,r,1] = N.nansum(dat['pr'][id])

        id = N.where(dat['jahr']==jo[j])[0]

        if(len(id)>0):

            id = id[0:nd]

            tmit[j,:] = dat['tas'][id]

    basl = N.mean(tmit[0:40,:],0)

    for j in [1,2,3,4,5]:

        if(mod=='obs-dwd'):

            anom = ma(N.ravel(tmit[0:40,:]-basl),5)

            pos = len(N.where(anom>=j)[0])/40.
            neg = len(N.where(anom<=-1*j)[0])/40.

            P.scatter(pos,neg,s=50,c='None',ec='k')
            P.text(pos,neg,'%i K'%j,fontsize=16,weight='bold')

        else:

            anom = ma(N.ravel(tmit[0:40,:]-basl),5)

            pos = len(N.where(anom>=j)[0])/40.
            neg = len(N.where(anom<=-1*j)[0])/40.

            P.scatter(pos,neg,s=50,c='None',ec='y')

            anom = ma(N.ravel(tmit[40:80,:]-basl),5)

            pos = len(N.where(anom>=j)[0])/40.
            neg = len(N.where(anom<=-1*j)[0])/40.

            P.scatter(pos,neg,s=50,c='None',ec='orange')

            anom = ma(N.ravel(tmit[80:120,:]-basl),5)

            pos = len(N.where(anom>=j)[0])/40.
            neg = len(N.where(anom<=-1*j)[0])/40.

            P.scatter(pos,neg,s=50,c='None',ec='r')

P.xlim(0,350)
P.ylim(0,150)

P.xlabel('Tage mit positiven Temperaturanomalien',fontsize=12,weight='bold')
P.ylabel('Tage mit negativen Temperaturanomalien',fontsize=10,weight='bold')

P.tick_params(direction='out')
P.tight_layout()

P.savefig('./img/anomalien.png',dpi=240,bbox_inches='tight')

Plotting

ens = ens-N.mean(ens[0:30,:,:,:],0)

fig = P.figure(figsize=(10,10))
fig.subplots_adjust(wspace=0.0,hspace=0.0)

n = -1

for r in range(nr):
    for p in [0,1]:

        n = n+1

        P.subplot(18,2,1+n)

        if(p==0): P.pcolor(jo,mo,ens[:,:,r,p].T,cmap=P.get_cmap('bwr'),vmin=-5,vmax=5)
        if(p==1): P.pcolor(jo,mo,ens[:,:,r,p].T,cmap=P.get_cmap('PuOr'),vmin=-50,vmax=50) 

        P.axis('off')
        P.tick_params(direction='out')

        P.text(1961,1,mods[r],fontsize=6,ha='left',weight='bold')

P.tight_layout()

P.savefig('./img/matrix.png',dpi=240,bbox_inches='tight')