Skip to content

Page1

Potsdam

Klimatrends

xxx

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "height": 500, "data": {"name":"Potsdam","url": "includes/potsdam_day.csv"}, "title": {"text": "Klimatrends, Potsdam","anchor":"start","fontSize":20}, "params": [{ "name": "_select_", "value": "tmit", "bind": {"input": "select","options":["tmin","tmit","tmax","relf","sonn","ludr","nied"]} }], "transform": [{ "calculate": "datum[_select_]", "as": "y" }], "layer": [{ "mark": {"type":"point","point": true,"color":"dodgerblue","size":50}, "encoding": { "x": {"field": "date", "timeUnit": "year","type": "quantitative","title":null,"axis": {"values": [1960,1970,1980,1990,2000,2010,2020]}}, "y": {"field": "y","aggregate": "mean","scale": {"zero": false},"color": {"field": "location"},"legend": null,"title":null}, "tooltip": {"field": "y","aggregate": "mean","type": "quantitative","format": ".1f"} } }, { "mark": "rule", "encoding": { "y": {"aggregate": "mean","field": "y","type": "quantitative"}, "tooltip": {"field": "y","aggregate": "mean","type": "quantitative","format": ".1f"}, "color": {"value": "black"}, "size": {"value": 2} } }, { "mark": {"type": "line","color":"dodgerblue","strokeWidth":3}, "transform": [{"regression": "y","on":"date"}], "encoding": { "x": {"field": "date", "timeUnit": "year","type": "quantitative","title":null}, "y": {"field": "y","type": "quantitative"}, "color":{"datum":"Trend"} } } ] }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "height": 500, "padding": 5, "data": {"name":"Potsdam","url": "includes/potsdam_year.csv"}, "title": {"text": "Klimatrends, Potsdam","anchor":"start","fontSize":20}, "params": [{ "name": "_select_", "value": "tx00", "bind": {"input": "select","options": ["tx00","tx01","tx25","tx30","tx99","pr30","pr99"]} }], "transform": [{ "calculate": "datum[_select_]", "as": "y" }], "layer": [{ "mark": {"type":"point","point": true,"color":"dodgerblue","size":50}, "encoding": { "x": {"field": "date", "timeUnit": "year","type": "quantitative","title":null,"axis": {"values": [1960,1970,1980,1990,2000,2010,2020]}}, "y": {"field": "y","aggregate": "mean","scale": {"zero": false},"color": {"field": "location"},"legend":null,"title":null}, "tooltip": {"field": "y","aggregate": "mean","type": "quantitative","format": ".1f"} } }, { "mark": "rule", "encoding": { "y": {"aggregate": "mean","field": "y","type":"quantitative","title":null}, "tooltip": {"field": "y","aggregate": "mean","type": "quantitative","format": ".1f"}, "color": {"value": "black"}, "size": {"value": 2} } }, { "mark": {"type": "line","color": "dodgerblue","strokeWidth":5}, "transform": [{"regression": "y","on": "date"}], "encoding": { "x": {"field": "date", "timeUnit": "year","type": "quantitative","title":null,"axis": {"values": [1960,1970,1980,1990,2000,2010,2020]}}, "y": {"field": "y","type": "quantitative","title":null} } } ] }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": {"url": "includes/potsdam.csv"}, "height": 500, "title": {"text":"Klimatrends, Potsdam","fontSize":30,"subtitle":"xxx","anchor":"start","subtitleColor":"red"}, "config": {"legend": {"orient": "bottom", "layout":{"bottom":{"anchor":"middle"}}}}, "params": [{ "name": "_select_", "value": "tmit", "bind": {"input": "select","options": ["tmin","tmit","tmax","relf","sonn","ludr","nied"]} }], "layer": [{ "transform": [{ "filter": {"timeUnit": "year", "field":"date","range":[1961,1990]} }, { "calculate": "datum[_select_]", "as": "y" }], "mark": {"type":"line","color":"dodgerblue","strokeWidth":3,"point": {"filled": false,"fill": "white","size":100,"color":"dodgerblue"}}, "encoding": { "x": {"type": "temporal", "field": "date", "timeUnit": "month","title":null}, "y": {"type": "quantitative","aggregate": "mean","field": "y","scale":{"zero":false},"title":null}, "tooltip": {"field": "y","aggregate": "mean","type": "quantitative","format":".1f"} } }, { "transform": [{ "filter": {"timeUnit": "year", "field":"date","range":[1961,1990]} }, { "calculate": "datum[_select_]", "as": "y" }], "mark": {"type":"rule"}, "encoding": { "y": {"aggregate": "mean","field": "y","type": "quantitative"}, "tooltip": {"field": "y","aggregate": "mean","type": "quantitative","format": ".2f"}, "color": {"value": "dodgerblue"}, "size": {"value": 3} } }, { "transform": [{ "filter": {"timeUnit": "year", "field":"date","range":[1991,2020]} }, { "calculate": "datum[_select_]", "as": "y" }], "mark": {"type":"line","color":"orangered","strokeWidth":3,"point": {"filled": false,"fill": "white","size":100,"color":"orangered"}}, "encoding": { "x": {"type": "temporal", "field": "date", "timeUnit": "month","title":null}, "y": {"type": "quantitative","aggregate": "mean","field": "y","scale": {"zero":false},"title":null}, "tooltip": {"field": "y","aggregate": "mean","type": "quantitative","format": ".2f"} } }, { "transform": [{ "filter": {"timeUnit": "year", "field":"date","range":[1991,2020]} }, { "calculate": "datum[_select_]", "as": "y" }], "mark": {"type":"rule"}, "encoding": { "y": {"aggregate": "mean","field": "y","type":"quantitative"}, "tooltip": {"field": "y","aggregate": "mean","type": "quantitative","format":".1f"}, "color": {"value":"orangered","legend": {"title": "xx"}}, "size": {"value": 3} } }] }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "title": {"text": "Klimatrends, Potsdam","anchor":"start","fontSize":20}, "height": 500, "data": {"url": "includes/potsdam.csv"}, "layer": [ { "mark": {"type":"line","color":"dodgerblue","interpolate": "basis"}, "encoding": { "x": {"timeUnit": "monthdate","field": "date","type": "temporal"}, "y": {"aggregate": "mean","field": "tmit","type":"quantitative","title":null} } } ] }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "title": {"text": "Klimatrends, Potsdam","anchor":"start","fontSize":20}, "data": {"url": "includes/potsdam_day.json"}, "height": 500, "layer": [{ "transform": [{ "filter": {"timeUnit": "year", "field":"date","range":[1961,1990]} }, { "density": "tmax", "bandwidth": 2.0 }], "mark": {"type":"line"}, "encoding": { "x": {"field": "value","title":"tmax","type":"quantitative","axis":{"values":[-20,-15,-10,-5,0,5,10,15,20,25,30,35,40]}}, "y": {"field": "density","type":"quantitative","title":null}, "color":{"value":"dodgerblue","datum":"1961-1990"} } }, { "transform": [{ "filter": {"timeUnit": "year", "field":"date","range":[1991,2020]} }, { "density": "tmax", "bandwidth": 2.0 }], "mark": {"type":"line"}, "encoding": { "x": {"field": "value","title":"tmax","type":"quantitative","axis":{"values":[-20,-15,-10,-5,0,5,10,15,20,25,30,35,40]}}, "y": {"field": "density","type": "quantitative","title":null}, "color": {"value":"orangered","datum":"1991-2020"} } }] }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "title": {"text": "Klimatrends, Potsdam","anchor":"start","fontSize":20}, "data": {"url": "includes/potsdam_day.csv"}, "mark": {"type":"tick","color":"magenta"}, "encoding": {"x": {"field": "tmax", "type": "quantitative"}} }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": {"url": "includes/potsdam.csv"}, "title": {"text": "Klimadiagramm, Potdsdam","anchor":"start","fontSize":20}, "config": { "view": {"strokeWidth": 0,"step": 10}, "axis": {"domain": true} }, "mark": "rect", "height": 400, "encoding": { "x": {"field": "date","timeUnit": "date","type": "ordinal","title": null,"axis": {"labelAngle": 0,"format": "%e"}}, "y": {"field": "date","timeUnit": "month","type": "ordinal","title": null}, "color": {"field": "nied","aggregate": "mean","type": "quantitative","scale": {"domain":[1,3],"scheme":"yellowgreenblue"},"legend":{"title":"mm/d"}} } }

Großwetterlagen

Großwetterlagen

xxx

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "title": {"text": "Klimatrends, Potsdam","anchor":"start","fontSize":20}, "data": {"url": "includes/potsdam_day.csv"}, "vconcat": [{ "encoding": { "color": { "condition": { "param": "brush", "title": "Patterns", "field": "gwl", "type": "nominal", "scale": { "domain": ["W","SW","NW","TRM","S","NE","N","HN","HF","HM","BM","HB","U","SE","TB","HNF","TRW"], "range": ["green","red","blue","magenta","red","blue","blue","yellow","yellow","orange","orange","yellow","gray","red","green","yellow","red"] } }, "value": "lightgray" }, "size": {"title": "Precipitation","field": "nied","scale": {"domain": [-1, 40]},"type": "quantitative"}, "x": {"field": "date","timeUnit": "monthdate","title": null,"axis": {"format": "%b"}}, "y": {"title": "Maximum Daily Temperature (°C)","field": "tmax","scale": {"domain": [-15, 40]},"type": "quantitative"} }, "width": 1000, "height": 500, "mark": "point", "params": [{ "name": "brush", "select": {"type": "interval", "encodings": ["x"]} }], "transform": [{"filter": {"param": "click"}}] }, { "encoding": { "color": { "condition": { "param": "click", "field": "gwl", "scale": { "domain": ["W","SW","NW","TRM","S","NE","N","HN","HF","HM","BM","HB","U","SE","TB","HNF","TRW"], "range": ["green","red","blue","magenta","red","blue","blue","yellow","yellow","orange","orange","yellow","gray","red","green","yellow","red"]} }, "value": "lightgray" }, "x": {"aggregate": "count"}, "y": {"title": null, "field": "gwl"} }, "width": 1000, "mark": "bar", "params": [{ "name": "click", "select": {"type": "point", "encodings": ["color"]} }], "transform": [{"filter": {"param": "brush"}}] } ] }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "title": {"text": "Klimatrends, Potsdam","anchor":"start","fontSize":20}, "data": {"url": "includes/gwl.csv"}, "config": { "view": {"strokeWidth": 0,"step": 10}, "axis": {"domain": true} }, "mark": "rect", "height": 400, "encoding": { "x": {"field": "gwl","type": "ordinal","title": null}, "y": {"field": "date","timeUnit": "month","type": "ordinal","title": null}, "color": {"field": "nied","aggregate": "mean","type": "quantitative","scale": {"domain":[1,3],"scheme":"yellowgreenblue"},"legend": {"title":"mm/d"}} } }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "title": {"text": "Klimatrends, Potdsdam","anchor":"start","fontSize":20}, "data": {"url": "includes/potsdam_day.csv"}, "transform": [{ "aggregate": [{"op": "count","field": "gwl","as": "num" }], "groupby": ["gwl"] }], "mark": {"type":"bar","color":"dodgerblue"}, "encoding": { "x": {"type": "quantitative","field": "num"}, "y":{"type":"nominal","field": "gwl"}, "tooltip": {"field": "gwl","type": "nominal","format": "i"} } }

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "height": 500, "data": {"name":"Potsdam","url": "includes/potsdam_day.csv"}, "title": {"text": "Klimatrends, Potsdam","anchor":"start","fontSize":20}, "params": [{ "name": "_select_", "value": "W", "bind": {"input": "select","options": ["W","SW","NW","TRM","S","NE","N","HN","HF","HM","BM","HB","U","SE","TB","HNF","TRW"]} }], "transform": [{ "filter": "datum.gwl == _select_" }], "layer": [{ "mark": {"type":"point","point": true,"color":"lime","size":50}, "encoding": { "x": {"field": "date", "timeUnit": "year","type": "quantitative","title":null,"axis": {"values": [1960,1970,1980,1990,2000,2010,2020]}}, "y": {"field":"gwl","type": "quantitative","aggregate": "count","scale": {"zero": false},"legend":null}, "tooltip": {"field": "gwl","aggregate": "count","type": "quantitative","format": "i"} } }, { "mark": "rule", "encoding": { "y": {"aggregate": "mean","field": "gwl","type": "quantitative","title":null}, "tooltip": {"field": "gwl","aggregate": "mean","type": "quantitative","format": ".1f"}, "color": {"value": "black"}, "size": {"value": 2} } }] }


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()