diff --git a/analysis/marginals.py b/analysis/marginals.py index 98baf359..72bfa9e7 100644 --- a/analysis/marginals.py +++ b/analysis/marginals.py @@ -8,14 +8,14 @@ HOUSEHOLD_SIZE_BOUNDS = [1, 3, np.inf] HOUSEHOLD_SIZE_LABELS = ["1", "2-3", "4+"] -NUMBER_OF_VEHICLES_BOUNDS = [0, 1, 2, np.inf] -NUMBER_OF_VEHICLES_LABELS = ["0", "1", "2", "3+"] +NUMBER_OF_CARS_BOUNDS = [0, 1, 2, np.inf] +NUMBER_OF_CARS_LABELS = ["0", "1", "2", "3+"] -NUMBER_OF_BIKES_BOUNDS = [0, 1, 2, np.inf] -NUMBER_OF_BIKES_LABELS = ["0", "1", "2", "3+"] +NUMBER_OF_BICYCLES_BOUNDS = [0, 1, 2, np.inf] +NUMBER_OF_BICYCLES_LABELS = ["0", "1", "2", "3+"] GENERAL_PERSON_MARGINALS = [("age_class",), ("sex",), ("employed",), ("studies",)] -GENERAL_HOUSEHOLD_MARGINALS = [("household_size_class",), ("number_of_vehicles_class",)] +GENERAL_HOUSEHOLD_MARGINALS = [("household_size_class",), ("number_of_cars_class",)] CENSUS_PERSON_MARGINALS = GENERAL_PERSON_MARGINALS + [("socioprofessional_class",)] CENSUS_HOUSEHOLD_MARGINALS = GENERAL_HOUSEHOLD_MARGINALS @@ -34,11 +34,11 @@ def prepare_classes(df): if "household_size" in df: df["household_size_class"] = np.digitize(df["household_size"], HOUSEHOLD_SIZE_BOUNDS, right = True) - if "number_of_vehicles" in df: - df["number_of_vehicles_class"] = np.digitize(df["number_of_vehicles"], NUMBER_OF_VEHICLES_BOUNDS, right = True) + if "number_of_cars" in df: + df["number_of_cars_class"] = np.digitize(df["number_of_cars"], NUMBER_OF_CARS_BOUNDS, right = True) - if "number_of_bikes" in df: - df["number_of_bikes_class"] = np.digitize(df["number_of_bikes"], NUMBER_OF_BIKES_BOUNDS, right = True) + if "number_of_bicycles" in df: + df["number_of_bicycles_class"] = np.digitize(df["number_of_bicycles"], NUMBER_OF_BICYCLES_BOUNDS, right = True) def cross(*marginals): result = [] diff --git a/analysis/reference/hts/mode_distances.py b/analysis/reference/hts/mode_distances.py index 6b556bd5..06f21fa0 100644 --- a/analysis/reference/hts/mode_distances.py +++ b/analysis/reference/hts/mode_distances.py @@ -20,7 +20,7 @@ def execute(context): data = dict() - for mode in ["car", "car_passenger", "pt", "bike", "walk"]: + for mode in ["car", "car_passenger", "pt", "bicycle", "walk"]: f = df["mode"] == mode if np.count_nonzero(f) > 0: diff --git a/analysis/synthesis/mode_distances.py b/analysis/synthesis/mode_distances.py index eea6b36d..fc673ae7 100644 --- a/analysis/synthesis/mode_distances.py +++ b/analysis/synthesis/mode_distances.py @@ -15,7 +15,7 @@ def execute(context): acquisition_sample_size = context.config("acquisition_sample_size") probabilities = np.linspace(0.0, 1.0, 20) - modes = ["car", "car_passenger", "pt", "bike", "walk"] + modes = ["car", "car_passenger", "pt", "bicycle", "walk"] quantiles = { mode : [] for mode in modes } diff --git a/data/census/cleaned.py b/data/census/cleaned.py index 789d0adb..60914413 100644 --- a/data/census/cleaned.py +++ b/data/census/cleaned.py @@ -60,9 +60,10 @@ def execute(context): # Clean TRANS df.loc[df["TRANS"] == "1", "commute_mode"] = np.nan df.loc[df["TRANS"] == "2", "commute_mode"] = "walk" - df.loc[df["TRANS"] == "3", "commute_mode"] = "bike" + df.loc[df["TRANS"] == "3", "commute_mode"] = "bicycle" df.loc[df["TRANS"] == "4", "commute_mode"] = "car" - df.loc[df["TRANS"] == "5", "commute_mode"] = "pt" + df.loc[df["TRANS"] == "5", "commute_mode"] = "car" + df.loc[df["TRANS"] == "6", "commute_mode"] = "pt" df.loc[df["TRANS"] == "Z", "commute_mode"] = np.nan df["commute_mode"] = df["commute_mode"].astype("category") @@ -81,11 +82,11 @@ def execute(context): df["studies"] = df["ETUD"] == "1" # Number of vehicles - df["number_of_vehicles"] = df["VOIT"].apply( + df["number_of_cars"] = df["VOIT"].apply( lambda x: str(x).replace("Z", "0").replace("X", "0") ).astype(int) - df["number_of_vehicles"] += df["DEROU"].apply( + df["number_of_cars"] += df["DEROU"].apply( lambda x: str(x).replace("U", "0").replace("Z", "0").replace("X", "0") ).astype(int) @@ -104,7 +105,7 @@ def execute(context): "iris_id", "commune_id", "departement_id", "age", "sex", "couple", "commute_mode", "employed", - "studies", "number_of_vehicles", "household_size", + "studies", "number_of_cars", "household_size", "consumption_units", "socioprofessional_class" ]] diff --git a/data/hts/edgt_44/cleaned.py b/data/hts/edgt_44/cleaned.py index 1fa9b526..8f702b4f 100644 --- a/data/hts/edgt_44/cleaned.py +++ b/data/hts/edgt_44/cleaned.py @@ -22,7 +22,8 @@ def configure(context): "car": [13, 15, 21, 81], "car_passenger": [14, 16, 22, 82], "pt": [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 51, 52, 53, 61, 71, 72, 73, 91, 92, 94, 95], - "bike": [11, 17, 12, 18, 93, 19], + "bicycle": [11, 17, 12, 18, 93, 19], + # "motorbike": [13, 15], "walk": [1, 2] # Actually, 2 is not really explained, but we assume it is walk } @@ -90,9 +91,9 @@ def execute(context): df_persons["studies"] = df_persons["P7"].isin(["3", "4", "5"]) # Number of vehicles - df_households["number_of_vehicles"] = df_households["M6"] + df_households["M5"] - df_households["number_of_vehicles"] = df_households["number_of_vehicles"].astype(int) - df_households["number_of_bikes"] = df_households["M7"].astype(int) + df_households["number_of_cars"] = df_households["M6"].astype(int) + df_households["number_of_cars"] += df_households["M5"].astype(int) # motorbikes + df_households["number_of_bicycles"] = df_households["M7"].astype(int) # License df_persons["has_license"] = df_persons["P5"] == "1" @@ -166,11 +167,6 @@ def execute(context): # Nonrespondent of travel questionary section (number_of_trips = -1) df_persons["number_of_trips"] = df_persons["number_of_trips"].fillna(-1).astype(int) - # Passenger attribute - df_persons["is_passenger"] = df_persons["person_id"].isin( - df_trips[df_trips["mode"] == "car_passenger"]["person_id"].unique() - ) - # Calculate consumption units hts.check_household_size(df_households, df_persons) df_households = pd.merge(df_households, hts.calculate_consumption_units(df_persons), on = "household_id") diff --git a/data/hts/edgt_lyon/cleaned_adisp.py b/data/hts/edgt_lyon/cleaned_adisp.py index 30a4dfcd..8f17e259 100644 --- a/data/hts/edgt_lyon/cleaned_adisp.py +++ b/data/hts/edgt_lyon/cleaned_adisp.py @@ -23,7 +23,8 @@ def configure(context): "car": [13, 15, 21, 81], "car_passenger": [14, 16, 22, 82], "pt": [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 51, 52, 53, 61, 71, 91, 92, 94, 95], - "bike": [11, 17, 12, 18, 93], + "bicycle": [11, 17, 12, 18, 93], + # "motorbike": [13, 15], "walk": [1, 2] # Actually, 2 is not really explained, but we assume it is walk } @@ -106,9 +107,9 @@ def execute(context): df_persons["studies"] = df_persons["P9"].isin(["3", "4", "5"]) # Number of vehicles - df_households["number_of_vehicles"] = df_households["M6"] + df_households["M14"] - df_households["number_of_vehicles"] = df_households["number_of_vehicles"].astype(int) - df_households["number_of_bikes"] = df_households["M21"].astype(int) + df_households["number_of_cars"] = df_households["M6"].astype(int) + df_households["number_of_cars"] += df_households["M14"].astype(int) # motorbikes + df_households["number_of_bicycles"] = df_households["M21"].astype(int) # License df_persons["has_license"] = df_persons["P7"] == "1" @@ -179,11 +180,6 @@ def execute(context): # Nonrespondent of travel questionary section (number_of_trips = -1) df_persons["number_of_trips"] = df_persons["number_of_trips"].fillna(-1).astype(int) - # Passenger attribute - df_persons["is_passenger"] = df_persons["person_id"].isin( - df_trips[df_trips["mode"] == "car_passenger"]["person_id"].unique() - ) - # Calculate consumption units hts.check_household_size(df_households, df_persons) df_households = pd.merge(df_households, hts.calculate_consumption_units(df_persons), on = "household_id") diff --git a/data/hts/edgt_lyon/cleaned_cerema.py b/data/hts/edgt_lyon/cleaned_cerema.py index d452820b..385fa3ee 100644 --- a/data/hts/edgt_lyon/cleaned_cerema.py +++ b/data/hts/edgt_lyon/cleaned_cerema.py @@ -22,7 +22,8 @@ def configure(context): "car": [13, 15, 21, 81], "car_passenger": [14, 16, 22, 82], "pt": [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 51, 52, 53, 61, 71, 91, 92, 94, 95], - "bike": [11, 17, 12, 18, 93], + "bicycle": [11, 17, 12, 18, 93], + # "motorbike": [13, 15], "walk": [1, 2] # Actually, 2 is not really explained, but we assume it is walk } @@ -105,9 +106,9 @@ def execute(context): df_persons["studies"] = df_persons["P7"].isin(["3", "4", "5"]) # Number of vehicles - df_households["number_of_vehicles"] = df_households["M6"] + df_households["M5"] - df_households["number_of_vehicles"] = df_households["number_of_vehicles"].astype(int) - df_households["number_of_bikes"] = df_households["M7"].astype(int) + df_households["number_of_cars"] = df_households["M6"].astype(int) + df_households["number_of_cars"] += df_households["M5"].astype(int) # motorbikes + df_households["number_of_bicycles"] = df_households["M7"].astype(int) # License df_persons["has_license"] = df_persons["P5"] == "1" @@ -180,11 +181,6 @@ def execute(context): # Nonrespondent of travel questionary section (number_of_trips = -1) df_persons["number_of_trips"] = df_persons["number_of_trips"].fillna(-1).astype(int) - # Passenger attribute - df_persons["is_passenger"] = df_persons["person_id"].isin( - df_trips[df_trips["mode"] == "car_passenger"]["person_id"].unique() - ) - # Calculate consumption units hts.check_household_size(df_households, df_persons) df_households = pd.merge(df_households, hts.calculate_consumption_units(df_persons), on = "household_id") diff --git a/data/hts/edgt_lyon/raw_adisp.py b/data/hts/edgt_lyon/raw_adisp.py index 5ec5f111..b69c6ce7 100644 --- a/data/hts/edgt_lyon/raw_adisp.py +++ b/data/hts/edgt_lyon/raw_adisp.py @@ -15,7 +15,7 @@ def configure(context): HOUSEHOLD_COLUMNS = { "ECH": str, "ZFM": str, # id - "M6": int, "M21": int, "M14": int, # number_of_cars, number_of_bikes, number_of_motorbikes + "M6": int, "M21": int, "M14": int, # number_of_cars, number_of_bicycles, number_of_motorbikes "COE0": float # weights } diff --git a/data/hts/egt/cleaned.py b/data/hts/egt/cleaned.py index 197da72b..cc7b706a 100644 --- a/data/hts/egt/cleaned.py +++ b/data/hts/egt/cleaned.py @@ -31,8 +31,8 @@ def configure(context): 1 : "pt", 2 : "car", 3 : "car_passenger", - 4 : "car", - 5 : "bike", + 4 : "car", # motorbike + 5 : "bicycle", #6 : "pt", # default (other) 7 : "walk" } @@ -99,9 +99,9 @@ def execute(context): df_persons["studies"] = df_persons["OCCP"].isin([3.0, 4.0, 5.0]) # Number of vehicles - df_households["number_of_vehicles"] = df_households["NB_2RM"] + df_households["NB_VD"] - df_households["number_of_vehicles"] = df_households["number_of_vehicles"].astype(int) - df_households["number_of_bikes"] = df_households["NB_VELO"].astype(int) + df_households["number_of_cars"] = df_households["NB_VD"].astype(int) + df_households["number_of_cars"] += df_households["NB_2RM"].astype(int) # motorbikes + df_households["number_of_bicycles"] = df_households["NB_VELO"].astype(int) # License df_persons["has_license"] = (df_persons["PERMVP"] == 1) | (df_persons["PERM2RM"] == 1) @@ -172,11 +172,6 @@ def execute(context): # Chain length df_persons["number_of_trips"] = df_persons["NBDEPL"].fillna(0).astype(int) - # Passenger attribute - df_persons["is_passenger"] = df_persons["person_id"].isin( - df_trips[df_trips["mode"] == "car_passenger"]["person_id"].unique() - ) - # Calculate consumption units hts.check_household_size(df_households, df_persons) df_households = pd.merge(df_households, hts.calculate_consumption_units(df_persons), on = "household_id") diff --git a/data/hts/entd/cleaned.py b/data/hts/entd/cleaned.py index 51bfd966..6f679105 100644 --- a/data/hts/entd/cleaned.py +++ b/data/hts/entd/cleaned.py @@ -28,7 +28,7 @@ def configure(context): MODES_MAP = [ ("1", "walk"), ("2", "car"), # - ("2.20", "bike"), # bike + ("2.20", "bicycle"), # bike ("2.23", "car_passenger"), # motorcycle passenger ("2.25", "car_passenger"), # same ("3", "car"), @@ -135,13 +135,12 @@ def execute(context): df_persons.loc[df_persons["age"] < 5, "studies"] = False # Number of vehicles - df_households["number_of_vehicles"] = 0 - df_households["number_of_vehicles"] += df_households["V1_JNBVEH"].fillna(0) - df_households["number_of_vehicles"] += df_households["V1_JNBMOTO"].fillna(0) - df_households["number_of_vehicles"] += df_households["V1_JNBCYCLO"].fillna(0) - df_households["number_of_vehicles"] = df_households["number_of_vehicles"].astype(int) + df_households["number_of_cars"] = df_households["V1_JNBVEH"].fillna(0) + df_households["number_of_cars"] += df_households["V1_JNBMOTO"].fillna(0) # motorbike + df_households["number_of_cars"] += df_households["V1_JNBCYCLO"].fillna(0) # motorbike + df_households["number_of_cars"] = df_households["number_of_cars"].astype(int) - df_households["number_of_bikes"] = df_households["V1_JNBVELOADT"].fillna(0).astype(int) + df_households["number_of_bicycles"] = df_households["V1_JNBVELOADT"].fillna(0).astype(int) # License df_persons["has_license"] = (df_persons["V1_GPERMIS"] == 1) | (df_persons["V1_GPERMIS2R"] == 1) @@ -236,11 +235,6 @@ def execute(context): df_persons["number_of_trips"] = df_persons["number_of_trips"].fillna(-1).astype(int) df_persons.loc[(df_persons["number_of_trips"] == -1) & df_persons["is_kish"], "number_of_trips"] = 0 - # Passenger attribute - df_persons["is_passenger"] = df_persons["person_id"].isin( - df_trips[df_trips["mode"] == "car_passenger"]["person_id"].unique() - ) - # Calculate consumption units hts.check_household_size(df_households, df_persons) df_households = pd.merge(df_households, hts.calculate_consumption_units(df_persons), on = "household_id") diff --git a/data/hts/hts.py b/data/hts/hts.py index 86bc0365..ca85beec 100644 --- a/data/hts/hts.py +++ b/data/hts/hts.py @@ -222,7 +222,7 @@ def calculate_consumption_units(df_persons): HOUSEHOLD_COLUMNS = [ "household_id", "household_weight", "household_size", - "number_of_vehicles", "number_of_bikes", "departement_id", + "number_of_cars", "number_of_bicycles", "departement_id", "consumption_units", # "income_class" ] @@ -231,7 +231,7 @@ def calculate_consumption_units(df_persons): "age", "sex", "employed", "studies", "has_license", "has_pt_subscription", "number_of_trips", "departement_id", "trip_weight", - "is_passenger", "socioprofessional_class" + "socioprofessional_class" ] TRIP_COLUMNS = [ diff --git a/data/od/cleaned.py b/data/od/cleaned.py index e13348f1..0765adfb 100644 --- a/data/od/cleaned.py +++ b/data/od/cleaned.py @@ -50,8 +50,8 @@ def execute(context): df_work["commute_mode"] = np.nan df_work.loc[df_work["TRANS"] == 1, "commute_mode"] = "no transport" df_work.loc[df_work["TRANS"] == 2, "commute_mode"] = "walk" - df_work.loc[df_work["TRANS"] == 3, "commute_mode"] = "bike" - df_work.loc[df_work["TRANS"] == 4, "commute_mode"] = "car" + df_work.loc[df_work["TRANS"] == 3, "commute_mode"] = "bicycle" + df_work.loc[df_work["TRANS"] == 4, "commute_mode"] = "car" # motorbike df_work.loc[df_work["TRANS"] == 5, "commute_mode"] = "car" df_work.loc[df_work["TRANS"] == 6, "commute_mode"] = "pt" df_work["commute_mode"] = df_work["commute_mode"].astype("category") diff --git a/documentation/plots/secondary_locations.py b/documentation/plots/secondary_locations.py index 296fb335..761aacaf 100644 --- a/documentation/plots/secondary_locations.py +++ b/documentation/plots/secondary_locations.py @@ -21,7 +21,6 @@ def execute(context): plt.figure() modes = list(context.stage("analysis.reference.hts.mode_distances").keys()) - #modes = ["car", "car_passenger", "pt", "bike", "walk"] for index, mode in enumerate(modes): mode_distribution = distributions[mode] @@ -71,10 +70,10 @@ def execute(context): limits = dict( car = 20 * 1e3, car_passenger = 20 * 1e3, pt = 20 * 1e3, - bike = 6 * 1e3, walk = 1 * 1e3 + bicycle = 6 * 1e3, walk = 1 * 1e3 ) - modes = ["car", "bike" if "bike" in modes else "walk" ] + modes = ["car", "bicycle" if "bicycle" in modes else "walk" ] for index, mode in enumerate(modes): plt.subplot(1, 2, index + 1) diff --git a/documentation/plots/sociodemographics/general.py b/documentation/plots/sociodemographics/general.py index 869f0604..81a055e6 100644 --- a/documentation/plots/sociodemographics/general.py +++ b/documentation/plots/sociodemographics/general.py @@ -79,11 +79,11 @@ def label(row): elif row["attribute"] == "household_size_class": return "Household size %s" % analysis.marginals.HOUSEHOLD_SIZE_LABELS[row["value"]] - elif row["attribute"] == "number_of_vehicles_class": - return "No. vehicles %s" % analysis.marginals.NUMBER_OF_VEHICLES_LABELS[row["value"]] + elif row["attribute"] == "number_of_cars_class": + return "No. vehicles %s" % analysis.marginals.NUMBER_OF_CARS_LABELS[row["value"]] - elif row["attribute"] == "number_of_bikes_class": - return "No. bicycles %s" % analysis.marginals.NUMBER_OF_BIKES_LABELS[row["value"]] + elif row["attribute"] == "number_of_bicycles_class": + return "No. bicycles %s" % analysis.marginals.NUMBER_OF_BICYCLES_LABELS[row["value"]] def add_labels(df_figure): df_figure["label"] = df_figure.apply(label, axis = 1, raw = False) @@ -115,7 +115,7 @@ def execute(context): ), dict( level = "household", label = "Number of households", size = plotting.WIDE_FIGSIZE, - marginals = ["household_size_class", "number_of_vehicles_class", "number_of_bikes_class"] + marginals = ["household_size_class", "number_of_cars_class", "number_of_bikes_class"] ) ] diff --git a/documentation/plotting.py b/documentation/plotting.py index 7900d8de..23dd10c2 100644 --- a/documentation/plotting.py +++ b/documentation/plotting.py @@ -23,7 +23,7 @@ car = "Car driver", car_passenger = "Car passenger", pt = "Public transport", - bike = "Bicycle", + bicycle = "Bicycle", walk = "Walking" ) diff --git a/matsim/runtime/eqasim.py b/matsim/runtime/eqasim.py index 72e4846e..0d1ecd1b 100644 --- a/matsim/runtime/eqasim.py +++ b/matsim/runtime/eqasim.py @@ -6,8 +6,8 @@ import matsim.runtime.maven as maven DEFAULT_EQASIM_VERSION = "1.5.0" -DEFAULT_EQASIM_BRANCH = "develop" -DEFAULT_EQASIM_COMMIT = "ece4932" +DEFAULT_EQASIM_BRANCH = "feat/model-2024" +DEFAULT_EQASIM_COMMIT = "7dae6d9" def configure(context): context.stage("matsim.runtime.git") diff --git a/matsim/scenario/households.py b/matsim/scenario/households.py index 2f47cfee..027923ba 100644 --- a/matsim/scenario/households.py +++ b/matsim/scenario/households.py @@ -8,7 +8,7 @@ def configure(context): context.stage("synthesis.population.enriched") -FIELDS = ["household_id", "person_id", "household_income", "car_availability", "bike_availability", "census_household_id"] +FIELDS = ["household_id", "person_id", "household_income", "car_availability", "bicycle_availability", "census_household_id"] def add_household(writer, household, member_ids): writer.start_household(household[FIELDS.index("household_id")]) @@ -16,7 +16,7 @@ def add_household(writer, household, member_ids): writer.start_attributes() writer.add_attribute("carAvailability", "java.lang.String", household[FIELDS.index("car_availability")]) - writer.add_attribute("bikeAvailability", "java.lang.String", household[FIELDS.index("bike_availability")]) + writer.add_attribute("bicycleAvailability", "java.lang.String", household[FIELDS.index("bicycle_availability")]) writer.add_attribute("household_income", "java.lang.Double", household[FIELDS.index("household_income")]) writer.add_attribute("censusId", "java.lang.Long", household[FIELDS.index("census_household_id")]) writer.end_attributes() diff --git a/matsim/scenario/population.py b/matsim/scenario/population.py index 2fc0fa4d..ab51013c 100644 --- a/matsim/scenario/population.py +++ b/matsim/scenario/population.py @@ -17,9 +17,9 @@ def configure(context): context.stage("synthesis.vehicles.vehicles") PERSON_FIELDS = [ - "person_id", "household_income", "car_availability", "bike_availability", + "person_id", "household_income", "car_availability", "bicycle_availability", "census_household_id", "census_person_id", "household_id", - "has_license", "has_pt_subscription", "is_passenger", + "has_license", "has_pt_subscription", "hts_id", "hts_household_id", "age", "employed", "sex" ] @@ -44,7 +44,7 @@ def add_person(writer, person, activities, trips, vehicles): writer.add_attribute("householdIncome", "java.lang.Double", person[PERSON_FIELDS.index("household_income")]) writer.add_attribute("carAvailability", "java.lang.String", person[PERSON_FIELDS.index("car_availability")]) - writer.add_attribute("bikeAvailability", "java.lang.String", person[PERSON_FIELDS.index("bike_availability")]) + writer.add_attribute("bicycleAvailability", "java.lang.String", person[PERSON_FIELDS.index("bicycle_availability")]) writer.add_attribute("censusHouseholdId", "java.lang.Long", person[PERSON_FIELDS.index("census_household_id")]) writer.add_attribute("censusPersonId", "java.lang.Long", person[PERSON_FIELDS.index("census_person_id")]) @@ -55,8 +55,6 @@ def add_person(writer, person, activities, trips, vehicles): writer.add_attribute("hasPtSubscription", "java.lang.Boolean", person[PERSON_FIELDS.index("has_pt_subscription")]) writer.add_attribute("hasLicense", "java.lang.String", writer.yes_no(person[PERSON_FIELDS.index("has_license")])) - writer.add_attribute("isPassenger", "java.lang.Boolean", person[PERSON_FIELDS.index("is_passenger")]) - writer.add_attribute("age", "java.lang.Integer", person[PERSON_FIELDS.index("age")]) writer.add_attribute("employed", "java.lang.String", person[PERSON_FIELDS.index("employed")]) writer.add_attribute("sex", "java.lang.String", person[PERSON_FIELDS.index("sex")][0]) diff --git a/matsim/simulation/prepare.py b/matsim/simulation/prepare.py index 7a73e6d8..7c00b373 100644 --- a/matsim/simulation/prepare.py +++ b/matsim/simulation/prepare.py @@ -116,23 +116,13 @@ def execute(context): eqasim.run(context, "org.eqasim.core.scenario.spatial.RunImputeSpatialAttribute", [ "--input-population-path", "prepared_population.xml.gz", "--output-population-path", "prepared_population.xml.gz", - "--input-network-path", "%snetwork.xml.gz" % context.config("output_prefix"), - "--output-network-path", "%snetwork.xml.gz" % context.config("output_prefix"), + "--input-schedule-path", "{}transit_schedule.xml.gz".format(context.config("output_prefix")), + "--output-schedule-path", "{}transit_schedule.xml.gz".format(context.config("output_prefix")), "--shape-path", "departments.shp", "--shape-attribute", "id", "--shape-value", "75", - "--attribute", "isUrban" + "--attribute", "isParis" ]) - - eqasim.run(context, "org.eqasim.core.scenario.spatial.RunAdjustCapacity", [ - "--input-path", "%snetwork.xml.gz" % context.config("output_prefix"), - "--output-path", "%snetwork.xml.gz" % context.config("output_prefix"), - "--shape-path", "departments.shp", - "--shape-attribute", "id", - "--shape-value", "75", - "--factor", str(0.8) - ]) - # Optionally, perform mode choice if context.config("mode_choice"): diff --git a/synthesis/output.py b/synthesis/output.py index 84c52a36..f605b280 100644 --- a/synthesis/output.py +++ b/synthesis/output.py @@ -131,8 +131,8 @@ def execute(context): "iris_id", "commune_id","departement_id","region_id"]].drop_duplicates("household_id"),how="left") df_households = df_households[[ "household_id","iris_id", "commune_id", "departement_id","region_id", - "car_availability", "bike_availability", - "number_of_vehicles", "number_of_bikes", + "car_availability", "bicycle_availability", + "number_of_cars", "number_of_bicycles", "income", "census_household_id" ]] diff --git a/synthesis/population/enriched.py b/synthesis/population/enriched.py index 15fc5649..74ec99e1 100644 --- a/synthesis/population/enriched.py +++ b/synthesis/population/enriched.py @@ -27,7 +27,8 @@ def execute(context): "person_id", "household_id", "census_person_id", "census_household_id", "age", "sex", "employed", "studies", - "number_of_vehicles", "household_size", "consumption_units", + "number_of_cars", + "household_size", "consumption_units", "socioprofessional_class" ]] @@ -45,11 +46,11 @@ def execute(context): df_hts_households = df_hts_households.rename(columns = { "household_id": "hts_household_id" }) df_population = pd.merge(df_population, df_hts_persons[[ - "hts_id", "hts_household_id", "has_license", "has_pt_subscription", "is_passenger" + "hts_id", "hts_household_id", "has_license", "has_pt_subscription", ]], on = "hts_id") df_population = pd.merge(df_population, df_hts_households[[ - "hts_household_id", "number_of_bikes" + "hts_household_id", "number_of_bicycles" ]], on = "hts_household_id") # Attach income @@ -68,22 +69,22 @@ def execute(context): assert initial_household_ids == final_household_ids # Add car availability - df_number_of_cars = df_population[["household_id", "number_of_vehicles"]].drop_duplicates("household_id") + df_number_of_cars = df_population[["household_id", "number_of_cars"]].drop_duplicates("household_id") df_number_of_licenses = df_population[["household_id", "has_license"]].groupby("household_id").sum().reset_index().rename(columns = { "has_license": "number_of_licenses" }) df_car_availability = pd.merge(df_number_of_cars, df_number_of_licenses) df_car_availability["car_availability"] = "all" - df_car_availability.loc[df_car_availability["number_of_vehicles"] < df_car_availability["number_of_licenses"], "car_availability"] = "some" - df_car_availability.loc[df_car_availability["number_of_vehicles"] == 0, "car_availability"] = "none" + df_car_availability.loc[df_car_availability["number_of_cars"] < df_car_availability["number_of_licenses"], "car_availability"] = "some" + df_car_availability.loc[df_car_availability["number_of_cars"] == 0, "car_availability"] = "none" df_car_availability["car_availability"] = df_car_availability["car_availability"].astype("category") df_population = pd.merge(df_population, df_car_availability[["household_id", "car_availability"]]) - # Add bike availability - df_population["bike_availability"] = "all" - df_population.loc[df_population["number_of_bikes"] < df_population["household_size"], "bike_availability"] = "some" - df_population.loc[df_population["number_of_bikes"] == 0, "bike_availability"] = "none" - df_population["bike_availability"] = df_population["bike_availability"].astype("category") + # Add bicycle availability + df_population["bicycle_availability"] = "all" + df_population.loc[df_population["number_of_bicycles"] < df_population["household_size"], "bicycle_availability"] = "some" + df_population.loc[df_population["number_of_bicycles"] == 0, "bicycle_availability"] = "none" + df_population["bicycle_availability"] = df_population["bicycle_availability"].astype("category") # Add age range for education df_population["age_range"] = "higher_education" diff --git a/synthesis/population/matched.py b/synthesis/population/matched.py index 5ab5bed0..fac9667f 100644 --- a/synthesis/population/matched.py +++ b/synthesis/population/matched.py @@ -195,8 +195,8 @@ def execute(context): df_target["income_class"] = INCOME_CLASS[hts](df_target) if "any_cars" in columns: - df_target["any_cars"] = df_target["number_of_vehicles"] > 0 - df_source["any_cars"] = df_source["number_of_vehicles"] > 0 + df_target["any_cars"] = df_target["number_of_cars"] > 0 + df_source["any_cars"] = df_source["number_of_cars"] > 0 # Perform statistical matching df_source = df_source.rename(columns = { "person_id": "hts_id" }) diff --git a/synthesis/population/spatial/secondary/locations.py b/synthesis/population/spatial/secondary/locations.py index b36fb214..8a6b96eb 100644 --- a/synthesis/population/spatial/secondary/locations.py +++ b/synthesis/population/spatial/secondary/locations.py @@ -85,7 +85,7 @@ def execute(context): # Resampling for calibration resample_distributions(distance_distributions, dict( - car = 0.0, car_passenger = 0.1, pt = 0.5, bike = 0.0, walk = -0.5 + car = 0.0, car_passenger = 0.1, pt = 0.5, bicycle = 0.0, walk = -0.5 )) # Segment into subsamples @@ -160,7 +160,7 @@ def process(context, arguments): # Set up assignment solver thresholds = dict( car = 200.0, car_passenger = 200.0, pt = 200.0, - bike = 100.0, walk = 100.0 + bicycle = 100.0, walk = 100.0 ) assignment_objective = DiscretizationErrorObjective(thresholds = thresholds) diff --git a/tests/test_determinism.py b/tests/test_determinism.py index e2755d7a..92d80dcb 100644 --- a/tests/test_determinism.py +++ b/tests/test_determinism.py @@ -69,7 +69,7 @@ def _test_determinism(index, data_path, tmpdir): REFERENCE_CSV_HASHES = { "ile_de_france_activities.csv": "53c44fb4026d2037729ee8ff1c8fb93f", - "ile_de_france_households.csv": "ca2a29ef13467326f937638f1ff8be1a", + "ile_de_france_households.csv": "60c8aafadb084cc56dceed407eba4af0", "ile_de_france_persons.csv": "ddbe9b418c915b14e888b54efbdf9b1e", "ile_de_france_trips.csv": "6c5f3427e41e683da768eeb53796a806", "ile_de_france_vehicle_types.csv": "00bee1ea6d7bc9af43ae6c7101dd75da", @@ -133,9 +133,9 @@ def _test_determinism_matsim(index, data_path, tmpdir): REFERENCE_HASHES = { #"ile_de_france_population.xml.gz": "e1407f918cb92166ebf46ad769d8d085", #"ile_de_france_network.xml.gz": "5f10ec295b49d2bb768451c812955794", - "ile_de_france_households.xml.gz": "64a0c9fab72aad51bc6adb926a1c9d44", + "ile_de_france_households.xml.gz": "936dd42548b205b822099dfd9a20d075", #"ile_de_france_facilities.xml.gz": "5ad41afff9ae5c470082510b943e6778", - "ile_de_france_config.xml": "30871dfbbd2b5bf6922be1dfe20ffe73", + "ile_de_france_config.xml": "6c2adf49fd7c0f7b28fb1a09397ed2b0", "ile_de_france_vehicles.xml.gz": "d7c8d0dba531a21dc83355b2f82778c2" }