Skip to content

Commit

Permalink
Only add in accel and decel secs if they're defined
Browse files Browse the repository at this point in the history
Relevent to issue #65
  • Loading branch information
Lisa Zorn committed May 8, 2017
1 parent bdd05ee commit 24d31dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fasttrips/Trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,10 @@ def update_trip_times(trips_df, MSA_RESULTS):
trips_df[Trip.VEHICLES_COLUMN_MAXIMUM_SPEED_FPS]/trips_df[Trip.VEHICLES_COLUMN_DECELERATION]

# update the travel time
trips_df[Trip.STOPTIMES_COLUMN_TRAVEL_TIME_SEC] = (trips_df[Trip.STOPTIMES_COLUMN_ORIGINAL_TRAVEL_TIME]/numpy.timedelta64(1, 's')) + trips_df["accel_secs"] + trips_df["decel_secs"]
trips_df[Trip.STOPTIMES_COLUMN_TRAVEL_TIME_SEC] = trips_df[Trip.STOPTIMES_COLUMN_ORIGINAL_TRAVEL_TIME]/numpy.timedelta64(1, 's')
trips_df.loc[ pandas.notnull(trips_df["accel_secs"]), Trip.STOPTIMES_COLUMN_TRAVEL_TIME_SEC] = trips_df[Trip.STOPTIMES_COLUMN_TRAVEL_TIME_SEC] + trips_df["accel_secs"]
trips_df.loc[ pandas.notnull(trips_df["decel_secs"]), Trip.STOPTIMES_COLUMN_TRAVEL_TIME_SEC] = trips_df[Trip.STOPTIMES_COLUMN_TRAVEL_TIME_SEC] + trips_df["decel_secs"]

trips_df[Trip.STOPTIMES_COLUMN_TRAVEL_TIME ] = trips_df[Trip.STOPTIMES_COLUMN_TRAVEL_TIME_SEC].map(lambda x: datetime.timedelta(seconds=x))

# put travel time + dwell together because that's the full time for a link (stop arrival time to next stop arrival time)
Expand Down

0 comments on commit 24d31dd

Please sign in to comment.