lasso.Project¶
-
class
lasso.
Project
(roadway_changes=None, transit_changes=None, base_roadway_network=None, base_transit_network=None, build_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_transit_source=os.path.join(CUBE_DIR, "transit.LIN"), build_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
-
roadway_changes
¶ pandas dataframe of CUBE roadway changes.
- Type
DataFrame
-
transit_changes
¶ - Type
-
base_roadway_network
¶ - Type
RoadwayNetwork
-
base_transit_network
¶ - Type
-
build_transit_network
¶ - Type
-
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_changes=None, transit_changes=None, base_roadway_network=None, base_transit_network=None, build_transit_network=None, project_name='', evaluate=False, parameters={})[source]¶ ProjectCard constructor.
- Parameters
roadway_changes – dataframe of roadway changes read from a log file
transit_changes –
base_roadway_network – RoadwayNetwork instance for base case
base_transit_network – CubeTransit instance for base transit network
build_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_changes, transit_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.
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.
Checks to see that any links or nodes that change exist in base roadway network.
Determines which changes should be evaluated, initiates self.card_data to be an aggregation of transit and highway changes.
read_logfile
(logfilename)Reads a Cube log file and returns a dataframe of roadway_changes
write_project_card
([filename])Writes project cards.
Attributes
-
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, base_roadway_dir=None, base_transit_source=None, build_transit_source=None, roadway_changes=None, transit_changes=None, base_roadway_network=None, base_transit_network=None, build_transit_network=None, project_name=None, recalculate_calculated_variables=False, recalculate_distance=False, parameters={})[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.
base_roadway_dir – Folder path to base roadway network.
base_transit_source – Folder path to base transit network or cube line file string.
base_transit_file – File path to base transit network.
build_transit_source – Folder path to build transit network or cube line file string.
build_transit_file – File path to build transit network.
roadway_changes – pandas dataframe of CUBE roadway changes.
transit_changes – build transit changes.
base_roadway_network – Base roadway network object.
base_transit_network – Base transit network object.
build_transit_network – Build 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
- Returns
A Project instance.
-
static
determine_roadway_network_changes_compatability
(base_roadway_network, roadway_changes, parameters)[source]¶ Checks to see that any links or nodes that change exist in base roadway network.
-
evaluate_changes
()[source]¶ Determines which changes should be evaluated, initiates self.card_data to be an aggregation of transit and highway changes.
-
static
read_logfile
(logfilename)[source]¶ Reads a Cube log file and returns a dataframe of roadway_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.
- Return type
DataFrame
-
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']¶
-