Skip to content

Park-and-ride modeling #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: initial_model_setup
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions configs/park_and_ride_lot_choice.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Label,Description,Expression,coefficient
# Driving utilities,,,
util_drive_time,drive time from origin to lot,@(olt_skims['SOV_NT_M_TIME'] + lot_skims['SOV_NT_M_TIME']),coef_ivt_work
util_drive_cost,auto operating cost,@df.sov_auto_op_cost * (olt_skims['SOV_NT_M_TIME'] + lot_skims['SOV_NT_M_DIST']) / df.cost_sensitivity,coef_income_work
util_drive_rel_out,reliability outbound,"@olt_skims['SOV_NT_M_REL'] / np.minimum(olt_skims['SOV_NT_M_DIST'], 0.1)",coef_rel_out_work
util_drive_rel_inb,reliability inbound,"@lot_skims['SOV_NT_M_REL'] / np.minimum(olt_skims['SOV_NT_M_DIST'], 0.1)",coef_rel_inb_work
# Transit utilties,,,
util_first_wait,first wait time,@(ldt_skims['WALK_LOC_FIRSTWAIT'] + dlt_skims['WALK_LOC_FIRSTWAIT']),coef_wait_work
util_xfer_wait,transfer wait time,@(ldt_skims['WALK_LOC_XFERWAIT'] + dlt_skims['WALK_LOC_XFERWAIT']),coef_xwait_work
util_walk_time,walk time,@(ldt_skims['WALK_LOC_XFERWALK'] + dlt_skims['WALK_LOC_XFERWALK']),coef_xwalk_work
util_ivtt,in vehcile transit time,@(ldt_skims['WALK_LOC_TOTALIVTT'] + dlt_skims['WALK_LOC_TOTALIVTT']),coef_ivt_work
util_xfer_penalty,transfer penalty,"@(-23+23*np.exp(0.414*np.clip(ldt_skims['WALK_LOC_XFERS'], a_min=None,a_max=4))) + (-23+23*np.exp(0.414*np.clip(dlt_skims['WALK_LOC_XFERS'], a_min=None,a_max=4)))",coef_xfer_work
util_fare,transit fare,"@df.transitSubsidyPassDiscount * (odt_skims['WALK_LOC_FARE'] + dot_skims['WALK_LOC_FARE']) * 100*df.num_participants/df.cost_sensitivity",coef_income_work
# Size Term,,,
util_size_variable,Size variable,@df['park_and_ride_spaces'].apply(np.log1p),1
#util_sp_utility_adjustment,shadow price utility adjustment,@df['shadow_price_utility_adjustment'],1
25 changes: 25 additions & 0 deletions configs/park_and_ride_lot_choice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SPEC: park_and_ride_lot_choice.csv

COEFFICIENTS: park_and_ride_lot_choice_coeffs.csv

preprocessor:
SPEC: park_and_ride_lot_choice_preprocessor.csv
DF: df
TABLES:
- land_use
- vehicles
- tours


LANDUSE_PNR_SPACES_COLUMN: park_and_ride_spaces

# will check the tour destination to make sure transit access is available
# if no transit access, then no PNR lot will be available and could get
# zero probabilities error
TRANSIT_SKIMS_FOR_ELIGIBILITY:
- WALK_LOC_TOTALIVTT__PM

compute_settings:
protect_columns:
- out_period
- in_period
11 changes: 11 additions & 0 deletions configs/park_and_ride_lot_choice_coeffs.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
coefficient_name,value,constrain
coef_zero,0.0,T
# took work coefficients from tour mode choice model,,
coef_ivt_work,-0.016,F
coef_rel_out_work,-0.224,F
coef_rel_inb_work,-0.192,F
coef_income_work,-0.625,F
coef_xwalk_work,-0.04,F
coef_wait_work,-0.024,F
coef_xfer_work,-0.024,F
coef_xwait_work,-0.032,F
16 changes: 16 additions & 0 deletions configs/park_and_ride_lot_choice_preprocessor.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Description,Target,Expression,
local,_DF_IS_TOUR,'tour_type' in df.columns,
,is_atwork_subtour,(df.tour_category == 'atwork') if _DF_IS_TOUR else False,
,_parent_tour_veh,"reindex(tours['selected_vehicle'], df['parent_tour_id']) if 'selected_vehicle' in df.columns else np.nan",
,_parent_tour_mode,"reindex(tours['tour_mode'], df['parent_tour_id']) if 'tour_mode' in df.columns else np.nan",
,_sov_veh_option,"np.where(is_atwork_subtour, _parent_tour_veh, df.get('vehicle_occup_1', np.nan))",
,num_participants,df.number_of_participants if _DF_IS_TOUR else 1,
# Auto operating costs,,,
,sov_auto_op_cost,"reindex(vehicles.groupby('vehicle_type')['auto_operating_cost'].mean(), pd.Series(_sov_veh_option, df.index)) if 'vehicle_occup_1' in df.columns else np.nan",
,sov_auto_op_cost,"np.where(sov_auto_op_cost.isna() | (pd.Series(_sov_veh_option, df.index) == 'non_hh_veh'), costPerMile, sov_auto_op_cost)",
# cost coef,,,
,_income_exponent,"np.where(df.get('tour_type') == 'work', 0.6, 0.5) if _DF_IS_TOUR else 0.5",
,cost_sensitivity,"np.maximum(df.income,1000).pow(_income_exponent)",
transit pass subsidy,_transit_pass_subsidy,"df.get('transit_pass_subsidy', False)",
transit pass ownership,_transit_pass_ownership,"df.get('transit_pass_ownership', False)",
transit subsidy pass discount, transitSubsidyPassDiscount,"np.where(_transit_pass_subsidy | _transit_pass_ownership,0,1)",
1 change: 1 addition & 0 deletions configs/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ models:
- external_non_mandatory_destination
- non_mandatory_tour_scheduling
- vehicle_allocation
- park_and_ride_lot_choice
- tour_mode_choice_simulate
- atwork_subtour_frequency
- atwork_subtour_destination
Expand Down
20 changes: 10 additions & 10 deletions configs/tour_mode_choice.csv
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ util_WALK_LOC - Origin Mix,WALK_LOC - Origin Mix,oMGRAMix,,,,,,coef_oMix_wTran,,
util_WALK_LOC - Origin Intersection Density,WALK_LOC - Origin Intersection Density,oMGRATotInt,,,,,,coef_oIntDen_wTran,,,,,,,,,
util_WALK_LOC - Destination Employment Density,WALK_LOC - Destination Employment Density,dMGRAEmpDen,,,,,,coef_dEmpDen_wTran,,,,,,,,,
#,PNR_LOC,,,,,,,,,,,,,,,,
util_PNR_LOC_Unavailable,PNR_LOC - Unavailable,"@(df.pnr_local_available == False)|(df.get('num_escortees', 0)>0)",,,,,,,-999,,,,,,,,
util_PNR_LOC_Unavailable,PNR_LOC - Unavailable,"@(df.is_valid_pnr == False)|(df.get('num_escortees', 0)>0)",,,,,,,-999,,,,,,,,
util_PNRTransit_0Auto,PNRTransit_0Auto,@(df.auto_ownership==0),,,,,,,-999,,,,,,,,
util_PNR_LOC_Unavailable_for_persons_less_than_16,PNR_LOC - Unavailable for persons less than 16,age < 16,,,,,,,-999,,,,,,,,
util_PNR_LOC_In_vehicle_time,PNR_LOC - In-vehicle time,@(odt_skims['PNROUT_LOC_TOTALIVTT'] + dot_skims['PNRIN_LOC_TOTALIVTT'])*df.time_factor,,,,,,,coef_ivt,,,,,,,,
util_PNR_LOC_iwait_time,PNR_LOC - First iwait time,@(odt_skims['PNROUT_LOC_FIRSTWAIT']) + (dot_skims['PNRIN_LOC_FIRSTWAIT'])*df.time_factor,,,,,,,coef_wait,,,,,,,,
util_PNR_LOC_transfer_wait_time,PNR_LOC - transfer wait time,@(odt_skims['PNROUT_LOC_XFERWAIT'] + dot_skims['PNRIN_LOC_XFERWAIT'])*df.time_factor,,,,,,,coef_xwait,,,,,,,,
util_PNR_LOC_number_of_transfers,PNR_LOC - number of transfers,"@(-23+23*np.exp(0.414*np.clip(odt_skims['PNROUT_LOC_XFERS'] + df.mtnev_egr_xfer, a_min=None,a_max=4))) + (-23+23*np.exp(0.414*np.clip(dot_skims['PNRIN_LOC_XFERS'] + df.mtnev_egr_xfer, a_min=None,a_max=4))) *df.time_factor",,,,,,,coef_xferdrive,,,,,,,,
util_PNR_LOC_PNR_time,PNR_LOC - PNR time,@(odt_skims['PNROUT_LOC_ACC'] + dot_skims['PNRIN_LOC_EGR']) *df.time_factor,,,,,,,coef_acctime,,,,,,,,
util_PNR_LOC_PNR_cost,PNR_LOC - PNR cost,@(df.sov_auto_op_cost * ((odt_skims['PNROUT_LOC_ACC'] + dot_skims['PNRIN_LOC_EGR'])/60) *driveSpeed )/df.cost_sensitivity,,,,,,,coef_income,,,,,,,,
util_PNR_LOC_Walk_egress_time_(at_attraction_end),PNR_LOC - Walk egress time (at attraction end),"@np.where(df.nev_local_egress_available, df.nev_local_egress_time, np.where(df.microtransit_local_egress_available, df.microtransit_local_egress_time, 2*df.dest_local_time)) * df.time_factor",,,,,,,coef_acctime,,,,,,,,
util_PNR_LOC_In_vehicle_time,PNR_LOC - In-vehicle time,@df.transit_time_pnr * df.time_factor,,,,,,,coef_ivt,,,,,,,,
util_PNR_LOC_iwait_time,PNR_LOC - First iwait time,@df.iwait_pnr * df.time_factor,,,,,,,coef_wait,,,,,,,,
util_PNR_LOC_transfer_wait_time,PNR_LOC - transfer wait time,@df.xfer_wait_pnr * df.time_factor,,,,,,,coef_xwait,,,,,,,,
util_PNR_LOC_number_of_transfers,PNR_LOC - number of transfers,"@(-23+23*np.exp(0.414*np.clip(df.xfer_walk_pnr + df.mtnev_egr_xfer, a_min=None,a_max=4))) * df.time_factor",,,,,,,coef_xferdrive,,,,,,,,
util_PNR_LOC_PNR_time,PNR_LOC - PNR time,@(df.auto_time_pnr_out + df.auto_time_pnr_inb) * df.time_factor,,,,,,,coef_acctime,,,,,,,,
util_PNR_LOC_PNR_cost,PNR_LOC - PNR cost,@df.sov_auto_op_cost * (df.auto_dist_pnr_out + df.auto_dist_pnr_inb) / df.cost_sensitivity,,,,,,,coef_income,,,,,,,,
util_PNR_LOC_Walk_egress_time_(at_attraction_end),PNR_LOC - Walk egress time (at attraction end),"@df.walk_at_dest_end_pnr * df.time_factor",,,,,,,coef_acctime,,,,,,,,
util_PNR_LOC_wait_egress_time_(at_attraction_end),PNR_LOC - Egress mt/nev wait time (at attraction end),"@np.where(df.nev_local_egress_available, 2*nevWaitTime, np.where(df.microtransit_local_egress_available, 2*microtransitWaitTime, 0)) * df.time_factor",,,,,,,coef_wait,,,,,,,,
util_PNR_LOC_Walk_other_time,PNR_LOC - Walk other time,@(odt_skims['PNROUT_LOC_XFERWALK'] + dot_skims['PNRIN_LOC_XFERWALK'])*df.time_factor,,,,,,,coef_xwalk,,,,,,,,
util_PNR_LOC_Fare_and_operating_cost,PNR_LOC - Fare ,@df.transitSubsidyPassDiscount*(odt_skims['PNROUT_LOC_FARE'] + dot_skims['PNRIN_LOC_FARE'])*100*df.num_participants/df.cost_sensitivity,,,,,,,coef_income,,,,,,,,
util_PNR_LOC_Walk_other_time,PNR_LOC - Walk other time,@df.xfer_walk_pnr * df.time_factor,,,,,,,coef_xwalk,,,,,,,,
util_PNR_LOC_Fare_and_operating_cost,PNR_LOC - Fare ,@df.transitSubsidyPassDiscount * df.fare_pnr * 100 * df.num_participants / df.cost_sensitivity,,,,,,,coef_income,,,,,,,,
util_PNR_LOC - Age 16 to 24,PNR_LOC - Age 16 to 24,@(df.age > 15) & (df.age < 25),,,,,,,coef_age1624_tran,,,,,,,,
util_PNR_LOC - Age 41 to 55,PNR_LOC - Age 41 to 55,@(df.age > 40) & (df.age < 56),,,,,,,coef_age4155_tran,,,,,,,,
util_PNR_LOC - Age 56 to 64,PNR_LOC - Age 56 to 64,@(df.age > 55) & (df.age < 65),,,,,,,coef_age5664_tran,,,,,,,,
Expand Down
3 changes: 3 additions & 0 deletions configs/tour_mode_choice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ SPEC: tour_mode_choice.csv
COEFFICIENTS: tour_mode_choice_coefficients.csv
COEFFICIENT_TEMPLATE: tour_mode_choice_coefficients_template.csv

include_explicit_pnr: True
include_pnr_for_logsums: False

# so far, we can use the same spec as for non-joint tours
preprocessor:
SPEC: tour_mode_choice_annotate_choosers_preprocessor
Expand Down
17 changes: 15 additions & 2 deletions configs/tour_mode_choice_annotate_choosers_preprocessor.csv
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ Determining Tour Destination,destination,df.destination if 'destination' in df.c
,dest_local_time,dest_local_dist * 60/walkSpeed,
#,,,
,walk_local_available,(odt_skims['WALK_LOC_TOTALIVTT']>0) & (dot_skims['WALK_LOC_TOTALIVTT']>0),
,pnr_local_available,(odt_skims['PNROUT_LOC_TOTALIVTT']>0) & (dot_skims['PNRIN_LOC_TOTALIVTT']>0),
,knr_local_available,(odt_skims['KNROUT_LOC_TOTALIVTT']>0) & (dot_skims['KNRIN_LOC_TOTALIVTT']>0),
,tnc_local_available,(odt_skims['KNROUT_LOC_TOTALIVTT']>0) & (dot_skims['KNRIN_LOC_TOTALIVTT']>0),
# Micromobility times,,,
Expand Down Expand Up @@ -228,4 +227,18 @@ microtransit/nev egress transfer,mtnev_egr_xfer,microtransit_local_egress_availa
# transit subsidi pass discount,,,
transit pas subsidy,transit_pass_subsidy,"df.get('transit_pass_subsidy', False)",
transit pass ownership,transit_pass_ownership,"df.get('transit_pass_ownership', False)",
transit subsidy pass discount, transitSubsidyPassDiscount,"np.where(transit_pass_subsidy | transit_pass_ownership,0,1)",
transit subsidy pass discount, transitSubsidyPassDiscount,"np.where(transit_pass_subsidy | transit_pass_ownership,0,1)",
# PNR with lot choice known -- needs to preface expressions on available lot since -1 index on skims returns error,,,
park and ride zone id,_CALC_PNR,"'pnr_zone_id' in df.columns",
has valid pnr lot choice,is_valid_pnr,((df.pnr_zone_id > 0) & (ldt_skims['WALK_LOC_TOTALIVTT']>0) & (dlt_skims['WALK_LOC_TOTALIVTT']>0)) if _CALC_PNR else False,
outbound auto time for pnr,auto_time_pnr_out,"0 if not _CALC_PNR else np.where(is_valid_pnr, (olt_skims['SOV_NT_L_TIME'] * (_vot_bin_da == 1)) + (olt_skims['SOV_NT_M_TIME'] * (_vot_bin_da == 2)) + (olt_skims['SOV_NT_H_TIME'] * (_vot_bin_da == 3)), 0)",
inbound auto time for pnr,auto_time_pnr_inb,"0 if not _CALC_PNR else np.where(is_valid_pnr, (lot_skims['SOV_NT_L_TIME'] * (_vot_bin_da == 1)) + (lot_skims['SOV_NT_M_TIME'] * (_vot_bin_da == 2)) + (lot_skims['SOV_NT_H_TIME'] * (_vot_bin_da == 3)), 0)",
outbound auto dist for pnr,auto_dist_pnr_out,"0 if not _CALC_PNR else np.where(is_valid_pnr, (olt_skims['SOV_NT_L_DIST'] * (_vot_bin_da == 1)) + (olt_skims['SOV_NT_M_DIST'] * (_vot_bin_da == 2)) + (olt_skims['SOV_NT_H_DIST'] * (_vot_bin_da == 3)), 0)",
inbound auto dist for pnr,auto_dist_pnr_inb,"0 if not _CALC_PNR else np.where(is_valid_pnr, (lot_skims['SOV_NT_L_DIST'] * (_vot_bin_da == 1)) + (lot_skims['SOV_NT_M_DIST'] * (_vot_bin_da == 2)) + (lot_skims['SOV_NT_H_DIST'] * (_vot_bin_da == 3)), 0)",
in vehicle transit time pnr,transit_time_pnr,"0 if not _CALC_PNR else np.where(is_valid_pnr, (ldt_skims['WALK_LOC_TOTALIVTT'] + dlt_skims['WALK_LOC_TOTALIVTT']), 0)",
transfers outbound pnr,transfers_pnr,"0 if not _CALC_PNR else np.where(is_valid_pnr, (ldt_skims['WALK_LOC_XFERS'] + dlt_skims['WALK_LOC_XFERS']), 0)",
transfer walk times pnr,xfer_walk_pnr,"0 if not _CALC_PNR else np.where(is_valid_pnr, (ldt_skims['WALK_LOC_XFERWALK'] + dlt_skims['WALK_LOC_XFERWALK']), 0)",
transfer wait times pnr,xfer_wait_pnr,"0 if not _CALC_PNR else np.where(is_valid_pnr, (ldt_skims['WALK_LOC_XFERWAIT'] + dlt_skims['WALK_LOC_XFERWAIT']), 0)",
first wait times pnr,iwait_pnr,"0 if not _CALC_PNR else np.where(is_valid_pnr, (ldt_skims['WALK_LOC_FIRSTWAIT'] + dlt_skims['WALK_LOC_FIRSTWAIT']), 0)",
walking access and egress times at dest end pnr,walk_at_dest_end_pnr,"2 * dest_local_time",
fare pnr,fare_pnr,"0 if not _CALC_PNR else np.where(is_valid_pnr, (ldt_skims['WALK_LOC_FARE'] + dlt_skims['WALK_LOC_FARE']), 0)",
1 change: 1 addition & 0 deletions configs/tour_mode_choice_with_pnr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inherit_settings: tour_mode_choice.yaml
2 changes: 1 addition & 1 deletion extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import av_ownership
from . import external_identification
from . import external_location_choice
from . import adjust_auto_operating_cost
from . import adjust_auto_operating_cost
2 changes: 1 addition & 1 deletion extensions/adjust_auto_operating_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def adjust_auto_operating_cost(state: workflow.State, vehicles: pd.DataFrame):
)
vehicles["auto_operating_cost"] *= adjustment_factor

state.add_table("vehicles", vehicles)
state.add_table("vehicles", vehicles)
2 changes: 1 addition & 1 deletion extensions/av_ownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,4 @@ def av_ownership(
tracing.print_summary("av_ownership", households.av_ownership, value_counts=True)

if trace_hh_id:
state.tracing.trace_df(households, label=trace_label, warn_if_empty=True)
state.tracing.trace_df(households, label=trace_label, warn_if_empty=True)
2 changes: 1 addition & 1 deletion extensions/external_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,4 @@ def external_joint_tour_identification(
)

if trace_hh_id:
state.tracing.trace_df(tours, label=trace_label, warn_if_empty=True)
state.tracing.trace_df(tours, label=trace_label, warn_if_empty=True)
2 changes: 1 addition & 1 deletion extensions/external_location_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,4 @@ def external_joint_tour_destination(
index_label="tour",
columns=None,
warn_if_empty=True,
)
)
69 changes: 15 additions & 54 deletions model_data/crop_metro_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 85,
"execution_count": null,
"id": "93a5ee20",
"metadata": {},
"outputs": [],
Expand All @@ -24,21 +24,21 @@
},
{
"cell_type": "code",
"execution_count": 86,
"execution_count": null,
"id": "b9c8494b",
"metadata": {},
"outputs": [],
"source": [
"# read full input data\n",
"input_folder = r\"C:\\Users\\david.hensle\\OneDrive - Resource Systems Group, Inc\\Documents\\projects\\ODOT\\ctramp_to_asim_data_conversion\\output\"\n",
"input_folder = r\".\\metro_data\"\n",
"full_households = pd.read_csv(os.path.join(input_folder, 'households.csv'))\n",
"full_persons = pd.read_csv(os.path.join(input_folder, 'persons.csv'))\n",
"full_landuse = pd.read_csv(os.path.join(input_folder, 'land_use.csv'))\n"
]
},
{
"cell_type": "code",
"execution_count": 87,
"execution_count": null,
"id": "c5745470",
"metadata": {},
"outputs": [],
Expand All @@ -49,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": 88,
"execution_count": null,
"id": "c6f3e2ea",
"metadata": {},
"outputs": [],
Expand All @@ -65,33 +65,10 @@
},
{
"cell_type": "code",
"execution_count": 89,
"execution_count": null,
"id": "cc20387b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Missing 14 zones in cropped land use data:\n",
" MAZ TAZ\n",
"860 24282 1448\n",
"861 24283 1470\n",
"862 24322 1\n",
"863 24323 2\n",
"864 24324 4\n",
"865 24325 6\n",
"866 24326 7\n",
"867 24327 8\n",
"868 24328 9\n",
"869 24329 10\n",
"870 24330 12\n",
"871 24331 3\n",
"872 24332 5\n",
"873 24333 11\n"
]
}
],
"outputs": [],
"source": [
"missed_zones = sandag_landuse[~sandag_landuse['MAZ'].isin(cropped_landuse['MAZ'])]\n",
"print(f\"Missing {len(missed_zones)} zones in cropped land use data:\")\n",
Expand All @@ -100,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 90,
"execution_count": null,
"id": "2f2a12dd",
"metadata": {},
"outputs": [],
Expand All @@ -114,7 +91,7 @@
},
{
"cell_type": "code",
"execution_count": 91,
"execution_count": null,
"id": "4131663e",
"metadata": {},
"outputs": [],
Expand All @@ -127,18 +104,10 @@
},
{
"cell_type": "code",
"execution_count": 92,
"execution_count": null,
"id": "234b6584",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Saving 22484 households and 51830 persons to cropped data.\n"
]
}
],
"outputs": [],
"source": [
"cropped_households = full_households[full_households['MAZ'].isin(cropped_landuse['MAZ'])].copy()\n",
"cropped_persons = full_persons[full_persons['household_id'].isin(cropped_households['household_id'])].copy()\n",
Expand All @@ -151,31 +120,23 @@
},
{
"cell_type": "code",
"execution_count": 93,
"execution_count": null,
"id": "9599ec8d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Adding ENROLL_COLL data to land use.\n"
]
}
],
"outputs": [],
"source": [
"# need to add some school enrollment data to land use or else size terms are zero\n",
"for col in ['ENROLL_K8','ENROLL_912','ENROLL_COLL']:\n",
" if cropped_landuse[col].sum() == 0:\n",
" print(f\"Adding {col} data to land use.\")\n",
" # sample 10% of the zones to have enrollment\n",
" enrollment_zones = cropped_landuse.sample(frac=.1).index\n",
" cropped_landuse.loc[enrollment_zones, col] = np.random.randint(100, 1000, size=len(enrollment_zones))"
" cropped_landuse.loc[enrollment_zones, col] = np.random.randint(100, 1000, size=len(enrollment_zones))\n"
]
},
{
"cell_type": "code",
"execution_count": 94,
"execution_count": null,
"id": "0d190500",
"metadata": {},
"outputs": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"metadata": {},
"outputs": [],
"source": [
"input_data_folder = r'./PopulationSim_to_RSG/HH_GQ_combined'\n",
"output_data_folder = r'./output'\n",
"input_data_folder = r'C:\\Users\\david.hensle\\OneDrive - Resource Systems Group, Inc\\Documents\\projects\\ODOT\\ctramp_to_asim_data_conversion\\PopulationSim_to_RSG\\HH_GQ_combined'\n",
"output_data_folder = r'.\\..\\metro_data'\n",
"\n",
"assert os.path.exists(input_data_folder), f\"Input data folder {input_data_folder} does not exist.\"\n",
"assert os.path.exists(output_data_folder), f\"Output data folder {output_data_folder} does not exist.\""
Expand Down Expand Up @@ -290,7 +290,10 @@
"landuse['external_work'] = np.where(landuse['TAZ'] <= 10, 10, 0) # adding non-zero size for external models so model won't crash\n",
"landuse['external_nonwork'] = np.where(landuse['TAZ'] <= 10, 10, 0) # adding non-zero size for external models so model won't crash\n",
"landuse['external_MAZ'] = np.where(landuse['TAZ'] <= 10, 1, 0)\n",
"landuse['totint'] = 10 # total intersections"
"landuse['totint'] = 10 # total intersections\n",
"# number of park-and-ride spaces in the zone\n",
"# just sample a random 10 percent of zones to have park-and-ride spaces\n",
"landuse['park_and_ride_spaces'] = np.where(np.random.rand(len(landuse)) < 0.1, np.random.randint(50, 200), 0)"
]
},
{
Expand Down
Loading
Loading