Commit 4232cc0f authored by Aurore Sallard's avatar Aurore Sallard
Browse files

Adding secondary locations

parent 9bd54326
Pipeline #86225 failed with stage
......@@ -12,35 +12,40 @@ from tqdm import tqdm
def configure(context):
context.config("output_path")
context.config("raw_data_path")
context.config("data_path")
context.config("analysis_path")
context.stage("analysis.import_syn_trips")
#context.stage("analysis.import_syn_trips")
def import_data_synthetic(context):
filepath = "%s/syn_trips.csv" % context.config["output_path"]
df_trips = pd.read_csv(filepath, encoding = "latin1")
filepath = "%s/trips_with_distance.csv" % context.config("output_path")
df_trips = pd.read_csv(filepath, encoding = "latin1", sep = ";")
filepath = "%s/persons.csv" % context.config["output_path"]
filepath = "%s/persons.csv" % context.config("output_path")
df_persons = pd.read_csv(filepath, encoding = "latin1", sep = ";")
df_syn = df_trips.merge(df_persons, left_on="person_id", right_on="person_id")
df_syn = df_persons.merge(df_trips, left_on="person_id", right_on="person_id")
df_syn = df_syn[df_syn["age"] >= 6]
t_id = df_syn["person_id"].values.tolist()
df_persons_no_trip = df_persons[np.logical_not(df_persons["person_id"].isin(t_id))]
df_persons_no_trip = df_persons_no_trip.set_index(["person_id"])
print("Synthetic: ", len(df_syn), ", ", len(df_persons_no_trip))
df_persons_no_trip = df_persons_no_trip[df_persons_no_trip["age"] >= 6]
print("Synthetic: ", len(list(set(df_syn["person_id"].values.tolist()))), ", ", len(df_persons_no_trip))
return df_syn, df_persons_no_trip
def import_data_actual(context):
df_act_persons = pd.read_csv(
"%s/microcensus/zielpersonen.csv" % context.config["raw_data_path"],
"%s/microcensus/zielpersonen.csv" % context.config("data_path"),
sep = ",", encoding = "latin1", parse_dates = ["USTag"]
)
filepath = "%s/microcensus_trips.csv" % context.config["output_path"]
filepath = "%s/microcensus_trips.csv" % context.config("output_path")
df_act_trips = pd.read_csv(filepath, encoding = "latin1")
# Merging with person information, correcting trips with erroneous purpose
......@@ -50,6 +55,11 @@ def import_data_actual(context):
df_act_persons["weight_person"] = df_act_persons["WP"]
df_act_persons["date"] = df_act_persons["USTag"]
df_act_persons["weekend"] = False
df_act_persons.loc[df_act_persons["tag"] == 6, "weekend"] = True
df_act_persons.loc[df_act_persons["tag"] == 7, "weekend"] = True
df_act_persons = df_act_persons[~df_act_persons["weekend"]]
# Driving license
df_act_persons["driving_license"] = df_act_persons["f20400a"] == 1
......@@ -66,9 +76,9 @@ def import_data_actual(context):
df_act_persons["age_class"] = np.digitize(df_act_persons["age"], c.AGE_CLASS_UPPER_BOUNDS)
df_act_persons.rename(columns = {"binary_car_availability":"car_availability"}, inplace = True)
df_act = df_act_trips.merge(df_act_persons[["person_id", "weight_person", "employed",
"age", "sex", "car_availability"]],
on=["person_id"], how='left')
df_px = df_act_persons[["person_id", "weight_person", "employed",
"age", "sex", "car_availability"]]
df_act = df_act_trips.merge(df_px, on=["person_id"], how='left')
df_act.loc[(df_act["purpose"]=='work') & (df_act["age"] < 16), "purpose"]="other"
# Only keep the persons that could have been used in activity chain matching
......@@ -80,27 +90,10 @@ def import_data_actual(context):
df_persons_no_trip = df_act_persons[np.logical_not(df_act_persons["person_id"].isin(t_id))]
df_persons_no_trip = df_persons_no_trip.set_index(["person_id"])
print(df_act.columns)
return df_act, df_persons_no_trip
def aux_data_frame(df_act, df_syn):
pers_ids = list(set(df_syn["person_id"].values.tolist()))
ids = []
chains = []
for pid in tqdm(pers_ids):
df = df_syn[df_syn["person_id"] == pid]
purposes = df["following_purpose"].values.tolist()
chain = "h-" + "-".join([purpose[0] for purpose in purposes])
#print(chain)
ids.append(pid)
chains.append(chain)
df_aux_syn = pd.DataFrame.from_dict({"person_id": ids, "weights": [1 for i in range(len(ids))], "chain": chains})
df_act["person_id"] = df_act.index
pers_ids = list(set(df_act["person_id"].values.tolist()))
......@@ -112,13 +105,27 @@ def aux_data_frame(df_act, df_syn):
df = df_act[df_act["person_id"] == pid]
weight = np.mean(df["weight_person"].values.tolist())
purposes = df["purpose"].values.tolist()
chain = "h-" + "-".join([purpose[0] for purpose in purposes])
chain = "home-" + "-".join([purpose for purpose in purposes])
ids.append(pid)
weights.append(weight)
chains.append(chain)
df_aux_act = pd.DataFrame.from_dict({"person_id": ids, "weight_person":weights, "chain": chains})
pers_ids = list(set(df_syn["person_id"].values.tolist()))
ids = []
chains = []
for pid in tqdm(pers_ids):
df = df_syn[df_syn["person_id"] == pid]
purposes = df["following_purpose"].values.tolist()
chain = "home-" + "-".join([purpose for purpose in purposes])
ids.append(pid)
chains.append(chain)
df_aux_syn = pd.DataFrame.from_dict({"person_id": ids, "weights": [1 for i in range(len(ids))], "chain": chains})
return df_aux_act, df_aux_syn
......@@ -127,6 +134,7 @@ def activity_chains_comparison(context, all_CC, suffix = None):
all_CC["synthetic Count"] = all_CC ["synthetic Count"] / all_CC["synthetic Count"].sum() *100
all_CC["actual Count"] = all_CC["actual Count"] / all_CC["actual Count"].sum() *100
all_CC = all_CC.sort_values(by=['actual Count'], ascending=False)
all_CC.to_csv("%s/actchains_DF.csv" % context.config("analysis_path"))
# First step done: plot activity chain counts
title_plot = "Synthetic and HTS activity chain comparison"
......@@ -416,23 +424,22 @@ def execute(context):
# 1. ACTIVITY CHAINS
# Creating the new dataframes with activity chain counts
#syn_CC = myutils.process_synthetic_activity_chain_counts(df_syn)
syn_CC.loc[len(syn_CC) + 1] = pd.Series({"Chain": "h", "synthetic Count": df_syn_no_trip.shape[0] })
syn_CC.loc[len(syn_CC) + 1] = pd.Series({"Chain": "home", "synthetic Count": df_syn_no_trip.shape[0] })
#act_CC = myutils.process_actual_activity_chain_counts(df_act, df_aux)
act_CC.loc[len(act_CC) + 1] = pd.Series({"Chain": "h", "actual Count": np.sum(df_act_no_trip["weight_person"].values.tolist())})
act_CC.loc[len(act_CC) + 1] = pd.Series({"Chain": "home", "actual Count": np.sum(df_act_no_trip["weight_person"].values.tolist())})
# Merging together, comparing
all_CC = pd.merge(syn_CC, act_CC, on = "Chain", how = "left")
all_CC = pd.merge(syn_CC, act_CC, on = "Chain", how = "outer")
activity_chains_comparison(context, all_CC)
# Number of activities
activity_counts_comparison(context, all_CC)
#activity_counts_comparison(context, all_CC)
# Number of activities per purposes
activity_counts_per_purpose(context, all_CC)
#activity_counts_per_purpose(context, all_CC)
# 2. MODE AND DESTINATION PURPOSE
#mode_purpose_comparison(context, df_syn, df_act)
......@@ -440,21 +447,21 @@ def execute(context):
# 3. CROWFLY DISTANCES
# 3.1. Compute the distances
df_syn_dist = compute_distances_synthetic(df_syn)
df_act_dist = compute_distances_actual(df_act)
#df_syn_dist = compute_distances_synthetic(df_syn)
#df_act_dist = compute_distances_actual(df_act)
print(list(set(df_syn["following_purpose"].values.tolist())))
#print(list(set(df_syn["following_purpose"].values.tolist())))
# 3.2 Prepare for plotting
df_act_dist["x"] = df_act_dist["weight_person"] * df_act_dist["crowfly_distance"]
#df_act_dist["x"] = df_act_dist["weight_person"] * df_act_dist["crowfly_distance"]
act = df_act_dist.groupby(["purpose"]).sum()["x"] / df_act_dist.groupby(["purpose"]).sum()["weight_person"]
syn = df_syn_dist.groupby(["following_purpose"]).mean()["crowfly_distance"]
print(syn)
#act = df_act_dist.groupby(["purpose"]).sum()["x"] / df_act_dist.groupby(["purpose"]).sum()["weight_person"]
#syn = df_syn_dist.groupby(["following_purpose"]).mean()["crowfly_distance"]
#print(syn)
# 3.3 Ready to plot!
myplottools.plot_comparison_bar(context, imtitle = "distancepurpose.png", plottitle = "Crowfly distance", ylabel = "Mean crowfly distance [km]", xlabel = "", lab = syn.index, actual = act, synthetic = syn, t = None, xticksrot = True )
all_the_plot_distances(context, df_act_dist, df_syn_dist)
#myplottools.plot_comparison_bar(context, imtitle = "distancepurpose.png", plottitle = "Crowfly distance", ylabel = "Mean crowfly distance [km]", xlabel = "", lab = syn.index, actual = act, synthetic = syn, t = None, xticksrot = True )
#all_the_plot_distances(context, df_act_dist, df_syn_dist)
# 3.4 Distance from home to education
#syn_0, act_0, act_w0 = compare_dist_educ(context, df_syn, df_act)
......
......@@ -7,16 +7,16 @@ import shutil
def configure(context):
context.config("output_path")
context.config("raw_data_path")
context.config("data_path")
context.config("analysis_path")
def import_data(context):
with gzip.open("%s/population_with_secondary_locations.xml.gz" % context.config["output_path"], 'rb') as f_in:
with open("%s/population_complete.xml" % context.config["output_path"], 'wb') as f_out:
with gzip.open("%s/population_with_secondary_locations.xml.gz" % context.config("output_path"), 'rb') as f_in:
with open("%s/population_complete.xml" % context.config("output_path"), 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
xml_tree = ET.parse("%s/population_complete.xml" % context.config["output_path"])
xml_tree = ET.parse("%s/population_complete.xml" % context.config("output_path"))
population = xml_tree.getroot()
return population
......
......@@ -64,9 +64,6 @@ def plot_comparison_bar(context, imtitle, plottitle, ylabel, xlabel, lab, actual
actual_means = actual
synthetic_means = synthetic
print("SYNTHETIC MEANS")
print(synthetic_means)
x = np.arange(len(labels)) # the label locations
width = w # the width of the bars
......@@ -91,25 +88,26 @@ def plot_comparison_bar(context, imtitle, plottitle, ylabel, xlabel, lab, actual
#plt.rcParams.update({'font.size': 12})
plt.xticks(rotation=30)
fig.tight_layout()
plt.savefig("%s/" % context.config["analysis_path"] + imtitle)
plt.savefig("%s/" % context.config("analysis_path") + imtitle)
#plt.rcParams.update({'font.size': 18})
def plot_comparison_hist_purpose(context, title, actual_df, synthetic_df, bins = np.linspace(0,25,120), dpi = 300, cols = 3, rows = 2):
modelist = synthetic_df["following_purpose"].unique()
print(modelist)
rows = (len(modelist) // 3) + (len(modelist) % 3 != 0)
plt.rcParams['figure.dpi'] = dpi
fig, axes = plt.subplots(nrows=rows, ncols=cols)
fig, axes = plt.subplots(nrows=rows, ncols=cols, figsize = (5*cols, 3*rows))
idx=0
for r in range(rows):
for c in range(cols):
if idx < len(modelist):
x = synthetic_df[synthetic_df["following_purpose"]==modelist[idx]]["crowfly_distance"]
y = actual_df[actual_df["purpose"]==modelist[idx]][["crowfly_distance", "weight_person"]]
axes = add_small_hist(axes, r, c, modelist[idx], x, y, bins)
idx = idx + 1
fig.tight_layout()
plt.savefig("%s/" % context.config["analysis_path"] + title)
plt.savefig("%s/" % context.config("analysis_path") + title)
......@@ -129,24 +127,26 @@ def plot_comparison_hist_mode(context, title, actual_df, synthetic_df, bins = np
fig.delaxes(axes[1,2])
fig.tight_layout()
plt.savefig("%s/" % context.config["analysis_path"] + title)
plt.savefig("%s/" % context.config("analysis_path") + title)
def plot_comparison_cdf_purpose(context, title, actual_df, synthetic_df, dpi = 300, cols = 3, rows = 2):
modelist = synthetic_df["following_purpose"].unique()
rows = (len(modelist) // 3) + (len(modelist) % 3 != 0)
plt.rcParams['figure.dpi'] = dpi
fig, axes = plt.subplots(nrows=rows, ncols=cols)
fig, axes = plt.subplots(nrows=rows, ncols=cols, figsize = (5*cols, 3*rows))
idx=0
for r in range(rows):
for c in range(cols):
if idx < len(modelist):
x = synthetic_df[synthetic_df["following_purpose"]==modelist[idx]]["crowfly_distance"]
y = actual_df[actual_df["purpose"]==modelist[idx]][["crowfly_distance", "weight_person"]]
axes = add_small_cdf(axes, r, c, modelist[idx], x, y)
idx = idx + 1
fig.tight_layout()
plt.savefig("%s/" % context.config["analysis_path"] + title)
plt.savefig("%s/" % context.config("analysis_path") + title)
def plot_comparison_cdf_mode(context, title, actual_df, synthetic_df, bins = np.linspace(0,25,120), dpi = 300, cols = 3, rows = 2):
......@@ -165,7 +165,7 @@ def plot_comparison_cdf_mode(context, title, actual_df, synthetic_df, bins = np.
fig.delaxes(axes[1,2])
fig.tight_layout()
plt.savefig("%s/" % context.config["analysis_path"] + title)
plt.savefig("%s/" % context.config("analysis_path") + title)
......@@ -200,7 +200,7 @@ def plot_mode_share(context, title, df_syn, df2, amdf2, dpi = 300):
autolabel(rects2)
fig.tight_layout()
plt.savefig("%s/" % context.config["analysis_path"] + title)
plt.savefig("%s/" % context.config("analysis_path") + title)
plt.show()
......
# General pipeline settings
working_directory: /home/asallard/Scenarios/Switzerland/cache
flowchart_path: /home/asallard/Scenarios/Switzerland/cache/flowchart.json
working_directory: /nas/asallard/Switzerland/cache_170221/act_true
flowchart_path: /nas/asallard/Switzerland/output_170221/flowchart.json
dryrun: false
# Requested stages
run:
# - data.statpop.persons
# - data.statpop.projections.households
# - data.statpop.scaled
# - population.matched
# - population.output
- matsim.run
# - data.statpop.persons
# - data.statpop.projections.households
- data.statpop.statpop
# - population.matched
# - data.microcensus.trips
# - population.destinations
# - synthesis.population.destinations
# - synthesis.population.spatial.secondary.locations
# - matsim.facilities
# - matsim.population
# - matsim.households
# - matsim.run
# - analysis.analysis
# - population.output
# These are configuration options that we use in the pipeline
config:
......@@ -18,11 +26,13 @@ config:
random_seed: 0
hot_deck_matching_runners: 2
disable_progress_bar: false
java_memory: 10G
input_downsampling: 0.01
java_memory: 80G
input_downsampling: 0.1
enable_scaling: true
scaling_year: 2020
use_freight: true
use_detailed_activities: false
hafas_date: 01.10.2018
data_path: /home/asallard/Scenarios/Switzerland/Data
output_path: /home/asallard/Scenarios/Switzerland/output
data_path: /nas/ivtmatsim/scenarios/switzerland/data
output_path: /nas/asallard/Switzerland/output_170221/act_true
analysis_path: /nas/asallard/Switzerland/analysis_170221/act_true
......@@ -130,7 +130,8 @@ def execute(context):
remove_ids = set(df_mz_persons["person_id"]) - set(df_mz_trips["person_id"])
initial_size = len(df_mz_persons)
df_mz_persons = df_mz_persons[~df_mz_persons["person_id"].isin(remove_ids)]
# TODO Uncomment if you DO WANT to exclude people staying at home all day
#df_mz_persons = df_mz_persons[~df_mz_persons["person_id"].isin(remove_ids)]
# Note: Around 7000 of them are those, which do not even have an activity chain in the first place
# because they have not been asked.
......
......@@ -7,9 +7,11 @@ from tqdm import tqdm
def configure(context):
context.config("data_path")
context.config("output_path")
context.config("use_detailed_activities")
def execute(context):
data_path = context.config("data_path")
det_activities = context.config("use_detailed_activities")
df_mz_trips = pd.read_csv("%s/microcensus/wege.csv" % data_path, encoding = "latin1")
df_mz_stages = pd.read_csv("%s/microcensus/etappen.csv" % data_path, encoding = "latin1")
......@@ -17,7 +19,7 @@ def execute(context):
df_mz_trips = df_mz_trips[[
"HHNR", "WEGNR", "f51100", "f51400", "wzweck1", "wzweck2", "wmittel",
"S_X_CH1903", "S_Y_CH1903", "Z_X_CH1903", "Z_Y_CH1903", "W_X_CH1903", "W_Y_CH1903",
"w_rdist"
"w_rdist", "f51800a", "f51700_weg"
]]
df_mz_stages = df_mz_stages[[
......@@ -74,6 +76,7 @@ def execute(context):
df_mz_trips.loc[df_mz_trips["wzweck1"] == 12, "purpose"] = "unknown" # Other
df_mz_trips.loc[df_mz_trips["wzweck1"] == 13, "purpose"] = "border" # Going out of country
if det_activities == "true":
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 4, df_mz_trips["f51800a"] == 1), "purpose"] = "grocery"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 4, df_mz_trips["f51800a"] >= 2), "purpose"] = "other(S)"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 4, df_mz_trips["f51800a"] <= 0), "purpose"] = "other(S)"
......@@ -98,7 +101,11 @@ def execute(context):
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] >= 17), "purpose"] = "other(L)"
# Adjust trips back home
df_mz_trips.loc[df_mz_trips["wzweck2"] > 1, "purpose"] = "home"
df_mz_trips.loc[df_mz_trips["wzweck2"] >= 2, "purpose"] = "home"
# For now exclude loop trips
#df_mz_trips.loc[df_mz_trips["wzweck2"] == 3, "purpose"] = "loop"
#df_mz_trips = df_mz_trips[df_mz_trips["purpose"] != "loop"]
# Adjust times
df_mz_trips.loc[:, "departure_time"] = df_mz_trips["f51100"] * 60
......
......@@ -156,6 +156,6 @@ def execute(context):
"home_municipality_id", "home_quarter_id", "canton_id", "population_density", "sp_region", "ovgk",
"statpop_person_id", "statpop_household_id"]]
df = data.statpop.head_of_household.impute(df)
df.to_csv("statpop.csv")
return df
import gzip
import io
import pandas as pd
import matsim.writers
import numpy as np
def configure(context):
context.stage("synthesis.population.destinations")
context.stage("synthesis.population.enriched")
context.stage("synthesis.population.spatial.home.locations")
context.config("use_detailed_activities")
FIELDS_DETAILED = [
"destination_id", "destination_x", "destination_y",
"offers_work", "offers_education", "offers_leisure", "offers_grocery", "offers_other(S)", "offers_culture", "education_type", "offers_religion", "offers_gastronomy", "offers_sport", "offers_other(L)", "offers_other", "offers_visits", "offers_volunteer",
"offers_outdoor"
]
FIELDS = [
FIELDS_NOT_DETAILED = [
"destination_id", "destination_x", "destination_y",
"offers_work", "offers_education", "offers_leisure", "offers_shop", "offers_other"
"offers_work", "offers_education", "offers_leisure", "education_type", "offers_shop", "offers_other",
]
def make_options(item):
def make_options_detailed(item):
options = []
if item[4]: options.append("work")
if item[5]: options.append("education")
if item[6]: options.append("other")
if item[7]: options.append("leisure")
if item[6]: options.append("leisure")
if item[7]: options.append("grocery")
if item[8]: options.append("other(S)")
if item[9]: options.append("culture")
if item[11]: options.append("religion")
if item[12]: options.append("gastronomy")
if item[13]: options.append("sport")
if item[14]: options.append("other(L)")
if item[15]: options.append("other")
if item[16]: options.append("visits")
if item[17]: options.append("volunteer")
if item[18]: options.append("outdoor")
return options
def make_options_not_detailed(item):
options = []
if item[4]: options.append("work")
if item[5]: options.append("education")
if item[6]: options.append("leisure")
if item[8]: options.append("shop")
if item[9]: options.append("other")
return options
def execute(context):
cache_path = context.cache_path
det_activities = context.config("use_detailed_activities")
# First, write actual facilities (from STATENT)
df_statent = context.stage("synthesis.population.destinations")
df_statent = df_statent[FIELDS]
if det_activities == "true":
df_statent = df_statent[FIELDS_DETAILED]
M = np.max(df_statent["destination_id"].values.tolist()) + 1
df_home = context.stage("synthesis.population.spatial.home.locations").copy()[["household_id", "geometry"]].rename({"household_id": "destination_id"}, axis = 1)
df_home.loc[:, "destination_id"] = np.array(range(M, M + len(df_home), 1))
df_home.loc[:, "offers_visits"] = True
df_home.loc[:, "offers_work"] = False
df_home.loc[:, "offers_education"] = False
df_home.loc[:, "offers_leisure"] = False
df_home.loc[:, "offers_grocery"] = False
df_home.loc[:, "offers_other(S)"] = False
df_home.loc[:, "offers_culture"] = False
df_home.loc[:, "education_type"] = False
df_home.loc[:, "offers_religion"] = False
df_home.loc[:, "offers_gastronomy"] = False
df_home.loc[:, "offers_sport"] = False
df_home.loc[:, "offers_other(L)"] = False
df_home.loc[:, "offers_other"] = False
df_home.loc[:, "offers_volunteer"] = False
df_home.loc[:, "offers_outdoor"] = False
df_home.loc[:, "destination_x"] = df_home["geometry"].apply(lambda x: x.x).values
df_home.loc[:, "destination_y"] = df_home["geometry"].apply(lambda x: x.y).values
df_home = pd.DataFrame(df_home)
print(df_home["destination_id"])
df_statent = pd.concat([df_statent, df_home])
else:
df_statent = df_statent[FIELDS_NOT_DETAILED]
with gzip.open("%s/facilities.xml.gz" % cache_path, "w+") as f:
with io.BufferedWriter(f, buffer_size=1024 * 1024 * 1024 * 2) as raw_writer:
......@@ -39,11 +96,28 @@ def execute(context):
for item in context.progress(df_statent.itertuples(), total=len(df_statent)):
writer.start_facility(item[1], item[2], item[3])
if det_activities == "true":
if item[4]: writer.add_activity("work")
if item[5]: writer.add_activity("education")
if item[6]: writer.add_activity("leisure")
if item[7]: writer.add_activity("grocery")
if item[8]: writer.add_activity("other(S)")
if item[9]: writer.add_activity("culture")
if item[11]: writer.add_activity("religion")
if item[12]: writer.add_activity("gastronomy")
if item[13]: writer.add_activity("sport")
if item[14]: writer.add_activity("other(L)")
if item[15]: writer.add_activity("other")
if item[16]: writer.add_activity("visits")
if item[17]: writer.add_activity("volunteer")
if item[18]: writer.add_activity("outdoor")
writer.end_facility()
else:
if item[4]: writer.add_activity("work")
if item[5]: writer.add_activity("education")
if item[6]: writer.add_activity("other")
if item[7]: writer.add_activity("leisure")
if item[6]: writer.add_activity("leisure")
if item[8]: writer.add_activity("shop")
if item[9]: writer.add_activity("other")
writer.end_facility()
# Second, write household facilities
......
......@@ -7,6 +7,7 @@ def configure(context):
context.config("output_path")
context.config("output_id")
context.stage("contracts.contracts")
context.stage("population.output")
def execute(context):
results_path = context.stage("matsim.run")
......
......@@ -4,40 +4,41 @@ import numpy as np
import shapely.geometry as geo
import os, datetime, json
def configure(context, require):
require.stage("population.sociodemographics")
require.stage("population.activities")
require.stage("population.trips")
require.stage("population.spatial.locations")
def configure(context):
context.stage("synthesis.population.enriched")
context.stage("synthesis.population.activities")
context.stage("synthesis.population.trips")
context.stage("synthesis.population.spatial.locations")
for option in ("output_path", "input_downsampling"):
require.config(option)
context.config(option)
def validate(context):
output_path = context.config["output_path"]
output_path = context.config("output_path")
if not os.path.isdir(output_path):
raise RuntimeError("Output directory must exist: %s" % output_path)
def execute(context):
output_path = context.config["output_path"]
output_path = context.config("output_path")
# Prepare households
df_households = context.stage("population.sociodemographics").rename(
df_households = context.stage("synthesis.population.enriched").rename(