quetzal.model.preparationmodel module

class quetzal.model.preparationmodel.PreparationModel(*args, **kwargs)[source]

Bases: quetzal.model.model.Model, quetzal.model.cubemodel.cubeModel

preparation_cast_network(nearest_method='nodes', weight='length', penalty_factor=1, speed=3, replace_nodes=False, dumb_cast=False, **nc_kwargs)[source]
Finds a path for the transport lines in an actual road network
  • requires: nodes, links, road_nodes, road_links
  • builds: links
Parameters:
  • nearest_method – if ‘links’, looks for the nearest link to a stop in road_links and links the stop to its end_node (b). If ‘node’ looks for the actual nearest node in road_nodes.
  • nodes_checkpoints – mandatory transit nodes
  • factor (penalty) –

Ng_kwargs:

preparation_clusterize_nodes(n_clusters, **kwargs)[source]
clusterize nodes
  • requires: nodes
  • builds: links, nodes
preparation_clusterize_zones(max_zones=500, cluster_column=None, is_od_stack=False, **kwargs)[source]
clusterize zones
  • requires: zones, volumes
  • builds: zones, volumes, cluster_series
preparation_drop_redundant_zone_to_transit()[source]
preparation_footpaths(road=False, speed=3, max_length=None, n_clusters=None, **kwargs)[source]
  • requires: nodes
  • builds: footpaths
preparation_logit(mode=1, pt_mode=1, pt_path=1, segments=[], time=-1, price=-1, transfers=-1, time_shift=None, route_types=None)[source]
  • requires:
  • builds: mode_utility, mode_nests, logit_scales, utility_values
Parameters:
  • mode – phi parameter used in the logit choice between modes
  • pt_mode – phi parameter used in the logit choice between pt modes
  • pt_mode – phi parameter used in the logit choice between pt paths
  • segments – the demand segments that will have to chose ex [‘car’, ‘nocar’]
  • time – number of utility units by seconds
  • price – number of utility units by currency unit
  • transfers – number of utility units by transfer

we should have 1 >= mode >= pt_mode >= pt_path > 0 if the three of them are equal to 1 the nested logit will be equivalent to a flat logit

preparation_map_tracks(agg={'gps_speed': <function PreparationModel.<lambda>>}, buffer=50, smoothing_span=100, *args, **kwargs)[source]
preparation_ntlegs(short_leg_speed=2, long_leg_speed=10, threshold=1000, n_ntlegs=5, max_ntleg_length=5000, zone_to_transit=True, zone_to_road=False)[source]
Builds the centroids and the ntlegs
  • requires: zones, nodes
  • builds: centroids, zone_to_transit, zone_to_road
Parameters:
  • ntleg_speed – in km/h
  • n_ntlegs – int
  • max_ntleg_length – in m

example:

sm.step_ntlegs(
    n_ntlegs=5,
    walk_speed=2,
    short_leg_speed=3,
    long_leg_speed=15,
    threshold=500,
    max_ntleg_length=5000
)
quetzal.model.preparationmodel.read_hdf(filepath)[source]
quetzal.model.preparationmodel.read_json(folder)[source]