Skip to content

Commit baf7c73

Browse files
committed
fix pnr bug, fill na and 0 values in link change evaluation
1 parent 862210d commit baf7c73

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

lasso/mtc.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,9 @@ def roadway_standard_to_mtc_network(
17541754
)
17551755
# roadway_network.nodes_mtc_df["pnr"]=roadway_network.nodes_mtc_df["pnr"].fillna(0)
17561756
WranglerLogger.info("Setting PNR value and converting it to string")
1757-
roadway_network.nodes_mtc_df["pnr"] = np.where(roadway_network.nodes_mtc_df['pnr'].isin([0,'',' ']), '0.0', '1.0')
1757+
roadway_network.nodes_mtc_df["pnr"] = np.where(
1758+
roadway_network.nodes_mtc_df['pnr'].isin([0, '0.0', '0', '',' ']), '0.0', '1.0'
1759+
)
17581760

17591761
# CUBE expect node id to be N
17601762
roadway_network.nodes_mtc_df.rename(columns={"model_node_id": "N"}, inplace=True)

lasso/parameters.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,10 @@ def __init__(self, **kwargs):
944944

945945
self.drive_buffer = 6
946946

947-
#self.network_build_crs = CRS("EPSG:2875")
948-
#self.project_card_crs = CRS("EPSG:4326")
949-
#self.transformer = pyproj.Transformer.from_crs(
950-
# self.network_build_crs, self.project_card_crs, always_xy=True
951-
#)
947+
self.network_build_crs = CRS("EPSG:2875")
948+
self.project_card_crs = CRS("EPSG:4326")
949+
self.transformer = pyproj.Transformer.from_crs(
950+
self.network_build_crs, self.project_card_crs, always_xy=True
951+
)
952952

953953
self.__dict__.update(kwargs)

lasso/project.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ def _process_single_link_change(change_row, changeable_col):
11531153
if col == "distance":
11541154
if (
11551155
abs(
1156-
(change_row[col] - float(base_row[col]))
1156+
(float(change_row[col]) - float(base_row[col]))
11571157
/ base_row[col].astype(float)
11581158
)
11591159
> 0.01
@@ -1375,6 +1375,7 @@ def _consolidate_actions(log, base, key_list):
13751375
& set(self.base_roadway_network.links_df.columns)
13761376
)
13771377
- set(Project.STATIC_VALUES)
1378+
- set(["cntype","distance"]) # will be calculated in model network
13781379
)
13791380

13801381
cols_in_changes_not_in_net = list(
@@ -1389,6 +1390,12 @@ def _consolidate_actions(log, base, key_list):
13891390
)
13901391
)
13911392

1393+
for c in changeable_col:
1394+
if c in self.parameters.string_col:
1395+
self.base_roadway_network.links_df[c].fillna("", inplace=True)
1396+
else:
1397+
self.base_roadway_network.links_df[c].fillna(0, inplace=True)
1398+
13921399
change_link_dict_list = _process_link_changes(link_changes_df, changeable_col)
13931400

13941401
if len(node_changes_df) != 0:

0 commit comments

Comments
 (0)