lasso.Project

class lasso.Project(roadway_link_changes=None, roadway_node_changes=None, transit_changes=None, base_roadway_network=None, base_transit_network=None, base_cube_transit_network=None, build_cube_transit_network=None, project_name='', evaluate=False, parameters={})[source]

Bases: object

A single or set of changes to the roadway or transit system.

Compares a base and a build transit network or a base and build highway network and produces project cards.

Typical usage example:

test_project = Project.create_project(
    base_cube_transit_source=os.path.join(CUBE_DIR, "transit.LIN"),
    build_cube_transit_source=os.path.join(CUBE_DIR, "transit_route_shape_change"),
)
test_project.evaluate_changes()
test_project.write_project_card(
    os.path.join(SCRATCH_DIR, "t_transit_shape_test.yml")
)
DEFAULT_PROJECT_NAME

a class-level constant that defines what the project name will be if none is set.

STATIC_VALUES

a class-level constant which defines values that are not evaluated when assessing changes.

card_data

{“project”: <project_name>, “changes”: <list of change dicts>}

Type:

dict

pandas dataframe of CUBE roadway link changes.

Type:

DataFrame

roadway_node_changes

pandas dataframe of CUBE roadway node changes.

Type:

DataFrame

transit_changes
Type:

CubeTransit

base_roadway_network
Type:

RoadwayNetwork

base_cube_transit_network
Type:

CubeTransit

build_cube_transit_network
Type:

CubeTransit

project_name

name of the project, set to DEFAULT_PROJECT_NAME if not provided

Type:

str

parameters

an instance of the Parameters class which sets a bunch of parameters

__init__(roadway_link_changes=None, roadway_node_changes=None, transit_changes=None, base_roadway_network=None, base_transit_network=None, base_cube_transit_network=None, build_cube_transit_network=None, project_name='', evaluate=False, parameters={})[source]

ProjectCard constructor.

Parameters:
  • roadway_link_changes – dataframe of roadway changes read from a log file

  • roadway_node_changes – dataframe of roadway changes read from a log file

  • transit_changes – dataframe of transit changes read from a log file

  • base_roadway_network – RoadwayNetwork instance for base case

  • base_transit_network – StandardTransit instance for base case

  • base_cube_transit_network – CubeTransit instance for base transit network

  • build_cube_transit_network – CubeTransit instance for build transit network

  • project_name – name of the project

  • evaluate – defaults to false, but if true, will create card data

  • parameters – dictionary of parameter settings (see Parameters class) or an instance of Parameters. If not specified, will use default parameters.

returns: instance of ProjectCard

Methods

__init__([roadway_link_changes, ...])

ProjectCard constructor.

add_highway_changes([...])

Evaluates changes from the log file based on the base highway object and adds entries into the self.card_data dictionary.

add_transit_changes()

Evaluates changes between base and build transit objects and adds entries into the self.card_data dictionary.

create_project([roadway_log_file, ...])

Constructor for a Project instance.

determine_roadway_network_changes_compatability(...)

Checks to see that any links or nodes that change exist in base roadway network.

emme_id_to_wrangler_id(emme_link_change_df, ...)

rewrite the emme id with wrangler id, using the emme wrangler id crosswalk located in database folder

emme_name_to_wrangler_name(...)

rename emme names to wrangler names using crosswalk file

evaluate_changes()

Determines which changes should be evaluated, initiates self.card_data to be an aggregation of transit and highway changes.

get_object_from_network_build_command()

determine the network build object is node or link

get_operation_from_network_build_command()

determine the network build object action type

read_logfile(logfilename)

Reads a Cube log file and returns separate dataframes of roadway_link_changes and roadway_node_changes

read_network_build_file(networkbuildfilename)

Reads a emme network build file and returns separate dataframes of roadway_link_changes and roadway_node_changes

write_project_card([filename])

Writes project cards.

Attributes

CALCULATED_VALUES

DEFAULT_PROJECT_NAME

STATIC_VALUES

add_highway_changes(limit_variables_to_existing_network=False)[source]

Evaluates changes from the log file based on the base highway object and adds entries into the self.card_data dictionary.

Parameters:

limit_variables_to_existing_network (bool) – True if no ad-hoc variables. Default to False.

add_transit_changes()[source]

Evaluates changes between base and build transit objects and adds entries into the self.card_data dictionary.

static create_project(roadway_log_file=None, roadway_shp_file=None, roadway_csv_file=None, network_build_file=None, emme_node_id_crosswalk_file=None, emme_name_crosswalk_file=None, base_roadway_dir=None, base_transit_dir=None, base_cube_transit_source=None, build_cube_transit_source=None, roadway_link_changes=None, roadway_node_changes=None, transit_changes=None, base_roadway_network=None, base_cube_transit_network=None, build_cube_transit_network=None, project_name=None, recalculate_calculated_variables=False, recalculate_distance=False, parameters={}, **kwargs)[source]

Constructor for a Project instance.

Parameters:
  • roadway_log_file – File path to consuming logfile or a list of logfile paths.

  • roadway_shp_file – File path to consuming shape file for roadway changes.

  • roadway_csv_file – File path to consuming csv file for roadway changes.

  • network_build_file – File path to consuming EMME network build for network changes.

  • base_roadway_dir – Folder path to base roadway network.

  • base_transit_dir – Folder path to base transit network.

  • base_cube_transit_source – Folder path to base transit network or cube line file string.

  • base_cube_transit_file – File path to base transit network.

  • build_cube_transit_source – Folder path to build transit network or cube line file string.

  • build_cube_transit_file – File path to build transit network.

  • roadway_link_changes – pandas dataframe of CUBE roadway link changes.

  • roadway_node_changes – pandas dataframe of CUBE roadway node changes.

  • transit_changes – build transit changes.

  • base_roadway_network – Base roadway network object.

  • base_cube_transit_network – Base cube transit network object.

  • build_cube_transit_network – Build cube transit network object.

  • project_name – If not provided, will default to the roadway_log_file filename if provided (or the first filename if a list is provided)

  • recalculate_calculated_variables – if reading in a base network, if this is true it will recalculate variables such as area type, etc. This only needs to be true if you are creating project cards that are changing the calculated variables.

  • recalculate_distance – recalculate the distance variable. This only needs to be true if you are creating project cards that change the distance.

  • parameters – dictionary of parameters

  • crs (int) – coordinate reference system, ESPG number

  • node_foreign_key (str) – variable linking the node table to the link table

  • link_foreign_key (list) – list of variable linking the link table to the node foreign key

  • shape_foreign_key (str) – variable linking the links table and shape table

  • unique_link_ids (list) – list of variables unique to each link

  • unique_node_ids (list) – list of variables unique to each node

  • modes_to_network_link_variables (dict) – Mapping of modes to link variables in the network

  • modes_to_network_nodes_variables (dict) – Mapping of modes to node variables in the network

  • managed_lanes_node_id_scalar (int) – Scalar values added to primary keys for nodes for corresponding managed lanes.

  • managed_lanes_link_id_scalar (int) – Scalar values added to primary keys for links for corresponding managed lanes.

  • managed_lanes_required_attributes (list) – attributes that must be specified in managed lane projects.

  • keep_same_attributes_ml_and_gp (list) – attributes to copy to managed lanes from parallel general purpose lanes.

Returns:

A Project instance.

static determine_roadway_network_changes_compatability(base_roadway_network, roadway_link_changes, roadway_node_changes, parameters)[source]

Checks to see that any links or nodes that change exist in base roadway network.

static emme_id_to_wrangler_id(emme_link_change_df, emme_node_change_df, emme_transit_changes_df, emme_node_id_crosswalk_file)[source]

rewrite the emme id with wrangler id, using the emme wrangler id crosswalk located in database folder

static emme_name_to_wrangler_name(emme_link_change_df, emme_node_change_df, emme_name_crosswalk_file)[source]

rename emme names to wrangler names using crosswalk file

evaluate_changes()[source]

Determines which changes should be evaluated, initiates self.card_data to be an aggregation of transit and highway changes.

get_object_from_network_build_command()[source]

determine the network build object is node or link

Parameters:

row – network build command history dataframe

Returns:

‘N’ for node, ‘L’ for link

get_operation_from_network_build_command()[source]

determine the network build object action type

Parameters:

row – network build command history dataframe

Returns:

‘A’, ‘C’, ‘D’

static read_logfile(logfilename)[source]

Reads a Cube log file and returns separate dataframes of roadway_link_changes and roadway_node_changes

Parameters:

logfilename (str or list[str]) – File path to CUBE logfile or list of logfile paths.

Returns:

A DataFrame reprsentation of the log file.

static read_network_build_file(networkbuildfilename)[source]

Reads a emme network build file and returns separate dataframes of roadway_link_changes and roadway_node_changes

Parameters:

networkbuildfilename (str or list[str]) – File path to emme nework build file or list of network build file paths.

Returns:

A DataFrame representation of the network build file

write_project_card(filename=None)[source]

Writes project cards.

Parameters:

filename (str) – File path to output .yml

Returns:

None

CALCULATED_VALUES = ['area_type', 'county', 'assign_group', 'centroidconnect']
DEFAULT_PROJECT_NAME = 'USER TO define'
STATIC_VALUES = ['model_link_id', 'area_type', 'county', 'centroidconnect']