Skip to content

Commit

Permalink
fix pnr bug, fill na and 0 values in link change evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
yueshuaing committed Sep 17, 2024
1 parent 862210d commit baf7c73
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lasso/mtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,9 @@ def roadway_standard_to_mtc_network(
)
# roadway_network.nodes_mtc_df["pnr"]=roadway_network.nodes_mtc_df["pnr"].fillna(0)
WranglerLogger.info("Setting PNR value and converting it to string")
roadway_network.nodes_mtc_df["pnr"] = np.where(roadway_network.nodes_mtc_df['pnr'].isin([0,'',' ']), '0.0', '1.0')
roadway_network.nodes_mtc_df["pnr"] = np.where(
roadway_network.nodes_mtc_df['pnr'].isin([0, '0.0', '0', '',' ']), '0.0', '1.0'
)

# CUBE expect node id to be N
roadway_network.nodes_mtc_df.rename(columns={"model_node_id": "N"}, inplace=True)
Expand Down
10 changes: 5 additions & 5 deletions lasso/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,10 +944,10 @@ def __init__(self, **kwargs):

self.drive_buffer = 6

#self.network_build_crs = CRS("EPSG:2875")
#self.project_card_crs = CRS("EPSG:4326")
#self.transformer = pyproj.Transformer.from_crs(
# self.network_build_crs, self.project_card_crs, always_xy=True
#)
self.network_build_crs = CRS("EPSG:2875")
self.project_card_crs = CRS("EPSG:4326")
self.transformer = pyproj.Transformer.from_crs(
self.network_build_crs, self.project_card_crs, always_xy=True
)

self.__dict__.update(kwargs)
9 changes: 8 additions & 1 deletion lasso/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ def _process_single_link_change(change_row, changeable_col):
if col == "distance":
if (
abs(
(change_row[col] - float(base_row[col]))
(float(change_row[col]) - float(base_row[col]))
/ base_row[col].astype(float)
)
> 0.01
Expand Down Expand Up @@ -1375,6 +1375,7 @@ def _consolidate_actions(log, base, key_list):
& set(self.base_roadway_network.links_df.columns)
)
- set(Project.STATIC_VALUES)
- set(["cntype","distance"]) # will be calculated in model network
)

cols_in_changes_not_in_net = list(
Expand All @@ -1389,6 +1390,12 @@ def _consolidate_actions(log, base, key_list):
)
)

for c in changeable_col:
if c in self.parameters.string_col:
self.base_roadway_network.links_df[c].fillna("", inplace=True)
else:
self.base_roadway_network.links_df[c].fillna(0, inplace=True)

change_link_dict_list = _process_link_changes(link_changes_df, changeable_col)

if len(node_changes_df) != 0:
Expand Down

0 comments on commit baf7c73

Please sign in to comment.