<jupyter_start><jupyter_text>START<jupyter_code>import sys
sys.path.insert(0, r'../../../quetzal')

from quetzal.model import stepmodel

import numpy as np
import pandas as pd
training_folder = '../../'
sm = stepmodel.read_zip(training_folder + 'model/{scen}/aon_pathfinder.zip'.format(scen=scenario))<jupyter_output>zones: 100%|███████████████████████████████████████████████████████████████████████████| 29/29 [00:01<00:00, 19.74it/s]<jupyter_text>generation- Production = Population- Attraction = Jobs<jupyter_code>sm.zones['emission'] =  sm.zones['pop'].astype(int) / 10 # peak hour generation
sm.zones['attraction'] =  sm.zones['emp'].astype(int) / 10
sm.zones['pop'].sum()<jupyter_output><empty_output><jupyter_text>car ownerscar owners distribution is based on car times<jupyter_code>motor_rate = 0.3
car = sm.copy()
car.zones['emission'] *= motor_rate
imp_matrix = car.car_los[
    ['origin', 'destination', 'time']
].set_index(['origin','destination']).unstack() 
imp_matrix = imp_matrix.replace(0, 120)

car.step_distribution(deterrence_matrix=imp_matrix)<jupyter_output><empty_output><jupyter_text>PT captivescar owners distribution is based on car times<jupyter_code>pt = sm.copy()
pt.zones['emission'] *= (1-motor_rate)
# Ici on prend comme fonction de coût le temps TC. Notez le .unstack() 
imp_matrix = pt.pt_los[
    ['origin', 'destination', 'gtime']
].set_index(['origin','destination']).unstack() 
imp_matrix = imp_matrix.replace(0, 120)
imp_matrix
pt.step_distribution(deterrence_matrix=imp_matrix)
pt.volumes<jupyter_output><empty_output><jupyter_text>merge matrices<jupyter_code>sm.volumes = pd.merge(
    car.volumes,
    pt.volumes,
    on=['origin', 'destination'],
    suffixes=[ '_car_owner', '_pt_captive']
).rename(columns={'volume_car_owner': 'car_owner', 'volume_pt_captive': 'pt_captive'})<jupyter_output><empty_output><jupyter_text>to_zip<jupyter_code>sm.to_zip(
    training_folder + 'model/{scen}/distribution.zip'.format(scen=scenario), 
    only_attributes=['volumes', 'epsg', 'coordinates_unit']
)<jupyter_output>jsons: 100%|█████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 40.75it/s]<jupyter_text>monitoring<jupyter_code>od = pd.merge(sm.volumes, sm.pt_los, on=['origin', 'destination'])
od = pd.merge(od, sm.car_los, on=['origin', 'destination'])
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, 2, figsize=[10, 5])
plot = od[['gtime']].plot(kind='hist', weights=od['pt_captive'], bins=50, alpha=0.5, ax=axes[0])
plot.set_title('car owners distribution')
plot = od[['time']].plot(kind='hist', weights=od['car_owner'], bins=50, alpha=0.5, ax=axes[1])
plot.set_title('PT captives distribution')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2208746784270489, 'fraction_numerical': 0.02462330025725836, 'mean_word_length': 7.837662337662338, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '368457', 'license': 'Apache-2.0', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1043, 'n_words': 156, 'path': 'quetzal_paris-master/notebooks/transport/B20_generation_distribution.ipynb', 'repo_name': 'avi-shake/Flensburg_Modeling', 'size': '2721'}