Skip to content

Frost


Übersicht

Indikator Definition
Eistage Anzahl der Tage mit einer Tagesmaximumtemperatur von unter als 0°C
Kältewellen Mindestens 3 aufeinanderfolgende Eistage
Kälteeintensität drittniedrigster Wert der Tagesmaximumtemperatur pro Jahr
Saisonalität Verteilung der Eistage im Jahresverlauf
Jährlichkeit Häufigkeit extremer Kältejahre der Vergangenheit

Steckbrief

Langname Kurzname 1971-2010 1971-2010 2011-2050 2051-2090
Jahresmitteltemperatur tmit50 8.7 8.6 9.7 11.3
Anzahl Eistage tmax00 15.3 16.1 9.8 3.8
Kälteintensität tmax01 -2.2 -2.6 -1.2 0.8
Kältewelle tx00an 127.1 80.8 30.1

Temperaturänderung

Eistage

Kältewellen

Kälteintensität

Saisonalität

Extremjahre


Code

Importing

import sys
import numpy as N
import pylab as P
from scipy import stats as S
import statsmodels.api as sm
from scipy import signal

P.style.use('bmh')

params = {'legend.fontsize': 8,'font.family': 'serif'}
P.rcParams.update(params)

Setting

ort = sys.argv[1]

basz = '%sbasz.txt'%ort

jo = N.arange(1971,2101,1);nj = len(jo)

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

def tmit50(inp):

    return N.mean(inp)

def tmax00(inp):

    id = N.where(inp<0.)[0]

    return len(id)

def tmax01(inp):

    return N.percentile(inp,1)

def tx00jz(inp):

    out = N.zeros(nd,float)

    for d in range(nd):

        if(inp[d]<0.):

            out[d] = 1

    return out

def tx00an(inp):

    out = N.zeros(60,float)

    n = 0

    for d in range(nd):

        if(inp[d]<0.):

            n = n+1

        else:

            if(n>0): out[n] = out[n] + 1

            n = 0

    return out

Running

pars = {'tmit50':['Jahresmitteltemperatur','[$^\circ$C]'],
        'tmax00':['Anzahl Eistage','[Tage]'],
        'tmax01':['Kälteintensität','[$^\circ$C]'],
        'tx00jz':['Anzahl Eistage',''],
        'tx00jj':['',''],
        'tx00an':['Kältewelle','']
}

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']

nm = len(mods)
nd = 365

f = open('./include/frost_steckbrief.md','w')
f.write('Langname|Kurzname|1971-2010|1971-2010|2011-2050|2051-2090\n')
f.write('---|---|---|---|---|---\n')

for par in pars:

    print (par)

    tmp = N.zeros((nj,nm),float);tmp[:,:] = N.nan
    bas = N.zeros((nj,nm),float);bas[:,:] = N.nan
    doy = N.zeros((nj,nm,nd),float)
    day = N.zeros((nj,nm,60),float)

    m = -1

    for mod in mods:

        m = m+1

        dat = N.genfromtxt('../../data/csv/rcp85/%s/%s'%(mod,basz),names=True,dtype=None)

        for j in range(nj):

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

            if(len(id)>0):

                if(par=='tmit50'): tmp[j,m] = tmit50(dat['tas'][id]);bas[j,m] = tmit50(dat['tas'][id])
                if(par=='tmax00'): tmp[j,m] = tmax00(dat['tasmax'][id]);bas[j,m] = tmit50(dat['tas'][id])
                if(par=='tmax01'): tmp[j,m] = tmax01(dat['tasmax'][id]);bas[j,m] = tmit50(dat['tas'][id])
                if(par=='tx00jz'): doy[j,m,:] = tx00jz(dat['tasmax'][id])
                if(par=='tx00jj'): tmp[j,m] = tmax00(dat['tasmax'][id])
                if(par=='tx00an'): day[j,m,:] = tx00an(dat['tasmax'][id])

    if((par=='tmit50')|(par=='tmax00')|(par=='tmax01')):

        tmp0 = N.mean(tmp[0:40,0])
        tmp1 = N.mean(tmp[0:40,1:])
        tmp2 = N.mean(tmp[41:80,1:])
        tmp3 = N.mean(tmp[81:120,1:]) 

        f.write('%s|%s|%.1f|%.1f|%.1f|%.1f\n'%(pars[par][0],par,tmp0,tmp1,tmp2,tmp3))

        P.figure(figsize=(8,3))

        tt = 30.*N.ones(nj,float)
        tt[30:] = tt[30:]+N.linspace(1,10,nj-30)

        zx = []

        for m in range(nm):

            zz = N.cumsum(tmp[:,m]-N.mean(tmp[:30,m]))/tt
            #zz = movave(tmp[:,m]-N.mean(tmp[:30,m]),11)
            aa = tmp[:,m]-N.mean(tmp[:30,m])

            P.subplot(121)

            if(m==0): P.plot(jo,zz,'k',alpha=1.0,lw=0.5,zorder=10)
            else: 

                for j in range(nj-1): 

                    zx.append(aa[j])

                P.scatter(jo,aa,c='None',s=10,ec='gray',lw=0.5,alpha=0.5,zorder=5)
                P.plot(jo,zz,'r',lw=0.5,zorder=6)                 

            P.subplot(122)

            yy = N.cumsum(bas[:,m]-N.mean(bas[:30,m]))/30.
            #yy = movave(tmp[:,m]-N.mean(tmp[:30,m]),11)

            co = ['y','orange','r']

            i = -1

            for j in [2020,2050,2080]:

                i = i+1

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

                P.scatter(yy[id],zz[id],c='None',s=50,ec=co[i],lw=0.5)

        zx = N.array(zx)

        P.subplot(121)

        P.plot([2020,2020],[N.nanmin(zx),N.nanmax(zx)],'y')
        P.plot([2050,2050],[N.nanmin(zx),N.nanmax(zx)],'orange')
        P.plot([2080,2080],[N.nanmin(zx),N.nanmax(zx)],'r')

        P.xlim(1970,2100)
        P.ylim(zx.min(),zx.max())
        P.xticks([1971,2010,2050,2090])
        P.tick_params(direction='out')
        P.xlabel('Jahre',fontsize=8,weight='bold')
        P.ylabel('Änderung: '+pars[par][0],fontsize=8,weight='bold')

        P.subplot(122)
        P.xlim(0,6)
        P.ylim(zx.min(),zx.max())
        P.tick_params(direction='out')
        P.xlabel('Temperaturänderung [K]',fontsize=8,weight='bold')
        P.ylabel('Änderung: '+pars[par][0],fontsize=8,weight='bold')

        P.tight_layout()

        P.savefig('./img/%s.png'%par,dpi=240,transparent=False,bbox_inches='tight',pad_inches=0)

    if(par=='tx00jz'):

        P.figure(figsize=(8,3))
        P.subplot(111)

        do = N.arange(1,nd+1,1)

        P.bar(movave(do,5),movave(N.mean(N.sum(doy[80:120:,1:,:],0),0),5),1,color='r',zorder=5,label='RCM:2051-2090')
        P.bar(movave(do,5),movave(N.mean(N.sum(doy[40:80:,1:,:],0),0),5),1,color='orange',zorder=4,label='RCM:2011-2050')
        P.bar(movave(do,5),movave(N.mean(N.sum(doy[0:40:,1:,:],0),0),5),1,color='y',zorder=3,label='RCM:1971-2010') 
        P.bar(movave(do,5),movave(N.sum(doy[0:40,0,:],0),5),1,color='gray',zorder=2,label='OBS:1971-2010')

        P.xticks([1,30,60,90,120,150,180,210,240,270,300,330,360],['1.Jan','1.Feb','1.Mar','1.Apr','1.May','1.Jun','1.Jul','1.Aug','1.Sep','1.Oct','1.Nov','1.Dec','1.Jan'])
        P.xlim(0,361)
        P.ylabel(pars[par][0],fontsize=12,weight='bold')
        P.legend(loc=2,shadow=True)
        P.tick_params(direction='out')

        P.savefig('./img/%s.png'%par,dpi=240,transparent=False,bbox_inches='tight',pad_inches=0)

    if(par=='tx00jj'):

        P.figure(figsize=(8,3))
        P.subplot(111)

        mx = N.nanmax(tmp[:,0])

        for m in range(nm):
            for j in range(nj):

                if(tmp[j,m]>=mx):

                    P.plot([jo[j],jo[j]],[0.1+m,0.9+m],'b')

        P.xlim(1970,2100)
        P.yticks(N.arange(nm)+0.5,mods)
        P.tick_params(direction='out')
        P.savefig('./img/%s.png'%par,dpi=240,transparent=False,bbox_inches='tight',pad_inches=0)

    if(par=='tx00an'):

        f.write('%s|%s|'%(pars[par][0],par))

        P.figure(figsize=(10,3))

        for k in [1,2,3]:

            P.subplot(1,3,k)

            if(k==1): zz = N.mean(N.sum(day[0:40,1:,:],0),0);title = '1971-2010'
            if(k==2): zz = N.mean(N.sum(day[40:80,1:,:],0),0);title ='2011-2050'
            if(k==3): zz = N.mean(N.sum(day[80:120,1:,:],0),0);title = '2051-2090'

            ratio = N.sum(zz[2:])#/N.sum(zz)            

            f.write('|%.1f'%ratio) 

            P.bar(N.arange(3,60),zz[3:],0.8,color='b',lw=0.5,label='%i'%ratio)

            P.title(title,fontsize=12,weight='bold')
            P.xlim(0,20)
            P.ylim(0,30)
            P.legend(loc=2,shadow=True)
            P.xlabel(pars[par][0],fontsize=12,weight='bold')
            P.ylabel('Häufigkeit',fontsize=12,weight='bold')
            P.tick_params(direction='out')

        f.write('\n')

        P.tight_layout()
        P.savefig('./img/%s.png'%par,dpi=240,transparent=False,bbox_inches='tight',pad_inches=0)

f.close()