public static void Main() { StreamWriter writeRoster = new StreamWriter("E:/Projects/Clients/bkr/model/bkrcast_tod_new/scripts/WriteRoster/bkr_roster_more_no_toll.csv"); writeRoster.WriteLine("#variable,mode,path-type,vot-group,start-minute,end-minute,length,file-type, name, field, transpose, blend-variable,blend-path-type,factor,scaling"); // the field "name" now needs to include the name of the hdf5 file // plus the skim; but the tod.name doesn't need to be specified inside the file List <TimeOfDay> highway_times_of_day = HighwayDimensions.DefineTimeOfDay(); List <Mode> highway_modes = HighwayDimensions.DefineModes(); List <PathType> highway_path_types = HighwayDimensions.DefinePathTypes(); List <SkimVariable> highway_skim_variables = HighwayDimensions.DefineSkimVariables(); List <ValueOfTime> sov_toll_highway_values_of_time = HighwayDimensions.DefineTollSOVValuesofTime(); List <ValueOfTime> hov_toll_highway_values_of_time = HighwayDimensions.DefineTollHOVValuesofTime(); List <ValueOfTime> sov_no_toll_highway_values_of_time = HighwayDimensions.DefineTollSOVValuesofTime(); List <ValueOfTime> hov_no_toll_highway_values_of_time = HighwayDimensions.DefineTollHOVValuesofTime(); List <Mode> transit_modes = TransitDimensions.DefineModes(); List <TimeOfDay> transit_times_of_day = TransitDimensions.DefineTimesOfDay(); List <PathType> transit_path_types = TransitDimensions.DefinePathTypes(); List <SkimVariable> transit_skim_variables = TransitDimensions.DefineSkimVariables(); List <ValueOfTime> transit_values_of_time = TransitDimensions.DefineValuesofTime(); List <Mode> nonmotorized_modes = NonMotorizedDimensions.DefineModes(); List <TimeOfDay> nonmotorized_times_of_day = NonMotorizedDimensions.DefineTimesOfDay(); List <PathType> nonmotorized_path_types = NonMotorizedDimensions.DefinePathTypes(); List <SkimVariable> nonmotorized_skim_variables = NonMotorizedDimensions.DefineSkimVariables(); List <ValueOfTime> nonmotorized_values_of_time = NonMotorizedDimensions.DefineValuesofTime(); //Write Highway Toll - SOV foreach (TimeOfDay tod in highway_times_of_day) { foreach (ValueOfTime vot in sov_toll_highway_values_of_time) { foreach (Mode mode in highway_modes) { foreach (PathType pt in highway_path_types) { foreach (SkimVariable skim in highway_skim_variables) { //var pt =highway_path_types[1]; string skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); string specificskim = "Skims/" + mode.emme_code + pt.emme_code + vot.vot_id.ToString() + skim.variable_emme_code; string fullpathtoskim = skimpath + specificskim; RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); // we only need one distance skim for all day- let 5 to 9 stand in if ((skim.variable_name_in_file == "Distance") && (tod.time_name != "6to9")) { } else if ((skim.variable_name_in_file == "Distance") && (tod.time_name == "6to9")) { record.start_minute = 0; record.end_minute = 1439; writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } else { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } } } } } } //Write Highway - HOV foreach (TimeOfDay tod in highway_times_of_day) { foreach (ValueOfTime vot in hov_toll_highway_values_of_time) { foreach (Mode mode in highway_modes) { foreach (PathType pt in highway_path_types) { foreach (SkimVariable skim in highway_skim_variables) { //var pt =highway_path_types[1]; string skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); string specificskim = "Skims/" + mode.emme_code + pt.emme_code + vot.vot_id.ToString() + skim.variable_emme_code; string fullpathtoskim = skimpath + specificskim; RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); // we only need one distance skim for all day- let 5 to 6 stand in if ((skim.variable_name_in_file == "Distance") && (tod.time_name != "6to9")) { } else if ((skim.variable_name_in_file == "Distance") && (tod.time_name == "6to9")) { record.start_minute = 0; record.end_minute = 1439; writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } else { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } } } //} } } } writeRoster.Flush(); //Write Transit foreach (TimeOfDay tod in transit_times_of_day) { foreach (ValueOfTime vot in transit_values_of_time) { foreach (Mode mode in transit_modes) { foreach (PathType pt in transit_path_types) { foreach (SkimVariable skim in transit_skim_variables) { string skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); string specificskim = "Skims/" + mode.emme_code + skim.variable_emme_code; string fullpathtoskim = skimpath + specificskim; RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); // pick up fare for all times from the 9to15 file for now if (record.start_minute == 360 && skim.variable_name_roster == "fare") { record.start_minute = 0; record.end_minute = 1439; tod.time_name = "9to1530"; skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); specificskim = "Skims/" + mode.emme_code + skim.variable_emme_code; record.name = skimpath + specificskim; writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } else if (skim.variable_name_roster != "fare") { // the overnight skims should have nulls for now if (record.start_minute == 1320) { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + "null,null,1,FALSE,null,null,null,TRUE"); } // PM as transpose of AM else if (record.start_minute == 930 && skim.variable_name_roster != "fare") { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + "TRUE" + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } else { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } } } } } } } writeRoster.Flush(); //Write Nonmotorized foreach (TimeOfDay tod in nonmotorized_times_of_day) { foreach (ValueOfTime vot in nonmotorized_values_of_time) { foreach (Mode mode in nonmotorized_modes) { foreach (PathType pt in nonmotorized_path_types) { foreach (SkimVariable skim in nonmotorized_skim_variables) { string skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); string specificskim = "Skims/" + "walkt"; string fullpathtoskim = skimpath + specificskim; //Console.WriteLine(fullpathtoskim); //Console.ReadLine(); if (skim.variable_name_roster == "distance") { //distance skim needs to be divided by 60, multiplied by mph, which 3 mph so 3/60 is the factor RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + "0.05" + ',' + record.scaling); } else if (mode.mode_name == "walk") { RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor + ',' + record.scaling); } else //bike time is the else { //assuming 15 mph speed on bike RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + "0.20" + ',' + record.scaling); } } } } } } writeRoster.Flush(); Console.WriteLine("All done."); Console.ReadLine(); }
public static void Main() { StreamWriter writeRoster = new StreamWriter("C:/psrc_roster_more_no_toll.csv"); writeRoster.WriteLine("#variable,mode,path-type,vot-group,start-minute,end-minute,length,file-type, name, field, transpose, blend-variable,blend-path-type,factor,scaling"); // the field "name" now needs to include the name of the hdf5 file // plus the skim; but the tod.name doesn't need to be specified inside the file List<TimeOfDay> highway_times_of_day = HighwayDimensions.DefineTimeOfDay(); List<Mode> highway_modes = HighwayDimensions.DefineModes(); List<PathType> highway_path_types = HighwayDimensions.DefinePathTypes(); List<SkimVariable> highway_skim_variables = HighwayDimensions.DefineSkimVariables(); List<ValueOfTime> sov_toll_highway_values_of_time = HighwayDimensions.DefineTollSOVValuesofTime(); List<ValueOfTime> hov_toll_highway_values_of_time = HighwayDimensions.DefineTollHOVValuesofTime(); List<ValueOfTime> sov_no_toll_highway_values_of_time = HighwayDimensions.DefineTollSOVValuesofTime(); List<ValueOfTime> hov_no_toll_highway_values_of_time = HighwayDimensions.DefineTollHOVValuesofTime(); List<Mode> transit_modes = TransitDimensions.DefineModes(); List<TimeOfDay> transit_times_of_day = TransitDimensions.DefineTimesOfDay(); List<PathType> transit_path_types = TransitDimensions.DefinePathTypes(); List<SkimVariable> transit_skim_variables = TransitDimensions.DefineSkimVariables(); List<ValueOfTime> transit_values_of_time = TransitDimensions.DefineValuesofTime(); List<Mode> nonmotorized_modes = NonMotorizedDimensions.DefineModes(); List<TimeOfDay> nonmotorized_times_of_day = NonMotorizedDimensions.DefineTimesOfDay(); List<PathType> nonmotorized_path_types = NonMotorizedDimensions.DefinePathTypes(); List<SkimVariable> nonmotorized_skim_variables = NonMotorizedDimensions.DefineSkimVariables(); List<ValueOfTime> nonmotorized_values_of_time = NonMotorizedDimensions.DefineValuesofTime(); //Write Highway Toll - SOV foreach (TimeOfDay tod in highway_times_of_day) { foreach (ValueOfTime vot in sov_toll_highway_values_of_time) { foreach (Mode mode in highway_modes) { foreach (PathType pt in highway_path_types) { foreach (SkimVariable skim in highway_skim_variables) { //var pt =highway_path_types[1]; string skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); string specificskim = "Skims/"+mode.emme_code + pt.emme_code + vot.vot_id.ToString() + skim.variable_emme_code; string fullpathtoskim = skimpath + specificskim; RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); // we only need one distance skim for all day- let 5 to 6 stand in if ((skim.variable_name_in_file == "Distance") && (tod.time_name != "7to8")) { } else if ((skim.variable_name_in_file == "Distance") && (tod.time_name == "7to8")) { record.start_minute = 0; record.end_minute = 1439; writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } else { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } } } } } } //Write Highway - HOV foreach (TimeOfDay tod in highway_times_of_day) { foreach (ValueOfTime vot in hov_toll_highway_values_of_time) { foreach (Mode mode in highway_modes) { foreach (PathType pt in highway_path_types) { foreach (SkimVariable skim in highway_skim_variables) { //var pt =highway_path_types[1]; string skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); string specificskim = "Skims/"+mode.emme_code + pt.emme_code + vot.vot_id.ToString() + skim.variable_emme_code; string fullpathtoskim = skimpath + specificskim; RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); // we only need one distance skim for all day- let 5 to 6 stand in if ((skim.variable_name_in_file == "Distance") && (tod.time_name != "7to8")) { } else if ((skim.variable_name_in_file == "Distance") && (tod.time_name == "7to8")) { record.start_minute = 0; record.end_minute = 1439; writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } else { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } } } //} } } } writeRoster.Flush(); //Write Transit foreach (TimeOfDay tod in transit_times_of_day) { foreach (ValueOfTime vot in transit_values_of_time) { foreach (Mode mode in transit_modes) { foreach (PathType pt in transit_path_types) { foreach (SkimVariable skim in transit_skim_variables) { string skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); string specificskim = "Skims/"+mode.emme_code + skim.variable_emme_code; string fullpathtoskim = skimpath + specificskim; RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); // pick up fare for all times from the 9to10 file for now if (record.start_minute == 300 && skim.variable_name_roster == "fare") { record.start_minute = 0; record.end_minute = 1439; tod.time_name = "9to10"; skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); specificskim ="Skims/"+ mode.emme_code + skim.variable_emme_code; record.name = skimpath + specificskim; writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } else if (skim.variable_name_roster != "fare") { // the overnight skims should have nulls for now if (record.start_minute == 1320) { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + "null,null,1,FALSE,null,null,null,TRUE"); } // PM as transpose of AM else if (record.start_minute == 960 && skim.variable_name_roster != "fare") { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + "TRUE" + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } else { writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor.ToString() + ',' + record.scaling); } } } } } } } writeRoster.Flush(); //Write Nonmotorized foreach (TimeOfDay tod in nonmotorized_times_of_day) { foreach (ValueOfTime vot in nonmotorized_values_of_time) { foreach (Mode mode in nonmotorized_modes) { foreach (PathType pt in nonmotorized_path_types) { foreach (SkimVariable skim in nonmotorized_skim_variables) { string skimpath = string.Format(@"{0}.{1}/", tod.time_name, "h5"); string specificskim = "Skims/"+"walkt"; string fullpathtoskim = skimpath + specificskim; //Console.WriteLine(fullpathtoskim); //Console.ReadLine(); if (skim.variable_name_roster == "distance") { //distance skim needs to be divided by 60, multiplied by mph, which 3 mph so 3/60 is the factor RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + "0.05" + ',' + record.scaling); } else if (mode.mode_name == "walk") { RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + record.factor + ',' + record.scaling); } else //bike time is the else { //assuming 15 mph speed on bike RosterRecord record = new RosterRecord(skim.variable_name_roster, mode.mode_name, pt.path_type_name, vot.vot_name, tod.start_time, tod.end_time, fullpathtoskim, skim.blend_variable, mode.factor); writeRoster.WriteLine(record.variable + ',' + record.mode + ',' + record.path_type + ',' + record.value_of_time_group + ',' + record.start_minute.ToString() + ',' + record.end_minute.ToString() + ',' + record.length + ',' + record.file_type + ',' + record.name + ',' + record.field + ',' + record.transpose + ',' + record.blend_var + ',' + record.blend_path_type + ',' + "0.20" + ',' + record.scaling); } } } } } } writeRoster.Flush(); Console.WriteLine("All done."); Console.ReadLine(); }