Skip to content

Commit d3f6e1e

Browse files
authored
Merge branch 'main' into get_template
2 parents ef68fc0 + 5e974e4 commit d3f6e1e

File tree

5 files changed

+45
-12
lines changed

5 files changed

+45
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- now uses topic specific thresholds for bin creation ([#668])
3939
- plot now shows relative and absolute contributions ([#668])
4040
- further improvements to description and plot ([#668])
41+
- mapping-saturation: now shows the estimated total data in the plot ([#658])
4142

4243
[#589]: https://github.com/GIScience/ohsome-quality-analyst/pull/589
4344
[#600]: https://github.com/GIScience/ohsome-quality-analyst/pull/600
@@ -54,6 +55,7 @@
5455
[#650]: https://github.com/GIScience/ohsome-quality-analyst/pull/650
5556
[#653]: https://github.com/GIScience/ohsome-quality-analyst/pull/653
5657
[#656]: https://github.com/GIScience/ohsome-quality-analyst/pull/656
58+
[#658]: https://github.com/GIScience/ohsome-quality-analyst/pull/658
5759
[#659]: https://github.com/GIScience/ohsome-quality-analyst/pull/659
5860
[#668]: https://github.com/GIScience/ohsome-quality-analyst/pull/668
5961
[#669]: https://github.com/GIScience/ohsome-quality-analyst/pull/669

ohsome_quality_analyst/indicators/mapping_saturation/indicator.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,43 @@ def create_figure(self) -> None:
162162
pgo.Scatter(
163163
x=self.timestamps,
164164
y=self.best_fit.fitted_values.tolist(),
165-
name="Fitted data",
165+
name="Modelled saturation curve",
166166
),
167167
)
168168
fig.update_layout(title_text="Mapping Saturation")
169-
fig.update_xaxes(title_text="Date")
169+
fig.update_xaxes(
170+
title_text="Date",
171+
ticks="outside",
172+
)
170173
if isinstance(self.topic, TopicData):
171174
fig.update_yaxes(title_text="Value")
172175
else:
173176
fig.update_yaxes(title_text=self.topic.aggregation_type.capitalize())
177+
178+
# plot asymptote
179+
asymptote = self.data["best_fit"]["asymptote"]
180+
if asymptote < max(self.values) * 5:
181+
fig.add_shape(
182+
type="line",
183+
x0=min(self.timestamps),
184+
x1=max(self.timestamps),
185+
y0=asymptote,
186+
y1=asymptote,
187+
line=dict(color="red", width=2, dash="dash"),
188+
name="Estimated total data",
189+
showlegend=True,
190+
)
191+
y_max = max(max(self.values), max(self.best_fit.fitted_values))
192+
padding_percentage = 1 - (y_max / asymptote)
193+
if 0 < padding_percentage < 0.5:
194+
padding = y_max * (padding_percentage + 0.05)
195+
else:
196+
padding = y_max * 0.05
197+
fig.update_yaxes(range=[min(self.values), y_max + padding])
198+
fig.update_layout(showlegend=True)
199+
# fixed legend, because we do not expect high contributions in 2008
200+
fig.update_legends(x=0.02, y=0.85, bgcolor="rgba(255,255,255,0.66)")
201+
174202
raw = fig.to_dict()
175203
raw["layout"].pop("template") # remove boilerplate
176204
self.result.figure = raw

ohsome_quality_analyst/oqt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ async def create_indicator(
3535
feature["id"] = i
3636
# Only enforce size limit if ohsome API data is not provided
3737
# Disable size limit for the Mapping Saturation indicator
38-
if isinstance(topic, TopicDefinition) and key != "mapping-saturation":
38+
if isinstance(topic, TopicDefinition) and key not in [
39+
"mapping-saturation",
40+
"currentness",
41+
]:
3942
validate_area(feature)
4043
tasks.append(_create_indicator(key, feature, topic, include_figure))
4144
return await gather_with_semaphore(tasks)

poetry.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ uvicorn = "^0.20.0"
4343
schema = "^0.7.5"
4444
building-completeness-model = {version = "^0.1.0rc4", source = "gistools-ohsome-machine-learning-models"}
4545
kaleido = "0.2.1"
46-
plotly = "^5.14.0"
4746
pyproj = "^3.6.0"
4847
pydantic = "^2.1.1"
4948
geojson-pydantic = "^1.0.0"
49+
plotly = "^5.16.1"
5050

5151
[tool.poetry.dev-dependencies]
5252
black = "^23.3.0"

0 commit comments

Comments
 (0)