Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/quickstart-fr.py.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@
# You can also plot the flows, with labels for the cities that are bigger than their neighbours
labels = pop_trips.get_prominent_cities()
pop_trips.plot_od_flows(labels=labels)

rapport = pop_trips.parameters_dict()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to put it here! Can we stick to English (report) ? Let's add a comment to help future users understand what it does

print(rapport.T)
43 changes: 40 additions & 3 deletions mobility/choice_models/population_trips.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import random
import warnings
import pandas as pd

import geopandas as gpd
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -685,8 +686,9 @@ def plot_od_flows(self, mode="all", motive="all", period="weekdays", level_of_de
# Put a legend for width on bottom right, title on the top
x_min = float(biggest_flows[["x"]].min().iloc[0])
y_min = float(biggest_flows[["y"]].min().iloc[0])
plt.plot([x_min, x_min+4000], [y_min, y_min], linewidth=2, color=color)
plt.text(x_min+6000, y_min-1000, "1 000", color=color)
plt.plot([x_min-6000, x_min-4000], [y_min, y_min], linewidth=2, color=color)
plt.text(x_min-2000, y_min-200, "1 000", color=color)
plt.text(x_min-6000, y_min-2000, f"hash: {self.inputs_hash}", fontsize=7, color=color)
plt.title(f"{mode_name} flows between transport zones on {period}")

# Draw all origin-destinations
Expand Down Expand Up @@ -717,7 +719,7 @@ def get_prominent_cities(self, n_cities=20, n_levels=3, distance_km=2):
"""
Get the most prominent cities, ie the biggest cities that are not close to a bigger city.

Useful to label a map and reducing the number of overlaps without mising an important city.
Useful to label a map and reducing the number of overlaps without missing an important city.

Parameters
----------
Expand Down Expand Up @@ -771,3 +773,38 @@ def get_prominent_cities(self, n_cities=20, n_levels=3, distance_km=2):
geoflows = geoflows.merge(xy_coords, left_index=True, right_index=True)

return geoflows

def parameters_dict(self) :
params_general = {
"inner_radius": self.population.transport_zones.inner_radius,
"local_admin_unit_id": self.population.transport_zones.study_area.local_admin_unit_id,
"level_of_detail" : self.population.transport_zones.level_of_detail,
"nb_local_admin_units": len(self.population.transport_zones.study_area.get()),
"osm_geofabrik_extract_date": self.population.transport_zones.osm_buildings.geofabrik_extract_date,
"population_sample_size": self.population.sample_size,
"survey_used": [s.survey_name for s in self.surveys],
"inputs_hash" : self.inputs_hash
}
params_modes = {
key: value
for i, m in enumerate(self.modes, start=1)
for key, value in [
(f"mode_{i}", m.name),
(f"mode_{i}_filter_max_time",m.travel_costs.routing_parameters.filter_max_time),
(f"mode_{i}_filter_max_speed",m.travel_costs.routing_parameters.filter_max_speed),
(f"mode_{i}_cost_constant",m.generalized_cost.parameters.cost_constant),
(f"mode_{i}_cost_of_distance",m.generalized_cost.parameters.cost_of_distance),
(f"mode_{i}_cost_of_time_intercept",m.generalized_cost.parameters.cost_of_time.intercept) #à voir ce qu'on veut connaitre
]
}
params_motives = {
key: value
for i, m in enumerate(self.motives, start=1)
for key, value in [
(f"motive_{i}", m.name),
(f"motive_{i}_value_of_time",m.value_of_time),
(f"motive_{i}_value_of_time_v2",m.value_of_time_v2)
]
}
params = params_general | params_modes | params_motives
return pd.DataFrame([params])
Loading