Skip to content

Commit

Permalink
Merge pull request #172 from ufal/update-visualizations
Browse files Browse the repository at this point in the history
Fix and update visualization for quintd-openweather
  • Loading branch information
kasnerz authored Dec 17, 2024
2 parents 350bed3 + eaf54dd commit d9c5fbc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 8 additions & 6 deletions factgenie/datasets/openweather.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def postprocess_data(self, examples):
forecasts = examples["forecasts"]
examples = []

# https://openweathermap.org/api/hourly-forecast, using metric system
# using metric system
units = {
"temp": "°C",
"wind": "m/s",
Expand All @@ -29,7 +29,7 @@ def postprocess_data(self, examples):
lst_filtered = []
timezone_shift_sec = city["timezone"]

for key in ["sunrise", "sunset", "population", "timezone"]:
for key in ["sunrise", "sunset", "population", "timezone", "coord", "id"]:
city.pop(key, None)

for i, f in enumerate(forecast["list"]):
Expand All @@ -38,9 +38,11 @@ def postprocess_data(self, examples):
continue
f = {k: v for k, v in f.items() if k not in ["dt", "pop", "sys", "visibility"]}

# remove the main -> temp_kf key
# remove extra keys
f["main"] = {
k: v for k, v in f["main"].items() if k not in ["temp_kf", "humidity", "sea_level", "grnd_level"]
k: v
for k, v in f["main"].items()
if k not in ["temp_kf", "humidity", "sea_level", "grnd_level", "temp_max", "temp_min"]
}

# convert "dt_txt" to timestamp
Expand All @@ -49,8 +51,8 @@ def postprocess_data(self, examples):
# shift timezone
local_datetime += timezone_shift_sec
# convert back to "2023-11-28 09:00:00"
local_datetime = datetime.fromtimestamp(local_datetime).strftime("%Y-%m-%d %H:%M:%S")
f["dt_txt"] = local_datetime
f["dt_txt"] = datetime.fromtimestamp(local_datetime).strftime("%Y-%m-%d %H:%M:%S")
f["day_of_week"] = datetime.fromtimestamp(local_datetime).strftime("%A")

lst_filtered.append(f)

Expand Down
9 changes: 9 additions & 0 deletions factgenie/static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -1014,4 +1014,13 @@ a:hover {

.out-placeholder {
line-height: 2;
}

.inline-icon {
margin-right: 0.2em;
margin-top: 0;
margin-bottom: -0.1em;
/* margin-bottom: 2px; */
height: 0.8em;
vertical-align: baseline;
}
2 changes: 1 addition & 1 deletion factgenie/static/js/lib/meteogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Meteogram.prototype.getChartOptions = function (cityName) {

plotOptions: {
series: {
pointPlacement: 'between',
pointPlacement: 0.1,
animation: false
}
},
Expand Down

0 comments on commit d9c5fbc

Please sign in to comment.