From 94dcf4fa7d686379da3f7c05e312efd7e8667a6c Mon Sep 17 00:00:00 2001 From: mariegrandclement Date: Mon, 1 Dec 2025 16:05:44 +0100 Subject: [PATCH 1/2] =?UTF-8?q?US=20198=20-=20Travail=20en=20cours=20sur?= =?UTF-8?q?=20les=20param=C3=A8tres=20d'entr=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/quickstart-fr.py.py | 3 +++ mobility/choice_models/population_trips.py | 24 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/quickstart-fr.py.py b/examples/quickstart-fr.py.py index ebc32e8..41bcdec 100644 --- a/examples/quickstart-fr.py.py +++ b/examples/quickstart-fr.py.py @@ -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() +print(rapport) diff --git a/mobility/choice_models/population_trips.py b/mobility/choice_models/population_trips.py index 761c7bb..b7a5617 100644 --- a/mobility/choice_models/population_trips.py +++ b/mobility/choice_models/population_trips.py @@ -4,6 +4,7 @@ import shutil import random import warnings +import pandas as pd import geopandas as gpd import matplotlib.pyplot as plt @@ -605,8 +606,10 @@ 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.text(x_min-6000, y_min-4000,self.parameters_dict(),fontsize=7, color=color) plt.title(f"{mode_name} flows between transport zones on {period}") # Draw all origin-destinations @@ -691,3 +694,20 @@ 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 = { + #study area radius + "radius": self.population.transport_zones.inner_radius, + #id number of administrative unit + "local_admin_unit_id": self.population.transport_zones.study_area.local_admin_unit_id, + #sample size of population surveyed + "population_sample_size": self.population.sample_size, + #referenced of survey used for parsing + "survey_used": [s.survey_name for s in self.surveys], + #liste des local admin units + "nombre_local_admin_units": len(self.population.transport_zones.study_area.get()), + #hash path# + "inputs_hash" : self.inputs_hash + } + return pd.DataFrame([params]) From a69cd58961e57404b1470b00c84992365c6b39b6 Mon Sep 17 00:00:00 2001 From: mariegrandclement Date: Mon, 8 Dec 2025 12:06:14 +0100 Subject: [PATCH 2/2] Update parameters_dict MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fonction parameters_dict mise à jour pour séparer les paramètres généraux, liés aux modes, et liés aux motifs --- examples/quickstart-fr.py.py | 2 +- mobility/choice_models/population_trips.py | 41 +++++++++++++++------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/examples/quickstart-fr.py.py b/examples/quickstart-fr.py.py index 41bcdec..ac35ebc 100644 --- a/examples/quickstart-fr.py.py +++ b/examples/quickstart-fr.py.py @@ -40,4 +40,4 @@ pop_trips.plot_od_flows(labels=labels) rapport = pop_trips.parameters_dict() -print(rapport) +print(rapport.T) diff --git a/mobility/choice_models/population_trips.py b/mobility/choice_models/population_trips.py index 7ac5d45..c28c714 100644 --- a/mobility/choice_models/population_trips.py +++ b/mobility/choice_models/population_trips.py @@ -689,7 +689,6 @@ def plot_od_flows(self, mode="all", motive="all", period="weekdays", level_of_de 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.text(x_min-6000, y_min-4000,self.parameters_dict(),fontsize=7, color=color) plt.title(f"{mode_name} flows between transport zones on {period}") # Draw all origin-destinations @@ -720,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 ---------- @@ -776,18 +775,36 @@ def get_prominent_cities(self, n_cities=20, n_levels=3, distance_km=2): return geoflows def parameters_dict(self) : - params = { - #study area radius - "radius": self.population.transport_zones.inner_radius, - #id number of administrative unit + params_general = { + "inner_radius": self.population.transport_zones.inner_radius, "local_admin_unit_id": self.population.transport_zones.study_area.local_admin_unit_id, - #sample size of population surveyed + "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, - #referenced of survey used for parsing "survey_used": [s.survey_name for s in self.surveys], - #liste des local admin units - "nombre_local_admin_units": len(self.population.transport_zones.study_area.get()), - #hash path# "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])