Skip to content

Commit

Permalink
Fix missing airport return trips
Browse files Browse the repository at this point in the history
  • Loading branch information
aber-sandag committed May 9, 2024
1 parent 1c4d433 commit 3c9fd6d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 42 deletions.
66 changes: 28 additions & 38 deletions src/asim/configs/common_airport/trip_mode_choice_annotate_trips.csv
Original file line number Diff line number Diff line change
Expand Up @@ -54,48 +54,38 @@ Description,Target,Expression
,_origin,"np.where((df.trip_mode == 'WALK') & (df.outbound == True), terminalMgra, _origin)"
,origin,_origin
#,,
,_is_drivealone," (df.trip_mode.isin(['PARK_LOC1','PARK_LOC2','PARK_LOC3','PARK_LOC4','PARK_LOC5','RENTAL']) & (_tour_participants ==1)) | (df.trip_mode.isin(['PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5']) & (df.trip_num == 2))"
,_is_shared2," (df.trip_mode.isin(['PARK_LOC1','PARK_LOC2','PARK_LOC3','PARK_LOC4','PARK_LOC5','RENTAL']) & ( _tour_participants ==2)) | (df.trip_mode.isin(['RIDEHAIL_LOC1','RIDEHAIL_LOC2','TAXI_LOC1','TAXI_LOC2','PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5']) & ( _tour_participants == 1) & (df['trip_num'] ==1))"
,_is_shared3," (df.trip_mode.isin(['PARK_LOC1','PARK_LOC2','PARK_LOC3','PARK_LOC4','PARK_LOC5','RENTAL', 'HOTEL_COURTESY', 'SHUTTLEVAN']) & (_tour_participants >= 3)) | (df.trip_mode.isin(['RIDEHAIL_LOC1','RIDEHAIL_LOC2','TAXI_LOC1','TAXI_LOC2','PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5', 'HOTEL_COURTESY', 'SHUTTLEVAN']) & (_tour_participants >=2) & (df.trip_num == 1))"
,arrival_mode, df.trip_mode
,_trip_mode, df.trip_mode
,_trip_mode," np.where(_is_drivealone, 'DRIVEALONE', _trip_mode)"
,_trip_mode," np.where(_is_shared2, 'SHARED2',_trip_mode)"
,_trip_mode," np.where((_is_shared3) | (df.trip_mode.isin(['HOTEL_COURTESY', 'SHUTTLEVAN'])), 'SHARED3', _trip_mode)"
,trip_mode,_trip_mode
#,,
,_cost_parking,"(arrival_mode=='PARK_LOC1')*parkLocation1CostDay*df.nights"
,_cost_parking,"_cost_parking+(arrival_mode=='PARK_LOC2')*parkLocation2CostDay*df.nights"
,_cost_parking,"_cost_parking+(arrival_mode=='PARK_LOC3')*parkLocation3CostDay*df.nights"
,_cost_parking,"_cost_parking+(arrival_mode=='PARK_LOC4')*parkLocation4CostDay*df.nights"
,cost_parking,"_cost_parking+(arrival_mode=='PARK_LOC5')*parkLocation5CostDay*df.nights"
,_cost_parking,"(df.trip_mode=='PARK_LOC1')*parkLocation1CostDay*df.nights"
,_cost_parking,"_cost_parking+(df.trip_mode=='PARK_LOC2')*parkLocation2CostDay*df.nights"
,_cost_parking,"_cost_parking+(df.trip_mode=='PARK_LOC3')*parkLocation3CostDay*df.nights"
,_cost_parking,"_cost_parking+(df.trip_mode=='PARK_LOC4')*parkLocation4CostDay*df.nights"
,cost_parking,"_cost_parking+(df.trip_mode=='PARK_LOC5')*parkLocation5CostDay*df.nights"
#,,
,_cost_fare_drive,0
,_cost_fare_drive,"_cost_fare_drive + np.where(arrival_mode == 'RIDEHAIL_LOC1',1,0) * (df.partySizeRideHailLocation1AutoDist*ridehailCostPerMile)"
,cost_fare_drive,"_cost_fare_drive + np.where(arrival_mode == 'RIDEHAIL_LOC2',1,0) * (df.partySizeRideHailLocation2AutoDist*ridehailCostPerMile)"
,_cost_fare_drive,"_cost_fare_drive + np.where(df.trip_mode == 'RIDEHAIL_LOC1',1,0) * (df.partySizeRideHailLocation1AutoDist*ridehailCostPerMile)"
,cost_fare_drive,"_cost_fare_drive + np.where(df.trip_mode == 'RIDEHAIL_LOC2',1,0) * (df.partySizeRideHailLocation2AutoDist*ridehailCostPerMile)"
#,,
#,_distance_walk,0
,_distance_walk,"(_origin_local_dist+_dest_local_dist) * np.where(trip_mode == 'WALK_LOC',1,0)"
,_distance_walk,"_distance_walk + (_origin_prm_dist+_dest_prm_dist) * np.where(trip_mode == 'WALK_PRM',1,0)"
,_distance_walk,"_distance_walk + (_origin_mix_dist+_dest_mix_dist) * np.where(trip_mode == 'WALK_MIX',1,0)"
,_distance_walk,"_distance_walk + _dest_local_dist * np.where(trip_mode == 'PNR_LOC',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_prm_dist * np.where(trip_mode == 'PNR_PRM',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_mix_dist * np.where(trip_mode == 'PNR_MIX',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_local_dist * np.where(trip_mode == 'KNR_LOC',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_prm_dist * np.where(trip_mode == 'KNR_PRM',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_mix_dist * np.where(trip_mode == 'KNR_MIX',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_local_dist * np.where(trip_mode == 'TNC_LOC',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_prm_dist * np.where(trip_mode == 'TNC_PRM',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_mix_dist * np.where(trip_mode == 'TNC_MIX',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_local_dist * np.where(trip_mode == 'PNR_LOC',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_prm_dist * np.where(trip_mode == 'PNR_PRM',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_mix_dist * np.where(trip_mode == 'PNR_MIX',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_local_dist * np.where(trip_mode == 'KNR_LOC',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_prm_dist * np.where(trip_mode == 'KNR_PRM',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_mix_dist * np.where(trip_mode == 'KNR_MIX',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_local_dist * np.where(trip_mode == 'TNC_LOC',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_prm_dist * np.where(trip_mode == 'TNC_PRM',1,0) * np.where(~df.outbound,1,0)"
,distance_walk,"_distance_walk + _origin_mix_dist * np.where(trip_mode == 'TNC_MIX',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"(_origin_local_dist+_dest_local_dist) * np.where(df.trip_mode == 'WALK_LOC',1,0)"
,_distance_walk,"_distance_walk + (_origin_prm_dist+_dest_prm_dist) * np.where(df.trip_mode == 'WALK_PRM',1,0)"
,_distance_walk,"_distance_walk + (_origin_mix_dist+_dest_mix_dist) * np.where(df.trip_mode == 'WALK_MIX',1,0)"
,_distance_walk,"_distance_walk + _dest_local_dist * np.where(df.trip_mode == 'PNR_LOC',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_prm_dist * np.where(df.trip_mode == 'PNR_PRM',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_mix_dist * np.where(df.trip_mode == 'PNR_MIX',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_local_dist * np.where(df.trip_mode == 'KNR_LOC',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_prm_dist * np.where(df.trip_mode == 'KNR_PRM',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_mix_dist * np.where(df.trip_mode == 'KNR_MIX',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_local_dist * np.where(df.trip_mode == 'TNC_LOC',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_prm_dist * np.where(df.trip_mode == 'TNC_PRM',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_mix_dist * np.where(df.trip_mode == 'TNC_MIX',1,0) * np.where(df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_local_dist * np.where(df.trip_mode == 'PNR_LOC',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_prm_dist * np.where(df.trip_mode == 'PNR_PRM',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_mix_dist * np.where(df.trip_mode == 'PNR_MIX',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _dest_local_dist * np.where(df.trip_mode == 'KNR_LOC',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_prm_dist * np.where(df.trip_mode == 'KNR_PRM',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_mix_dist * np.where(df.trip_mode == 'KNR_MIX',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_local_dist * np.where(df.trip_mode == 'TNC_LOC',1,0) * np.where(~df.outbound,1,0)"
,_distance_walk,"_distance_walk + _origin_prm_dist * np.where(df.trip_mode == 'TNC_PRM',1,0) * np.where(~df.outbound,1,0)"
,distance_walk,"_distance_walk + _origin_mix_dist * np.where(df.trip_mode == 'TNC_MIX',1,0) * np.where(~df.outbound,1,0)"
#,,
,time_mm,0
,distance_mm,0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description,Target,Expression
,vot3,trips.vot3
,distance,od_skims['DIST']
,_sample_rate,trips.household_id.map(households.sample_rate)
,add_driver," (trips.arrival_mode.isin(['RIDEHAIL_LOC1','RIDEHAIL_LOC2','TAXI_LOC1','TAXI_LOC2','PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5', 'HOTEL_COURTESY', 'SHUTTLEVAN']) & ( tour_participants == 1) & (trips['trip_num'] ==1)) | (trips.trip_mode.isin(['RIDEHAIL_LOC1','RIDEHAIL_LOC2','TAXI_LOC1','TAXI_LOC2','PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5', 'HOTEL_COURTESY', 'SHUTTLEVAN']) & (tour_participants >=2) & (trips.trip_num == 1))"
,add_driver," (trips.trip_mode.isin(['RIDEHAIL_LOC1','RIDEHAIL_LOC2','TAXI_LOC1','TAXI_LOC2','PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5', 'HOTEL_COURTESY', 'SHUTTLEVAN']) & ( tour_participants == 1) & (trips['trip_num'] ==1)) | (trips.trip_mode.isin(['RIDEHAIL_LOC1','RIDEHAIL_LOC2','TAXI_LOC1','TAXI_LOC2','PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5', 'HOTEL_COURTESY', 'SHUTTLEVAN']) & (tour_participants >=2) & (trips.trip_num == 1))"
,weightTrip,1/_sample_rate
,weightPersonTrip,"np.where(add_driver, tour_participants + 1, tour_participants )/_sample_rate"
# code time periods,,
Expand All @@ -16,9 +16,9 @@ Description,Target,Expression
,is_md,"trips.depart.between(time_periods['MD']['first_hour'], time_periods['MD']['last_hour'])"
,is_pm,"trips.depart.between(time_periods['PM']['first_hour'], time_periods['PM']['last_hour'])"
,is_ev,"trips.depart.between(time_periods['EV']['first_hour'], time_periods['EV']['last_hour'])"
,is_drivealone,"(trips.trip_mode == 'DRIVEALONE')"
,is_shared2,"(trips.trip_mode == 'SHARED2')"
,is_shared3,"(trips.trip_mode == 'SHARED3')"
,is_drivealone," (trips.trip_mode.isin(['PARK_LOC1','PARK_LOC2','PARK_LOC3','PARK_LOC4','PARK_LOC5','RENTAL']) & (_tour_participants ==1)) | (trips.trip_mode.isin(['PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5']) & (trips.trip_num == 2))"
,is_shared2," (trips.trip_mode.isin(['PARK_LOC1','PARK_LOC2','PARK_LOC3','PARK_LOC4','PARK_LOC5','RENTAL']) & ( _tour_participants ==2)) | (trips.trip_mode.isin(['RIDEHAIL_LOC1','RIDEHAIL_LOC2','TAXI_LOC1','TAXI_LOC2','PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5']) & ( _tour_participants == 1) & (trips['trip_num'] ==1))"
,is_shared3," (trips.trip_mode.isin(['PARK_LOC1','PARK_LOC2','PARK_LOC3','PARK_LOC4','PARK_LOC5','RENTAL', 'HOTEL_COURTESY', 'SHUTTLEVAN']) & (_tour_participants >= 3)) | (trips.trip_mode.isin(['RIDEHAIL_LOC1','RIDEHAIL_LOC2','TAXI_LOC1','TAXI_LOC2','PARK_ESCORT','CURB_LOC1','CURB_LOC2','CURB_LOC3','CURB_LOC4','CURB_LOC5', 'HOTEL_COURTESY', 'SHUTTLEVAN']) & (_tour_participants >=2) & (trips.trip_num == 1))"
,is_walk,trips.trip_mode == 'WALK'
,is_walk_LOC_transit,trips.trip_mode == 'WALK_LOC'
,is_walk_PRM_transit,trips.trip_mode == 'WALK_PRM'
Expand All @@ -30,6 +30,13 @@ Description,Target,Expression
,is_tnc_prm,trips.trip_mode.isin(['TNC_PRM'])
,is_tnc_mix,trips.trip_mode.isin(['TNC_MIX'])
#,,
,arrival_mode, trips.trip_mode
,_trip_mode, trips.trip_mode
,_trip_mode," np.where(is_drivealone, 'DRIVEALONE', _trip_mode)"
,_trip_mode," np.where(is_shared2, 'SHARED2',_trip_mode)"
,_trip_mode," np.where((is_shared3) | (trips.trip_mode.isin(['HOTEL_COURTESY', 'SHUTTLEVAN'])), 'SHARED3', _trip_mode)"
,trip_mode,_trip_mode
#,,
,costOperatingDrive,"np.where((is_drivealone) | (is_shared2) | (is_shared3), costPerMile * distance/100, np.NaN)"
#trip legs are swapped since origin is airport and home end is destination,,
,outbound, ~trips.outbound
Expand Down

0 comments on commit 3c9fd6d

Please sign in to comment.