diff --git a/input/input_checker/config/inputs_checks.csv b/input/input_checker/config/inputs_checks.csv index 0b76d4bef..d0a9c4629 100644 --- a/input/input_checker/config/inputs_checks.csv +++ b/input/input_checker/config/inputs_checks.csv @@ -1,5 +1,6 @@ Test,Input_Table,Input_ID_Column,Severity,Type,Expression,Test_Vals,Report_Statistic,Test_Description -scenarioYear,scenario,Year,NA,Calculation,scenario['Year'][0],,,Obtain scenario year +scenarioYear,scenario,Year,NA,Calculation,scenario['Year'].iloc[0],,,Obtain scenario year +zoneCount,scenario,zoneCount,NA,Calculation,scenario['zoneCount'].iloc[0],,,Obtain number of zones in scenario. Number of zones may change as a result of zone splitting. PERSON_CTRAMP_Fields_Availability,persons,perid,Fatal,Test,test_val in persons.columns,"hhid,perid,household_serial_no,pnum,age,sex,miltary,pemploy,pstudent,ptype,educ,grade,occen5,occsoc5,indcen,weeks,hours,rac1p,hisp,version",,Check if person file contains all the required fields for ABM PERSON_military_valueCheck_agg,persons,perid,Warning,Test,"set(persons.miltary)=={0,1}",,,"Check if Person data matches the pre-defined military categories [0 = N/A Less than 17 years old, 1 = Yes, Now on Active Duty]" PERSON_military_valueCheck_disagg,persons,perid,Fatal,Test,"persons.miltary.apply(lambda x: True if x in [0,1,2,3,4] else False)",,,"Check if Person data matches the pre-defined military categories [0 = N/A Less than 17 years old, 1 = Yes, Now on Active Duty, 2 = Yes, on Active Duty in Past, but not Now, 3 = No, Training for Reserves/National Guard Only, 4 = No, Never Served in the Military]" @@ -47,7 +48,7 @@ LINK_POSITIVE_LENGTH,network_links,id,Logical,Test,network_links.length>0,,,All #TRANSITSEGMENT_Unique_Stop_ID_Check,transit_segments,id,Fatal,Test,len(set(transit_segments['@stop_id'])) == len(transit_segments['@stop_id']),,,All transit segment stop IDs must be unique mgra_total_employment,mgra_data,mgra,NA,Calculation,mgra_data[[col for col in mgra_data if (col.startswith('emp_')) and not (col.endswith('total'))]].sum(axis=1),,, MGRA_TotalEmployment_CalcCheck,mgra_data,mgra,Logical,Test,mgra_data.emp_total==mgra_total_employment,,,Check if employment by industry adds up to total employment -ZONE_CHECK,centroids,id,Fatal,Test,len(centroids) == 4996,,len(centroids),Check that there are 4996 zones present in network +ZONE_CHECK,centroids,id,Fatal,Test,len(centroids) == zoneCount,,len(centroids),Check that there are 4996 zones present in network zone_connector_table,centroids,id,NA,Calculation,centroids.loc[(centroids['numInLinks']>0) & (centroids['numOutLinks']>0)],,,Obtain table of centroids (i.e. zones) that have more than 1 incoming and outgoing links (i.e. centroid connectors) zone_connector_list,zone_connector_table,id,NA,Calculation,set(zone_connector_table.id),,,Obtain list of unique centroid ids that have more than 1 incoming and outgoing links NO_ZONE_CONNECTOR_CHECK,centroids,id,Fatal,Test,centroids.id.apply(lambda x: True if x in zone_connector_list else False),,,Check that each zone has a zone connector diff --git a/src/main/emme/init_emme_project.py b/src/main/emme/init_emme_project.py index 98d53d1be..c2d6a2f66 100644 --- a/src/main/emme/init_emme_project.py +++ b/src/main/emme/init_emme_project.py @@ -28,35 +28,50 @@ import argparse import os +from collections import OrderedDict + WKT_PROJECTION = 'PROJCS["NAD_1983_NSRS2007_StatePlane_California_VI_FIPS_0406_Ft_US",GEOGCS["GCS_NAD_1983_NSRS2007",DATUM["D_NAD_1983_NSRS2007",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",6561666.666666666],PARAMETER["False_Northing",1640416.666666667],PARAMETER["Central_Meridian",-116.25],PARAMETER["Standard_Parallel_1",32.78333333333333],PARAMETER["Standard_Parallel_2",33.88333333333333],PARAMETER["Latitude_Of_Origin",32.16666666666666],UNIT["Foot_US",0.3048006096012192]];-118608900 -91259500 3048.00609601219;-100000 10000;-100000 10000;3.28083333333333E-03;0.001;0.001;IsHighPrecision' def init_emme_project(root, title, emmeversion): project_path = _app.create_project(root, "emme_project") - desktop = _app.start_dedicated( - project=project_path, user_initials="WS", visible=False) + project_root = os.path.dirname(project_path) + desktop = _app.start_dedicated(project=project_path, user_initials="WS", visible=False) project = desktop.project project.name = "SANDAG Emme project" - prj_file_path = os.path.join(os.path.dirname(project_path), 'NAD 1983 NSRS2007 StatePlane California VI FIPS 0406 (US Feet).prj') + prj_file_path = os.path.join(project_root, 'NAD 1983 NSRS2007 StatePlane California VI FIPS 0406 (US Feet).prj') with open(prj_file_path, 'w') as f: f.write(WKT_PROJECTION) project.spatial_reference_file = prj_file_path project.initial_view = _ws_types.Box(6.18187e+06, 1.75917e+06, 6.42519e+06, 1.89371e+06) - project_root = os.path.dirname(project_path) + + property_path = os.path.join(root, "conf", "sandag_abm.properties") + properties = load_properties(property_path) + sla_limit = properties.get('traffic.sla_limit', 3) + + num_links = 90000 + num_turn_entries = 13000 + num_traffic_classes = 15 + if sla_limit > 3: + # extra_attribute_values = 18000000 + 90000 * (sla_limit - 3) + extra_attribute_values = 18000000 + (sla_limit - 3) * ((num_links + 1) * (num_traffic_classes + 1) + (num_turn_entries + 1) * (num_traffic_classes)) + else: + extra_attribute_values = 18000000 + dimensions = { 'scalar_matrices': 9999, 'destination_matrices': 999, 'origin_matrices': 999, - 'full_matrices': 1600, + 'full_matrices': 9999, 'scenarios': 10, 'centroids': 5000, 'regular_nodes': 29999, - 'links': 90000, - 'turn_entries': 13000, + 'links': num_links, + 'turn_entries': num_turn_entries, 'transit_vehicles': 200, 'transit_lines': 450, 'transit_segments': 40000, - 'extra_attribute_values': 28000000, + 'extra_attribute_values': extra_attribute_values, 'functions': 99, 'operators': 5000 @@ -84,6 +99,45 @@ def init_emme_project(root, title, emmeversion): desktop.add_modeller_toolbox("%<$ProjectPath>%/scripts/solutions.mtbx") project.save() +def load_properties(path): + prop = OrderedDict() + comments = {} + with open(path, 'r') as properties: + comment = [] + for line in properties: + line = line.strip() + if not line or line.startswith('#'): + comment.append(line) + continue + key, value = line.split('=') + key = key.strip() + tokens = value.split(',') + if len(tokens) > 1: + value = _parse_list(tokens) + else: + value = _parse(value) + prop[key] = value + comments[key], comment = comment, [] + return prop + +def _parse_list(values): + converted_values = [] + for v in values: + converted_values.append(_parse(v)) + return converted_values + +def _parse(value): + value = str(value).strip() + if value == 'true': + return True + elif value == 'false': + return False + for caster in int, float: + try: + return caster(value) + except ValueError: + pass + return value if __name__ == "__main__": parser = argparse.ArgumentParser(description="Create a new empty Emme project and database with Sandag defaults.") diff --git a/src/main/emme/toolbox/import/import_auto_demand.py b/src/main/emme/toolbox/import/import_auto_demand.py index 375a27c2e..6772dfc96 100644 --- a/src/main/emme/toolbox/import/import_auto_demand.py +++ b/src/main/emme/toolbox/import/import_auto_demand.py @@ -422,7 +422,7 @@ def import_commercial_vehicle_demand(self, props): path = os.path.join(self.output_dir, "TripMatrices.csv") table = _pandas.read_csv(path) for key, value in mapping.iteritems(): - cvm_array = table[key].values.reshape((4996, 4996)) # reshape method deprecated since v 0.19.0, yma, 2/12/2019 + cvm_array = table[key].values.reshape((props["zones.count"], props["zones.count"])) # reshape method deprecated since v 0.19.0, yma, 2/12/2019 #factor in cvm demand by the scale factor used in trip generation cvm_array = cvm_array/scale_factor #scale trips to take care of underestimation @@ -440,7 +440,7 @@ def import_commercial_vehicle_demand(self, props): key_new = "CVM_%s:%sNT" % (period, veh) value_new = mapping[key_new] if value_new["share"] != 0.0: - cvm_array = table[key_new].values.reshape((4996, 4996)) + cvm_array = table[key_new].values.reshape((props["zones.count"], props["zones.count"])) cvm_array = cvm_array/scale_factor cvm_array = cvm_array * value_new["scale"] value["array"] = value["array"] + (cvm_array * value_new["share"]) diff --git a/src/main/emme/toolbox/import/input_checker.py b/src/main/emme/toolbox/import/input_checker.py index eedffcbba..198876936 100644 --- a/src/main/emme/toolbox/import/input_checker.py +++ b/src/main/emme/toolbox/import/input_checker.py @@ -297,7 +297,7 @@ def get_emme_object(emme_network, emme_network_object, fields_to_export): df = dbf.to_dataframe() self.inputs[table_name] = df - # add scenario year + # add scenario table to input dictionary self.inputs['scenario'] = self.scenario_df def checks(self): @@ -444,8 +444,9 @@ def prop_file_paths(self): input_path = props[row['Property_Token']] self.prop_input_paths[input_table] = input_path - # obtain scenario year + # obtain scenario year and number of zones self.scenario_df['Year'] = [props['scenarioYear']] + self.scenario_df['zoneCount'] = [props['zones.count']] def write_log(self): # function to write out the input checker log file diff --git a/src/main/emme/toolbox/import/input_checker.py.bak b/src/main/emme/toolbox/import/input_checker.py.bak new file mode 100644 index 000000000..a93904b47 --- /dev/null +++ b/src/main/emme/toolbox/import/input_checker.py.bak @@ -0,0 +1,767 @@ +#////////////////////////////////////////////////////////////////////////////// +#//// /// +#//// Copyright RSG, 2019-2020. /// +#//// Rights to use and modify are granted to the /// +#//// San Diego Association of Governments and partner agencies. /// +#//// This copyright notice must be preserved. /// +#//// /// +#//// import/input_checker.py /// +#//// /// +#//// /// +#//// /// +#//// /// +#////////////////////////////////////////////////////////////////////////////// +# +# Reviews all inputs to SANDAG ABM for possible issues that will result in model errors +# +# Files referenced: +# input_checker\config\inputs_checks.csv +# input_checker\config\inputs_list.csv + +import os, shutil, sys, time, csv, logging +import win32com.client as com +import numpy as np +import pandas as pd +import traceback as _traceback +import datetime +import warnings +from simpledbf import Dbf5 +import inro.modeller as _m +import inro.emme.database.emmebank as _eb +import inro.director.util.qtdialog as dialog +import textwrap + +warnings.filterwarnings("ignore") + +_join = os.path.join +_dir = os.path.dirname + +class input_checker(_m.Tool()): + + path = _m.Attribute(unicode) + + tool_run_msg = "" + + @_m.method(return_type=_m.UnicodeType) + def tool_run_msg_status(self): + return self.tool_run_msg + + def __init__(self): + project_dir = _dir(_m.Modeller().desktop.project.path) + self.path = _dir(project_dir) + self.input_checker_path = '' + self.inputs_list_path = '' + self.inputs_checks_path = '' + self.log_path = '' + self.logical_log_path = '' + self.prop_input_paths = {} + self.inputs_list = pd.DataFrame() + self.inputs_checks = pd.DataFrame() + self.inputs = {} + self.results = {} + self.result_list = {} + self.problem_ids = {} + self.report_stat = {} + self.num_fatal = int() + self.num_warning = int() + self.num_logical = int() + self.logical_fails = pd.DataFrame() + self.scenario_df = pd.DataFrame() + + def page(self): + pb = _m.ToolPageBuilder(self) + pb.title = "Input Checker" + pb.description = """ + Reviews all inputs to SANDAG ABM for possible issues that could result + in model errors. List of inputs and checks are read from two CSV files: +
+
+ +
+ The input checker goes through the list of checks and evaluates each + one as True or False. A summary file is produced at the end with results + for each check. The input checker additionally outputs a report for + failed checks of severity type Logical with more than 25 failed records. + The additional summary report lists every failed record. + The following reports are output: +
+
+ +
+ """ + pb.branding_text = "SANDAG - Input Checker" + + if self.tool_run_msg != "": + pb.tool_run_status(self.tool_run_msg_status) + + return pb.render() + + def run(self): + self.tool_run_msg = "" + try: + self(path = self.path) + run_msg = "Input Checker Complete" + self.tool_run_msg = _m.PageBuilder.format_info(run_msg, escape=False) + except Exception as error: + self.tool_run_msg = _m.PageBuilder.format_exception( + error, _traceback.format_exc(error)) + raise + + def __call__(self, path = ""): + _m.logbook_write("Started running input checker...") + + self.path = path + + self.input_checker_path = _join(self.path, 'input_checker') + self.inputs_list_path = _join(self.input_checker_path, 'config', 'inputs_list.csv') + self.inputs_checks_path = _join(self.input_checker_path, 'config', 'inputs_checks.csv') + + file_paths = [self.inputs_list_path, self.inputs_checks_path] + for path in file_paths: + if not os.path.exists(path): + raise Exception("missing file '%s'" % (path)) + + _m.logbook_write("Reading inputs...") + self.read_inputs() + + _m.logbook_write("Conducting checks...") + self.checks() + + _m.logbook_write("Writing logical fail logs...") + self.write_logical_log() + + _m.logbook_write("Writing logs...") + self.write_log() + + _m.logbook_write("Checking for logical errors...") + self.check_logical() + + _m.logbook_write("Checking for fatal errors...") + self.check_num_fatal() + + _m.logbook_write("Finisehd running input checker") + + def read_inputs(self): + # read list of inputs from CSV file + self.inputs_list = pd.read_csv(self.inputs_list_path) + + # remove all commented inputs from the inputs list + self.inputs_list = self.inputs_list.loc[[not i for i in (self.inputs_list['Input_Table'].str.startswith('#'))]] + + # obtain file paths from the sandag_abm.properties + self.prop_file_paths() + + # load emmebank + eb_path = _join(self.path, "emme_project", "Database", "emmebank") + eb = _eb.Emmebank(eb_path) + + # load emme network + network = eb.scenario(100).get_network() + + # create extra network attributes (maybe temporary) + + # link modes_str attribute + network.create_attribute("LINK", "mode_str") + for link in network.links(): + link.mode_str = "".join([m.id for m in link.modes]) + + # link isTransit flag attribute + network.create_attribute("LINK", "isTransit") + transit_modes = set([m for m in network.modes() if m.type == "TRANSIT"]) + for link in network.links(): + link.isTransit = bool(link.modes.intersection(transit_modes)) + + # transit segment isFirst and isLast flags attributes + network.create_attribute("TRANSIT_SEGMENT", "isFirst", False) + network.create_attribute("TRANSIT_SEGMENT", "isLast", False) + for line in network.transit_lines(): + first_seg = line.segment(0) + last_seg = line.segment(-2) + first_seg.isFirst = True + last_seg.isLast = True + + # node isCentroid flag attribute + network.create_attribute("NODE", "isCentroid", False) + centroids = [c for c in network.nodes() if c.is_centroid] + for node in network.nodes(): + node.isCentroid = bool(node in centroids) + + # node numInLinks and numOutLinks attributes + network.create_attribute("NODE", "numInLinks") + network.create_attribute("NODE", "numOutLinks") + for node in network.nodes(): + node.numInLinks = len(list(node.incoming_links())) + node.numOutLinks = len(list(node.outgoing_links())) + + # node hasLocalConnection flag attribute + class BreakLoop (Exception): + pass + + network.create_attribute("NODE", "hasLocalConnection", False) + for node in network.centroids(): + try: + for zone_connector in node.incoming_links(): + for local_link in zone_connector.i_node.incoming_links(): + if local_link["@lane_restriction"] == 1.0: + node.hasLocalConnection = True + raise BreakLoop("") + except: + pass + + # transit line hasTAP flag attribute + network.create_attribute("TRANSIT_LINE", "hasTAP", False) + for line in network.transit_lines(): + has_first_tap = False + has_last_tap = False + for link in line.segment(0).i_node.outgoing_links(): + if link.j_node["@tap_id"] > 0: + has_first_tap = True + break + for link in line.segment(-2).j_node.outgoing_links(): + if link.j_node["@tap_id"] > 0: + has_last_tap = True + break + line.hasTAP = has_first_tap and has_last_tap + + # link names attribute + network.create_attribute("LINK", "linkNames") + for link in network.links(): + link.linkNames = str(link['#name'] + "," + link['#name_from'] + "," + link['#name_to']) + + def get_emme_object(emme_network, emme_network_object, fields_to_export): + # Emme network attribute and object names + net_attr = { + 'NODE':'nodes', + 'LINK':'links', + 'TRANSIT_SEGMENT':'transit_segments', + 'TRANSIT_LINE':'transit_lines', + 'CENTROID':'centroids' + } + + # read-in entire emme network object as a list + get_objs = 'list(emme_network.' + net_attr[emme_network_object] + '())' + uda = eval(get_objs) + + # get list of network object attributes + obj_attr = [] + if fields_to_export[0] in ['all','All','ALL']: + if emme_network_object == 'CENTROID': + obj_attr = emme_network.attributes('NODE') + else: + obj_attr = emme_network.attributes(emme_network_object) + else: + obj_attr = fields_to_export + + # instantiate list of network objects + net_objs = [] + for i in range(len(uda)): + obj_fields = [] + get_id = 'uda[i].id' + obj_fields.append(eval(get_id)) + for attr in obj_attr: + get_field = 'uda[i]["' + attr + '"]' + obj_fields.append(eval(get_field)) + net_objs.append(obj_fields) + net_obj_df = pd.DataFrame(net_objs, columns = ['id'] + obj_attr) + + return(net_obj_df) + + for item, row in self.inputs_list.iterrows(): + + table_name = row['Input_Table'] + emme_network_object = row['Emme_Object'] + column_map = row['Column_Map'] + fields_to_export = row['Fields'].split(',') + + # obtain emme network object, csv or dbf input + if not (pd.isnull(emme_network_object)): + df = get_emme_object(network, emme_network_object, fields_to_export) + self.inputs[table_name] = df + else: + input_path = self.prop_input_paths[table_name] + input_ext = os.path.splitext(input_path)[1] + if input_ext == '.csv': + df = pd.read_csv(_join(self.path, input_path)) + self.inputs[table_name] = df + else: + dbf_path = input_path + if '%project.folder%' in dbf_path: + dbf_path = dbf_path.replace('%project.folder%/', '') + dbf = Dbf5(_join(self.path, dbf_path)) + df = dbf.to_dataframe() + self.inputs[table_name] = df + + # add scenario table to input dictionary + self.inputs['scenario'] = self.scenario_df + + def checks(self): + # read all input DFs into memory + for key, df in self.inputs.items(): + expr = key + ' = df' + exec(expr) + + # copy of locals(), a dictionary of all local variables + calc_dict = locals() + + # read list of checks from CSV file + self.inputs_checks = pd.read_csv(self.inputs_checks_path) + + # remove all commented checks from the checks list + self.inputs_checks = self.inputs_checks.loc[[not i for i in (self.inputs_checks['Test'].str.startswith('#'))]] + + # perform calculations and add user-defined data frame subsets + for item, row in self.inputs_checks.iterrows(): + + test = row['Test'] + table = row['Input_Table'] + id_col = row['Input_ID_Column'] + expr = row['Expression'] + test_vals = row['Test_Vals'] + if not (pd.isnull(row['Test_Vals'])): + test_vals = test_vals.split(',') + test_vals = [txt.strip() for txt in test_vals] + test_type = row['Type'] + Severity = row['Severity'] + stat_expr = row['Report_Statistic'] + + if test_type == 'Calculation': + + try: + calc_expr = test + ' = ' + expr + exec(calc_expr, {}, calc_dict) + calc_out = eval(expr, calc_dict) + except Exception as error: + print('An error occurred with the calculation: {}'.format(test)) + raise + + if str(type(calc_out)) == "": + print('added '+ row['Test'] + ' as new DataFrame input') + self.inputs[row['Test']] = calc_out + self.inputs_list = self.inputs_list.append({'Input_Table': row['Test'],'Property_Token':'NA','Emme_Object':'NA', \ + 'Fields':'NA','Column_Map':'NA','Input_Description':'NA'}, ignore_index = True) + self.inputs_checks = self.inputs_checks.append({'Test':test, 'Input_Table': table, 'Input_ID_Column':id_col, 'Severity':Severity, \ + 'Type':test_type, 'Expression': expr, 'Test_Vals':test_vals, 'Report_Statistic':stat_expr, 'Test_Description': row['Test_Description']}, \ + ignore_index = True) + + # loop through list of checks and conduct all checks + # checks must evaluate to True if inputs are correct + for item, row in self.inputs_checks.iterrows(): + + test = row['Test'] + table = row['Input_Table'] + id_col = row['Input_ID_Column'] + expr = row['Expression'] + test_vals = row['Test_Vals'] + if not (pd.isnull(row['Test_Vals'])): + test_vals = test_vals.split(',') + test_vals = [txt.strip() for txt in test_vals] + test_type = row['Type'] + Severity = row['Severity'] + stat_expr = row['Report_Statistic'] + + if test_type == 'Test': + + if (pd.isnull(row['Test_Vals'])): + + # perform test + try: + out = eval(expr, calc_dict) + except Exception as error: + print('An error occurred with the check: {}'.format(test)) + raise + + # check if test result is a series + if str(type(out)) == "": + # for series, the test must be evaluated across all items + # result is False if a single False is found + self.results[test] = not (False in out.values) + + # reverse results list since we need all False IDs + reverse_results = [not i for i in out.values] + error_expr = table + "['" + id_col + "']" + "[reverse_results]" + error_id_list = eval(error_expr) + + # report first 25 problem IDs in the log + self.problem_ids[test] = error_id_list if error_id_list.size > 0 else [] + + # compute report statistics + if (pd.isnull(stat_expr)): + self.report_stat[test] = '' + else: + stat_list = eval(stat_expr) + self.report_stat[test] = stat_list[reverse_results] + else: + self.results[test] = out + self.problem_ids[test] = [] + if (pd.isnull(stat_expr)): + self.report_stat[test] = '' + else: + self.report_stat[test] = eval(stat_expr) + else: + # loop through test_vals and perform test for each item + self.result_list[test] = [] + for test_val in test_vals: + # perform test (test result must not be of type Series) + try: + out = eval(expr) + except Exception as error: + print('An error occurred with the check: {}'.format(test)) + raise + + # compute report statistic + if (pd.isnull(stat_expr)): + self.report_stat[test] = '' + else: + self.report_stat[test] = eval(stat_expr) + + # append to list + self.result_list[test].append(out) + self.results[test] = not (False in self.result_list[test]) + self.problem_ids[test] = [] + else: + # perform calculation + try: + calc_expr = test + ' = ' + expr + exec(calc_expr, {}, calc_dict) + except Exception as error: + print('An error occurred with the calculation: {}'.format(test)) + raise + + def prop_file_paths(self): + prop_files = self.inputs_list[['Input_Table','Property_Token']].dropna() + + load_properties = _m.Modeller().tool('sandag.utilities.properties') + props = load_properties(_join(self.path, 'conf', 'sandag_abm.properties')) + + for item, row in prop_files.iterrows(): + input_table = row['Input_Table'] + input_path = props[row['Property_Token']] + self.prop_input_paths[input_table] = input_path + + # obtain scenario year + self.scenario_df['Year'] = [props['scenarioYear']] + + def write_log(self): + # function to write out the input checker log file + # there are four blocks + # - Introduction + # - Summary of checks + # - Action Required: FATAL, LOGICAL, WARNINGS + # - List of passed checks + + # create log file + now = datetime.datetime.now() + + self.log_path = _join(self.input_checker_path, ('inputCheckerSummary_' + now.strftime("[%Y-%m-%d]") + '.txt')) + f = open(self.log_path, 'wb') + + # define re-usable elements + seperator1 = '###########################################################' + seperator2 = '***********************************************************' + + # write out Header + f.write(seperator1 + seperator1 + "\r\n") + f.write(seperator1 + seperator1 + "\r\n\r\n") + f.write("\t SANDAG ABM Input Checker Summary File \r\n") + f.write("\t _____________________________________ \r\n\r\n\r\n") + f.write("\t Created on: " + now.strftime("%Y-%m-%d %H:%M") + "\r\n\r\n") + f.write("\t Notes:-\r\n") + f.write("\t The SANDAG ABM Input Checker performs various QA/QC checks on SANDAG ABM inputs as specified by the user.\r\n") + f.write("\t The Input Checker allows the user to specify three severity levels for each QA/QC check:\r\n\r\n") + f.write("\t 1) FATAL 2) LOGICAL 3) WARNING\r\n\r\n") + f.write("\t FATAL Checks: The failure of these checks would result in a FATAL errors in the SANDAG ABM run.\r\n") + f.write("\t In case of FATAL failure, the Input Checker returns a return code of 1 to the\r\n") + f.write("\t main SANDAG ABM model, cauing the model run to halt.\r\n") + f.write("\t LOGICAL Checks: The failure of these checks indicate logical inconsistencies in the inputs.\r\n") + f.write("\t With logical errors in inputs, the SANDAG ABM outputs may not be meaningful.\r\n") + f.write("\t WARNING Checks: The failure of Warning checks would indicate problems in data that would not.\r\n") + f.write("\t halt the run or affect model outputs but might indicate an issue with inputs.\r\n\r\n\r\n") + f.write("\t The contents of this summary file are organized as follows: \r\n\r\n") + f.write("\t TALLY OF FAILED CHECKS:\r\n") + f.write("\t -----------------------\r\n") + f.write("\t A tally of all failed checks per severity level\r\n\r\n") + f.write("\t IMMEDIATE ACTION REQUIRED:\r\n") + f.write("\t -------------------------\r\n") + f.write("\t A log under this heading will be generated in case of failure of a FATAL check\r\n\r\n") + f.write("\t ACTION REQUIRED:\r\n") + f.write("\t ---------------\r\n") + f.write("\t A log under this heading will be generated in case of failure of a LOGICAL check\r\n\r\n") + f.write("\t WARNINGS:\r\n") + f.write("\t ---------\r\n") + f.write("\t A log under this heading will be generated in case of failure of a WARNING check\r\n\r\n") + f.write("\t SUMMARY OF ALL PASSED CHECKS:\r\n") + f.write("\t ----------------------------\r\n") + f.write("\t A complete listing of results of all passed checks\r\n\r\n") + f.write(seperator1 + seperator1 + "\r\n") + f.write(seperator1 + seperator1 + "\r\n\r\n\r\n\r\n") + + # combine results, inputs_checks and inputs_list + self.inputs_checks['result'] = self.inputs_checks['Test'].map(self.results) + checks_df = pd.merge(self.inputs_checks, self.inputs_list, on='Input_Table') + checks_df = checks_df[checks_df.Type=='Test'] + checks_df['reverse_result'] = [not i for i in checks_df.result] + + # get count of all FATAL failures + self.num_fatal = checks_df.result[(checks_df.Severity=='Fatal') & (checks_df.reverse_result)].count() + + # get count of all LOGICAL failures + self.num_logical = checks_df.result[(checks_df.Severity=='Logical') & (checks_df.reverse_result)].count() + self.logical_fails = checks_df[(checks_df.Severity=='Logical') & (checks_df.reverse_result)] + + # get count of all WARNING failures + self.num_warning = checks_df.result[(checks_df.Severity=='Warning') & (checks_df.reverse_result)].count() + + # write summary of failed checks + f.write('\r\n\r\n' + seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n") + f.write('\t' + "TALLY OF FAILED CHECKS \r\n") + f.write('\t' + "---------------------- \r\n\r\n") + f.write(seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n\t") + f.write(' Number of Fatal Errors: ' + str(self.num_fatal)) + f.write('\r\n\t Number of Logical Errors: ' + str(self.num_logical)) + f.write('\r\n\t Number of Warnings: ' + str(self.num_warning)) + + def write_check_log(self, fh, row): + # define constants + seperator2 = '-----------------------------------------------------------' + + # integerize problem ID list + problem_ids = self.problem_ids[row['Test']] + #problem_ids = [int(x) for x in problem_ids] + + # write check summary + fh.write('\r\n\r\n' + seperator2 + seperator2) + fh.write("\r\n\t Input File Name: " + ('NA' if not pd.isnull(row['Emme_Object']) else + (self.prop_input_paths[row['Input_Table']].rsplit('/', 1)[-1]))) + fh.write("\r\n\t Input File Location: " + ('NA' if not pd.isnull(row['Emme_Object']) else + (_join(self.input_checker_path, self.prop_input_paths[row['Input_Table']].replace('/','\\'))))) + fh.write("\r\n\t Emme Object: " + (row['Emme_Object'] if not pd.isnull(row['Emme_Object']) else 'NA')) + fh.write("\r\n\t Input Description: " + (row['Input_Description'] if not pd.isnull(row['Input_Description']) else "")) + fh.write("\r\n\t Test Name: " + row['Test']) + fh.write("\r\n\t Test_Description: " + (row['Test_Description'] if not pd.isnull(row['Test_Description']) else "")) + fh.write("\r\n\t Test Severity: " + row['Severity']) + fh.write("\r\n\r\n\t TEST RESULT: " + ('PASSED' if row['result'] else 'FAILED')) + + # display problem IDs for failed column checks + wrapper = textwrap.TextWrapper(width = 70) + if (not row['result']) & (len(problem_ids)>0) : + fh.write("\r\n\t TEST failed for following values of ID Column: " + row['Input_ID_Column'] + " (only up to 25 IDs displayed)") + fh.write("\r\n\t " + row['Input_ID_Column'] + ": " + "\r\n\t " + "\r\n\t ".join(wrapper.wrap(text = ", ".join(map(str, problem_ids[0:25]))))) + if not (pd.isnull(row['Report_Statistic'])): + this_report_stat = self.report_stat[row['Test']] + fh.write("\r\n\t Test Statistics: " + "\r\n\t " + "\r\n\t ".join(wrapper.wrap(text = ", ".join(map(str, this_report_stat[0:25]))))) + fh.write("\r\n\t Total number of failures: " + str(len(self.problem_ids[row['Test']]))) + if ((len(self.problem_ids[row['Test']])) > 25) and (row['Severity'] == 'Logical'): + fh.write("\r\n\t Open {} for complete list of failed Logical failures.".format(self.logical_log_path)) + else: + if not (pd.isnull(row['Report_Statistic'])): + fh.write("\r\n\t Test Statistic: " + str(self.report_stat[row['Test']])) + + # display result for each test val if it was specified + if not (pd.isnull(row['Test_Vals'])): + fh.write("\r\n\t TEST results for each test val") + result_tuples = zip(row['Test_Vals'].split(","), self.result_list[row['Test']]) + fh.write("\r\n\t ") + fh.write(','.join('[{} - {}]'.format(x[0],x[1]) for x in result_tuples)) + + fh.write("\r\n" + seperator2 + seperator2 + "\r\n\r\n") + + # write out IMMEDIATE ACTION REQUIRED section if needed + if self.num_fatal > 0: + fatal_checks = checks_df[(checks_df.Severity=='Fatal') & (checks_df.reverse_result)] + f.write('\r\n\r\n' + seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n") + f.write('\t' + "IMMEDIATE ACTION REQUIRED \r\n") + f.write('\t' + "------------------------- \r\n\r\n") + f.write(seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n") + + # write out log for each check + for item, row in fatal_checks.iterrows(): + #self.write_check_log(f, row, self.problem_ids[row['Test']]) + #write_check_log(self, f, row, self.problem_ids[row['Test']]) + write_check_log(self, f, row) + + # write out ACTION REQUIRED section if needed + if self.num_logical > 0: + logical_checks = checks_df[(checks_df.Severity=='Logical') & (checks_df.reverse_result)] + f.write('\r\n\r\n' + seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n") + f.write('\t' + "ACTION REQUIRED \r\n") + f.write('\t' + "--------------- \r\n\r\n") + f.write(seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n") + + #write out log for each check + for item, row in logical_checks.iterrows(): + write_check_log(self, f, row) + + # write out WARNINGS section if needed + if self.num_warning > 0: + warning_checks = checks_df[(checks_df.Severity=='Warning') & (checks_df.reverse_result)] + f.write('\r\n\r\n' + seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n") + f.write('\t' + "WARNINGS \r\n") + f.write('\t' + "-------- \r\n\r\n") + f.write(seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n") + + # write out log for each check + for item, row in warning_checks.iterrows(): + write_check_log(self, f, row) + + # write out the complete listing of all checks that passed + passed_checks = checks_df[(checks_df.result)] + f.write('\r\n\r\n' + seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n") + f.write('\t' + "LOG OF ALL PASSED CHECKS \r\n") + f.write('\t' + "------------------------ \r\n\r\n") + f.write(seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n") + + # write out log for each check + for item, row in passed_checks.iterrows(): + write_check_log(self, f, row) + + f.close() + + def write_logical_log(self): + # function to write out the complete list of Logical failures + + # combine results, inputs_checks and inputs_list + self.inputs_checks['result'] = self.inputs_checks['Test'].map(self.results) + checks_df = pd.merge(self.inputs_checks, self.inputs_list, on='Input_Table') + checks_df = checks_df[checks_df.Type=='Test'] + checks_df['reverse_result'] = [not i for i in checks_df.result] + + # get count of all LOGICAL failures + self.num_logical = checks_df.result[(checks_df.Severity=='Logical') & (checks_df.reverse_result)].count() + self.logical_fails = checks_df[(checks_df.Severity=='Logical') & (checks_df.reverse_result)] + + log_fail_id_tally = 0 + if self.num_logical > 0: + for item, row in self.logical_fails.iterrows(): + problem_ids = self.problem_ids[row['Test']] + if len(problem_ids) > 0: + log_fail_id_tally += 1 + + if log_fail_id_tally > 0: + + # create log file + now = datetime.datetime.now() + + self.logical_log_path = _join(self.input_checker_path, ('completeLogicalFails_' + now.strftime("[%Y-%m-%d]") + '.txt')) + f = open(self.logical_log_path, 'wb') + + # define re-usable elements + seperator1 = '###########################################################' + seperator2 = '***********************************************************' + + # write out Header + f.write(seperator1 + seperator1 + "\r\n") + f.write(seperator1 + seperator1 + "\r\n\r\n") + f.write("\t SANDAG ABM Input Checker Logical Failures Complete List \r\n") + f.write("\t _______________________________________________________ \r\n\r\n\r\n") + f.write("\t Created on: " + now.strftime("%Y-%m-%d %H:%M") + "\r\n\r\n") + f.write("\t Notes:-\r\n") + f.write("\t The SANDAG ABM Input Checker performs various QA/QC checks on SANDAG ABM inputs as specified by the user.\r\n") + f.write("\t The Input Checker allows the user to specify three severity levels for each QA/QC check:\r\n\r\n") + f.write("\t 1) FATAL 2) LOGICAL 3) WARNING\r\n\r\n") + f.write("\t This file provides the complete list of failed checks for checks of severity type Logical. \r\n") + f.write(seperator1 + seperator1 + "\r\n") + f.write(seperator1 + seperator1 + "\r\n\r\n\r\n\r\n") + + # write total number of failed logical checks + f.write('\r\n\r\n' + seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n") + f.write('\t' + "TALLY OF FAILED CHECKS \r\n") + f.write('\t' + "---------------------- \r\n\r\n") + f.write(seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n\t") + f.write('\r\n\t Number of Logical Errors: ' + str(self.num_logical)) + + def write_logical_check_log(self, fh, row): + # define constants + seperator2 = '-----------------------------------------------------------' + + # integerize problem ID list + problem_ids = self.problem_ids[row['Test']] + #problem_ids = [int(x) for x in problem_ids] + + # write check summary + fh.write('\r\n\r\n' + seperator2 + seperator2) + fh.write("\r\n\t Input File Name: " + ('NA' if not pd.isnull(row['Emme_Object']) else + (self.prop_input_paths[row['Input_Table']].rsplit('/', 1)[-1]))) + fh.write("\r\n\t Input File Location: " + ('NA' if not pd.isnull(row['Emme_Object']) else + (_join(self.input_checker_path, self.prop_input_paths[row['Input_Table']].replace('/','\\'))))) + fh.write("\r\n\t Emme Object: " + (row['Emme_Object'] if not pd.isnull(row['Emme_Object']) else 'NA')) + fh.write("\r\n\t Input Description: " + (row['Input_Description'] if not pd.isnull(row['Input_Description']) else "")) + fh.write("\r\n\t Test Name: " + row['Test']) + fh.write("\r\n\t Test_Description: " + (row['Test_Description'] if not pd.isnull(row['Test_Description']) else "")) + fh.write("\r\n\t Test Severity: " + row['Severity']) + fh.write("\r\n\r\n\t TEST RESULT: " + ('PASSED' if row['result'] else 'FAILED')) + + # display problem IDs for failed column checks + wrapper = textwrap.TextWrapper(width = 70) + if (not row['result']) & (len(problem_ids)>0) : + fh.write("\r\n\t TEST failed for following values of ID Column: " + row['Input_ID_Column']) + fh.write("\r\n\t " + row['Input_ID_Column'] + ": " + "\r\n\t " + "\r\n\t ".join(wrapper.wrap(text = ", ".join(map(str, problem_ids))))) + if not (pd.isnull(row['Report_Statistic'])): + this_report_stat = self.report_stat[row['Test']] + fh.write("\r\n\t Test Statistics: " + "\r\n\t " + "\r\n\t ".join(wrapper.wrap(text = ", ".join(map(str, this_report_stat))))) + fh.write("\r\n\t Total number of failures: " + str(len(self.problem_ids[row['Test']]))) + else: + if not (pd.isnull(row['Report_Statistic'])): + fh.write("\r\n\t Test Statistic: " + str(self.report_stat[row['Test']])) + + # display result for each test val if it was specified + if not (pd.isnull(row['Test_Vals'])): + fh.write("\r\n\t TEST results for each test val") + result_tuples = zip(row['Test_Vals'].split(","), self.result_list[row['Test']]) + fh.write("\r\n\t ") + fh.write(','.join('[{} - {}]'.format(x[0],x[1]) for x in result_tuples)) + + fh.write("\r\n" + seperator2 + seperator2 + "\r\n\r\n") + + # write out ACTION REQUIRED section if needed + if self.num_logical > 0: + logical_checks = checks_df[(checks_df.Severity=='Logical') & (checks_df.reverse_result)] + f.write('\r\n\r\n' + seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n\r\n") + f.write('\t' + "LOG OF ALL FAILED LOGICAL CHECKS \r\n") + f.write('\t' + "-------------------------------- \r\n\r\n") + f.write(seperator2 + seperator2 + "\r\n") + f.write(seperator2 + seperator2 + "\r\n") + + #write out log for each check + for item, row in logical_checks.iterrows(): + if len(self.problem_ids[row['Test']]) > 25: + write_logical_check_log(self, f, row) + + f.close() + + def check_logical(self): + if self.num_logical > 0: + # raise exception for each logical check fail + for item, row in self.logical_fails.iterrows(): + answer = dialog.alert_question( + message = "The following Logical check resulted in at least 1 error: {} \n Open {} for details. \ + \n\n Click OK to continue or Cancel to stop run.".format(row['Test'], self.log_path), + title = "Logical Check Error", + answers = [("OK", dialog.YES_ROLE), ("Cancel", dialog.REJECT_ROLE)] + ) + + if answer == 1: + raise Exception("Input checker was cancelled") + + def check_num_fatal(self): + # return code to the main model based on input checks and results + if self.num_fatal > 0: + raise Exception("Input checker failed, {} fatal errors found. Open {} for details.".format(self.num_fatal, self.log_path)) \ No newline at end of file diff --git a/src/main/emme/toolbox/master_run.py b/src/main/emme/toolbox/master_run.py index b24daf9e9..d81128c7d 100644 --- a/src/main/emme/toolbox/master_run.py +++ b/src/main/emme/toolbox/master_run.py @@ -82,6 +82,7 @@ import datetime import pyodbc import win32com.client as win32 +import json as _json _join = os.path.join _dir = os.path.dirname @@ -282,6 +283,7 @@ def __call__(self, main_directory, scenario_id, scenario_title, emmebank_title, raise Exception(error_text % name) scenarioYear = str(props["scenarioYear"]) + geographyID = str(props["geographyID"]) startFromIteration = props["RunModel.startFromIteration"] precision = props["RunModel.MatrixPrecision"] minSpaceOnC = props["RunModel.minSpaceOnC"] @@ -304,6 +306,7 @@ def __call__(self, main_directory, scenario_id, scenario_title, emmebank_title, deleteAllMatrices = props["RunModel.deleteAllMatrices"] skipCopyWarmupTripTables = props["RunModel.skipCopyWarmupTripTables"] skipCopyBikeLogsum = props["RunModel.skipCopyBikeLogsum"] + skipShadowPricing = props["RunModel.skipShadowPricing"] skipCopyWalkImpedance = props["RunModel.skipCopyWalkImpedance"] skipWalkLogsums = props["RunModel.skipWalkLogsums"] skipBikeLogsums = props["RunModel.skipBikeLogsums"] @@ -373,6 +376,74 @@ def __call__(self, main_directory, scenario_id, scenario_title, emmebank_title, max_assign_iterations = 1000 mgra_lu_input_file = props["mgra.socec.file"] + #change emme databank dimensions based on number of select links - SANDAG ABM2+ Enhancements (06-28-2021) + num_select_links = 0 + if select_link: + num_select_links = len(_json.loads(select_link)) + change_dimensions = modeller.tool("inro.emme.data.database.change_database_dimensions") + dims = main_emmebank.dimensions + num_nodes = dims["regular_nodes"] + dims['centroids'] + num_links = dims["links"] + num_turn_entries = dims["turn_entries"] + num_transit_lines = dims['transit_lines'] + num_transit_segments = dims['transit_segments'] + num_traffic_classes = 15 + + additional_node_extra_attributes = 4 + additional_link_extra_attributes = 26 + additional_line_extra_attributes = 4 + additional_segment_extra_attributes = 12 + + extra_attribute_values = 18000000 + extra_attribute_values += (num_nodes + 1) * additional_node_extra_attributes + extra_attribute_values += (num_links + 1) * additional_link_extra_attributes + extra_attribute_values += (num_transit_lines + 1)* additional_line_extra_attributes + extra_attribute_values += (num_transit_segments + 1) * additional_segment_extra_attributes + + if num_select_links > 3: + extra_attribute_values += (num_select_links - 3) * ((num_links + 1) * (num_traffic_classes + 1) + (num_turn_entries + 1) * (num_traffic_classes)) + + if extra_attribute_values > dims["extra_attribute_values"] or dims["full_matrices"] < 9999: + dims["extra_attribute_values"] = extra_attribute_values + dims["full_matrices"] = 9999 + #add logging for when this setp is run, add before and after attribute value + #change_dimensions(emmebank_dimensions=dims, emmebank=main_emmebank, keep_backup=False) + #replaced the above line with the below lines - suggested by Antoine, Bentley (2022-06-02) + if main_emmebank.scenario(1) is None: + main_emmebank.create_scenario(1) + change_dimensions(dims, main_emmebank, False) + with open(_join(self._path, "logFiles", "select_link_log.txt"),"a+") as f: + f.write("Num Select links {}\nExtra Attribute Value {}".format(num_select_links,extra_attribute_values)) + f.close() + + if os.path.exists(_join(self._path, "emme_project", "Database_transit", "emmebank")): + with _eb.Emmebank(_join(self._path, "emme_project", "Database_transit", "emmebank")) as transit_db: + transit_db_dims = transit_db.dimensions + num_nodes = transit_db_dims["regular_nodes"] + transit_db_dims['centroids'] + num_links = transit_db_dims["links"] + num_turn_entries = transit_db_dims["turn_entries"] + num_transit_lines = transit_db_dims['transit_lines'] + num_transit_segments = transit_db_dims['transit_segments'] + num_traffic_classes = 15 + + extra_attribute_values = 18000000 + extra_attribute_values += (num_nodes + 1) * additional_node_extra_attributes + extra_attribute_values += (num_links + 1) * additional_link_extra_attributes + extra_attribute_values += (num_transit_lines + 1)* additional_line_extra_attributes + extra_attribute_values += (num_transit_segments + 1) * additional_segment_extra_attributes + + if num_select_links > 3: + extra_attribute_values += 18000000 + (num_select_links - 3) * ((num_links + 1) * (num_traffic_classes + 1) + (num_turn_entries + 1) * (num_traffic_classes)) + + if extra_attribute_values > transit_db_dims["extra_attribute_values"] or transit_db_dims["full_matrices"] < 9999: + transit_db_dims["extra_attribute_values"] = extra_attribute_values + transit_db_dims["full_matrices"] = 9999 + #change_dimensions(emmebank_dimensions=transit_db_dims, emmebank=transit_db, keep_backup=False) + #replaced the above line with the below lines - suggested by Antoine, Bentley (2022-06-02) + if transit_db.scenario(1) is None: + transit_db.create_scenario(1) + change_dimensions(transit_db_dims, transit_db, False) + with _m.logbook_trace("Setup and initialization"): self.set_global_logbook_level(props) @@ -532,6 +603,22 @@ def __call__(self, main_directory, scenario_id, scenario_title, emmebank_title, # doesn't produced csv/omx files for assignment # also needed as CT-RAMP does not overwrite existing files if not skipCoreABM[iteration]: + if not skipShadowPricing: + #reload properties from the run location + props = load_properties(_join(self._path, "conf", "sandag_abm.properties")) + if iteration == 0: + props['UsualWorkLocationChoice.ShadowPrice.Input.File'] = "" + props['UsualSchoolLocationChoice.ShadowPrice.Input.File'] = "" + props['uwsl.ShadowPricing.Work.MaximumIterations'] = 10 + props['uwsl.ShadowPricing.School.MaximumIterations'] = 10 + props.save() + + else: + props['UsualWorkLocationChoice.ShadowPrice.Input.File'] = "output/ShadowPricingOutput_work_9.csv" + props['UsualSchoolLocationChoice.ShadowPrice.Input.File'] = "output/ShadowPricingOutput_school_9.csv" + props['uwsl.ShadowPricing.Work.MaximumIterations'] = 1 + props['uwsl.ShadowPricing.School.MaximumIterations'] = 1 + props.save() self.remove_prev_iter_files(core_abm_files, output_dir, iteration) self.run_proc( "runSandagAbm_SDRM.cmd", @@ -692,7 +779,7 @@ def __call__(self, main_directory, scenario_id, scenario_title, emmebank_title, start_db_time = datetime.datetime.now() # record the time to search for request id in the load request table, YMA, 1/23/2019 # start_db_time = start_db_time + datetime.timedelta(minutes=0) self.run_proc("DataLoadRequest.bat", - [drive + path_no_drive, end_iteration, scenarioYear, sample_rate[end_iteration - 1]], + [drive + path_no_drive, end_iteration, scenarioYear, sample_rate[end_iteration - 1], geographyID], "Data load request") # delete trip table files in iteration sub folder if model finishes without errors diff --git a/src/main/emme/toolbox/utilities/properties.py b/src/main/emme/toolbox/utilities/properties.py index 228bc07b6..191fb6c9b 100644 --- a/src/main/emme/toolbox/utilities/properties.py +++ b/src/main/emme/toolbox/utilities/properties.py @@ -39,7 +39,7 @@ class PropertiesSetter(object): skipCopyWalkImpedance = _m.Attribute(bool) skipBikeLogsums = _m.Attribute(bool) skipCopyBikeLogsum = _m.Attribute(bool) - + skipShadowPricing = _m.Attribute(bool) skipHighwayAssignment_1 = _m.Attribute(bool) skipHighwayAssignment_2 = _m.Attribute(bool) skipHighwayAssignment_3 = _m.Attribute(bool) @@ -131,7 +131,7 @@ def __init__(self): self._run_model_names = ( "useLocalDrive", "skip4Ds", "skipInputChecker", "startFromIteration", "skipInitialization", "deleteAllMatrices", "skipCopyWarmupTripTables", - "skipCopyBikeLogsum", "skipCopyWalkImpedance", "skipWalkLogsums", "skipBikeLogsums", "skipBuildNetwork", + "skipCopyBikeLogsum", "skipShadowPricing", "skipCopyWalkImpedance", "skipWalkLogsums", "skipBikeLogsums", "skipBuildNetwork", "skipHighwayAssignment", "skipTransitSkimming", "skipTransponderExport", "skipCoreABM", "skipOtherSimulateModel", "skipMAASModel","skipCTM", "skipEI", "skipExternalExternal", "skipTruck", "skipTripTableCreation", "skipFinalHighwayAssignment", 'skipFinalHighwayAssignmentStochastic', "skipFinalTransitAssignment", "skipVisualizer", "skipDataExport", "skipDataLoadRequest", @@ -180,6 +180,7 @@ def add_properties_interface(self, pb, disclosure=False): ("skipCopyWalkImpedance", "Skip copy of walk impedance"), ("skipBikeLogsums", "Skip bike logsums"), ("skipCopyBikeLogsum", "Skip copy of bike logsum"), + ("skipShadowPricing", "Skip shadow pricing"), ] skip_per_iteration_items = [ ("skipHighwayAssignment", "Skip highway assignments and skims"), @@ -313,6 +314,7 @@ def load_properties(self): self.skipCopyWalkImpedance = props.get("RunModel.skipCopyWalkImpedance", False) self.skipBikeLogsums = props.get("RunModel.skipBikeLogsums", False) self.skipCopyBikeLogsum = props.get("RunModel.skipCopyBikeLogsum", False) + self.skipShadowPricing = props.get("RunModel.skipShadowPricing", False) self.skipHighwayAssignment = props.get("RunModel.skipHighwayAssignment", [False, False, False]) self.skipTransitSkimming = props.get("RunModel.skipTransitSkimming", [False, False, False]) @@ -334,6 +336,10 @@ def load_properties(self): self.skipDataLoadRequest = props.get("RunModel.skipDataLoadRequest", False) self.skipDeleteIntermediateFiles = props.get("RunModel.skipDeleteIntermediateFiles", False) + self.UsualWorkLocationChoiceShadowPriceInputFile = props.get("UsualWorkLocationChoice.ShadowPrice.Input.File","") + self.UsualSchoolLocationChoiceShadowPriceInputFile = props.get("UsualSchoolLocationChoice.ShadowPrice.Input.File","") + self.uwslShadowPricingWorkMaximumIterations = props.get("uwsl.ShadowPricing.Work.MaximumIterations",10) + self.uwslShadowPricingSchoolMaximumIterations = props.get("uwsl.ShadowPricing.School.MaximumIterations",10) def save_properties(self): props = self._properties props["RunModel.startFromIteration"] = self.startFromIteration @@ -350,6 +356,7 @@ def save_properties(self): props["RunModel.skipCopyWalkImpedance"] = self.skipCopyWalkImpedance props["RunModel.skipBikeLogsums"] = self.skipBikeLogsums props["RunModel.skipCopyBikeLogsum"] = self.skipCopyBikeLogsum + props["RunModel.skipShadowPricing"] = self.skipShadowPricing props["RunModel.skipHighwayAssignment"] = self.skipHighwayAssignment props["RunModel.skipTransitSkimming"] = self.skipTransitSkimming @@ -371,6 +378,11 @@ def save_properties(self): props["RunModel.skipDataLoadRequest"] = self.skipDataLoadRequest props["RunModel.skipDeleteIntermediateFiles"] = self.skipDeleteIntermediateFiles + props["UsualWorkLocationChoice.ShadowPrice.Input.File"] = self.UsualWorkLocationChoiceShadowPriceInputFile + props["UsualSchoolLocationChoice.ShadowPrice.Input.File"] = self.UsualSchoolLocationChoiceShadowPriceInputFile + props["uwsl.ShadowPricing.Work.MaximumIterations"] = self.uwslShadowPricingWorkMaximumIterations + props["uwsl.ShadowPricing.School.MaximumIterations"] = self.uwslShadowPricingSchoolMaximumIterations + props.save() # Log current state of props interface for debugging of UI / file sync issues @@ -508,8 +520,8 @@ def save(self, path=None): # check for possible interference if user edits the # properties files directly while it is already open in Modeller timestamp = os.path.getmtime(path) - if timestamp != self._timestamp: - raise Exception("%s file conflict - edited externally after loading" % path) + # if timestamp != self._timestamp: + # raise Exception("%s file conflict - edited externally after loading" % path) self["SavedFrom"] = "Emme Modeller properties writer Process ID %s" % os.getpid() self["SavedLast"] = time.strftime("%b-%d-%Y %H:%M:%S") with open(path, 'w') as f: diff --git a/src/main/java/org/sandag/abm/active/sandag/SandagBikePathChoiceLogsumMatrixApplication.java b/src/main/java/org/sandag/abm/active/sandag/SandagBikePathChoiceLogsumMatrixApplication.java index 48c613633..465340d3a 100644 --- a/src/main/java/org/sandag/abm/active/sandag/SandagBikePathChoiceLogsumMatrixApplication.java +++ b/src/main/java/org/sandag/abm/active/sandag/SandagBikePathChoiceLogsumMatrixApplication.java @@ -22,6 +22,7 @@ import org.sandag.abm.active.PathAlternativeListGenerationConfiguration; import org.sandag.abm.application.SandagModelStructure; import org.sandag.abm.ctramp.BikeLogsum; +import org.sandag.abm.ctramp.Household; import org.sandag.abm.ctramp.Person; import org.sandag.abm.ctramp.Tour; import com.pb.common.util.ResourceUtil; @@ -71,7 +72,9 @@ protected SandagBikePathChoiceModel initialValue() SandagModelStructure modelStructure = new SandagModelStructure(); for (int i = 0; i < MARKET_SEGMENT_NAMES.length; i++) { - persons[i] = new Person(null, 1, modelStructure); + //persons[i] = new Person(null, 1, modelStructure); + Household hh = new Household(modelStructure); + persons[i] = new Person(hh, 1, modelStructure); persons[i].setPersGender(MARKET_SEGMENT_GENDER_VALUES[i]); tours[i] = new Tour(persons[i], 1, MARKET_SEGMENT_TOUR_PURPOSE_INDICES[i]); } diff --git a/src/main/java/org/sandag/abm/application/SandagHouseholdDataManager2.java b/src/main/java/org/sandag/abm/application/SandagHouseholdDataManager2.java index d6364c4ec..ca8f30f72 100644 --- a/src/main/java/org/sandag/abm/application/SandagHouseholdDataManager2.java +++ b/src/main/java/org/sandag/abm/application/SandagHouseholdDataManager2.java @@ -69,6 +69,7 @@ public void mapTablesToHouseholdObjects() // read the correspondence files for mapping persons to occupation and HashMap occCodes = readOccupCorrespondenceData(); int[] indCodes = readIndustryCorrespondenceData(); + boolean hasSampleRate=(hhTable.getColumnPosition(HH_SAMPLERATE_FIELD_NAME) > -1 ? true : false); // get the maximum HH id value to use to dimension the hhIndex // correspondence @@ -179,6 +180,14 @@ public void mapTablesToHouseholdObjects() int numAutos = (int) hhTable.getValueAt(r, hhTable.getColumnPosition(HH_AUTOS_FIELD_NAME)); hh.setHhAutos(numAutos); + + // read sample rate from file if it exists, and multiply by the global sample rate since there might be a sample of households + // that doesn't vary by TAZ + + float hhSampleRate = sampleRate; + if(hasSampleRate) + hhSampleRate = hhTable.getValueAt(r, hhTable.getColumnPosition(HH_SAMPLERATE_FIELD_NAME))*sampleRate; + hh.setSampleRate(hhSampleRate); // set the hhSize variable and create Person objects for each // person @@ -305,6 +314,7 @@ public void mapTablesToHouseholdObjects() personTable.getColumnPosition(PERSON_PERSON_ID_FIELD_NAME)); Person person = hh.getPerson(persNum++); person.setPersId(persId); + person.setSampleRate(hh.getSampleRate()); fieldCount++; // get required values from table record and store in Person diff --git a/src/main/java/org/sandag/abm/application/SandagTripTables.java b/src/main/java/org/sandag/abm/application/SandagTripTables.java index a8c81f0c0..3c17f517f 100644 --- a/src/main/java/org/sandag/abm/application/SandagTripTables.java +++ b/src/main/java/org/sandag/abm/application/SandagTripTables.java @@ -64,18 +64,18 @@ public class SandagTripTables private float[][] CBDVehicles; // an // period private float[][] PNRVehicles; // an - private float sampleRate; + //private float sampleRate; private int iteration; private MatrixType mt; private MatrixDataServerRmi ms; private String[] indivColumns = {"stop_period", "orig_mgra", "dest_mgra", "trip_mode", "inbound", "trip_board_tap", "trip_alight_tap", "set", - "parking_mgra", "tour_purpose", "valueOfTime", "transponder_avail" }; + "parking_mgra", "tour_purpose", "valueOfTime", "transponder_avail", "sampleRate" }; private String[] jointColumns = {"stop_period", "orig_mgra", "dest_mgra", "trip_mode", "inbound", "trip_board_tap", "trip_alight_tap", "set", - "parking_mgra", "tour_purpose", "num_participants", "valueOfTime", "transponder_avail"}; + "parking_mgra", "tour_purpose", "num_participants", "valueOfTime", "transponder_avail", "sampleRate"}; private HashMap averageOcc3Plus; // a @@ -101,7 +101,7 @@ public class SandagTripTables * Iteration number, program will look for trip file names with * _iteration appended */ - public SandagTripTables(HashMap rbMap, float sampleRate, int iteration) + public SandagTripTables(HashMap rbMap, int iteration) //, float sampleRate { this.rbMap = rbMap; @@ -161,7 +161,7 @@ public SandagTripTables(HashMap rbMap, float sampleRate, int ite CBDVehicles = new float[mgraManager.getMaxMgra() + 1][numberOfPeriods]; PNRVehicles = new float[tapManager.getMaxTap() + 1][numberOfPeriods]; - setSampleRate(sampleRate); + //setSampleRate(sampleRate); setIteration(iteration); //value of time thresholds @@ -459,6 +459,7 @@ public void processTrips(int timePeriod, TableDataSet tripData) int originTAZ = mgraManager.getTaz(originMGRA); int destinationTAZ = mgraManager.getTaz(destinationMGRA); int inbound = (int) tripData.getValueAt(i, "inbound"); + float sampleRate = tripData.getValueAt(i, "sampleRate"); //value of time float valueOfTime = tripData.getValueAt(i,valueOfTimeCol); @@ -837,10 +838,10 @@ public void writePNRFile(String fileName) * @param sampleRate * The sample rate, used for expanding trips */ - public void setSampleRate(float sampleRate) - { - this.sampleRate = sampleRate; - } + //public void setSampleRate(float sampleRate) + //{ + // this.sampleRate = sampleRate; + //} /** * Set the iteration number @@ -892,7 +893,7 @@ public static void main(String[] args) logger.info(String.format("-sampleRate %.4f.", sampleRate)); logger.info("-iteration " + iteration); - SandagTripTables tripTables = new SandagTripTables(pMap, sampleRate, iteration); + SandagTripTables tripTables = new SandagTripTables(pMap, iteration); //, sampleRate String matrixTypeName = Util.getStringValueFromPropertyMap(pMap, "Results.MatrixType"); tripTables.mt = MatrixType.lookUpMatrixType(matrixTypeName); diff --git a/src/main/java/org/sandag/abm/ctramp/DestChoiceDMU.java b/src/main/java/org/sandag/abm/ctramp/DestChoiceDMU.java index be69e848f..10f962ab5 100644 --- a/src/main/java/org/sandag/abm/ctramp/DestChoiceDMU.java +++ b/src/main/java/org/sandag/abm/ctramp/DestChoiceDMU.java @@ -54,8 +54,9 @@ private void initDmuObject() // create default objects - some choice models use these as place // holders for values - person = new Person(null, -1, modelStructure); + //person = new Person(null, -1, modelStructure); hh = new Household(modelStructure); + person = new Person(hh, -1, modelStructure); mgraManager = MgraDataManager.getInstance(); diff --git a/src/main/java/org/sandag/abm/ctramp/DestChoiceTwoStageModelDMU.java b/src/main/java/org/sandag/abm/ctramp/DestChoiceTwoStageModelDMU.java index a23453cfb..a12ec0a54 100644 --- a/src/main/java/org/sandag/abm/ctramp/DestChoiceTwoStageModelDMU.java +++ b/src/main/java/org/sandag/abm/ctramp/DestChoiceTwoStageModelDMU.java @@ -57,8 +57,9 @@ private void initDmuObject() // create default objects - some choice models use these as place // holders for values - person = new Person(null, -1, modelStructure); + //person = new Person(null, -1, modelStructure); hh = new Household(modelStructure); + person = new Person(hh, -1, modelStructure); mgraManager = MgraDataManager.getInstance(); diff --git a/src/main/java/org/sandag/abm/ctramp/Household.java b/src/main/java/org/sandag/abm/ctramp/Household.java index ba5b01142..361b2b357 100644 --- a/src/main/java/org/sandag/abm/ctramp/Household.java +++ b/src/main/java/org/sandag/abm/ctramp/Household.java @@ -75,6 +75,7 @@ public class Household private int maxMixedOverlaps; private ModelStructure modelStructure; + private float sampleRate; private long seed; public Household(ModelStructure modelStructure) @@ -1773,6 +1774,15 @@ public enum HouseholdType { nul, FAMILY_MARRIED, FAMILY_MALE_NO_WIFE, FAMILY_FEMALE_NO_HUSBAND, NON_FAMILY_MALE_ALONE, NON_FAMILY_MALE_NOT_ALONE, NON_FAMILY_FEMALE_ALONE, NON_FAMILY_FEMALE_NOT_ALONE } + + public float getSampleRate() { + return this.sampleRate; + } + + public void setSampleRate(float aSampleRate) { + this.sampleRate = aSampleRate; + } + /** * Iterate through persons in household grab all adults and add them to an ArrayList of adults. Return the list. diff --git a/src/main/java/org/sandag/abm/ctramp/HouseholdDataManager.java b/src/main/java/org/sandag/abm/ctramp/HouseholdDataManager.java index 515f48f8d..bf4e8d0e5 100644 --- a/src/main/java/org/sandag/abm/ctramp/HouseholdDataManager.java +++ b/src/main/java/org/sandag/abm/ctramp/HouseholdDataManager.java @@ -68,6 +68,7 @@ public abstract class HouseholdDataManager public static final String HH_TYPE_FIELD_NAME = "HHT"; public static final String HH_BLDGSZ_FIELD_NAME = "BLDGSZ"; public static final String HH_UNITTYPE_FIELD_NAME = "UNITTYPE"; + public static final String HH_SAMPLERATE_FIELD_NAME = "SampleRate"; // HHID,PERID,AGE,SEX,OCCCEN1,INDCEN,PEMPLOY,PSTUDENT,PTYPE,EDUC,GRADE public static final String PERSON_HH_ID_FIELD_NAME = "HHID"; @@ -976,6 +977,7 @@ public int[][] getTourPurposePersonsByHomeMgra(String[] purposeList) { Person person = persons[p]; + double expansionFactor = 1.0/person.getSampleRate(); int purposeIndex = -1; try @@ -985,7 +987,7 @@ public int[][] getTourPurposePersonsByHomeMgra(String[] purposeList) { purposeIndex = person.getWorkLocationSegmentIndex(); - personsWithMandatoryPurpose[purposeIndex][homeMgra]++; + personsWithMandatoryPurpose[purposeIndex][homeMgra]+=expansionFactor; } @@ -996,7 +998,7 @@ public int[][] getTourPurposePersonsByHomeMgra(String[] purposeList) { purposeIndex = person.getSchoolLocationSegmentIndex(); - personsWithMandatoryPurpose[purposeIndex][homeMgra]++; + personsWithMandatoryPurpose[purposeIndex][homeMgra]+=expansionFactor; } @@ -1097,6 +1099,7 @@ public int[][] getWorkersByHomeMgra(HashMap segmentValueIndexM { Person person = persons[p]; + double expansionFactor = 1.0/person.getSampleRate(); if (person.getPersonIsFullTimeWorker() == 1 || person.getPersonIsPartTimeWorker() == 1) @@ -1109,7 +1112,7 @@ public int[][] getWorkersByHomeMgra(HashMap segmentValueIndexM occup = person.getPersPecasOccup(); segmentIndex = segmentValueIndexMap.get(occup); - workersByHomeMgra[segmentIndex][homeMgra]++; + workersByHomeMgra[segmentIndex][homeMgra]+=expansionFactor; } catch (Exception e) { @@ -1152,6 +1155,7 @@ public int[][] getStudentsByHomeMgra() { Person person = persons[p]; + double expansionFactor = 1.0/person.getSampleRate(); if (person.getPersonIsPreschoolChild() == 1 || person.getPersonIsStudentNonDriving() == 1 @@ -1190,7 +1194,7 @@ public int[][] getStudentsByHomeMgra() // if person type is a student but segment index is -1, // the person is not enrolled; assume home schooled and // don't add to sum by home mgra - if (segmentIndex >= 0) studentsByHomeMgra[segmentIndex][homeMgra]++; + if (segmentIndex >= 0) studentsByHomeMgra[segmentIndex][homeMgra]+=expansionFactor; } catch (Exception e) { @@ -1229,6 +1233,7 @@ public int[] getIndividualNonMandatoryToursByHomeMgra(String purposeString) { Person person = persons[p]; + double expansionFactor = 1.0/person.getSampleRate(); ArrayList it = person.getListOfIndividualNonMandatoryTours(); @@ -1244,7 +1249,7 @@ public int[] getIndividualNonMandatoryToursByHomeMgra(String purposeString) if (purposeString.startsWith(tourPurpose)) { int homeMgra = hhs[r].getHhMgra(); - individualNonMandatoryTours[homeMgra]++; + individualNonMandatoryTours[homeMgra]+=expansionFactor; count++; } } @@ -1283,6 +1288,7 @@ public int[][] getWorkToursByDestMgra(HashMap segmentValueInde { Person person = persons[p]; + double expansionFactor = 1.0/person.getSampleRate(); int occup = -1; int segmentIndex = -1; @@ -1298,7 +1304,7 @@ public int[][] getWorkToursByDestMgra(HashMap segmentValueInde { occup = person.getPersPecasOccup(); segmentIndex = segmentValueIndexMap.get(occup); - workTours[segmentIndex][destMgra]++; + workTours[segmentIndex][destMgra]+=expansionFactor; } } @@ -1337,6 +1343,7 @@ public int[] getWorksAtHomeBySegment(HashMap segmentValueIndex { Person person = persons[p]; + double expansionFactor = 1.0/person.getSampleRate(); int occup = -1; int segmentIndex = -1; @@ -1352,7 +1359,7 @@ public int[] getWorksAtHomeBySegment(HashMap segmentValueIndex { occup = person.getPersPecasOccup(); segmentIndex = segmentValueIndexMap.get(occup); - workAtHome[segmentIndex]++; + workAtHome[segmentIndex]+=expansionFactor; } } @@ -1405,6 +1412,8 @@ public int[][] getSchoolToursByDestMgra() { Person person = persons[p]; + double expansionFactor = 1.0/person.getSampleRate(); + destMgra = person.getPersonSchoolLocationZone(); if (destMgra == 0) continue; @@ -1437,7 +1446,7 @@ public int[][] getSchoolToursByDestMgra() // if person type is a student but segment index is -1, the // person is not enrolled; assume home schooled and don't // add to sum by home mgra - if (segmentIndex >= 0) schoolTours[segmentIndex][destMgra]++; + if (segmentIndex >= 0) schoolTours[segmentIndex][destMgra]+=expansionFactor; } catch (Exception e) { @@ -1472,7 +1481,9 @@ public int[] getJointToursByHomeZoneSubZone(String purposeString) try { - Tour[] jt = hhs[r].getJointTourArray(); + double expansionFactor = 1.0/hhs[r].getSampleRate(); + + Tour[] jt = hhs[r].getJointTourArray(); if (jt == null) continue; @@ -1482,7 +1493,7 @@ public int[] getJointToursByHomeZoneSubZone(String purposeString) if (jt[i].getTourPurpose().equalsIgnoreCase(purposeString)) { int homeMgra = hhs[r].getHhMgra(); - jointTours[homeMgra]++; + jointTours[homeMgra]+=expansionFactor; count++; } } @@ -1519,6 +1530,7 @@ public int[] getAtWorkSubtoursByWorkMgra(String purposeString) { Person person = persons[p]; + double expansionFactor = 1.0/person.getSampleRate(); ArrayList subtourList = person.getListOfAtWorkSubtours(); @@ -1534,7 +1546,7 @@ public int[] getAtWorkSubtoursByWorkMgra(String purposeString) if (tourPurpose.startsWith(purposeString)) { int workZone = tour.getTourOrigMgra(); - subtours[workZone]++; + subtours[workZone]+=expansionFactor; count++; } } diff --git a/src/main/java/org/sandag/abm/ctramp/HouseholdDataWriter.java b/src/main/java/org/sandag/abm/ctramp/HouseholdDataWriter.java index 4a304b6ce..0db9f6030 100644 --- a/src/main/java/org/sandag/abm/ctramp/HouseholdDataWriter.java +++ b/src/main/java/org/sandag/abm/ctramp/HouseholdDataWriter.java @@ -286,6 +286,7 @@ private List formHouseholdColumnNames() data.add("out_escort_choice"); data.add("inb_escort_choice"); data.add("jtf_choice"); + data.add("sampleRate"); if(writeLogsums){ data.add("aoLogsum"); @@ -311,6 +312,7 @@ private List formHouseholdColumnTypes() data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.INTEGER); + data.add(SqliteDataTypes.REAL); if(writeLogsums){ data.add(SqliteDataTypes.REAL); @@ -335,6 +337,7 @@ private List formHouseholdDataEntry(Household hh) data.add(string(hh.getOutboundEscortChoice())); data.add(string(hh.getInboundEscortChoice())); data.add(string(hh.getJointTourFreqChosenAlt())); + data.add(string(hh.getSampleRate())); if(writeLogsums){ data.add(string(hh.getAutoOwnershipLogsum())); @@ -364,6 +367,7 @@ private List formPersonColumnNames() data.add("ie_choice"); data.add("timeFactorWork"); data.add("timeFactorNonWork"); + data.add("sampleRate"); if(writeLogsums){ data.add("wfhLogsum"); @@ -399,6 +403,7 @@ private List formPersonColumnTypes() data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.REAL); data.add(SqliteDataTypes.REAL); + data.add(SqliteDataTypes.REAL); if(writeLogsums){ data.add(SqliteDataTypes.REAL); @@ -434,6 +439,7 @@ private List formPersonDataEntry(Person p) data.add(string(p.getInternalExternalTripChoiceResult())); data.add(string(p.getTimeFactorWork())); data.add(string(p.getTimeFactorNonWork())); + data.add(string(p.getSampleRate())); if(writeLogsums){ data.add(string(p.getWorksFromHomeLogsum())); @@ -476,6 +482,7 @@ private List formIndivTourColumnNames() data.add("escort_type_in"); data.add("driver_num_out"); data.add("driver_num_in"); + data.add("sampleRate"); if (saveUtilsProbsFlag) { @@ -533,6 +540,7 @@ private List formJointTourColumnNames() data.add("num_ob_stops"); data.add("num_ib_stops"); data.add("valueOfTime"); + data.add("sampleRate"); if (saveUtilsProbsFlag) { @@ -596,6 +604,7 @@ private List formIndivTourColumnTypes() data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.INTEGER); + data.add(SqliteDataTypes.REAL); if (saveUtilsProbsFlag) { @@ -649,6 +658,7 @@ private List formJointTourColumnTypes() data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.REAL); + data.add(SqliteDataTypes.REAL); if (saveUtilsProbsFlag) { @@ -709,6 +719,7 @@ private List formIndivTourDataEntry(Tour t) data.add(string(t.getEscortTypeInbound())); data.add(string(t.getDriverPnumOutbound())); data.add(string(t.getDriverPnumInbound())); + data.add(string(t.getSampleRate())); if (saveUtilsProbsFlag) { @@ -785,6 +796,7 @@ private List formJointTourDataEntry(Tour t) data.add(string(t.getNumOutboundStops() == 0 ? 0 : t.getNumOutboundStops() - 1)); data.add(string(t.getNumInboundStops() == 0 ? 0 : t.getNumInboundStops() - 1)); data.add(string(t.getValueOfTime())); + data.add(string(t.getSampleRate())); if (saveUtilsProbsFlag) { @@ -896,6 +908,7 @@ private List formIndivTripColumnNames() data.add("micro_trnAcc"); data.add("micro_trnEgr"); data.add("parkingCost"); + data.add("sampleRate"); if(writeLogsums) { data.add("tripModeLogsum"); @@ -934,6 +947,7 @@ private List formJointTripColumnNames() //data.add("micro_trnAcc"); //data.add("micro_trnEgr"); data.add("parkingCost"); + data.add("sampleRate"); if(writeLogsums) { data.add("tripModeLogsum"); @@ -978,6 +992,7 @@ private List formIndivTripColumnTypes() data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.REAL); + data.add(SqliteDataTypes.REAL); if(writeLogsums) { data.add(SqliteDataTypes.REAL); @@ -1014,6 +1029,7 @@ private List formJointTripColumnTypes() data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.INTEGER); data.add(SqliteDataTypes.REAL); + data.add(SqliteDataTypes.REAL); if(writeLogsums) { data.add(SqliteDataTypes.REAL); @@ -1120,6 +1136,7 @@ private List formIndivTripDataEntry(Stop s) data.add(string(s.getMicromobilityAccessMode())); data.add(string(s.getMicromobilityEgressMode())); data.add(string(s.getParkingCost())); + data.add(string(t.getSampleRate())); if(writeLogsums) { data.add(string(s.getModeLogsum())); @@ -1228,6 +1245,7 @@ private List formJointTripDataEntry(Stop s) //data.add(string(s.getMicromobilityAccessMode())); //data.add(string(s.getMicromobilityEgressMode())); data.add(string(s.getParkingCost())); + data.add(string(t.getSampleRate())); if(writeLogsums) { data.add(string(s.getModeLogsum())); diff --git a/src/main/java/org/sandag/abm/ctramp/Person.java b/src/main/java/org/sandag/abm/ctramp/Person.java index 9ce748674..561707d88 100644 --- a/src/main/java/org/sandag/abm/ctramp/Person.java +++ b/src/main/java/org/sandag/abm/ctramp/Person.java @@ -138,7 +138,9 @@ public class Person private int windowBetweenFirstLastMandJointTour; private int windowAfterLastMandJointTour; - private ModelStructure modelStructure; + private float sampleRate; + + private ModelStructure modelStructure; public Person(Household hhObj, int persNum, ModelStructure modelStructure) { @@ -149,6 +151,9 @@ public Person(Household hhObj, int persNum, ModelStructure modelStructure) this.indNonManTourArrayList = new ArrayList(); this.atWorkSubtourArrayList = new ArrayList(); this.modelStructure = modelStructure; + + if(hhObj!=null) + this.sampleRate = hhObj.getSampleRate(); initializeWindows(); @@ -502,6 +507,8 @@ public void createIndividualNonMandatoryTours(int numberOfTours, String primaryP tempTour.setTourDepartPeriod(DEFAULT_NON_MANDATORY_START_PERIOD); tempTour.setTourArrivePeriod(DEFAULT_NON_MANDATORY_END_PERIOD); + + tempTour.setSampleRate(this.sampleRate); indNonManTourArrayList.add(tempTour); } @@ -531,6 +538,8 @@ public void createWorkTours(int numberOfTours, int startId, String tourPurpose, tempTour.setTourArrivePeriod(-1); // tempTour.setTourDepartPeriod(DEFAULT_MANDATORY_START_PERIOD); // tempTour.setTourArrivePeriod(DEFAULT_MANDATORY_END_PERIOD); + + tempTour.setSampleRate(this.sampleRate); workTourArrayList.add(tempTour); } @@ -565,6 +574,8 @@ public void createAtWorkSubtour(int id, int choice, int workMgra, String subtour tempTour.setTourDepartPeriod(DEFAULT_AT_WORK_SUBTOUR_START_PERIOD); tempTour.setTourArrivePeriod(DEFAULT_AT_WORK_SUBTOUR_END_PERIOD); + + tempTour.setSampleRate(this.sampleRate); atWorkSubtourArrayList.add(tempTour); @@ -593,6 +604,8 @@ public void createSchoolTours(int numberOfTours, int startId, String tourPurpose tempTour.setTourArrivePeriod(-1); // tempTour.setTourDepartPeriod(DEFAULT_MANDATORY_START_PERIOD); // tempTour.setTourArrivePeriod(DEFAULT_MANDATORY_END_PERIOD); + + tempTour.setSampleRate(sampleRate); schoolTourArrayList.add(tempTour); } @@ -1683,6 +1696,7 @@ public void logPersonObject(Logger logger, int totalChars) Household.logHelper(logger, "persEmploymentCategory: ", persEmploymentCategory, totalChars); Household.logHelper(logger, "persStudentCategory: ", persStudentCategory, totalChars); Household.logHelper(logger, "personType: ", personType, totalChars); + Household.logHelper(logger, "sampleRate: ", String.format("%.3f", this.sampleRate), totalChars); Household.logHelper(logger, "workLoc: ", workLocation, totalChars); Household.logHelper(logger, "schoolLoc: ", schoolLoc, totalChars); Household.logHelper(logger, "workLocSegmentIndex: ", workLocSegmentIndex, totalChars); @@ -1841,6 +1855,7 @@ public void logEntirePersonObject(Logger logger) Household.logHelper(logger, "persEmploymentCategory: ", persEmploymentCategory, totalChars); Household.logHelper(logger, "persStudentCategory: ", persStudentCategory, totalChars); Household.logHelper(logger, "personType: ", personType, totalChars); + Household.logHelper(logger, "sampleRate: ", String.format("%.3f", this.sampleRate), totalChars); Household.logHelper(logger, "workLoc: ", workLocation, totalChars); Household.logHelper(logger, "schoolLoc: ", schoolLoc, totalChars); Household.logHelper(logger, "workLocSegmentIndex: ", workLocSegmentIndex, totalChars); @@ -1997,6 +2012,15 @@ public enum PersonType nul, FT_worker_age_16plus, PT_worker_nonstudent_age_16plus, University_student, Nonworker_nonstudent_age_16_64, Nonworker_nonstudent_age_65plus, Student_age_16_19_not_FT_wrkr_or_univ_stud, Student_age_6_15_schpred, Preschool_under_age_6 } + public float getSampleRate() { + return this.sampleRate; + } + + public void setSampleRate(float aSampleRate) + { + this.sampleRate = aSampleRate; + } + /** * Returns true if this person is an active adult, else returns false. Active adult * is defined as full-time worker, part-time worker, university student, diff --git a/src/main/java/org/sandag/abm/ctramp/Stop.java b/src/main/java/org/sandag/abm/ctramp/Stop.java index 882b5b80b..8ca77e3f0 100644 --- a/src/main/java/org/sandag/abm/ctramp/Stop.java +++ b/src/main/java/org/sandag/abm/ctramp/Stop.java @@ -28,6 +28,7 @@ public class Stop int boardTap; int alightTap; boolean inbound; + float sampleRate; int set = -1; private int escorteePnumOrig; @@ -52,6 +53,8 @@ public Stop(Tour parentTour, String origPurpose, String destPurpose, int id, boo this.stopPurposeIndex = stopPurposeIndex; this.id = id; this.inbound = inbound; + if(parentTour!=null) + this.sampleRate = parentTour.getSampleRate(); } public void setOrig(int orig) @@ -272,6 +275,14 @@ public void setParkingCost(float parkingCost) { this.parkingCost = parkingCost; } + public float getSampleRate() { + return sampleRate; + } + + public void setSampleRate(float aSampleRate) { + this.sampleRate = aSampleRate; + } + public void logStopObject(Logger logger, int totalChars) { diff --git a/src/main/java/org/sandag/abm/ctramp/Tour.java b/src/main/java/org/sandag/abm/ctramp/Tour.java index 0646c5c60..4223fea79 100644 --- a/src/main/java/org/sandag/abm/ctramp/Tour.java +++ b/src/main/java/org/sandag/abm/ctramp/Tour.java @@ -78,6 +78,8 @@ public class Tour private int escortTypeInbound; private int driverPnumOutbound; private int driverPnumInbound; + + private float sampleRate; // this constructor used for mandatory tour creation public Tour(Person perObj, int tourId, int primaryIndex) @@ -87,6 +89,8 @@ public Tour(Person perObj, int tourId, int primaryIndex) this.tourId = tourId; tourCategory = ModelStructure.MANDATORY_CATEGORY; tourPrimaryPurposeIndex = primaryIndex; + if(hhObj!=null) + this.sampleRate = perObj.getSampleRate(); outboundStopDestinationLogsums = new ArrayList(); inboundStopDestinationLogsums = new ArrayList(); @@ -99,6 +103,9 @@ public Tour(Household hhObj, String tourPurpose, String category, int primaryInd this.tourPurpose = tourPurpose; tourCategory = category; tourPrimaryPurposeIndex = primaryIndex; + if(hhObj!=null) + this.sampleRate = hhObj.getSampleRate(); + outboundStopDestinationLogsums = new ArrayList(); inboundStopDestinationLogsums = new ArrayList(); } @@ -114,6 +121,9 @@ public Tour(int id, Household hhObj, Person persObj, String tourPurpose, String this.tourPurpose = tourPurpose; tourCategory = category; tourPrimaryPurposeIndex = primaryIndex; + if(hhObj!=null) + this.sampleRate = hhObj.getSampleRate(); + outboundStopDestinationLogsums = new ArrayList(); inboundStopDestinationLogsums = new ArrayList(); } @@ -871,5 +881,16 @@ public double getJointTourTimeFactor() { return 1.0; } + + public float getSampleRate() + { + return this.sampleRate; + } + + public void setSampleRate(float aSampleRate) + { + this.sampleRate = aSampleRate; + } + } \ No newline at end of file diff --git a/src/main/java/org/sandag/abm/internalexternal/InternalExternalModel.java b/src/main/java/org/sandag/abm/internalexternal/InternalExternalModel.java index 0355e1bc2..cd39393fa 100644 --- a/src/main/java/org/sandag/abm/internalexternal/InternalExternalModel.java +++ b/src/main/java/org/sandag/abm/internalexternal/InternalExternalModel.java @@ -67,6 +67,14 @@ public void setIteration(int iteration) this.iteration = iteration; } + public float getSampleRate() { + return sampleRate; + } + + public void setSampleRate(float sampleRate) { + this.sampleRate = sampleRate; + } + /** * Run InternalExternal model. */ @@ -76,13 +84,13 @@ public void runModel() InternalExternalModelStructure modelStructure = new InternalExternalModelStructure(); InternalExternalDmuFactoryIf dmuFactory = new InternalExternalDmuFactory(modelStructure); - - InternalExternalTourManager tourManager = new InternalExternalTourManager(rbMap, iteration); - + + InternalExternalTourManager tourManager = new InternalExternalTourManager(rbMap, iteration, sampleRate); + tourManager.generateTours(); - + InternalExternalTour[] tours = tourManager.getTours(); - + tazDistanceCalculator = new AutoTazSkimsCalculator(rbMap); tazDistanceCalculator.computeTazDistanceArrays(); logsumsCalculator = new McLogsumsCalculator(); @@ -99,7 +107,7 @@ public void runModel() InternalExternalTripModeChoiceModel tripModeChoiceModel = new InternalExternalTripModeChoiceModel( rbMap, modelStructure, dmuFactory); - + // Run models for array of tours for (int i = 0; i < tours.length; ++i) { @@ -136,7 +144,7 @@ public void runModel() tour.setTrips(trips); } - + tourManager.writeOutputFile(rbMap); logger.info("Internal-External Model successfully completed!"); @@ -234,6 +242,7 @@ public static void main(String[] args) logger.info("IE Model:"+String.format("-sampleRate %.4f.", sampleRate)+"-iteration " + iteration); InternalExternalModel internalExternalModel = new InternalExternalModel(pMap); internalExternalModel.setIteration(iteration); + internalExternalModel.setSampleRate(sampleRate); String matrixServerAddress = ""; int serverPort = 0; diff --git a/src/main/java/org/sandag/abm/internalexternal/InternalExternalTour.java b/src/main/java/org/sandag/abm/internalexternal/InternalExternalTour.java index 97a7dc819..b7f6f7991 100644 --- a/src/main/java/org/sandag/abm/internalexternal/InternalExternalTour.java +++ b/src/main/java/org/sandag/abm/internalexternal/InternalExternalTour.java @@ -23,6 +23,7 @@ public class InternalExternalTour private double nonWorkTimeFactor; private boolean avAvailable; + private float sampleRate; // private InternalExternalStop[] outboundStops; // private InternalExternalStop[] inboundStops; @@ -244,6 +245,14 @@ public void setAge(int age) this.age = age; } + public float getSampleRate() { + return sampleRate; + } + + public void setSampleRate(float sampleRate) { + this.sampleRate = sampleRate; + } + public int getFemale() { return female; diff --git a/src/main/java/org/sandag/abm/internalexternal/InternalExternalTourManager.java b/src/main/java/org/sandag/abm/internalexternal/InternalExternalTourManager.java index 3d5d669d8..f40331455 100644 --- a/src/main/java/org/sandag/abm/internalexternal/InternalExternalTourManager.java +++ b/src/main/java/org/sandag/abm/internalexternal/InternalExternalTourManager.java @@ -27,6 +27,7 @@ public class InternalExternalTourManager public static final String PROPERTIES_DISTRIBUTED_TIME = "distributedTimeCoefficients"; protected boolean readTimeFactors; public static final String PERSON_TIMEFACTOR_NONWORK_FIELD_NAME = "timeFactorNonWork"; + public static final String HH_SAMPLERATE_FIELD_NAME = "sampleRate"; InternalExternalModelStructure modelStructure; @@ -36,6 +37,7 @@ public class InternalExternalTourManager private int traceId; private MersenneTwister random; + private class HouseholdClass { @@ -44,6 +46,7 @@ private class HouseholdClass int income; int homeMGRA; int autonomousVehicles; + float sampleRate; } private HashMap householdData; @@ -58,7 +61,7 @@ private class HouseholdClass * * Creates the array of cross-border tours. */ - public InternalExternalTourManager(HashMap rbMap, int iteration) + public InternalExternalTourManager(HashMap rbMap, int iteration, float sampleRate) { modelStructure = new InternalExternalModelStructure(); @@ -83,7 +86,7 @@ public InternalExternalTourManager(HashMap rbMap, int iteration) extension = getFileExtension(householdFile); householdFile = removeFileExtension(householdFile) + iterationString + extension; - readHouseholdFile(householdFile); + readHouseholdFile(householdFile, sampleRate); personData = readFile(personFile); seek = new Boolean(Util.getStringValueFromPropertyMap(rbMap, "internalExternal.seek")); @@ -141,9 +144,8 @@ public String removeFileExtension(String fileName) * @param fileName * household file path/name. */ - public void readHouseholdFile(String fileName) + public void readHouseholdFile(String fileName, float sampleRate) { - householdData = new HashMap(); logger.info("Begin reading the data in file " + fileName); @@ -157,6 +159,8 @@ public void readHouseholdFile(String fileName) { throw new RuntimeException(e); } + + boolean hasSampleRate=(hhData.getColumnPosition(HH_SAMPLERATE_FIELD_NAME) > -1 ? true : false); // iterate through the table and save number of autos for (int i = 1; i <= hhData.getRowCount(); ++i) @@ -167,6 +171,12 @@ public void readHouseholdFile(String fileName) int mgra = (int) hhData.getValueAt(i, "home_mgra"); int AVs = (int) hhData.getValueAt(i,"AVs"); + float hhSampleRate = sampleRate; + + //hh data here is output of ct-ramp so already has both (regional and hh) sampling in the samplerate field + //so directly use the value from the sample rate column + if(hasSampleRate) + hhSampleRate = (float) hhData.getValueAt(i, HH_SAMPLERATE_FIELD_NAME); // new household HouseholdClass hh = new HouseholdClass(); @@ -174,6 +184,7 @@ public void readHouseholdFile(String fileName) hh.income = income; hh.homeMGRA = mgra; hh.autonomousVehicles = AVs; + hh.sampleRate = hhSampleRate; // store in HashMap householdData.put(hhID, hh); @@ -244,6 +255,7 @@ public void generateTours() tour.setIncome(hh.income); tour.setAutos(hh.autos); tour.setAge(age); + tour.setSampleRate(hh.sampleRate); if(hh.autonomousVehicles>0) tour.setAvAvailable(true); @@ -261,8 +273,10 @@ public void generateTours() tour.setNonWorkTimeFactor(timeFactorNonWork); tourList.add(tour); + double expansionFactor = 1.0/tour.getSampleRate(); - ++tourCount; + //++tourCount; + tourCount += expansionFactor; } } @@ -305,7 +319,7 @@ public void writeOutputFile(HashMap rbMap) throw new RuntimeException(); } String tripHeaderString = new String( - "hhID,pnum,personID,tourID,originMGRA,destinationMGRA,originTAZ,destinationTAZ,inbound,originIsTourDestination,destinationIsTourDestination,period,tripMode,av_avail,boardingTap,alightingTap,set,valueOfTime\n"); + "hhID,pnum,personID,tourID,originMGRA,destinationMGRA,originTAZ,destinationTAZ,inbound,originIsTourDestination,destinationIsTourDestination,period,tripMode,av_avail,boardingTap,alightingTap,set,valueOfTime,sampleRate\n"); tripWriter.print(tripHeaderString); for (int i = 0; i < tours.length; ++i) @@ -336,7 +350,7 @@ private void writeTrip(int hhID, int pnum, int personID, int tourID, InternalExt + trip.isDestinationIsTourDestination() + "," + trip.getPeriod() + "," + trip.getTripMode() + "," + (tour.isAvAvailable() ? 1 : 0) + "," + trip.getBoardTap() + "," + trip.getAlightTap() + "," + trip.getSet()+ "," - +String.format("%9.2f",trip.getValueOfTime()) + "\n"); + +String.format("%9.2f",trip.getValueOfTime()) + "," + trip.getSampleRate() + "\n"); writer.print(record); } @@ -367,7 +381,7 @@ public static void main(String[] args) } else propertiesFile = args[0]; pMap = ResourceUtil.getResourceBundleAsHashMap(propertiesFile); - InternalExternalTourManager apm = new InternalExternalTourManager(pMap, 1); + InternalExternalTourManager apm = new InternalExternalTourManager(pMap, 1, 1); apm.generateTours(); apm.writeOutputFile(pMap); diff --git a/src/main/java/org/sandag/abm/internalexternal/InternalExternalTrip.java b/src/main/java/org/sandag/abm/internalexternal/InternalExternalTrip.java index c347392dd..ca6958393 100644 --- a/src/main/java/org/sandag/abm/internalexternal/InternalExternalTrip.java +++ b/src/main/java/org/sandag/abm/internalexternal/InternalExternalTrip.java @@ -21,6 +21,7 @@ public class InternalExternalTrip private boolean lastTrip; private boolean originIsTourDestination; private boolean destinationIsTourDestination; + private float sampleRate; private int boardTap; private int alightTap; @@ -88,6 +89,7 @@ public void initializeFromTour(InternalExternalTour tour, boolean outbound, this.originIsTourDestination = true; this.destinationIsTourDestination = false; } + this.sampleRate = tour.getSampleRate(); } /** @@ -309,5 +311,13 @@ public double getValueOfTime() { public void setValueOfTime(double valueOfTime) { this.valueOfTime = valueOfTime; } + + public float getSampleRate() { + return sampleRate; + } + + public void setSampleRate(float sampleRate) { + this.sampleRate = sampleRate; + } } diff --git a/src/main/java/org/sandag/abm/internalexternal/InternalExternalTripTables.java b/src/main/java/org/sandag/abm/internalexternal/InternalExternalTripTables.java index 6a3f74789..bfd9d287c 100644 --- a/src/main/java/org/sandag/abm/internalexternal/InternalExternalTripTables.java +++ b/src/main/java/org/sandag/abm/internalexternal/InternalExternalTripTables.java @@ -362,6 +362,7 @@ public void processTrips(int timePeriod, TableDataSet tripData) int originTAZ = (int) tripData.getValueAt(i, "originTaz"); int destinationTAZ = (int) tripData.getValueAt(i, "destinationTaz"); boolean inbound = tripData.getBooleanValueAt(i, "inbound"); + float sampleRate = tripData.getValueAt(i, "sampleRate"); // transit trip - get boarding and alighting tap int boardTap = 0; @@ -382,7 +383,7 @@ public void processTrips(int timePeriod, TableDataSet tripData) // scale individual person trips by occupancy for tNCVehicle trips // (auto modes only) - float vehicleTrips = 1 / sampleRate; + float vehicleTrips = 1; if (modelStructure.getTripModeIsS2(tripMode)) { @@ -395,8 +396,12 @@ public void processTrips(int timePeriod, TableDataSet tripData) } // calculate person trips for all other modes - float personTrips = 1 / sampleRate; + float personTrips = 1; + // apply sample rate + vehicleTrips = vehicleTrips * 1 / sampleRate; + personTrips = personTrips * 1 / sampleRate; + // Store in matrix int mode = modeIndex[tripMode]; int mat = matrixIndex[tripMode]; diff --git a/src/main/python/pythonGUI/createStudyAndScenario.py b/src/main/python/pythonGUI/createStudyAndScenario.py index a6a9eb92c..9107527b1 100644 --- a/src/main/python/pythonGUI/createStudyAndScenario.py +++ b/src/main/python/pythonGUI/createStudyAndScenario.py @@ -1,101 +1,234 @@ -__author__ = 'wsu' -#Wu.Sun@sandag.org 10-27-2016 import Tkinter import Tkconstants import tkFileDialog import os from Tkinter import * +from tkMessageBox import showerror from PIL import Image,ImageTk import popupMsg +class SelectStudyYears(Tkinter.Frame): + def __init__(self, root, parent): + Tkinter.Frame.__init__(self, root, border = 5) + self.root = root + self.parent = parent + body = Tkinter.Frame(self) + body.pack(fill=Tkconstants.X, expand=1) + body.grid_columnconfigure(1, weight=2) + + current_row = 0 + Tkinter.Label(body, text=u"Year Selection", font=("Helvetica", 10, 'bold')).grid(row=current_row) + current_row += 1 + + self.is_selected_year = {} + for year in parent.studyYearList: + self.is_selected_year[year] = BooleanVar(self.root) + if year in parent.selected_study_years: + self.is_selected_year[year].set(True) + Tkinter.Checkbutton(body, text = year, variable = self.is_selected_year[year], font = ("Helvetica", 8)).grid(row=current_row, sticky = 'W') + current_row += 1 + + Tkinter.Button(body, text=u"Select", font=("Helvetica", 8, 'bold'),width=10,command=lambda: self.record_selection()).grid(row=current_row) + + def record_selection(self): + selection = [] + for year in self.is_selected_year: + if self.is_selected_year[year].get(): + selection.append(year) + self.parent.selected_study_years = ','.join(selection) + self.parent.studyyears.delete(0, Tkconstants.END) + self.parent.studyyears.insert(0, self.parent.selected_study_years) + self.root.destroy() + pass + + class CreateScenarioGUI(Tkinter.Frame): - def __init__(self, root): + def __init__(self, root, emme_version = "4.3.7", year = "2016", geo = "1", lu = "DS41"): Tkinter.Frame.__init__(self, root, border=5) body = Tkinter.Frame(self) body.pack(fill=Tkconstants.X, expand=1) sticky = Tkconstants.E + Tkconstants.W body.grid_columnconfigure(1, weight=2) + #Define land use options + self.lu_options = {"DS41": {"name": "Baseline", + "years": ["2016", "2020", "2025nb", "2030nb", "2035nb", "2040nb", "2050nb"]}, + "DS42": {"name": "Sustainable Community Strategy", + "years": ["2023", "2025", "2026", "2029", "2030", "2032", "2035", "2040", "2050"]}, + "DS41 Hybrid": {"name": "Parking Update", + "years": ["2025", "2030", "2035", "2040", "2050"]}} + + self.root = root + self.emme_version = emme_version + self.year = year + self.geo = geo + self.lu = lu + + if self.year not in self.lu_options[self.lu]["years"]: + if self.year in self.lu_options["DS41"]["years"]: + self.lu = "DS41" + else: + self.lu = "DS42" + + yearOptionList = [] + for lu in self.lu_options: + yearOptionList += self.lu_options[lu]["years"] + yearOptionList = list(set(yearOptionList)) #Remove duplicates + yearOptionList.sort() + + self.yearOptionList = yearOptionList + self.studyYearList = ["2016", "2020", "2023", "2025_Vision", "2025nb", "2026_Vision", "2029_Vision", + "2030_Vision", "2030nb", "2032_Vision", "2035_Vision", "2035nb", "2040_Vision", + "2040nb", "2050_Vision", "2050nb"] + #divider line - divider=u"_"*120 - self.releaseDir='T:\\ABM\\release\\ABM' + divider=u"_"*200 + self.releaseDir='T:\\ABM\\release_test\\ABM' self.defaultScenarioDir="T:\\projects\\sr14" - self.defaultNetworkDir="T:\\projects\\sr14\\version14_2_0\\network_build" + self.defaultNetworkDir="T:\\RTP\\2021RP\\2021rp_final\\network_build" + + current_row = 0 + n_columns = 3 self.buttonVar= IntVar(root) self.yButton=Radiobutton(body, text="Yes", variable=self.buttonVar, value=1, command=self.initStudy) self.nButton=Radiobutton(body, text="No", variable=self.buttonVar, value=0,command=self.initStudy) - Tkinter.Label(body, text=divider, font=("Helvetica", 11, 'bold'), width=50, fg='royal blue').grid(row=0,columnspan=5) - Tkinter.Label(body, text=u"Create an ABM Work Space", font=("Helvetica", 10, 'bold')).grid(row=1,columnspan=3) - self.yButton.grid(row=2,column=0, columnspan=2) - self.nButton.grid(row=2,column=1, columnspan=2) + Tkinter.Label(body, text=u"Release Version 14.3.0\n"+divider, font=("Helvetica", 11, 'bold'), width=50, fg='royal blue').grid(row=current_row,columnspan=5) + current_row += 1 + Tkinter.Label(body, text=u"Create an ABM Work Space", font=("Helvetica", 10, 'bold')).grid(row=current_row,columnspan=n_columns) + current_row += 1 + self.yButton.grid(row=current_row,column=0, columnspan=n_columns-1) + self.nButton.grid(row=current_row,column=1, columnspan=n_columns-1) + current_row += 1 - Tkinter.Label(body, text=u"Study Folder", font=("Helvetica", 8, 'bold')).grid(row=3) + Tkinter.Label(body, text=u"Study Folder", font=("Helvetica", 8, 'bold')).grid(row=current_row) self.studypath = Tkinter.Entry(body, width=40) - self.studypath.grid(row=3, column=1, sticky=sticky) + self.studypath.grid(row=current_row, column=1, sticky=sticky) self.studypath.delete(0, Tkconstants.END) self.studypath.insert(0, self.defaultScenarioDir) self.studybutton = Tkinter.Button(body, text=u"...",width=4,command=lambda:self.get_path("study")) - self.studybutton.grid(row=3, column=2) + self.studybutton.grid(row=current_row, column=n_columns-1) + current_row += 1 - Tkinter.Label(body, text=u"Network Folder",font=("Helvetica", 8, 'bold')).grid(row=4) + Tkinter.Label(body, text=u"Network Folder",font=("Helvetica", 8, 'bold')).grid(row=current_row) self.studynetworkpath = Tkinter.Entry(body, width=40) - self.studynetworkpath.grid(row=4, column=1, sticky=sticky) + self.studynetworkpath.grid(row=current_row, column=1, sticky=sticky) self.studynetworkpath.delete(0, Tkconstants.END) self.studynetworkpath.insert(0, self.defaultNetworkDir) self.studynetworkbutton = Tkinter.Button(body, text=u"...",width=4,command=lambda: self.get_path("studynetwork")) - self.studynetworkbutton.grid(row=4, column=2) + self.studynetworkbutton.grid(row=current_row, column=n_columns-1) + self.selected_study_years = '' + current_row += 1 + Tkinter.Label(body, text=u"Year Selection",font=("Helvetica", 8, 'bold')).grid(row=current_row) + self.studyyears = Tkinter.Entry(body, width=40) + self.studyyears.grid(row=current_row, column=1, sticky=sticky) + self.studyyears.delete(0, Tkconstants.END) + self.studyyearsbutton = Tkinter.Button(body, text=u"...",width=4,command=lambda: self.select_study_years()) + self.studyyearsbutton.grid(row=current_row, column=n_columns-1) + current_row += 1 + self.copyButton = Tkinter.Button(body, text=u"Create", font=("Helvetica", 8, 'bold'),width=10, command=lambda: self.checkPath("study")) - self.copyButton.grid(row=5,column=0,columnspan=4) + self.copyButton.grid(row=current_row,column=0,columnspan=n_columns+1) + current_row += 1 - Tkinter.Label(body, text=divider, font=("Helvetica", 11, 'bold'), width=50, fg='royal blue').grid(row=6,columnspan=5) - Tkinter.Label(body, text=u"Create an ABM scenario", font=("Helvetica", 10, 'bold')).grid(row=7,columnspan=3) + Tkinter.Label(body, text=divider, font=("Helvetica", 11, 'bold'), width=50, fg='royal blue').grid(row=current_row,columnspan=n_columns+2) + current_row += 1 + Tkinter.Label(body, text=u"Create an ABM scenario", font=("Helvetica", 10, 'bold')).grid(row=current_row,columnspan=n_columns) + current_row += 1 - Tkinter.Label(body, text=u"Version", font=("Helvetica", 8, 'bold')).grid(row=8) - var = StringVar(root) - self.version="version_14_2_2" - optionList=["version_14_2_2"] - option=Tkinter.OptionMenu(body,var,*optionList,command=self.setversion) - option.config(width=50) - option.grid(row=8, column=1) + #Tkinter.Label(body, text=u"Version", font=("Helvetica", 8, 'bold')).grid(row=8) + #var = StringVar(root) + self.version="version_14_3_0" + #optionList=["version_14_2_2"] + #option=Tkinter.OptionMenu(body,var,*optionList,command=self.setversion) + #option.config(width=50) + #option.grid(row=8, column=1) - Tkinter.Label(body, text=u"Emme Version", font=("Helvetica", 8, 'bold')).grid(row=9) + Tkinter.Label(body, text=u"Emme Version", font=("Helvetica", 8, 'bold')).grid(row=current_row) var = StringVar(root) - self.emme_version = "4.4.4.1" - optionList = ["4.3.7", "4.4.4.1"] + #self.emme_version = "4.4.4.1" + optionList = ["4.3.7"] + var.set(self.emme_version) option = Tkinter.OptionMenu(body, var, *optionList, command=self.setEmmeVersion) option.config(width=50) - option.grid(row=9, column=1) - - Tkinter.Label(body, text=u"Year", font=("Helvetica", 8, 'bold')).grid(row=10) + option.grid(row=current_row, column=1) + current_row += 1 + Tkinter.Label(body, text=u"Year", font=("Helvetica", 8, 'bold')).grid(row=current_row) var = StringVar(root) - self.year="2016" - yearOptionList = ["2016", "2020", "2023", "2025", "2025nb", "2026", "2029", "2030", "2030nb", "2032", "2035", "2035nb", "2040", "2040nb", "2050","2050nb"] + #self.year="2016" + #yearOptionList = ["2016", "2020", "2023", "2025", "2025nb", "2026", "2029", "2030", "2030nb", "2032", "2035", "2035nb", "2040", "2040nb", "2050","2050nb"] + #if self.select_lu: + var.set(self.year) + #else: + # var.set("Select Year") option=Tkinter.OptionMenu(body,var,*yearOptionList,command=self.setyear) + option.config(text = self.year) + option.config(width=50) + option.grid(row=current_row, column=1) + current_row += 1 + #option.pack(expand = True) + + Tkinter.Label(body, text=u"Land Use", font=("Helvetica", 8, 'bold')).grid(row=current_row) + #self.lu="DS41" + #if self.select_lu: + var = StringVar(root) + var.set(self.lu + '-' + self.lu_options[self.lu]["name"]) + #if self.year in self.invalid_combos["DS42"]: + # luOptionList = ["DS41-Baseline"] + #elif self.year in self.invalid_combos["DS41"]: + # luOptionList = ["DS42-Sustainable Community Strategy"] + #else: + # luOptionList = ["DS41-Baseline", "DS42"] + luOptionList = [] + for lu in self.lu_options: + if self.year in self.lu_options[lu]["years"]: + luOptionList.append(lu + '-' + self.lu_options[lu]["name"]) + option=Tkinter.OptionMenu(body,var,*luOptionList,command=self.setLU) + option.config(width=50) - option.grid(row=10, column=1) + option.grid(row=current_row, column=1) + current_row += 1 - Tkinter.Label(body, text=u"Scenario Folder", font=("Helvetica", 8, 'bold')).grid(row=11) + Tkinter.Label(body, text=u"Geography ID", font=("Helvetica", 8, 'bold')).grid(row=current_row) + #self.geo="1" + self.geo = Tkinter.Entry(body, width=40) + self.geo.grid(row=current_row, column=1, sticky=sticky) + self.geo.delete(0, Tkconstants.END) + self.geo.insert(0, 1) + current_row += 1 + #option.pack(expand = True) + + Tkinter.Label(body, text=u"Scenario Folder", font=("Helvetica", 8, 'bold')).grid(row=current_row) self.scenariopath = Tkinter.Entry(body, width=40) - self.scenariopath.grid(row=11, column=1, sticky=sticky) + self.scenariopath.grid(row=current_row, column=1, sticky=sticky) button = Tkinter.Button(body, text=u"...",width=4,command=lambda: self.get_path("scenario")) - button.grid(row=11, column=2) + button.grid(row=current_row, column=2) + current_row += 1 - Tkinter.Label(body, text=u"Network Folder",font=("Helvetica", 8, 'bold')).grid(row=12) + Tkinter.Label(body, text=u"Network Folder",font=("Helvetica", 8, 'bold')).grid(row=13) self.networkpath = Tkinter.Entry(body, width=40) - self.networkpath.grid(row=12, column=1, sticky=sticky) + self.networkpath.grid(row=current_row, column=1, sticky=sticky) button = Tkinter.Button(body, text=u"...",width=4,command=lambda: self.get_path("network")) - button.grid(row=12, column=2) + button.grid(row=current_row, column=2) + current_row += 1 buttons = Tkinter.Frame(self) buttons.pack() botton = Tkinter.Button(buttons, text=u"Create", font=("Helvetica", 8, 'bold'),width=10, command=lambda: self.checkPath("scenario")) botton.pack(side=Tkconstants.LEFT) + #botton.grid(row=13, column = 0) Tkinter.Frame(buttons, width=10).pack(side=Tkconstants.LEFT) button = Tkinter.Button(buttons, text=u"Quit", font=("Helvetica", 8, 'bold'), width=10, command=self.quit) button.pack(side=Tkconstants.RIGHT) + #button.grid(row = 13, columns = 2) + + self.defaultpath=self.releaseDir+"\\"+self.version+'\\input\\'+self.year + self.scenariopath.delete(0, Tkconstants.END) + self.scenariopath.insert(0, self.defaultScenarioDir) + self.networkpath.delete(0, Tkconstants.END) + self.networkpath.insert(0, self.defaultpath) self.initStudy() @@ -106,6 +239,8 @@ def initStudy(self): self.studybutton.config(state=NORMAL) self.studynetworkpath.config(state=NORMAL) self.studynetworkbutton.config(state=NORMAL) + self.studyyears.config(state=NORMAL) + self.studyyearsbutton.config(state=NORMAL) self.copyButton.configure(state=NORMAL) #enable study setting buttons elif self.buttonVar.get()==0: @@ -113,6 +248,8 @@ def initStudy(self): self.studybutton.config(state=DISABLED) self.studynetworkpath.config(state=DISABLED) self.studynetworkbutton.config(state=DISABLED) + self.studyyears.config(state=DISABLED) + self.studyyearsbutton.config(state=DISABLED) self.copyButton.configure(state=DISABLED) #set default input and network paths based on selected year @@ -127,12 +264,20 @@ def setEmmeVersion(self, value): #set default input and network paths based on selected year def setyear(self,value): - self.defaultpath=self.releaseDir+"\\"+self.version+'\\input\\'+value - self.scenariopath.delete(0, Tkconstants.END) - self.scenariopath.insert(0, self.defaultScenarioDir) - self.networkpath.delete(0, Tkconstants.END) - self.networkpath.insert(0, self.defaultpath) self.year=value + #Refresh the GUI with inputs already entered + self.destroy() + CreateScenarioGUI(self.root, self.emme_version, self.year, self.geo, self.lu).pack(fill=Tkconstants.X, expand=1) + return + + # set Geography Set ID + def setgeo(self, value): + self.geo = value + return + + # set land use + def setLU(self,value): + self.lu = value.split("-")[0] return #set cluster @@ -178,6 +323,10 @@ def get_path(self,type): def checkPath(self,type): self.popup=Tkinter.Tk() if type=="scenario": + #Check if invalid year/land use combo and don't create scenario if that is the case + if self.year not in self.lu_options[self.lu]["years"]: + showerror("Error", "Invalid year/land use combination") + return if os.path.exists(self.scenariopath.get()): if not self.networkpath.get(): popupMsg.popupmsg(self,"Network folder is empty!",1,type) @@ -205,6 +354,20 @@ def checkPath(self,type): self.executeBatch(type) return + def select_study_years(self): + selection_root = Tkinter.Tk() + SelectStudyYears(selection_root, self).pack(fill=Tkconstants.X, expand=1) + + #Update properties file + def update_property(self, old, new): + property_file = os.path.join(self.scenariopath.get(), 'conf', 'sandag_abm.properties') + property_file = property_file.replace('\\\\', '/') + with open(property_file, 'r') as file : + filedata = file.read() + filedata = filedata.replace(old, new) + with open(property_file, 'w') as file: + file.write(filedata) + #execute DOS commands def executeBatch(self, type): self.popup.destroy() @@ -215,11 +378,26 @@ def executeBatch(self, type): self.networkpath.get(), self.emme_version ) + os.chdir(self.releaseDir+"\\"+self.version+'\\') + os.system(commandstr) + #self.update_property("version=version_14_2_2", "version=version_14_2_2\nLU version=" + self.lu) + self.update_property("version=version_14_3_0", "version=version_14_3_0\nLU version=" + self.lu) + self.update_property("geographyID=1", "geographyID=" + self.geo.get()) elif type=="study": + studyyears = self.studyyears.get().split(',') + exclude_file = self.studynetworkpath.get() + '\\exclude.txt' + exclude = ["exclude.txt", "\\2050_vision_nopurple\\"] + for year in self.studyYearList: + if year not in studyyears: + exclude.append("\\" + year + "\\") + f = open(exclude_file, 'w') + f.write('\n'.join(exclude)) + f.close() commandstr=u"copy_networkfiles_to_study.cmd "+self.studypath.get()+" "+self.studynetworkpath.get() - print (commandstr) - os.chdir(self.releaseDir+"\\"+self.version+'\\') - os.system(commandstr) + print commandstr + os.chdir(self.releaseDir+"\\"+self.version+'\\') + os.system(commandstr) + os.remove(exclude_file) self.popup=Tkinter.Tk() msg="You have successfully created the "+ type+"!" popupMsg.popupmsg(self,msg,1,type) diff --git a/src/main/python/sdcvm_settings.py b/src/main/python/sdcvm_settings.py index e5c1192b7..cbc4ac022 100644 --- a/src/main/python/sdcvm_settings.py +++ b/src/main/python/sdcvm_settings.py @@ -14,7 +14,8 @@ opCostScale = 1.0 # Scale factor for operating cost -maxTaz = 4996 # highest taz number; assumes skims are 1-maxTaz without gaps +#will get maxTaz from property file in case of zone splits -- added by hannah.carson@rsginc.com +#maxTaz = 4996 # highest taz number; assumes skims are 1-maxTaz without gaps # Costs defined as [time, distance, money]. Not used right now. diff --git a/src/main/python/sdcvm_summarize.py b/src/main/python/sdcvm_summarize.py index 16f802a2f..037c01bfd 100644 --- a/src/main/python/sdcvm_summarize.py +++ b/src/main/python/sdcvm_summarize.py @@ -27,8 +27,13 @@ class excelOne(csv.excel): cvmZonalProperties = cvmInputPath + "Zonal Properties CVM.csv" skimPath = options.path + "/output/" cvmPath = options.path + "/output/" - -tazList = range(1, settings.maxTaz+1) +#read in max zones from property file -- added by hannah.carson@rsginc.com to incorporate zone splits +with open(options.path + "/conf/" + 'sandag_abm.properties' ,'r') as f: + props = f.readlines() + for prop in props: + if prop.startswith('zones.count'): + maxTaz = int(prop.split('=')[1].replace(" ","")) +tazList = range(1, maxTaz+1) tazList, zonals = sdcvm.zonalProperties(fileName=cvmZonalProperties) tazDict = {} # tazList = tazList[:25] diff --git a/src/main/r/visualizer/SummarizeABM2016.R b/src/main/r/visualizer/SummarizeABM2016.R index fb6eb5070..1ae638413 100644 --- a/src/main/r/visualizer/SummarizeABM2016.R +++ b/src/main/r/visualizer/SummarizeABM2016.R @@ -79,6 +79,17 @@ aoResults_Pre$HHVEH[aoResults_Pre$AO == 2] <- 2 aoResults_Pre$HHVEH[aoResults_Pre$AO == 3] <- 3 aoResults_Pre$HHVEH[aoResults_Pre$AO >= 4] <- 4 +# calculate HH weights +tryCatch( + expr = { + hh$finalweight <- 1/hh$sampleRate + }, + error = function(e){ + # (Optional) + hh$finalweight <- 1 + } +) + hh$HHVEH[hh$autos == 0] <- 0 hh$HHVEH[hh$autos == 1] <- 1 hh$HHVEH[hh$autos == 2] <- 2 @@ -106,6 +117,14 @@ hh$HHSIZE[hh$HHSIZ == 3] <- 3 hh$HHSIZE[hh$HHSIZ == 4] <- 4 hh$HHSIZE[hh$HHSIZ >= 5] <- 5 +aoResults$finalweight <- hh$finalweight[match(aoResults$HHID, hh$hh_id)] +aoResults_Pre$finalweight <- hh$finalweight[match(aoResults_Pre$HHID, hh$hh_id)] +per$finalweight <- hh$finalweight[match(per$hh_id, hh$hh_id)] +tours$finalweight <- hh$finalweight[match(tours$hh_id, hh$hh_id)] +trips$finalweight <- hh$finalweight[match(trips$hh_id, hh$hh_id)] +jtrips$finalweight <- hh$finalweight[match(jtrips$hh_id, hh$hh_id)] +wsLoc$finalweight <- hh$finalweight[match(wsLoc$HHID, hh$hh_id)] +unique_joint_tours$finalweight <- hh$finalweight[match(unique_joint_tours$hh_id, hh$hh_id)] #Adults in the HH adults <- count(per, c("hh_id"), "age>=18 & age<99") hh$ADULTS <- adults$freq[match(hh$hh_id, adults$hh_id)] @@ -141,10 +160,10 @@ wsLoc$SchoolLocationDistance[is.na(wsLoc$SchoolLocationDistance)] <- 0 #***************************************** # Auto ownership -autoOwnership_Pre <- count(aoResults_Pre, c("HHVEH")) +autoOwnership_Pre <- count(aoResults_Pre, c("HHVEH"), "finalweight") write.csv(autoOwnership_Pre, "autoOwnership_Pre.csv", row.names = TRUE) -autoOwnership <- count(aoResults, c("HHVEH")) +autoOwnership <- count(aoResults, c("HHVEH"), "finalweight") write.csv(autoOwnership, "autoOwnership.csv", row.names = TRUE) autoOwnership_AV <- count(hh, c("AVs")) @@ -161,7 +180,7 @@ zeroAutoByTaz <- aggregate(hh$ZeroAutoWgt, list(TAZ = hh$HHTAZ), sum) write.csv(zeroAutoByTaz, "zeroAutoByTaz.csv", row.names = TRUE) # Persons by person type -pertypeDistbn <- count(per, c("PERTYPE")) +pertypeDistbn <- count(per, c("PERTYPE"), "finalweight") write.csv(pertypeDistbn, "pertypeDistbn.csv", row.names = TRUE) # Telecommute Freuency @@ -203,7 +222,7 @@ distBinCat <- data.frame(distbin = seq(1,51, by=1)) districtList_df <- data.frame(id = districtList) # compute TLFDs by district and total -tlfd_work <- ddply(workers[,c("HDISTRICT", "distbin")], c("HDISTRICT", "distbin"), summarise, work = sum(HDISTRICT>0)) +tlfd_work <- ddply(workers[,c("HDISTRICT", "distbin", "finalweight")], c("HDISTRICT", "distbin"), summarise, work = sum(HDISTRICT>0*finalweight)) tlfd_work <- cast(tlfd_work, distbin~HDISTRICT, value = "work", sum) work_ditbins <- tlfd_work$distbin tlfd_work <- transpose(tlfd_work[,!colnames(tlfd_work) %in% c("distbin")]) @@ -217,7 +236,7 @@ names(tlfd_work) <- sub("V", "District_", names(tlfd_work)) tlfd_work_df <- merge(x = distBinCat, y = tlfd_work, by = "distbin", all.x = TRUE) tlfd_work_df[is.na(tlfd_work_df)] <- 0 -tlfd_univ <- ddply(students[students$PersonType==3,c("HDISTRICT", "distbin")], c("HDISTRICT", "distbin"), summarise, univ = sum(HDISTRICT>0)) +tlfd_univ <- ddply(students[students$PersonType==3,c("HDISTRICT", "distbin", "finalweight")], c("HDISTRICT", "distbin"), summarise, univ = sum(HDISTRICT>0*finalweight)) tlfd_univ <- cast(tlfd_univ, distbin~HDISTRICT, value = "univ", sum) univ_ditbins <- tlfd_univ$distbin tlfd_univ <- transpose(tlfd_univ[,!colnames(tlfd_univ) %in% c("distbin")]) @@ -231,7 +250,7 @@ names(tlfd_univ) <- sub("V", "District_", names(tlfd_univ)) tlfd_univ_df <- merge(x = distBinCat, y = tlfd_univ, by = "distbin", all.x = TRUE) tlfd_univ_df[is.na(tlfd_univ_df)] <- 0 -tlfd_schl <- ddply(students[students$PersonType>=6,c("HDISTRICT", "distbin")], c("HDISTRICT", "distbin"), summarise, schl = sum(HDISTRICT>0)) +tlfd_schl <- ddply(students[students$PersonType>=6,c("HDISTRICT", "distbin", "finalweight")], c("HDISTRICT", "distbin"), summarise, schl = sum(HDISTRICT>0*finalweight)) tlfd_schl <- cast(tlfd_schl, distbin~HDISTRICT, value = "schl", sum) schl_ditbins <- tlfd_schl$distbin tlfd_schl <- transpose(tlfd_schl[,!colnames(tlfd_schl) %in% c("distbin")]) @@ -254,18 +273,18 @@ cat("\n Average distance to university (Total): ", mean(students$SchoolLocationD cat("\n Average distance to school (Total): ", mean(students$SchoolLocationDistance[students$PersonType>=6], na.rm = TRUE)) ## Output avg trip lengths for visualizer -workTripLengths <- ddply(workers[,c("HDISTRICT", "WorkLocationDistance")], c("HDISTRICT"), summarise, work = mean(WorkLocationDistance)) -totalLength <- data.frame("Total", mean(workers$WorkLocationDistance)) +workTripLengths <- ddply(workers[,c("HDISTRICT", "WorkLocationDistance", "finalweight")], c("HDISTRICT"), summarise, work = weighted.mean(WorkLocationDistance, finalweight)) +totalLength <- data.frame("Total", weighted.mean(workers$WorkLocationDistance, workers$finalweight)) colnames(totalLength) <- colnames(workTripLengths) workTripLengths <- rbind(workTripLengths, totalLength) -univTripLengths <- ddply(students[students$PersonType==3,c("HDISTRICT", "SchoolLocationDistance")], c("HDISTRICT"), summarise, univ = mean(SchoolLocationDistance)) -totalLength <- data.frame("Total", mean(students$SchoolLocationDistance[students$PersonType==3])) +univTripLengths <- ddply(students[students$PersonType==3,c("HDISTRICT", "SchoolLocationDistance", "finalweight")], c("HDISTRICT"), summarise, univ = weighted.mean(SchoolLocationDistance, finalweight)) +totalLength <- data.frame("Total", weighted.mean(students$SchoolLocationDistance[students$PersonType==3], students$finalweight[students$PersonType==3])) colnames(totalLength) <- colnames(univTripLengths) univTripLengths <- rbind(univTripLengths, totalLength) -schlTripLengths <- ddply(students[students$PersonType>=6,c("HDISTRICT", "SchoolLocationDistance")], c("HDISTRICT"), summarise, schl = mean(SchoolLocationDistance)) -totalLength <- data.frame("Total", mean(students$SchoolLocationDistance[students$PersonType>=6])) +schlTripLengths <- ddply(students[students$PersonType>=6,c("HDISTRICT", "SchoolLocationDistance", "finalweight")], c("HDISTRICT"), summarise, schl = weighted.mean(SchoolLocationDistance, finalweight)) +totalLength <- data.frame("Total", weighted.mean(students$SchoolLocationDistance[students$PersonType>=6], students$finalweight[students$PersonType>=6])) colnames(totalLength) <- colnames(schlTripLengths) schlTripLengths <- rbind(schlTripLengths, totalLength) @@ -274,18 +293,18 @@ colnames(mandTripLengths) <- c("District", "Work", "Univ", "Schl") write.csv(mandTripLengths, "mandTripLengths.csv", row.names = F) # Work from home [for each district and total] -districtWorkers <- ddply(wsLoc[wsLoc$WorkLocation > 0,c("HDISTRICT")], c("HDISTRICT"), summarise, workers = sum(HDISTRICT>0)) -districtWfh <- ddply(wsLoc[wsLoc$WorkLocation==99999,c("HDISTRICT", "WorkLocation")], c("HDISTRICT"), summarise, wfh = sum(HDISTRICT>0)) +districtWorkers <- ddply(wsLoc[wsLoc$WorkLocation > 0,c("HDISTRICT", "finalweight")], c("HDISTRICT"), summarise, workers = sum(finalweight)) +districtWfh <- ddply(wsLoc[wsLoc$WorkLocation==99999,c("HDISTRICT", "WorkLocation", "finalweight")], c("HDISTRICT"), summarise, wfh = sum(finalweight)) wfh_summary <- cbind(districtWorkers, districtWfh$wfh) colnames(wfh_summary) <- c("District", "Workers", "WFH") -totalwfh <- data.frame("Total", sum(wsLoc$WorkLocation>0), sum(wsLoc$WorkLocation==99999)) +totalwfh <- data.frame("Total", sum((wsLoc$WorkLocation>0)*wsLoc$finalweight), sum((wsLoc$WorkLocation==99999)*wsLoc$finalweight)) colnames(totalwfh) <- colnames(wfh_summary) wfh_summary <- rbind(wfh_summary, totalwfh) write.csv(wfh_summary, "wfh_summary.csv", row.names = F) write.csv(totalwfh, "wfh_summary_region.csv", row.names = F) # County-County Flows -countyFlows <- xtabs(~HDISTRICT+WDISTRICT, data = workers) +countyFlows <- xtabs(finalweight~HDISTRICT+WDISTRICT, data = workers) countyFlows[is.na(countyFlows)] <- 0 countyFlows <- addmargins(as.table(countyFlows)) countyFlows <- as.data.frame.matrix(countyFlows) @@ -375,7 +394,40 @@ unique_joint_tours$PER5[unique_joint_tours$NUMBER_HH>=5] <- substr(as.character( unique_joint_tours$PER6[unique_joint_tours$NUMBER_HH>=6] <- substr(as.character(unique_joint_tours$tour_participants[unique_joint_tours$NUMBER_HH>=6]), 11, 11) unique_joint_tours$PER7[unique_joint_tours$NUMBER_HH>=7] <- substr(as.character(unique_joint_tours$tour_participants[unique_joint_tours$NUMBER_HH>=7]), 13, 13) unique_joint_tours$PER8[unique_joint_tours$NUMBER_HH>=8] <- substr(as.character(unique_joint_tours$tour_participants[unique_joint_tours$NUMBER_HH>=8]), 15, 15) - +returnPERID <- function(str_txt, pos) +{ + ret_val <- unlist(strsplit(str_txt, " ", fixed = T))[pos] + ret_val <- as.numeric(ret_val) + return(ret_val) +} + +PER1 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 1)) +PER2 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 2)) +PER3 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 3)) +PER4 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 4)) +PER5 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 5)) +PER6 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 6)) +PER7 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 7)) +PER8 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 8)) +PER9 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 9)) +PER10 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 10)) +PER11 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 11)) +PER12 <- apply(unique_joint_tours, 1, function(x) returnPERID(x["tour_participants"], 12)) + +PER1 <- data.frame(cbind(PER1)) +PER2 <- data.frame(cbind(PER2)) +PER3 <- data.frame(cbind(PER3)) +PER4 <- data.frame(cbind(PER4)) +PER5 <- data.frame(cbind(PER5)) +PER6 <- data.frame(cbind(PER6)) +PER7 <- data.frame(cbind(PER7)) +PER8 <- data.frame(cbind(PER8)) +PER9 <- data.frame(cbind(PER9)) +PER10 <- data.frame(cbind(PER10)) +PER11 <- data.frame(cbind(PER11)) +PER12 <- data.frame(cbind(PER12)) + +unique_joint_tours <- cbind(unique_joint_tours,PER1,PER2,PER3,PER4,PER5,PER6,PER7,PER8,PER9,PER10,PER11,PER12) unique_joint_tours[is.na(unique_joint_tours)] <- 0 # get person type for each participant @@ -409,9 +461,16 @@ unique_joint_tours$TOURMODE <- unique_joint_tours$tour_mode # ---- # this part is added by nagendra.dhakar@rsginc.com from binny.paul@rsginc.com soabm summaries +jtours_per <- melt(unique_joint_tours[,c("hh_id","tour_id", "PER1","PER2","PER3","PER4","PER5","PER6","PER7","PER8", "PER9", "PER10", "PER11", "PER12")], + id = c("hh_id","tour_id")) +jtours_per$value <- as.numeric(jtours_per$value) +colnames(jtours_per) <- c("hh_id","tour_id","variable","perno") +jtours_per$variable <- NULL +jtours_per <- jtours_per[jtours_per$perno>0,] +jtours_per$finalweight <- hh$finalweight[match(jtours_per$hh_id, hh$hh_id)] # create a combined temp tour file for creating stop freq model summary -temp_tour1 <- tours[,c("TOURPURP","num_ob_stops","num_ib_stops")] -temp_tour2 <- unique_joint_tours[,c("JOINT_PURP","num_ob_stops","num_ib_stops")] +temp_tour1 <- tours[,c("TOURPURP","num_ob_stops","num_ib_stops", "finalweight")] +temp_tour2 <- unique_joint_tours[,c("JOINT_PURP","num_ob_stops","num_ib_stops", "finalweight")] colnames(temp_tour2) <- colnames(temp_tour1) temp_tour <- rbind(temp_tour1,temp_tour2) @@ -434,7 +493,7 @@ temp_tour$STOP_FREQ_ALT[temp_tour$num_ob_stops>=3 & temp_tour$num_ib_stops==2] < temp_tour$STOP_FREQ_ALT[temp_tour$num_ob_stops>=3 & temp_tour$num_ib_stops>=3] <- 16 temp_tour$STOP_FREQ_ALT[is.na(temp_tour$STOP_FREQ_ALT)] <- 0 -stopFreqModel_summary <- xtabs(~STOP_FREQ_ALT+TOURPURP, data = temp_tour[temp_tour$TOURPURP<=10,]) +stopFreqModel_summary <- xtabs(finalweight~STOP_FREQ_ALT+TOURPURP, data = temp_tour[temp_tour$TOURPURP<=10,]) write.csv(stopFreqModel_summary, "stopFreqModel_summary.csv", row.names = T) # ------ @@ -660,18 +719,35 @@ inmCounts <- count(tours, c("hh_id", "person_num"), "TOURPURP>=4 & TOURPURP<=9") # ----------------------- # added for calibration by nagendra.dhakar@rsginc.com # for indivudal NM tour generation -workCounts_temp <- workCounts -schlCounts_temp <- schlCounts -inmCounts_temp <- count(tours, c("hh_id", "person_num"), "TOURPURP>4 & TOURPURP<=9") #excluding school escort tours -atWorkCounts_temp <- count(tours, c("hh_id", "person_num"), "TOURPURP == 10") -escortCounts_temp <- count(tours, c("hh_id", "person_num"), "TOURPURP==4") +tours_temp <- tours[,c("hh_id", "person_num", "TOURPURP", "finalweight")] + +tours_temp <- tours[,c("hh_id", "person_num", "TOURPURP", "finalweight")] +tours_temp$FULLY_JOINT <- 0 +jtours_temp <- jtours_per[,c("hh_id", "perno", "tour_id", "finalweight")] +colnames(jtours_temp)[colnames(jtours_temp)=="perno"] <- "person_num" + +jtours_temp$TOURPURP <- unique_joint_tours$JOINT_PURP[match(paste(jtours_temp$hh_id, jtours_temp$tour_id), + paste(unique_joint_tours$hh_id, unique_joint_tours$tour_id))] +jtours_temp$FULLY_JOINT <- 1 +jtours_temp <- jtours_temp[,-c("tour_id")] + +all_tours <- rbind(tours_temp, jtours_temp) + +#all_tours$cdap <- hh$cdap_pattern[match(all_tours$hh_id, hh$hh_id)] + +workCounts_temp <- count(all_tours, c("hh_id", "person_num"), "TOURPURP == 1") +schlCounts_temp <- count(all_tours, c("hh_id", "person_num"), "TOURPURP == 2 | TOURPURP == 3") +inmCounts_temp <- count(all_tours, c("hh_id", "person_num"), "TOURPURP>=4 & TOURPURP<=9 & FULLY_JOINT==0") +atWorkCounts_temp <- count(all_tours, c("hh_id", "person_num"), "TOURPURP == 10") +escortCounts_temp <- count(all_tours, c("hh_id", "person_num"), "TOURPURP==4") +jToursCounts_temp <- count(all_tours, c("hh_id", "person_num"), "FULLY_JOINT==1") - colnames(workCounts_temp)[3] <- "freq_work" colnames(schlCounts_temp)[3] <- "freq_schl" colnames(inmCounts_temp)[3] <- "freq_inm" colnames(atWorkCounts_temp)[3] <- "freq_atwork" colnames(escortCounts_temp)[3] <- "freq_escort" +colnames(jToursCounts_temp)[3] <- "freq_jtours" temp <- merge(workCounts_temp, schlCounts_temp, by = c("hh_id", "person_num")) temp1 <- merge(temp, inmCounts_temp, by = c("hh_id", "person_num")) @@ -691,16 +767,17 @@ temp_joint$joint[temp_joint$person_num>0] <- 1 temp_joint <- temp_joint[temp_joint$joint==1,] person_unique_joint <- aggregate(joint~hh_id+person_num, temp_joint, sum) -temp2 <- merge(temp1, person_unique_joint, by = c("hh_id", "person_num"), all = T) +temp2 <- merge(temp1, jToursCounts_temp, by = c("hh_id", "person_num"), all = T) temp2 <- merge(temp2, atWorkCounts_temp, by = c("hh_id", "person_num"), all = T) temp2 <- merge(temp2, escortCounts_temp, by = c("hh_id", "person_num"), all = T) temp2[is.na(temp2)] <- 0 #add number of joint tours to non-mandatory -temp2$freq_nm <- temp2$freq_inm + temp2$joint +temp2$freq_nm <- temp2$freq_inm + temp2$freq_jtours #get person type temp2$PERTYPE <- per$PERTYPE[match(temp2$hh_id*10+temp2$person_num,per$hh_id*10+per$person_num)] +temp2$finalweight <- per$finalweight[match(temp2$hh_id*10+temp2$person_num,per$hh_id*10+per$person_num)] #total tours temp2$total_tours <- temp2$freq_nm+temp2$freq_m+temp2$freq_atwork+temp2$freq_escort @@ -708,9 +785,9 @@ temp2$total_tours <- temp2$freq_nm+temp2$freq_m+temp2$freq_atwork+temp2$freq_esc persons_mand <- temp2[temp2$freq_m>0,] #persons with atleast 1 mandatory tours persons_nomand <- temp2[temp2$freq_m==0,] #active persons with 0 mandatory tours -freq_nmtours_mand <- count(persons_mand, c("PERTYPE","freq_nm")) -freq_nmtours_nomand <- count(persons_nomand, c("PERTYPE","freq_nm")) -test <- count(temp2, c("PERTYPE","freq_inm","freq_m","freq_nm","freq_atwork","freq_escort")) +freq_nmtours_mand <- count(persons_mand, c("PERTYPE","freq_nm"), "finalweight") +freq_nmtours_nomand <- count(persons_nomand, c("PERTYPE","freq_nm"), "finalweight") +test <- count(temp2, c("PERTYPE","freq_inm","freq_m","freq_nm","freq_atwork"), "finalweight") write.csv(test, "tour_rate_debug.csv", row.names = F) write.csv(temp2,"temp2.csv", row.names = F) @@ -817,13 +894,13 @@ per$i9numTours[is.na(per$i9numTours)] <- 0 # Total tours by person type per$numTours[is.na(per$numTours)] <- 0 -toursPertypeDistbn <- count(tours[tours$PERTYPE>0 & tours$TOURPURP!=10,], c("PERTYPE")) +toursPertypeDistbn <- count(tours[tours$PERTYPE>0 & tours$TOURPURP!=10,], c("PERTYPE"), "finalweight") write.csv(toursPertypeDistbn, "toursPertypeDistbn.csv", row.names = TRUE) # count joint tour fr each person type -temp_joint <- melt(unique_joint_tours[, c("hh_id","tour_id","PTYPE1","PTYPE2","PTYPE3","PTYPE4","PTYPE5","PTYPE6","PTYPE7","PTYPE8")], id = c("hh_id", "tour_id")) +temp_joint <- melt(unique_joint_tours[, c("hh_id","tour_id","PTYPE1","PTYPE2","PTYPE3","PTYPE4","PTYPE5","PTYPE6","PTYPE7","PTYPE8","finalweight")], id = c("hh_id", "tour_id", "finalweight")) names(temp_joint)[names(temp_joint)=="value"] <- "PERTYPE" -jtoursPertypeDistbn <- count(temp_joint[temp_joint$PERTYPE>0,], c("PERTYPE")) +jtoursPertypeDistbn <- count(temp_joint[temp_joint$PERTYPE>0,], c("PERTYPE"), "finalweight") # Total tours by person type for visualizer totaltoursPertypeDistbn <- toursPertypeDistbn @@ -831,7 +908,7 @@ totaltoursPertypeDistbn$freq <- totaltoursPertypeDistbn$freq + jtoursPertypeDist write.csv(totaltoursPertypeDistbn, "total_tours_by_pertype_vis.csv", row.names = F) # Total indi NM tours by person type and purpose -tours_pertype_purpose <- count(tours[tours$TOURPURP>=4 & tours$TOURPURP<=9,], c("PERTYPE", "TOURPURP")) +tours_pertype_purpose <- count(tours[tours$TOURPURP>=4 & tours$TOURPURP<=9,], c("PERTYPE", "TOURPURP"), "finalweight") write.csv(tours_pertype_purpose, "tours_pertype_purpose.csv", row.names = TRUE) # --------------------------------------------------- @@ -902,8 +979,10 @@ nm_tour_rates$tour_purp[nm_tour_rates$tour_purp==9] <- "Discretionary" write.csv(nm_tour_rates, "nm_tour_rates.csv", row.names = F) # Total tours by purpose X tourtype -t1 <- hist(tours$TOURPURP[tours$TOURPURP<10], breaks = seq(1,10, by=1), freq = NULL, right=FALSE) -t3 <- hist(unique_joint_tours$JOINT_PURP, breaks = seq(1,10, by=1), freq = NULL, right=FALSE) +#t1 <- hist(tours$TOURPURP[tours$TOURPURP<10], breaks = seq(1,10, by=1), freq = NULL, right=FALSE) +#t3 <- hist(unique_joint_tours$JOINT_PURP, breaks = seq(1,10, by=1), freq = NULL, right=FALSE) +t1 <- wtd.hist(tours$TOURPURP[tours$TOURPURP<10], breaks = seq(1,10, by=1), freq = NULL, right=FALSE, weight=tours$finalweight[tours$TOURPURP<10]) +t3 <- wtd.hist(unique_joint_tours$JOINT_PURP, breaks = seq(1,10, by=1), freq = NULL, right=FALSE, weight=unique_joint_tours$finalweight[unique_joint_tours$JOINT_PURP]) tours_purpose_type <- data.frame(t1$counts, t3$counts) colnames(tours_purpose_type) <- c("indi", "joint") write.csv(tours_purpose_type, "tours_purpose_type.csv", row.names = TRUE) @@ -914,7 +993,7 @@ write.csv(tours_purpose_type, "tours_purpose_type.csv", row.names = TRUE) per[per$activity_pattern == 'M' & per$imf_choice==0 & per$inmf_choice>0]$activity_pattern = 'N' per[per$activity_pattern == 'M' & per$imf_choice==0 & per$inmf_choice==0]$activity_pattern = 'H' -dapSummary <- count(per, c("PERTYPE", "activity_pattern")) +dapSummary <- count(per, c("PERTYPE", "activity_pattern"), "finalweight") write.csv(dapSummary, "dapSummary.csv", row.names = TRUE) # Prepare DAP summary for visualizer @@ -932,11 +1011,11 @@ dapSummary_vis$PERTYPE[dapSummary_vis$PERTYPE=="Sum"] <- "Total" write.csv(dapSummary_vis, "dapSummary_vis.csv", row.names = TRUE) # HHSize X Joint -hhsizeJoint <- count(hh[hh$HHSIZE>=2,], c("HHSIZE", "JOINT")) +hhsizeJoint <- count(hh[hh$HHSIZE>=2,], c("HHSIZE", "JOINT"), "finalweight") write.csv(hhsizeJoint, "hhsizeJoint.csv", row.names = TRUE) #mandatory tour frequency -mtfSummary <- count(per[per$imf_choice > 0,], c("PERTYPE", "imf_choice")) +mtfSummary <- count(per[per$imf_choice > 0,], c("PERTYPE", "imf_choice"), "finalweight") write.csv(mtfSummary, "mtfSummary.csv") #write.csv(tours, "tours_test.csv") @@ -955,10 +1034,10 @@ mtfSummary_vis$PERTYPE[mtfSummary_vis$PERTYPE=="Sum"] <- "Total" write.csv(mtfSummary_vis, "mtfSummary_vis.csv") # indi NM summary -inm0Summary <- count(per[per$inmTours==0,], c("PERTYPE")) -inm1Summary <- count(per[per$inmTours==1,], c("PERTYPE")) -inm2Summary <- count(per[per$inmTours==2,], c("PERTYPE")) -inm3Summary <- count(per[per$inmTours>=3,], c("PERTYPE")) +inm0Summary <- count(per[per$numTours==0,], c("PERTYPE"), "finalweight") +inm1Summary <- count(per[per$numTours==1,], c("PERTYPE"), "finalweight") +inm2Summary <- count(per[per$numTours==2,], c("PERTYPE"), "finalweight") +inm3Summary <- count(per[per$numTours>=3,], c("PERTYPE"), "finalweight") inmSummary <- data.frame(PERTYPE = c(1,2,3,4,5,6,7,8)) inmSummary$tour0 <- inm0Summary$freq[match(inmSummary$PERTYPE, inm0Summary$PERTYPE)] @@ -989,16 +1068,16 @@ inmSummary_vis$PERTYPE[inmSummary_vis$PERTYPE=="Sum"] <- "Total" write.csv(inmSummary_vis, "inmSummary_vis.csv") # Joint Tour Frequency and composition -jtfSummary <- count(hh[!is.na(hh$jtf),], c("jtf")) -jointComp <- count(unique_joint_tours, c("tour_composition")) -jointPartySize <- count(unique_joint_tours, c("NUMBER_HH")) -jointCompPartySize <- count(unique_joint_tours, c("tour_composition","NUMBER_HH")) +jtfSummary <- count(hh[!is.na(hh$jtf),], c("jtf"), "finalweight") +jointComp <- count(unique_joint_tours, c("tour_composition"), "finalweight") +jointPartySize <- count(unique_joint_tours, c("NUMBER_HH"), "finalweight") +jointCompPartySize <- count(unique_joint_tours, c("tour_composition","NUMBER_HH"), "finalweight") hh$jointCat[hh$jtours==0] <- 0 hh$jointCat[hh$jtours==1] <- 1 hh$jointCat[hh$jtours>=2] <- 2 -jointToursHHSize <- count(hh[!is.na(hh$HHSIZE) & !is.na(hh$jointCat),], c("HHSIZE", "jointCat")) +jointToursHHSize <- count(hh[!is.na(hh$HHSIZE) & !is.na(hh$jointCat),], c("HHSIZE", "jointCat"), "finalweight") write.table(jtfSummary, "jtfSummary.csv", col.names=TRUE, sep=",") write.table(jointComp, "jtfSummary.csv", col.names=TRUE, sep=",", append=TRUE) @@ -1075,24 +1154,24 @@ write.csv(jointToursHHSizeProp, "jointToursHHSize.csv", row.names = F) # TOD Profile #work.dep <- table(cut(tours$ANCHOR_DEPART_BIN[!is.na(tours$ANCHOR_DEPART_BIN)], seq(1,48, by=1), right=FALSE)) -tod1 <- hist(tours$start_period[tours$TOURPURP==1], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod1 <- wtd.hist(tours$start_period[tours$TOURPURP==1], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1]) #tod1_2 <- hist(tours$start_period[tours$TOURPURP==1 & tours$PERTYPE==2], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod2 <- hist(tours$start_period[tours$TOURPURP==2], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod3 <- hist(tours$start_period[tours$TOURPURP==3], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod4 <- hist(tours$start_period[tours$TOURPURP==4], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todi56 <- hist(tours$start_period[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todi789 <- hist(tours$start_period[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod2 <- wtd.hist(tours$start_period[tours$TOURPURP==2], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2]) +tod3 <- wtd.hist(tours$start_period[tours$TOURPURP==3], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3]) +tod4 <- wtd.hist(tours$start_period[tours$TOURPURP==4], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==4]) +todi56 <- wtd.hist(tours$start_period[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6]) +todi789 <- wtd.hist(tours$start_period[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9]) #tod6 <- hist(tours$start_period[tours$TOURPURP==6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod7 <- hist(tours$start_period[tours$TOURPURP==7], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod8 <- hist(tours$start_period[tours$TOURPURP==8], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod9 <- hist(tours$start_period[tours$TOURPURP==9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todj56 <- hist(unique_joint_tours$start_period[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todj789 <- hist(unique_joint_tours$start_period[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +todj56 <- wtd.hist(unique_joint_tours$start_period[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$finalweight[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6]) +todj789 <- wtd.hist(unique_joint_tours$start_period[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$finalweight[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9]) #tod11 <- hist(unique_joint_tours$start_period[unique_joint_tours$JOINT_PURP==6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod12 <- hist(unique_joint_tours$start_period[unique_joint_tours$JOINT_PURP==7], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod13 <- hist(unique_joint_tours$start_period[unique_joint_tours$JOINT_PURP==8], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod14 <- hist(unique_joint_tours$start_period[unique_joint_tours$JOINT_PURP==9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod15 <- hist(tours$start_period[tours$TOURPURP==10], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod15 <- wtd.hist(tours$start_period[tours$TOURPURP==10], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10]) todDepProfile <- data.frame(tod1$counts, tod2$counts, tod3$counts, tod4$counts, todi56$counts, todi789$counts , todj56$counts, todj789$counts, tod15$counts) @@ -1119,22 +1198,22 @@ todDepProfile_vis <- todDepProfile_vis[todDepProfile_vis$timebin!="Sum",] todDepProfile_vis$PURPOSE[todDepProfile_vis$PURPOSE=="Sum"] <- "Total" todDepProfile_vis$timebin <- as.numeric(todDepProfile_vis$timebin) -tod1 <- hist(tours$end_period[tours$TOURPURP==1], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod1 <- wtd.hist(tours$end_period[tours$TOURPURP==1], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1]) #tod1_2 <- hist(tours$end_period[tours$TOURPURP==1 & tours$PERTYPE==2], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod2 <- hist(tours$end_period[tours$TOURPURP==2], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod3 <- hist(tours$end_period[tours$TOURPURP==3], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod4 <- hist(tours$end_period[tours$TOURPURP==4], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todi56 <- hist(tours$end_period[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todi789 <- hist(tours$end_period[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod2 <- wtd.hist(tours$end_period[tours$TOURPURP==2], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2]) +tod3 <- wtd.hist(tours$end_period[tours$TOURPURP==3], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3]) +tod4 <- wtd.hist(tours$end_period[tours$TOURPURP==4], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==4]) +todi56 <- wtd.hist(tours$end_period[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6]) +todi789 <- wtd.hist(tours$end_period[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9]) #tod8 <- hist(tours$end_period[tours$TOURPURP==8], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod9 <- hist(tours$end_period[tours$TOURPURP==9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todj56 <- hist(unique_joint_tours$end_period[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todj789 <- hist(unique_joint_tours$end_period[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +todj56 <- wtd.hist(unique_joint_tours$end_period[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$finalweight[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6]) +todj789 <- wtd.hist(unique_joint_tours$end_period[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$finalweight[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9]) #tod11 <- hist(unique_joint_tours$end_period[unique_joint_tours$JOINT_PURP==6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod12 <- hist(unique_joint_tours$end_period[unique_joint_tours$JOINT_PURP==7], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod13 <- hist(unique_joint_tours$end_period[unique_joint_tours$JOINT_PURP==8], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) #tod14 <- hist(unique_joint_tours$end_period[unique_joint_tours$JOINT_PURP==9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod15 <- hist(tours$end_period[tours$TOURPURP==10], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod15 <- wtd.hist(tours$end_period[tours$TOURPURP==10], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10]) todArrProfile <- data.frame(tod1$counts, tod2$counts, tod3$counts, tod4$counts, todi56$counts, todi789$counts , todj56$counts, todj789$counts, tod15$counts) @@ -1200,24 +1279,24 @@ todArrProfile_vis$PURPOSE[todArrProfile_vis$PURPOSE=="Sum"] <- "Total" todArrProfile_vis$timebin <- as.numeric(todArrProfile_vis$timebin) -tod1 <- hist(tours$tourdur[tours$TOURPURP==1], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod1 <- wtd.hist(tours$tourdur[tours$TOURPURP==1], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1]) #tod1_2 <- hist(tours$tourdur[tours$TOURPURP==1 & tours$PERTYPE==2], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) -tod2 <- hist(tours$tourdur[tours$TOURPURP==2], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod3 <- hist(tours$tourdur[tours$TOURPURP==3], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -tod4 <- hist(tours$tourdur[tours$TOURPURP==4], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todi56 <- hist(tours$tourdur[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todi789 <- hist(tours$tourdur[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod2 <- wtd.hist(tours$tourdur[tours$TOURPURP==2], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2]) +tod3 <- wtd.hist(tours$tourdur[tours$TOURPURP==3], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3]) +tod4 <- wtd.hist(tours$tourdur[tours$TOURPURP==4], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==4]) +todi56 <- wtd.hist(tours$tourdur[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6]) +todi789 <- wtd.hist(tours$tourdur[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9]) #tod6 <- hist(tours$tourdur[tours$TOURPURP==6], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) #tod7 <- hist(tours$tourdur[tours$TOURPURP==7], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) #tod8 <- hist(tours$tourdur[tours$TOURPURP==8], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) #tod9 <- hist(tours$tourdur[tours$TOURPURP==9], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) -todj56 <- hist(unique_joint_tours$tourdur[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) -todj789 <- hist(unique_joint_tours$tourdur[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +todj56 <- wtd.hist(unique_joint_tours$tourdur[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$finalweight[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6]) +todj789 <- wtd.hist(unique_joint_tours$tourdur[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$finalweight[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9]) #tod11 <- hist(unique_joint_tours$tourdur[unique_joint_tours$JOINT_PURP==6], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) #tod12 <- hist(unique_joint_tours$tourdur[unique_joint_tours$JOINT_PURP==7], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) #tod13 <- hist(unique_joint_tours$tourdur[unique_joint_tours$JOINT_PURP==8], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) #tod14 <- hist(unique_joint_tours$tourdur[unique_joint_tours$JOINT_PURP==9], breaks = seq(0,41, by=1), freq = NULL, right=FALSE) -tod15 <- hist(tours$tourdur[tours$TOURPURP==10], breaks = seq(1,41, by=1), freq = NULL, right=FALSE) +tod15 <- wtd.hist(tours$tourdur[tours$TOURPURP==10], breaks = seq(1,41, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10]) todDurProfile <- data.frame(tod1$counts, tod2$counts, tod3$counts, tod4$counts, todi56$counts, todi789$counts , todj56$counts, todj789$counts, tod15$counts) @@ -1251,15 +1330,18 @@ todProfile_vis <- data.frame(todDepProfile_vis, todArrProfile_vis$freq, todDurPr colnames(todProfile_vis) <- c("id", "purpose", "freq_dep", "freq_arr", "freq_dur") write.csv(todProfile_vis, "todProfile_vis.csv", row.names = F) +unique_joint_tours$numberhh_wgt <- unique_joint_tours$finalweight*unique_joint_tours$NUMBER_HH + # Tour Mode X Auto Suff (seq changed from 10 to 13 due to increase in number of modes, changed by Khademul.haque@rsginc.com) -tmode1_as0 <- hist(tours$TOURMODE[tours$TOURPURP==1 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode2_as0 <- hist(tours$TOURMODE[tours$TOURPURP==2 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode3_as0 <- hist(tours$TOURMODE[tours$TOURPURP==3 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode4_as0 <- hist(tours$TOURMODE[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode5_as0 <- hist(tours$TOURMODE[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode6_as0 <- hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode7_as0 <- hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode8_as0 <- hist(tours$TOURMODE[tours$TOURPURP==10 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tmode1_as0 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==1 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1 & tours$AUTOSUFF==0]) +tmode2_as0 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==2 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2 & tours$AUTOSUFF==0]) +tmode3_as0 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==3 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3 & tours$AUTOSUFF==0]) +tmode4_as0 <- wtd.hist(tours$TOURMODE[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==0]) +tmode5_as0 <- wtd.hist(tours$TOURMODE[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==0]) +tmode6_as0 <- wtd.hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==0]) +tmode7_as0 <- wtd.hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==0]) +tmode8_as0 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==10 & tours$AUTOSUFF==0], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10 & tours$AUTOSUFF==0]) + tmodeAS0Profile <- data.frame(tmode1_as0$counts, tmode2_as0$counts, tmode3_as0$counts, tmode4_as0$counts, tmode5_as0$counts, tmode6_as0$counts, tmode7_as0$counts, tmode8_as0$counts) @@ -1286,14 +1368,14 @@ tmodeAS0Profile_vis <- tmodeAS0Profile_vis[tmodeAS0Profile_vis$id!="Sum",] tmodeAS0Profile_vis$purpose[tmodeAS0Profile_vis$purpose=="Sum"] <- "Total" # (seq changed from 10 to 13 due to increase in number of modes, changed by Khademul.haque@rsginc.com) -tmode1_as1 <- hist(tours$TOURMODE[tours$TOURPURP==1 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode2_as1 <- hist(tours$TOURMODE[tours$TOURPURP==2 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode3_as1 <- hist(tours$TOURMODE[tours$TOURPURP==3 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode4_as1 <- hist(tours$TOURMODE[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode5_as1 <- hist(tours$TOURMODE[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode6_as1 <- hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode7_as1 <- hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode8_as1 <- hist(tours$TOURMODE[tours$TOURPURP==10 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tmode1_as1 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==1 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1 & tours$AUTOSUFF==1]) +tmode2_as1 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==2 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2 & tours$AUTOSUFF==1]) +tmode3_as1 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==3 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3 & tours$AUTOSUFF==1]) +tmode4_as1 <- wtd.hist(tours$TOURMODE[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==1]) +tmode5_as1 <- wtd.hist(tours$TOURMODE[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==1]) +tmode6_as1 <- wtd.hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==1]) +tmode7_as1 <- wtd.hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==1]) +tmode8_as1 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==10 & tours$AUTOSUFF==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10 & tours$AUTOSUFF==1]) tmodeAS1Profile <- data.frame(tmode1_as1$counts, tmode2_as1$counts, tmode3_as1$counts, tmode4_as1$counts, tmode5_as1$counts, tmode6_as1$counts, tmode7_as1$counts, tmode8_as1$counts) @@ -1320,14 +1402,14 @@ tmodeAS1Profile_vis <- tmodeAS1Profile_vis[tmodeAS1Profile_vis$id!="Sum",] tmodeAS1Profile_vis$purpose[tmodeAS1Profile_vis$purpose=="Sum"] <- "Total" # (seq changed from 10 to 13 due to increase in number of modes, changed by Khademul.haque@rsginc.com) -tmode1_as2 <- hist(tours$TOURMODE[tours$TOURPURP==1 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode2_as2 <- hist(tours$TOURMODE[tours$TOURPURP==2 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode3_as2 <- hist(tours$TOURMODE[tours$TOURPURP==3 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode4_as2 <- hist(tours$TOURMODE[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode5_as2 <- hist(tours$TOURMODE[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode6_as2 <- hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode7_as2 <- hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tmode8_as2 <- hist(tours$TOURMODE[tours$TOURPURP==10 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tmode1_as2 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==1 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1 & tours$AUTOSUFF==2]) +tmode2_as2 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==2 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2 & tours$AUTOSUFF==2]) +tmode3_as2 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==3 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3 & tours$AUTOSUFF==2]) +tmode4_as2 <- wtd.hist(tours$TOURMODE[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=4 & tours$TOURPURP<=6 & tours$AUTOSUFF==2]) +tmode5_as2 <- wtd.hist(tours$TOURMODE[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9 & tours$AUTOSUFF==2]) +tmode6_as2 <- wtd.hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=4 & unique_joint_tours$JOINT_PURP<=6 & unique_joint_tours$AUTOSUFF==2]) +tmode7_as2 <- wtd.hist(unique_joint_tours$TOURMODE[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9 & unique_joint_tours$AUTOSUFF==2]) +tmode8_as2 <- wtd.hist(tours$TOURMODE[tours$TOURPURP==10 & tours$AUTOSUFF==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10 & tours$AUTOSUFF==2]) tmodeAS2Profile <- data.frame(tmode1_as2$counts, tmode2_as2$counts, tmode3_as2$counts, tmode4_as2$counts, tmode5_as2$counts, tmode6_as2$counts, tmode7_as2$counts, tmode8_as2$counts) @@ -1362,12 +1444,12 @@ write.csv(tmodeProfile_vis, "tmodeProfile_vis.csv", row.names = F) # Non Mand Tour lengths -tourdist4 <- hist(tours$tour_distance[tours$TOURPURP==4], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -tourdisti56 <- hist(tours$tour_distance[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -tourdisti789 <- hist(tours$tour_distance[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -tourdistj56 <- hist(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -tourdistj789 <- hist(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -tourdist10 <- hist(tours$tour_distance[tours$TOURPURP==10], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE) +tourdist4 <- wtd.hist(tours$tour_distance[tours$TOURPURP==4], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==4]) +tourdisti56 <- wtd.hist(tours$tour_distance[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6]) +tourdisti789 <- wtd.hist(tours$tour_distance[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9]) +tourdistj56 <- wtd.hist(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6]) +tourdistj789 <- wtd.hist(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9]) +tourdist10 <- wtd.hist(tours$tour_distance[tours$TOURPURP==10], breaks = c(seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10]) tourDistProfile <- data.frame(tourdist4$counts, tourdisti56$counts, tourdisti789$counts, tourdistj56$counts, tourdistj789$counts, tourdist10$counts) @@ -1395,12 +1477,12 @@ tourDistProfile_vis$distbin <- as.numeric(tourDistProfile_vis$distbin) write.csv(tourDistProfile_vis, "tourDistProfile_vis.csv", row.names = F) -cat("\n Average Tour Distance [esco]: ", mean(tours$tour_distance[tours$TOURPURP==4], na.rm = TRUE)) -cat("\n Average Tour Distance [imain]: ", mean(tours$tour_distance[tours$TOURPURP>=5 & tours$TOURPURP<=6], na.rm = TRUE)) -cat("\n Average Tour Distance [idisc]: ", mean(tours$tour_distance[tours$TOURPURP>=7 & tours$TOURPURP<=9], na.rm = TRUE)) -cat("\n Average Tour Distance [jmain]: ", mean(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], na.rm = TRUE)) -cat("\n Average Tour Distance [jdisc]: ", mean(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], na.rm = TRUE)) -cat("\n Average Tour Distance [atwork]: ", mean(tours$tour_distance[tours$TOURPURP==10], na.rm = TRUE)) +cat("\n Average Tour Distance [esco]: ", weighted.mean(tours$tour_distance[tours$TOURPURP==4], tours$finalweight[tours$TOURPURP==4], na.rm = TRUE)) +cat("\n Average Tour Distance [imain]: ", weighted.mean(tours$tour_distance[tours$TOURPURP>=5 & tours$TOURPURP<=6], tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6], na.rm = TRUE)) +cat("\n Average Tour Distance [idisc]: ", weighted.mean(tours$tour_distance[tours$TOURPURP>=7 & tours$TOURPURP<=9], tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9], na.rm = TRUE)) +cat("\n Average Tour Distance [jmain]: ", weighted.mean(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], na.rm = TRUE)) +cat("\n Average Tour Distance [jdisc]: ", weighted.mean(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], na.rm = TRUE)) +cat("\n Average Tour Distance [atwork]: ", weighted.mean(tours$tour_distance[tours$TOURPURP==10], tours$finalweight[tours$TOURPURP==10], na.rm = TRUE)) ## Retirees #cat("\n Average Tour Distance [esco]: ", mean(tours$tour_distance[tours$TOURPURP==4 & tours$PERTYPE==5], na.rm = TRUE)) @@ -1421,35 +1503,46 @@ cat("\n Average Tour Distance [atwork]: ", mean(tours$tour_distance[tours$TOURPU ## Output average trips lengths for visualizer -avgTripLengths <- c(mean(tours$tour_distance[tours$TOURPURP==4], na.rm = TRUE), - mean(tours$tour_distance[tours$TOURPURP>=5 & tours$TOURPURP<=6], na.rm = TRUE), - mean(tours$tour_distance[tours$TOURPURP>=7 & tours$TOURPURP<=9], na.rm = TRUE), - mean(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], na.rm = TRUE), - mean(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], na.rm = TRUE), - mean(tours$tour_distance[tours$TOURPURP==10], na.rm = TRUE)) - -totAvgNonMand <- mean(c(tours$tour_distance[tours$TOURPURP %in% c(4,5,6,7,8,9,10)], - unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP %in% c(5,6,7,8,9)]), - na.rm = T) +avgTripLengths <- c(weighted.mean(tours$tour_distance[tours$TOURPURP==4], tours$finalweight[tours$TOURPURP==4], na.rm = TRUE), + weighted.mean(tours$tour_distance[tours$TOURPURP>=5 & tours$TOURPURP<=6], tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6], na.rm = TRUE), + weighted.mean(tours$tour_distance[tours$TOURPURP>=7 & tours$TOURPURP<=9], tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9], na.rm = TRUE), + weighted.mean(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], na.rm = TRUE), + weighted.mean(unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], na.rm = TRUE), + weighted.mean(tours$tour_distance[tours$TOURPURP==10], tours$finalweight[tours$TOURPURP==10], na.rm = TRUE)) + +# totAvgNonMand <- mean(c(tours$tour_distance[tours$TOURPURP %in% c(4,5,6,7,8,9,10)], + + +# unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP %in% c(5,6,7,8,9)]), +# na.rm = T) + +nmSkimDist <- c(tours$tour_distance[tours$TOURPURP %in% c(4,5,6,7,8,9,10)], + unique_joint_tours$tour_distance[unique_joint_tours$JOINT_PURP %in% c(5,6,7,8,9)]) +nmWeights <- c(tours$finalweight[tours$TOURPURP %in% c(4,5,6,7,8,9,10)], + unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP %in% c(5,6,7,8,9)]) +totAvgNonMand <- weighted.mean(nmSkimDist, nmWeights, na.rm = TRUE) + + + + avgTripLengths <- c(avgTripLengths, totAvgNonMand) -nonMandTourPurpose <- c("esco", "imain", "idisc", "jmain", "jdisc", "atwork", "Total") +nonMandTourPurpose <- c("esco", "imain", "idisc", "jmain", "jdisc", "atwork", "Total") nonMandTripLengths <- data.frame(purpose = nonMandTourPurpose, avgTripLength = avgTripLengths) write.csv(nonMandTripLengths, "nonMandTripLengths.csv", row.names = F) - # STop Frequency #Outbound -stopfreq1 <- hist(tours$num_ob_stops[tours$TOURPURP==1], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreq2 <- hist(tours$num_ob_stops[tours$TOURPURP==2], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreq3 <- hist(tours$num_ob_stops[tours$TOURPURP==3], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreq4 <- hist(tours$num_ob_stops[tours$TOURPURP==4], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi56 <- hist(tours$num_ob_stops[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi789 <- hist(tours$num_ob_stops[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj56 <- hist(unique_joint_tours$num_ob_stops[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj789 <- hist(unique_joint_tours$num_ob_stops[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreq10 <- hist(tours$num_ob_stops[tours$TOURPURP==10], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) +stopfreq1 <- wtd.hist(tours$num_ob_stops[tours$TOURPURP==1], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1]) +stopfreq2 <- wtd.hist(tours$num_ob_stops[tours$TOURPURP==2], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2]) +stopfreq3 <- wtd.hist(tours$num_ob_stops[tours$TOURPURP==3], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3]) +stopfreq4 <- wtd.hist(tours$num_ob_stops[tours$TOURPURP==4], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==4]) +stopfreqi56 <- wtd.hist(tours$num_ob_stops[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6]) +stopfreqi789 <- wtd.hist(tours$num_ob_stops[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9]) +stopfreqj56 <- wtd.hist(unique_joint_tours$num_ob_stops[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6]) +stopfreqj789 <- wtd.hist(unique_joint_tours$num_ob_stops[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9]) +stopfreq10 <- wtd.hist(tours$num_ob_stops[tours$TOURPURP==10], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10]) stopFreq <- data.frame(stopfreq1$counts, stopfreq2$counts, stopfreq3$counts, stopfreq4$counts, stopfreqi56$counts , stopfreqi789$counts, stopfreqj56$counts, stopfreqj789$counts, stopfreq10$counts) @@ -1474,15 +1567,15 @@ stopFreqout_vis <- stopFreqout_vis[stopFreqout_vis$nstops!="Sum",] stopFreqout_vis$purpose[stopFreqout_vis$purpose=="Sum"] <- "Total" #Inbound -stopfreq1 <- hist(tours$num_ib_stops[tours$TOURPURP==1], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreq2 <- hist(tours$num_ib_stops[tours$TOURPURP==2], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreq3 <- hist(tours$num_ib_stops[tours$TOURPURP==3], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreq4 <- hist(tours$num_ib_stops[tours$TOURPURP==4], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi56 <- hist(tours$num_ib_stops[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi789 <- hist(tours$num_ib_stops[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj56 <- hist(unique_joint_tours$num_ib_stops[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj789 <- hist(unique_joint_tours$num_ib_stops[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) -stopfreq10 <- hist(tours$num_ib_stops[tours$TOURPURP==10], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE) +stopfreq1 <- wtd.hist(tours$num_ib_stops[tours$TOURPURP==1], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1]) +stopfreq2 <- wtd.hist(tours$num_ib_stops[tours$TOURPURP==2], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2]) +stopfreq3 <- wtd.hist(tours$num_ib_stops[tours$TOURPURP==3], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3]) +stopfreq4 <- wtd.hist(tours$num_ib_stops[tours$TOURPURP==4], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==4]) +stopfreqi56 <- wtd.hist(tours$num_ib_stops[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6]) +stopfreqi789 <- wtd.hist(tours$num_ib_stops[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9]) +stopfreqj56 <- wtd.hist(unique_joint_tours$num_ib_stops[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6]) +stopfreqj789 <- wtd.hist(unique_joint_tours$num_ib_stops[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9]) +stopfreq10 <- wtd.hist(tours$num_ib_stops[tours$TOURPURP==10], breaks = c(seq(0,3, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10]) stopFreq <- data.frame(stopfreq1$counts, stopfreq2$counts, stopfreq3$counts, stopfreq4$counts, stopfreqi56$counts , stopfreqi789$counts, stopfreqj56$counts, stopfreqj789$counts, stopfreq10$counts) @@ -1513,15 +1606,15 @@ write.csv(stopfreqDir_vis, "stopfreqDir_vis.csv", row.names = F) #Total -stopfreq1 <- hist(tours$num_tot_stops[tours$TOURPURP==1], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) -stopfreq2 <- hist(tours$num_tot_stops[tours$TOURPURP==2], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) -stopfreq3 <- hist(tours$num_tot_stops[tours$TOURPURP==3], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) -stopfreq4 <- hist(tours$num_tot_stops[tours$TOURPURP==4], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi56 <- hist(tours$num_tot_stops[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi789 <- hist(tours$num_tot_stops[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj56 <- hist(unique_joint_tours$num_tot_stops[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj789 <- hist(unique_joint_tours$num_tot_stops[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) -stopfreq10 <- hist(tours$num_tot_stops[tours$TOURPURP==10], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE) +stopfreq1 <- wtd.hist(tours$num_tot_stops[tours$TOURPURP==1], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==1]) +stopfreq2 <- wtd.hist(tours$num_tot_stops[tours$TOURPURP==2], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==2]) +stopfreq3 <- wtd.hist(tours$num_tot_stops[tours$TOURPURP==3], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==3]) +stopfreq4 <- wtd.hist(tours$num_tot_stops[tours$TOURPURP==4], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==4]) +stopfreqi56 <- wtd.hist(tours$num_tot_stops[tours$TOURPURP>=5 & tours$TOURPURP<=6], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=5 & tours$TOURPURP<=6]) +stopfreqi789 <- wtd.hist(tours$num_tot_stops[tours$TOURPURP>=7 & tours$TOURPURP<=9], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP>=7 & tours$TOURPURP<=9]) +stopfreqj56 <- wtd.hist(unique_joint_tours$num_tot_stops[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=5 & unique_joint_tours$JOINT_PURP<=6]) +stopfreqj789 <- wtd.hist(unique_joint_tours$num_tot_stops[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = unique_joint_tours$numberhh_wgt[unique_joint_tours$JOINT_PURP>=7 & unique_joint_tours$JOINT_PURP<=9]) +stopfreq10 <- wtd.hist(tours$num_tot_stops[tours$TOURPURP==10], breaks = c(seq(0,6, by=1), 9999), freq = NULL, right=FALSE, weight = tours$finalweight[tours$TOURPURP==10]) stopFreq <- data.frame(stopfreq1$counts, stopfreq2$counts, stopfreq3$counts, stopfreq4$counts, stopfreqi56$counts , stopfreqi789$counts, stopfreqj56$counts, stopfreqj789$counts, stopfreq10$counts) @@ -1547,16 +1640,17 @@ stopFreq_vis$purpose[stopFreq_vis$purpose=="Sum"] <- "Total" write.csv(stopFreq_vis, "stopfreq_total_vis.csv", row.names = F) +jstops$nump_wgt <- jstops$finalweight*jstops$num_participants #STop purpose X TourPurpose -stopfreq1 <- hist(stops$DPURP[stops$TOURPURP==1], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) -stopfreq2 <- hist(stops$DPURP[stops$TOURPURP==2], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) -stopfreq3 <- hist(stops$DPURP[stops$TOURPURP==3], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) -stopfreq4 <- hist(stops$DPURP[stops$TOURPURP==4], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi56 <- hist(stops$DPURP[stops$TOURPURP>=5 & stops$TOURPURP<=6], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi789 <- hist(stops$DPURP[stops$TOURPURP>=7 & stops$TOURPURP<=9], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj56 <- hist(jstops$DPURP[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj789 <- hist(jstops$DPURP[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) -stopfreq10 <- hist(stops$DPURP[stops$TOURPURP==10], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE) +stopfreq1 <- wtd.hist(stops$DPURP[stops$TOURPURP==1], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==1]) +stopfreq2 <- wtd.hist(stops$DPURP[stops$TOURPURP==2], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==2]) +stopfreq3 <- wtd.hist(stops$DPURP[stops$TOURPURP==3], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==3]) +stopfreq4 <- wtd.hist(stops$DPURP[stops$TOURPURP==4], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==4]) +stopfreqi56 <- wtd.hist(stops$DPURP[stops$TOURPURP>=5 & stops$TOURPURP<=6], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP>=5 & stops$TOURPURP<=6]) +stopfreqi789 <- wtd.hist(stops$DPURP[stops$TOURPURP>=7 & stops$TOURPURP<=9], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP>=7 & stops$TOURPURP<=9]) +stopfreqj56 <- wtd.hist(jstops$DPURP[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = jstops$finalweight[jstops$TOURPURP>=5 & jstops$TOURPURP<=6]) +stopfreqj789 <- wtd.hist(jstops$DPURP[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = jstops$finalweight[jstops$TOURPURP>=7 & jstops$TOURPURP<=9]) +stopfreq10 <- wtd.hist(stops$DPURP[stops$TOURPURP==10], breaks = c(seq(1,10, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==10]) stopFreq <- data.frame(stopfreq1$counts, stopfreq2$counts, stopfreq3$counts, stopfreq4$counts, stopfreqi56$counts , stopfreqi789$counts, stopfreqj56$counts, stopfreqj789$counts, stopfreq10$counts) @@ -1583,15 +1677,15 @@ stopFreq_vis$purpose[stopFreq_vis$purpose=="Sum"] <- "Total" write.csv(stopFreq_vis, "stoppurpose_tourpurpose_vis.csv", row.names = F) #Out of direction - Stop Location -stopfreq1 <- hist(stops$out_dir_dist[stops$TOURPURP==1], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq2 <- hist(stops$out_dir_dist[stops$TOURPURP==2], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq3 <- hist(stops$out_dir_dist[stops$TOURPURP==3], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq4 <- hist(stops$out_dir_dist[stops$TOURPURP==4], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi56 <- hist(stops$out_dir_dist[stops$TOURPURP>=5 & stops$TOURPURP<=6], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi789 <- hist(stops$out_dir_dist[stops$TOURPURP>=7 & stops$TOURPURP<=9], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj56 <- hist(jstops$out_dir_dist[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj789 <- hist(jstops$out_dir_dist[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq10 <- hist(stops$out_dir_dist[stops$TOURPURP==10], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE) +stopfreq1 <- wtd.hist(stops$out_dir_dist[stops$TOURPURP==1], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==1]) +stopfreq2 <- wtd.hist(stops$out_dir_dist[stops$TOURPURP==2], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==2]) +stopfreq3 <- wtd.hist(stops$out_dir_dist[stops$TOURPURP==3], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==3]) +stopfreq4 <- wtd.hist(stops$out_dir_dist[stops$TOURPURP==4], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==4]) +stopfreqi56 <- wtd.hist(stops$out_dir_dist[stops$TOURPURP>=5 & stops$TOURPURP<=6], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP>=5 & stops$TOURPURP<=6]) +stopfreqi789 <- wtd.hist(stops$out_dir_dist[stops$TOURPURP>=7 & stops$TOURPURP<=9], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP>=7 & stops$TOURPURP<=9]) +stopfreqj56 <- wtd.hist(jstops$out_dir_dist[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = jstops$finalweight[jstops$TOURPURP>=5 & jstops$TOURPURP<=6]) +stopfreqj789 <- wtd.hist(jstops$out_dir_dist[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = jstops$finalweight[jstops$TOURPURP>=7 & jstops$TOURPURP<=9]) +stopfreq10 <- wtd.hist(stops$out_dir_dist[stops$TOURPURP==10], breaks = c(-9999,seq(0,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==10]) stopFreq <- data.frame(stopfreq1$counts, stopfreq2$counts, stopfreq3$counts, stopfreq4$counts, stopfreqi56$counts , stopfreqi789$counts, stopfreqj56$counts, stopfreqj789$counts, stopfreq10$counts) @@ -1619,33 +1713,49 @@ stopDC_vis$distbin <- as.numeric(stopDC_vis$distbin) write.csv(stopDC_vis, "stopDC_vis.csv", row.names = F) # compute average out of dir distance for visualizer -avgDistances <- c(mean(stops$out_dir_dist[stops$TOURPURP==1], na.rm = TRUE), - mean(stops$out_dir_dist[stops$TOURPURP==2], na.rm = TRUE), - mean(stops$out_dir_dist[stops$TOURPURP==3], na.rm = TRUE), - mean(stops$out_dir_dist[stops$TOURPURP==4], na.rm = TRUE), - mean(stops$out_dir_dist[stops$TOURPURP>=5 & stops$TOURPURP<=6], na.rm = TRUE), - mean(stops$out_dir_dist[stops$TOURPURP>=7 & stops$TOURPURP<=9], na.rm = TRUE), - mean(jstops$out_dir_dist[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], na.rm = TRUE), - mean(jstops$out_dir_dist[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], na.rm = TRUE), - mean(stops$out_dir_dist[stops$TOURPURP==10], na.rm = TRUE), +avgDistances <- c(weighted.mean(stops$out_dir_dist[stops$TOURPURP==1], weight = stops$finalweight[stops$TOURPURP==1], na.rm = TRUE), + weighted.mean(stops$out_dir_dist[stops$TOURPURP==2], weight = stops$finalweight[stops$TOURPURP==2], na.rm = TRUE), + weighted.mean(stops$out_dir_dist[stops$TOURPURP==3], weight = stops$finalweight[stops$TOURPURP==3], na.rm = TRUE), + weighted.mean(stops$out_dir_dist[stops$TOURPURP==4], weight = stops$finalweight[stops$TOURPURP==4], na.rm = TRUE), + weighted.mean(stops$out_dir_dist[stops$TOURPURP>=5 & stops$TOURPURP<=6], weight = stops$finalweight[stops$TOURPURP>=5 & stops$TOURPURP<=6], na.rm = TRUE), + weighted.mean(stops$out_dir_dist[stops$TOURPURP>=7 & stops$TOURPURP<=9], weight = stops$finalweight[stops$TOURPURP>=7 & stops$TOURPURP<=9], na.rm = TRUE), + weighted.mean(jstops$out_dir_dist[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], weight = jstops$finalweight[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], na.rm = TRUE), + weighted.mean(jstops$out_dir_dist[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], weight = jstops$finalweight[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], na.rm = TRUE), + weighted.mean(stops$out_dir_dist[stops$TOURPURP==10], weight = stops$finalweight[stops$TOURPURP==10], na.rm = TRUE), mean(stops$out_dir_dist, na.rm = TRUE)) purp <- c("work", "univ", "sch", "esco","imain", "idisc", "jmain", "jdisc", "atwork", "total") +### +stopsDist <- c(stops$out_dir_dist[stops$TOURPURP %in% c(1, 2, 3,4,5,6,7,8,9, 10)], + jstops$out_dir_dist[jstops$TOURPURP %in% c(5,6,7,8,9)]) +stopsWeights <- c(stops$finalweight[stops$TOURPURP %in% c(1, 2, 3,4,5,6,7,8,9, 10)], + jstops$finalweight[jstops$TOURPURP %in% c(5,6,7,8,9)]) + +totAvgStopDist <- weighted.mean(stopsDist, stopsWeights, na.rm = TRUE) +# stopsDist <- c(stops$out_dir_dist[stops$TOURPURP %in% c(1, 2, 3,4,5,6,7,8,9, 10)], +# jstops$out_dir_dist[jstops$TOURPURP %in% c(5,6,7,8,9)]) +# +# totAvgStopDist <- mean(stopsDist, na.rm = TRUE) + +# avgDistances <- c(avgDistances, totAvgStopDist) + +### + avgStopOutofDirectionDist <- data.frame(purpose = purp, avgDist = avgDistances) write.csv(avgStopOutofDirectionDist, "avgStopOutofDirectionDist_vis.csv", row.names = F) #Stop Departure Time -stopfreq1 <- hist(stops$stop_period[stops$TOURPURP==1], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq2 <- hist(stops$stop_period[stops$TOURPURP==2], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq3 <- hist(stops$stop_period[stops$TOURPURP==3], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq4 <- hist(stops$stop_period[stops$TOURPURP==4], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi56 <- hist(stops$stop_period[stops$TOURPURP>=5 & stops$TOURPURP<=6], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi789 <- hist(stops$stop_period[stops$TOURPURP>=7 & stops$TOURPURP<=9], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj56 <- hist(jstops$stop_period[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj789 <- hist(jstops$stop_period[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq10 <- hist(stops$stop_period[stops$TOURPURP==10], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) +stopfreq1 <- wtd.hist(stops$stop_period[stops$TOURPURP==1], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==1]) +stopfreq2 <- wtd.hist(stops$stop_period[stops$TOURPURP==2], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==2]) +stopfreq3 <- wtd.hist(stops$stop_period[stops$TOURPURP==3], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==3]) +stopfreq4 <- wtd.hist(stops$stop_period[stops$TOURPURP==4], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==4]) +stopfreqi56 <- wtd.hist(stops$stop_period[stops$TOURPURP>=5 & stops$TOURPURP<=6], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP>=5 & stops$TOURPURP<=6]) +stopfreqi789 <- wtd.hist(stops$stop_period[stops$TOURPURP>=7 & stops$TOURPURP<=9], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP>=7 & stops$TOURPURP<=9]) +stopfreqj56 <- wtd.hist(jstops$stop_period[jstops$TOURPURP>=5 & jstops$TOURPURP<=6], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = jstops$finalweight[jstops$TOURPURP>=5 & jstops$TOURPURP<=6]) +stopfreqj789 <- wtd.hist(jstops$stop_period[jstops$TOURPURP>=7 & jstops$TOURPURP<=9], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = jstops$finalweight[jstops$TOURPURP>=7 & jstops$TOURPURP<=9]) +stopfreq10 <- wtd.hist(stops$stop_period[stops$TOURPURP==10], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = stops$finalweight[stops$TOURPURP==10]) stopFreq <- data.frame(stopfreq1$counts, stopfreq2$counts, stopfreq3$counts, stopfreq4$counts, stopfreqi56$counts , stopfreqi789$counts, stopfreqj56$counts, stopfreqj789$counts, stopfreq10$counts) @@ -1672,15 +1782,15 @@ stopDep_vis$PURPOSE[stopDep_vis$PURPOSE=="Sum"] <- "Total" stopDep_vis$timebin <- as.numeric(stopDep_vis$timebin) #Trip Departure Time -stopfreq1 <- hist(trips$stop_period[trips$TOURPURP==1], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq2 <- hist(trips$stop_period[trips$TOURPURP==2], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq3 <- hist(trips$stop_period[trips$TOURPURP==3], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq4 <- hist(trips$stop_period[trips$TOURPURP==4], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi56 <- hist(trips$stop_period[trips$TOURPURP>=5 & trips$TOURPURP<=6], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqi789 <- hist(trips$stop_period[trips$TOURPURP>=7 & trips$TOURPURP<=9], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj56 <- hist(jtrips$stop_period[jtrips$TOURPURP>=5 & jtrips$TOURPURP<=6], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreqj789 <- hist(jtrips$stop_period[jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) -stopfreq10 <- hist(trips$stop_period[trips$TOURPURP==10], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE) +stopfreq1 <- wtd.hist(trips$stop_period[trips$TOURPURP==1], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TOURPURP==1]) +stopfreq2 <- wtd.hist(trips$stop_period[trips$TOURPURP==2], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TOURPURP==2]) +stopfreq3 <- wtd.hist(trips$stop_period[trips$TOURPURP==3], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TOURPURP==3]) +stopfreq4 <- wtd.hist(trips$stop_period[trips$TOURPURP==4], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TOURPURP==4]) +stopfreqi56 <- wtd.hist(trips$stop_period[trips$TOURPURP>=5 & trips$TOURPURP<=6], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TOURPURP>=5 & trips$TOURPURP<=6]) +stopfreqi789 <- wtd.hist(trips$stop_period[trips$TOURPURP>=7 & trips$TOURPURP<=9], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TOURPURP>=7 & trips$TOURPURP<=9]) +stopfreqj56 <- wtd.hist(jtrips$stop_period[jtrips$TOURPURP>=5 & jtrips$TOURPURP<=6], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = jtrips$finalweight[jtrips$TOURPURP>=5 & jtrips$TOURPURP<=6]) +stopfreqj789 <- wtd.hist(jtrips$stop_period[jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = jtrips$finalweight[jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9]) +stopfreq10 <- wtd.hist(trips$stop_period[trips$TOURPURP==10], breaks = c(seq(1,40, by=1), 9999), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TOURPURP==10]) stopFreq <- data.frame(stopfreq1$counts, stopfreq2$counts, stopfreq3$counts, stopfreq4$counts, stopfreqi56$counts , stopfreqi789$counts, stopfreqj56$counts, stopfreqj789$counts, stopfreq10$counts) @@ -1712,19 +1822,19 @@ write.csv(stopTripDep_vis, "stopTripDep_vis.csv", row.names = F) #Trip Mode Summary (added 3 lines due to change in mode codes, changed seq 9 to 13, Khademul Haque) #Work -tripmode1 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode2 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode3 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode4 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode5 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode6 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode7 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode8 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode9 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode10 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode11 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode12 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode13 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tripmode1 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==1]) +tripmode2 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==2]) +tripmode3 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==3]) +tripmode4 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==4]) +tripmode5 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==5]) +tripmode6 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==6]) +tripmode7 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==7]) +tripmode8 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==8]) +tripmode9 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==9]) +tripmode10 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==10]) +tripmode11 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==11]) +tripmode12 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==12]) +tripmode13 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==1 & trips$TOURMODE==13]) tripModeProfile <- data.frame(tripmode1$counts, tripmode2$counts, tripmode3$counts, tripmode4$counts, tripmode5$counts, tripmode6$counts, tripmode7$counts, tripmode8$counts, tripmode9$counts, @@ -1753,19 +1863,19 @@ tripModeProfile1_vis$purpose[tripModeProfile1_vis$purpose=="Sum"] <- "Total" #University (added 3 lines due to change in mode codes, changed seq 9 to 13, Khademul Haque) -tripmode1 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode2 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode3 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode4 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode5 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode6 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode7 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode8 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode9 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode10 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode11 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode12 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode13 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tripmode1 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==1]) +tripmode2 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==2]) +tripmode3 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==3]) +tripmode4 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==4]) +tripmode5 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==5]) +tripmode6 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==6]) +tripmode7 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==7]) +tripmode8 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==8]) +tripmode9 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==9]) +tripmode10 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==10]) +tripmode11 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==11]) +tripmode12 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==12]) +tripmode13 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==2 & trips$TOURMODE==13]) tripModeProfile <- data.frame(tripmode1$counts, tripmode2$counts, tripmode3$counts, tripmode4$counts, @@ -1793,19 +1903,19 @@ tripModeProfile2_vis <- tripModeProfile2_vis[tripModeProfile2_vis$id!="Sum",] tripModeProfile2_vis$purpose[tripModeProfile2_vis$purpose=="Sum"] <- "Total" #School -tripmode1 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode2 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode3 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode4 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode5 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode6 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode7 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode8 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode9 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode10 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode11 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode12 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode13 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tripmode1 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==1]) +tripmode2 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==2]) +tripmode3 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==3]) +tripmode4 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==4]) +tripmode5 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==5]) +tripmode6 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==6]) +tripmode7 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==7]) +tripmode8 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==8]) +tripmode9 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==9]) +tripmode10 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==10]) +tripmode11 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==11]) +tripmode12 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==12]) +tripmode13 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==3 & trips$TOURMODE==13]) tripModeProfile <- data.frame(tripmode1$counts, tripmode2$counts, tripmode3$counts, tripmode4$counts, @@ -1833,19 +1943,19 @@ tripModeProfile3_vis <- tripModeProfile3_vis[tripModeProfile3_vis$id!="Sum",] tripModeProfile3_vis$purpose[tripModeProfile3_vis$purpose=="Sum"] <- "Total" #iMain -tripmode1 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode2 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode3 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode4 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode5 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode6 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode7 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode8 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode9 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode10 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode11 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode12 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode13 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tripmode1 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==1]) +tripmode2 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==2]) +tripmode3 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==3]) +tripmode4 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==4]) +tripmode5 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==5]) +tripmode6 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==6]) +tripmode7 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==7]) +tripmode8 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==8]) +tripmode9 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==9]) +tripmode10 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==10]) +tripmode11 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==11]) +tripmode12 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==12]) +tripmode13 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=4 & trips$TOURPURP<=6 & trips$TOURMODE==13]) tripModeProfile <- data.frame(tripmode1$counts, tripmode2$counts, tripmode3$counts, tripmode4$counts, @@ -1873,19 +1983,19 @@ tripModeProfile4_vis <- tripModeProfile4_vis[tripModeProfile4_vis$id!="Sum",] tripModeProfile4_vis$purpose[tripModeProfile4_vis$purpose=="Sum"] <- "Total" #iDisc -tripmode1 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode2 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode3 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode4 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode5 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode6 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode7 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode8 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode9 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode10 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode11 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode12 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode13 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tripmode1 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==1]) +tripmode2 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==2]) +tripmode3 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==3]) +tripmode4 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==4]) +tripmode5 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==5]) +tripmode6 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==6]) +tripmode7 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==7]) +tripmode8 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==8]) +tripmode9 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==9]) +tripmode10 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==10]) +tripmode11 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==11]) +tripmode12 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==12]) +tripmode13 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP>=7 & trips$TOURPURP<=9 & trips$TOURMODE==13]) tripModeProfile <- data.frame(tripmode1$counts, tripmode2$counts, tripmode3$counts, tripmode4$counts, tripmode5$counts, tripmode6$counts, tripmode7$counts, tripmode8$counts, tripmode9$counts, @@ -1912,19 +2022,19 @@ tripModeProfile5_vis <- tripModeProfile5_vis[tripModeProfile5_vis$id!="Sum",] tripModeProfile5_vis$purpose[tripModeProfile5_vis$purpose=="Sum"] <- "Total" #jMain -tripmode1 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode2 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode3 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode4 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode5 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode6 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode7 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode8 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode9 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode10 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode11 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode12 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode13 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tripmode1 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==1]) +tripmode2 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==2]) +tripmode3 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==3]) +tripmode4 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==4]) +tripmode5 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==5]) +tripmode6 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==6]) +tripmode7 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==7]) +tripmode8 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==8]) +tripmode9 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==9]) +tripmode10 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==10]) +tripmode11 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==11]) +tripmode12 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==12]) +tripmode13 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=4 & jtrips$TOURPURP<=6 & jtrips$TOURMODE==13]) tripModeProfile <- data.frame(tripmode1$counts, tripmode2$counts, tripmode3$counts, tripmode4$counts, tripmode5$counts, tripmode6$counts, tripmode7$counts, tripmode8$counts, tripmode9$counts, @@ -1951,19 +2061,19 @@ tripModeProfile6_vis <- tripModeProfile6_vis[tripModeProfile6_vis$id!="Sum",] tripModeProfile6_vis$purpose[tripModeProfile6_vis$purpose=="Sum"] <- "Total" #jDisc -tripmode1 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode2 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode3 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode4 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode5 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode6 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode7 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode8 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode9 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode10 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode11 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode12 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode13 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tripmode1 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==1]) +tripmode2 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==2]) +tripmode3 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==3]) +tripmode4 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==4]) +tripmode5 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==5]) +tripmode6 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==6]) +tripmode7 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==7]) +tripmode8 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==8]) +tripmode9 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==9]) +tripmode10 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==10]) +tripmode11 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==11]) +tripmode12 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==12]) +tripmode13 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURPURP>=7 & jtrips$TOURPURP<=9 & jtrips$TOURMODE==13]) tripModeProfile <- data.frame(tripmode1$counts, tripmode2$counts, tripmode3$counts, tripmode4$counts, tripmode5$counts, tripmode6$counts, tripmode7$counts, tripmode8$counts, tripmode9$counts, @@ -1990,19 +2100,19 @@ tripModeProfile7_vis <- tripModeProfile7_vis[tripModeProfile7_vis$id!="Sum",] tripModeProfile7_vis$purpose[tripModeProfile7_vis$purpose=="Sum"] <- "Total" #At work -tripmode1 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode2 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode3 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode4 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode5 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode6 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode7 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode8 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode9 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode10 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode11 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode12 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -tripmode13 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +tripmode1 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==1]) +tripmode2 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==2]) +tripmode3 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==3]) +tripmode4 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==4]) +tripmode5 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==5]) +tripmode6 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==6]) +tripmode7 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==7]) +tripmode8 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==8]) +tripmode9 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==9]) +tripmode10 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==10]) +tripmode11 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==11]) +tripmode12 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==12]) +tripmode13 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURPURP==10 & trips$TOURMODE==13]) tripModeProfile <- data.frame(tripmode1$counts, tripmode2$counts, tripmode3$counts, tripmode4$counts, tripmode5$counts, tripmode6$counts, tripmode7$counts, tripmode8$counts, tripmode9$counts, @@ -2029,34 +2139,34 @@ tripModeProfile8_vis <- tripModeProfile8_vis[tripModeProfile8_vis$id!="Sum",] tripModeProfile8_vis$purpose[tripModeProfile8_vis$purpose=="Sum"] <- "Total" #iTotal -itripmode1 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode2 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode3 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode4 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode5 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode6 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode7 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode8 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode9 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode10 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode11 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode12 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -itripmode13 <- hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +itripmode1 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==1]) +itripmode2 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==2]) +itripmode3 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==3]) +itripmode4 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==4]) +itripmode5 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==5]) +itripmode6 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==6]) +itripmode7 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==7]) +itripmode8 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==8]) +itripmode9 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==9]) +itripmode10 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==10]) +itripmode11 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==11]) +itripmode12 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==12]) +itripmode13 <- wtd.hist(trips$TRIPMODE[trips$TRIPMODE>0 & trips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = trips$finalweight[trips$TRIPMODE>0 & trips$TOURMODE==13]) #jTotal -jtripmode1 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode2 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode3 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode4 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode5 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode6 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode7 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode8 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode9 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode10 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode11 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode12 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) -jtripmode13 <- hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE) +jtripmode1 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==1], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==1]) +jtripmode2 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==2], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==2]) +jtripmode3 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==3], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==3]) +jtripmode4 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==4], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==4]) +jtripmode5 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==5], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==5]) +jtripmode6 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==6], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==6]) +jtripmode7 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==7], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==7]) +jtripmode8 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==8], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==8]) +jtripmode9 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==9], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==9]) +jtripmode10 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==10], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==10]) +jtripmode11 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==11], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==11]) +jtripmode12 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==12], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==12]) +jtripmode13 <- wtd.hist(jtrips$TRIPMODE[jtrips$TRIPMODE>0 & jtrips$TOURMODE==13], breaks = seq(1,14, by=1), freq = NULL, right=FALSE, weight = jtrips$numpart_wgt[jtrips$TRIPMODE>0 & jtrips$TOURMODE==13]) tripModeProfile <- data.frame(itripmode1$counts+jtripmode1$counts, itripmode2$counts+jtripmode2$counts, itripmode3$counts+jtripmode3$counts, itripmode4$counts+jtripmode4$counts, itripmode5$counts+jtripmode5$counts, itripmode6$counts+jtripmode6$counts, itripmode7$counts+jtripmode7$counts, itripmode8$counts+jtripmode8$counts, @@ -2144,17 +2254,18 @@ write.csv(jtrips_summary, "jtrips_tripmode_summary.csv", row.names = F) # Total number of stops, trips & tours -cat("Total number of stops : ", nrow(stops) + nrow(jstops)) -cat("Total number of trips : ", nrow(trips) + nrow(jtrips)) -cat("Total number of tours : ", nrow(tours) + sum(unique_joint_tours$NUMBER_HH)) +cat("Total number of stops : ", sum(stops$finalweight) + sum(jstops$nump_wgt)) +cat("Total number of trips : ", sum(trips$finalweight) + sum(jtrips$numpart_wgt)) +cat("Total number of tours : ", sum(tours$finalweight) + sum(unique_joint_tours$numberhh_wgt)) # output total numbers in a file total_population <- sum(pertypeDistbn$freq) -total_households <- nrow(hh) -total_tours <- nrow(tours) + sum(unique_joint_tours$NUMBER_HH) -total_trips <- nrow(trips) + nrow(jtrips) -total_stops <- nrow(stops) + nrow(jstops) +#total_households <- nrow(hh) +total_households <- sum(hh$finalweight) +total_tours <- sum(tours$finalweight) + sum(unique_joint_tours$numberhh_wgt) +total_trips <- sum(trips$finalweight) + sum(jtrips$numpart_wgt) +total_stops <- sum(stops$finalweight) + sum(jstops$nump_wgt) trips$num_travel[trips$TRIPMODE==1] <- 1 #sov trips$num_travel[trips$TRIPMODE==2] <- 2 #hov2 @@ -2164,7 +2275,7 @@ trips$num_travel[trips$TRIPMODE==11] <- 1.2 #tnc single trips$num_travel[trips$TRIPMODE==12] <- 2.0 #tnc shared trips$num_travel[is.na(trips$num_travel)] <- 0 -total_vmt <- sum((trips$od_dist[trips$TRIPMODE<=3])/trips$num_travel[trips$TRIPMODE<=3]) + sum((trips$od_dist[trips$TRIPMODE>=10 & trips$TRIPMODE<=12])/trips$num_travel[trips$TRIPMODE>=10 & trips$TRIPMODE<=12]) +total_vmt <- sum((trips$finalweight[trips$TRIPMODE<=3]*trips$od_dist[trips$TRIPMODE<=3])/trips$num_travel[trips$TRIPMODE<=3]) + sum((trips$finalweight[trips$TRIPMODE>=10 & trips$TRIPMODE<=12]*trips$od_dist[trips$TRIPMODE>=10 & trips$TRIPMODE<=12])/trips$num_travel[trips$TRIPMODE>=10 & trips$TRIPMODE<=12]) totals_var <- c("total_population", "total_households", "total_tours", "total_trips", "total_stops", "total_vmt") totals_val <- c(total_population,total_households, total_tours, total_trips, total_stops, total_vmt) @@ -2174,11 +2285,11 @@ totals_df <- data.frame(name = totals_var, value = totals_val) write.csv(totals_df, "totals.csv", row.names = F) # HH Size distribution -hhSizeDist <- count(hh, c("HHSIZE")) +hhSizeDist <- count(hh, c("HHSIZE"), "finalweight") write.csv(hhSizeDist, "hhSizeDist.csv", row.names = F) # Persons by person type -actpertypeDistbn <- count(per[per$activity_pattern!="H"], c("PERTYPE")) +actpertypeDistbn <- count(per[per$activity_pattern!="H",], c("PERTYPE"), "finalweight") write.csv(actpertypeDistbn, "activePertypeDistbn.csv", row.names = TRUE) diff --git a/src/main/resources/DataLoadRequest.bat b/src/main/resources/DataLoadRequest.bat index 1e640fab9..d79ccd37e 100644 --- a/src/main/resources/DataLoadRequest.bat +++ b/src/main/resources/DataLoadRequest.bat @@ -2,6 +2,7 @@ set PROJECT_DIRECTORY="%1" set ITERATION=%2 set YEAR=%3 set SAMPLE_RATE=%4 -set ABM_VERSION=${version} +set GEO_ID=%5 +set ABM_VERSION=version_14_3_0 -sqlcmd -d ${database_name} -E -S ${database_server} -Q "EXEC [data_load].[SP_REQUEST] $(year),'$(path)',$(iteration),$(sample_rate),'$(abm_version)'" -v year=%YEAR% path=%PROJECT_DIRECTORY% iteration=%ITERATION% sample_rate=%SAMPLE_RATE% abm_version=%ABM_VERSION% \ No newline at end of file +sqlcmd -d abm_14_3_0 -E -S DDAMWSQL16 -Q "EXEC [data_load].[SP_REQUEST] $(year),'$(path)',$(iteration),$(sample_rate), '$(abm_version)', $(geography_set_id)" -v year=%YEAR% path=%PROJECT_DIRECTORY% iteration=%ITERATION% sample_rate=%SAMPLE_RATE% geography_set_id=%GEO_ID% abm_version=%ABM_VERSION% \ No newline at end of file diff --git a/src/main/resources/pskill.exe b/src/main/resources/pskill.exe deleted file mode 100644 index 2e9d0d497..000000000 Binary files a/src/main/resources/pskill.exe and /dev/null differ diff --git a/src/main/resources/sandag_abm.properties b/src/main/resources/sandag_abm.properties index 48b72b806..7945b3e0b 100644 --- a/src/main/resources/sandag_abm.properties +++ b/src/main/resources/sandag_abm.properties @@ -1,6 +1,8 @@ #SANDAG ABM Properties #Software Version version=${version} +# geography ID +geographyID=1 ############################################################################################################################################################################# # # CLUSTER PROPERTIES: MODIFY WHEN CHANGING CLUSTER CONFIGURATION OR MOVING TO NEW CLUSTER. @@ -30,6 +32,7 @@ RunModel.skip4Ds = false RunModel.skipInputChecker = false RunModel.skipCopyWarmupTripTables = false RunModel.skipCopyBikeLogsum = false +RunModel.skipShadowPricing = false RunModel.skipBikeLogsums = true #always create walk logsum (walk to TAP file); modification from GUI disallowed RunModel.skipCopyWalkImpedance = true @@ -177,6 +180,10 @@ truck.FFyear =${year} # Destination zones for the transponder accessibility calculator transponder.destinations = 4027,2563,2258 +traffic.sla_limit = 3 + +# Number of zones where 4996 is the default, but may be changed by Land Use Converter Tool zone split +zones.count = 4996 ############################################################################################ # EMERGING MOBILITY SECTION: MODIFY WHEN CHANGE AV, TNC, and MICROMOBILITY ASSUMPTIONS