Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Brueni92/rapp
Browse files Browse the repository at this point in the history
  • Loading branch information
Brueni92 committed Sep 3, 2022
2 parents 2fd625f + 0f38f49 commit 0074861
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
26 changes: 26 additions & 0 deletions meteo-scraper/lage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"0-15": {
"W": 1,
"SW": 2,
"S'": 2,
"SE": 1
},
"15-25": {
"W": 2,
"SW": 3,
"S'": 3,
"SE": 2
},
"25-35": {
"W": 2,
"SW": 3,
"S'": 3,
"SE": 2
},
"35+": {
"W": 1,
"SW": 2,
"S'": 2,
"SE": 1
}
}
34 changes: 34 additions & 0 deletions meteo-scraper/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

import pandas as pd
import requests
import json

STATIONS = {
"Graenichen": 179,
"Frick": 164,
"Tegenfeld": 169,
"Oberflachs": 167,
"Birmensdorf": 191}

YEARS = 13

URL = 'https://www.agrometeo.ch/backend/api/meteo/data?from=2008-01-01&to=2020-12-28&scale=day&stations=179%2C164%2C169%2C167%2C191&sensors=1%3Aavg%2C1%3Amax%2C6%3Asum%2C11%3Aavg%2C41%3Asum&show_cflag=0&language=de'
response = requests.get(URL).content
string = response.decode('utf-8')
json_obj = json.loads(string)
df = pd.DataFrame(json_obj['data'])

df['month'] = pd.DatetimeIndex(df['date']).month
df['day'] = pd.DatetimeIndex(df['date']).day
df = df[((df['month'] >= 4) & (df['month'] <=9))]
values = {}
for key, station in STATIONS.items():
df[f'{station}_daily_huglin'] = (pd.to_numeric(df[f'{station}_1_avg']) + pd.to_numeric(df[f'{station}_1_max']) - 20) / 2
huglin = pd.to_numeric(df[f'{station}_daily_huglin']).sum()/YEARS * 1.045
rain = pd.to_numeric(df[f'{station}_6_sum']).sum()/YEARS
temp = df[pd.DatetimeIndex(df['date']).year >= 2016]
sun = pd.to_numeric(temp[f'{station}_11_avg']).sum() / 5
values[key] = {'huglin': huglin, 'rain': rain, 'sun': sun}

with open('meteo.json', 'w') as fp:
json.dump(values, fp)
1 change: 1 addition & 0 deletions meteo-scraper/meteo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Graenichen": {"huglin": 1787.701596153846, "rain": 579.0769230769231, "sun": 31385.920000000002}, "Frick": {"huglin": 1747.6017307692307, "rain": 525.0, "sun": 41733.759999999995}, "Tegenfeld": {"huglin": 1843.1147307692306, "rain": 493.84615384615387, "sun": 37633.28}, "Oberflachs": {"huglin": 1704.9617115384613, "rain": 521.6461538461538, "sun": 37377.36}, "Birmensdorf": {"huglin": 1793.9434615384614, "rain": 553.0076923076923, "sun": 34611.1}}
26 changes: 26 additions & 0 deletions web-app/src/data/lage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"0-15": {
"W": 1,
"SW": 2,
"S'": 2,
"SE": 1
},
"15-25": {
"W": 2,
"SW": 3,
"S'": 3,
"SE": 2
},
"25-35": {
"W": 2,
"SW": 3,
"S'": 3,
"SE": 2
},
"35+": {
"W": 1,
"SW": 2,
"S'": 2,
"SE": 1
}
}
1 change: 1 addition & 0 deletions web-app/src/data/meteo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Graenichen": {"huglin": 1787.701596153846, "rain": 579.0769230769231, "sun": 31385.920000000002}, "Frick": {"huglin": 1747.6017307692307, "rain": 525.0, "sun": 41733.759999999995}, "Tegenfeld": {"huglin": 1843.1147307692306, "rain": 493.84615384615387, "sun": 37633.28}, "Oberflachs": {"huglin": 1704.9617115384613, "rain": 521.6461538461538, "sun": 37377.36}, "Birmensdorf": {"huglin": 1793.9434615384614, "rain": 553.0076923076923, "sun": 34611.1}}

0 comments on commit 0074861

Please sign in to comment.