<jupyter_start><jupyter_text>MASTER FUNCTIONThe master function contains all the modules to build a simulation. All of the parameters are pre set for you and change them as you see fit. Below is the function and it's parameters and respective data types.```pythondef master_function(demand=demand,                    Date='2018-06-11',                    percentOfPassenger=.309,                     percentDropOff=.5,                    percentPickUp=.5,                    percentOfTNC=.255,                    percentOfTaxi=.027,                    percentOfTransit=.005,                    percentOfParking=.25,                    percentOfLimo=.01,                    percentOfRental=.144,                    dwell_times=dwell_time,                    years = 0,                    growth = 1.03,                    capacity = 50,                     peopleToCars = 1.7,                    peopleToCarsPolicy = 1.7,                    level = 'high',                    sigma=.5 0 is perfect driver and 1 is max imperfection                   ):```<jupyter_code>from __future__ import print_function
import xml.etree.ElementTree as ET
from xml.etree.ElementTree import Element, SubElement, Comment
from lxml import etree
from copy import copy
import os
import inspect
from xml.dom import minidom
import pandas as pd
import numpy as np
import random
import matplotlib.pyplot as plt
import seaborn as sns
import sys
import datetime

import ipywidgets as widgets
from ipywidgets import interact, interactive, fixed, interact_manual
from ipywidgets import ToggleButtons
import math 
import MasterModule as mm
import matplotlib
from plotly import __version__
%matplotlib inline
import cufflinks as cf
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot 
init_notebook_mode(connected=True)
init_notebook_mode(connected=True)
cf.go_offline()
import warnings
warnings.filterwarnings('ignore')

dwell_time = pd.read_csv("Dwell_Distributions.csv")
demand = pd.read_csv("../Example_Files/athena_sumo_v1.csv")
selected = pd.read_csv("selected_demand.csv")

figure = dwell_time.iplot(kind="hist", color=['#7a7a7a','#53a6a2'],title="Curbside Dwell Time Distributions",asFigure=True)
figure['layout']['yaxis1'].update({'title': {'text': 'Frequency'}})
figure['layout']['xaxis1'].update({'title': {'text': 'Seconds @ Curb'}})
figure.show()

test_df = pd.DataFrame()
for col in demand.columns:
    test_df[col] = [10]
test_df['scheduled_fight_time'] = ['2017-10-10 00:00:00']
test_df['year'] = [2017]
test_df['month'] = [10]
test_df['day'] = [10]
test_df.head()
# Importing dwelltimes
dwell_times = pd.read_csv("Dwell_Distributions.csv")
selected
def master_function(demand = demand,
                    dwell_times = dwell_times,
                    Date='2018-06-11',
                    percentOfPassenger=.309, 
                    percentDropOff=.5,
                    percentPickUp=.5,
                    percentOfTNC=.255,
                    percentOfTaxi=.027,
                    percentOfTransit=.005,
                    percentOfParking=.25,
                    percentOfLimo=.01,
                    percentOfRental=.144,
                    years = 0,
                    growth = 1.03,
                    capacity = 50, 
                    peopleToCars = 1.7,
                    peopleToCarsPolicy = 1.7,
                    level = 'high',
                    sigma=.5, #0 is perfect driver and 1 is max imperfection
                    Delete_Files =True
                   ):
    total = percentOfPassenger + percentOfTNC + percentOfTaxi + percentOfTransit + percentOfParking + percentOfRental + percentOfLimo 
    message = "Mode choices do not sum to 1; Seems to add to " + str(total)
    
    assert total == 1, message
    assert percentDropOff + percentPickUp == 1, "Drop off and Pickup must add to 1"
    # Get date in correct format
    strg = Date.split('-')
    if len(strg[1]) == 2 and strg[1][0] == '0':
        strg[1] = strg[1][1]    
    if len(strg[2]) == 2 and strg[2][0] == '0':
        strg[2] = strg[2][1] 
    Date = "-".join(strg)
    
    
    #1. Split Arrival and Departure
    day = mm.pick_day(demand, Date,level)  
    
    #2 scale
    day = mm.scale_vehicles(day,years,growth)
   
    day = mm.distributeParking(day,['A','B','C','D','E'])    
    cars = mm.create_depart_arrive(day,percentDropOff,percentPickUp)

    #2. Convert Vehicles to People    
    people_demand = mm.cars_to_people(cars,peopleToCars,percentOfTransit)
    #3. Generate Demand for each Mode of Travel
#         a. Passenger
    print("Generating Passenger  Demand")
    print(80*"=")
  
    mm.create_sumo_demand_passenger_curbside(people_demand,level,Date,percentOfPassenger,peopleToCarsPolicy,
                                            stop_duration=dwell_times['Personal'])
    print("Generating Taxi Demand")
    print(80*"=")
    mm.create_sumo_demand_taxi_curbside(people_demand,level,Date,percentOfTaxi,peopleToCarsPolicy,
                                       stop_duration=dwell_times['TaxiTNC'])
    print("Generating TNC Demand")
    print(80*"=")
    mm.create_sumo_demand_TNC_curbside(people_demand,level,Date,percentOfTNC,peopleToCarsPolicy,
                                      stop_duration=dwell_times['TaxiTNC'])
    print("Generating Limo Demand")
    print(80*"=")
    mm.create_sumo_demand_limo_curbside(people_demand,level,Date,percentOfLimo,peopleToCarsPolicy,
                                       stop_duration=dwell_times['TaxiTNC'])
    print("Generating Parking Demand")
    print(80*"=")
    buses = mm.create_sumo_demand_parking(people_demand,level,Date,percentOfParking,peopleToCarsPolicy)
    mm.add_buses_for_people(buses,Date,level,capacity)
    print("Generating Pass-Thru Demand")
    print(80*"=")
    mm.create_sumo_demand_passthru(people_demand,Date,level)
    
    #4. Combine XML Files
    scaledPercent = round(100*((growth**years)-1))
    if scaledPercent > 0:
        scale = "Scaled" + str(scaledPercent) +"%"
        file_name = Date + '.' + scale +".trips.xml"
    else: 
        file_name = Date + '.' + level +".trips.xml"
    mm.combineTrips(file_name)
    # Clear TMP files
   
    tmp_folder = "../Example_Files/TempDemandXML/"
    files = Date + "*"
    command = "rm " + tmp_folder + files
    if Delete_Files:
        os.system(command)
    #5. Move Files to Eagle
        #Note: currently using scp
    #6. Run on Eagle
        #Note: ensure you have Network, Route file, additional file/s
        #also generate some type of output
    #7. Analyis of Outputs
        #a. convert to csv
        
# Creating scenarios projected out to 2045
end_year = 2045-2018
for i in range(0,end_year+1):
    master_function(Date='2018-9-2', level='TEST', years=i,)
# Creating COVID-19 scenarios
master_function(Date='2018-3-16',
                percentOfPassenger=.55, 
                percentDropOff=.5,
                percentPickUp=.5,
                percentOfTNC=.02,
                percentOfTaxi=.02,
                percentOfTransit=0,
                percentOfParking=.35,
                percentOfLimo=.02,
                percentOfRental=.04,
                years = 1,
                level='covid-19')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10344350712211313, 'fraction_numerical': 0.02904162633107454, 'mean_word_length': 2.3559164733178655, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '299925', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2400, 'n_tokens_neox': 2135, 'n_words': 487, 'path': 'Congestion_Policies/old_Master_Function.ipynb', 'repo_name': 'NREL/ATHENA-sumo', 'size': '7231'}