Page1
Potsdam¶
Trends: Meßgrößen¶
Klimatrends
xxx
Großwetterlagen¶
Großwetterlagen
xxx
Code¶
Importing¶
import numpy as N
Reading¶
file = '/home/peterh/Documents/DATA/dat/03987.dat'
dat = N.genfromtxt(file,names=True,dtype=None)
file = '/home/peterh/Documents/DATA/dat/gwlneudatum.dat'
gwl = N.genfromtxt(file,names=True,dtype=None)
Setting¶
id = N.where((dat['jahr']>=1961)&(dat['jahr']<=2021))[0]
ta = dat['ta'][id]
mo = dat['mo'][id]
ja = dat['jahr'][id]
tn = dat['tmin'][id]
tg = dat['tmit'][id]
tx = dat['tmax'][id]
pr = dat['nied'][id]
rf = dat['relf'][id]
so = dat['sonn'][id]
ld = dat['ludr'][id]
id = N.where((gwl['ja']>=1961)&(gwl['ja']<=2021))[0]
gw = gwl['gw']
gw = N.array(gw,str)
gw[gw=='SWZ'] = 'SW'
gw[gw=='SWA'] = 'SW'
gw[gw=='SEZ'] = 'SE'
gw[gw=='SEA'] = 'SE'
gw[gw=='NWZ'] = 'NW'
gw[gw=='NWA'] = 'NW'
gw[gw=='TM'] = 'TRM'
gw[gw=='SZ'] = 'S'
gw[gw=='SA'] = 'S'
gw[gw=='NEZ'] = 'NE'
gw[gw=='NEA'] = 'NE'
gw[gw=='NZ'] = 'N'
gw[gw=='NA'] = 'N'
gw[gw=='WZ'] = 'W'
gw[gw=='WA'] = 'W'
gw[gw=='WW'] = 'W'
gw[gw=='WS'] = 'W'
gw[gw=='HNZ'] = 'HN'
gw[gw=='HNA'] = 'HN'
gw[gw=='HFZ'] = 'HF'
gw[gw=='HFA'] = 'HF'
gw[gw=='HNFZ'] = 'HNF'
gw[gw=='HNFA'] = 'HNF'
nd = len(ta)
Writing CSV¶
f = open('./includes/potsdam_day.csv','w')
f.write('date,tmin,tmit,tmax,relf,sonn,ludr,nied,gwl\n')
for d in range(nd):
f.write('%04i-%02i-%02i,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%s\n'%(ja[d],mo[d],ta[d],tn[d],tg[d],tx[d],rf[d],so[d],ld[d],pr[d],gw[d]))
f.close()
jo = N.arange(1961,2022,1)
nj = len(jo)
f = open('./includes/potsdam_year.csv','w')
f.write('date,tx00,tx01,tx25,tx30,tx99,pr30,pr99\n')
for j in range(nj):
id = N.where(ja==jo[j])[0]
tx00 = N.where((ja==jo[j])&(tx<=0))[0]
tx01 = N.percentile(tx[id],1)
tx25 = N.where((ja==jo[j])&(tx>=25))[0]
tx30 = N.where((ja==jo[j])&(tx>=30))[0]
tx99 = N.percentile(tx[id],99)
pr30 = N.where((ja==jo[j])&(pr>=30))[0]
pr99 = N.percentile(pr[id],99)
f.write('%i-01-01,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f\n'%(jo[j],len(tx00),tx01,len(tx25),len(tx30),tx99,len(pr30),pr99))
f.close()
Writing JSON¶
f = open('./includes/potsdam_day.json','w')
f.write('[\n')
for d in range(nd):
f.write('{')
f.write('"date":"%04i-%02i-%02i",'%(ja[d],mo[d],ta[d]))
f.write('"tmin":%.1f,'%(tn[d]))
f.write('"tmit":%.1f,'%(tg[d]))
f.write('"tmax":%.1f'%(tx[d]))
f.write('},\n')
f.write(']\n')
f.close()
jo = N.arange(1961,2022,1)
nj = len(jo)
f = open('./includes/potsdam_year.json','w')
f.write('[\n')
for j in range(nj):
f.write('{')
id = N.where(ja==jo[j])[0]
tx00 = N.where((ja==jo[j])&(tx<=0))[0]
f.write('"tx00":%i,'%len(tx00))
tx01 = N.percentile(tx[id],1)
f.write('"tx01":%.1f,'%tx01)
tx25 = N.where((ja==jo[j])&(tx>=25))[0]
f.write('"tx25":%i,'%len(tx25))
tx30 = N.where((ja==jo[j])&(tx>=30))[0]
f.write('"tx30":%i,'%len(tx30))
tx99 = N.percentile(tx[id],99)
f.write('"tx99":%.1f,'%tx99)
pr30 = N.where((ja==jo[j])&(pr>=30))[0]
f.write('"pr30":%i,'%len(pr30))
pr99 = N.percentile(pr[id],99)
f.write('"pr99":%.1f'%pr99)
f.write('},\n')
f.write(']\n')
f.close()