@@ -26,7 +26,6 @@ class MatrixTableSettings(PydanticReadable):
2626class MatrixSettings (PydanticReadable ):
2727 file_name : Path
2828 tables : list [MatrixTableSettings ] = []
29- is_tap : bool = False
3029
3130
3231class WriteTripMatricesSettings (PydanticReadable ):
@@ -62,9 +61,7 @@ def write_trip_matrices(
6261 then aggregates trip counts and writes OD matrices to OMX. Save annotated
6362 trips table to pipeline if desired.
6463
65- Writes taz trip tables for one and two zone system. Add ``is_tap:True`` to
66- the settings file to identify an output matrix as tap level trips as opposed
67- to taz level trips.
64+ Writes taz trip tables for one and two zone system.
6865
6966 For one zone system, uses the land use table for the set of possible tazs.
7067 For two zone system, uses the taz skim zone names for the set of possible
@@ -351,7 +348,6 @@ def write_matrices(
351348 orig_index ,
352349 dest_index ,
353350 model_settings : WriteTripMatricesSettings ,
354- is_tap = False ,
355351):
356352 """
357353 Write aggregated trips to OMX format.
@@ -371,42 +367,40 @@ def write_matrices(
371367 logger .error ("Missing MATRICES setting in write_trip_matrices.yaml" )
372368
373369 for matrix in matrix_settings :
374- matrix_is_tap = matrix .is_tap
375-
376- if matrix_is_tap == is_tap : # only write tap matrices to tap matrix files
377- filename = str (matrix .file_name )
378- filepath = state .get_output_file_path (filename )
379- logger .info ("opening %s" % filepath )
380- file = omx .open_file (str (filepath ), "w" ) # possibly overwrite existing file
381- table_settings = matrix .tables
382-
383- for table in table_settings :
384- table_name = table .name
385- col = table .data_field
386-
387- if col not in aggregate_trips :
388- logger .error (f"missing { col } column in aggregate_trips DataFrame" )
389- return
390-
391- hh_weight_col = model_settings .HH_EXPANSION_WEIGHT_COL
392- if hh_weight_col :
393- aggregate_trips [col ] = (
394- aggregate_trips [col ] / aggregate_trips [hh_weight_col ]
395- )
396-
397- data = np .zeros ((len (zone_index ), len (zone_index )))
398- data [orig_index , dest_index ] = aggregate_trips [col ]
399- logger .debug (
400- "writing %s sum %0.2f" % (table_name , aggregate_trips [col ].sum ())
370+
371+ filename = str (matrix .file_name )
372+ filepath = state .get_output_file_path (filename )
373+ logger .info ("opening %s" % filepath )
374+ file = omx .open_file (str (filepath ), "w" ) # possibly overwrite existing file
375+ table_settings = matrix .tables
376+
377+ for table in table_settings :
378+ table_name = table .name
379+ col = table .data_field
380+
381+ if col not in aggregate_trips :
382+ logger .error (f"missing { col } column in aggregate_trips DataFrame" )
383+ return
384+
385+ hh_weight_col = model_settings .HH_EXPANSION_WEIGHT_COL
386+ if hh_weight_col :
387+ aggregate_trips [col ] = (
388+ aggregate_trips [col ] / aggregate_trips [hh_weight_col ]
401389 )
402- file [table_name ] = data # write to file
403390
404- # include the index-to-zone map in the file
405- logger . info (
406- "adding %s mapping for %s zones to %s"
407- % ( zone_index . name , zone_index . size , filename )
391+ data = np . zeros (( len ( zone_index ), len ( zone_index )))
392+ data [ orig_index , dest_index ] = aggregate_trips [ col ]
393+ logger . debug (
394+ "writing %s sum %0.2f" % ( table_name , aggregate_trips [ col ]. sum () )
408395 )
409- file .create_mapping (zone_index .name , zone_index .to_numpy ())
396+ file [table_name ] = data # write to file
397+
398+ # include the index-to-zone map in the file
399+ logger .info (
400+ "adding %s mapping for %s zones to %s"
401+ % (zone_index .name , zone_index .size , filename )
402+ )
403+ file .create_mapping (zone_index .name , zone_index .to_numpy ())
410404
411- logger .info ("closing %s" % filepath )
412- file .close ()
405+ logger .info ("closing %s" % filepath )
406+ file .close ()
0 commit comments