Skip to content

Commit fb62c68

Browse files
committed
Merge branch 'nrferguson-master'
2 parents cdcfcdd + b6ed245 commit fb62c68

9 files changed

+187
-125
lines changed

apply_future_rail_actions.sas

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
PROGRAM APPLIES FUTURE RAIL CODING CHANGES TO ITINERARIES. CALLED BY
66
CREATE_EMME_RAIL_FILES_GTFS.SAS.
77
------------- -------------
8+
9+
NRF 8/29/2017: Revised station consolidation processing to skip future itineraries that already have new station coded.
810
__________________________________________________________________________________________________________________________ */
911

1012
filename inrte "&inpath.\Temp\rte_out.txt";
@@ -180,7 +182,7 @@ filename inrte "&inpath.\Temp\rte_out.txt";
180182
data rte7; set ftrrte(where=(action=7)); proc sort; by tr_line;
181183
data limit(keep=tr_line); set rte7;
182184
data itn7(keep=itin_a ln start end new); merge ftritin limit(in=hit); by tr_line; if hit;
183-
length ln $3.;
185+
length ln $3. new 8.;
184186
ln=substr(tr_line,1,3); start=itin_a; end=itin_b; new=layover;
185187

186188
data __null__; merge ftritin rte7(in=hit); by tr_line; if hit;
@@ -190,13 +192,35 @@ filename inrte "&inpath.\Temp\rte_out.txt";
190192
put "--> " descr ": consolidated " ln "stations between itin_a = " itin_a "and itin_b = " itin_b "into new station at " new;
191193

192194
proc sort; by ln itin_a;
195+
196+
proc sql;
197+
create table skip as
198+
select distinct tr_line, 1 as skip
199+
from itins left join itn7 on (itins.itin_a=itn7.new or itins.itin_b=itn7.new)
200+
where itn7.new > 0;
201+
quit;
193202

194203
data itins; set itins;
195204
length ln $3.;
196205
ln=substr(tr_line,1,3);
197206
proc sort; by ln itin_a;
198207
data itins; merge itins(in=hit) itn7; by ln itin_a; if hit;
199208
proc sort; by tr_line it_order;
209+
210+
data itins;
211+
merge itins(in=hit) skip;
212+
by tr_line;
213+
if hit;
214+
run;
215+
216+
data itins (drop=skip); *** remove matches where new station already in future itinerary;
217+
set itins;
218+
if skip=1 then do;
219+
start=.;
220+
end=.;
221+
new=.;
222+
end;
223+
run;
200224

201225
data itins (drop=d); set itins; *** remove false matches on 2-way routes;
202226
retain d;
@@ -210,6 +234,8 @@ filename inrte "&inpath.\Temp\rte_out.txt";
210234
flag=f; *** flag affected links;
211235
if f=1 then t=trv_time+t; *** sum travel time on affected links;
212236
if itin_b=e and f=1 then do; f=0; new=n; end=e; time=t; t=0; end;
237+
238+
213239

214240
data itins (drop=start end new flag); set itins; *** replace consolidating station itin with new station itin;
215241
if itin_a=start and flag=1 then itin_b=new;

create_Emme_rail_files_GTFS.sas

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
------------- -------------
55
PROGRAM CREATES TIME-OF-DAY RAIL TRANSIT NETWORK BATCHIN FILES.
66
7-
Action=1: Entire itinerary coded. Route and itinerary are appended to base year tables for processing. Assume only apply to
8-
TOD=3 or TOD=am.
7+
Action=1: Entire itinerary coded. Route and itinerary are appended to base year tables for processing.
8+
Routes and headways are applied to TOD periods according to coding in HEADWAY and TOD fields.
99
1010
1111
Revisions:
@@ -17,6 +17,8 @@
1717
01-08-2016: Corrected itinerary batchin formatting
1818
02-01-2016: Metra headways coded as '99' are replaced by the TOD period duration.
1919
12-20-2016: Updated 'basescen' variable to '200' after base year moved to 2015.
20+
NRF 8/23/2017: Added support for updated future coding of additional service (action = 1)
21+
to include appropriate additional service in all TOD periods.
2022
2123
------------- -------------
2224
__________________________________________________________________________________________________________________________ */
@@ -78,7 +80,7 @@ data __null__;
7880
%if &sc>&basescen %then %do;
7981
proc import datafile="&inpath.\Temp\temp_route_ftr.dbf" out=ftrrte replace; *** future routes, limited to specified scenario;
8082
data ftrrte(rename=(descriptio=descr)); set ftrrte(where=(scenario ? "&scen"));
81-
length actcode$2.; actcode=compress('a'||action); it_order=0; acthdwy=headway;
83+
length actcode$2.; actcode=compress('a'||action); it_order=0;
8284
proc sort; by tr_line;
8385

8486
proc freq data=ftrrte noprint; tables actcode / out=ftract;
@@ -138,14 +140,26 @@ run;
138140

139141

140142
data routes(rename=(descriptio=descr)); set routes1(where=(&select)); it_order=0; acthdwy=.;
141-
%if &a1>0 & (&tod=3 or &tod=am) %then %do;
143+
%if &a1>0 %then %do;
142144

143145
data __null__;
144146
file "&reportpath" mod;
145147
put /"### NEW ROUTES &tod ###";
146148

147149
*** -- Include Full Future Routes (Action=1) in processing -- ***;
148-
data frte2(drop=actcode); set ftrrte(where=(action=1));
150+
data frte2(drop=actcode headway c rename=(phdwy=headway));
151+
set ftrrte(where=(action=1 and (tod ? "&tod")));
152+
c=count(headway,':');
153+
if c>0 then c=c+1;
154+
if c>0 then do;
155+
do i=1 to c by 2;
156+
p1=scan(headway,i,':');
157+
h1=scan(headway,i+1,':');
158+
if find(p1,"&tod")>0 then phdwy=input(h1, 8.);
159+
end;
160+
end;
161+
else if c=0 then phdwy=input(headway, 8.);
162+
acthdwy=phdwy;
149163

150164
data __null__; set frte2;
151165
file "&reportpath" mod;
@@ -215,8 +229,18 @@ run;
215229
data rte(drop=it_order); set routes;
216230

217231
data itins; merge itins rte(in=hit); by tr_line; if hit; proc sort; by tr_line it_order;
218-
data itins; set itins(where=(itin_a not in (&dropnode) & itin_b not in (&dropnode))); by tr_line it_order;
219-
if last.tr_line then layover='3';
232+
data itins;
233+
set itins(where=(itin_a not in (&dropnode) & itin_b not in (&dropnode)));
234+
by tr_line it_order;
235+
retain o 1;
236+
it_order=o;
237+
o=o+1;
238+
if first.tr_line then do;
239+
o=1;
240+
it_order=o;
241+
o=o+1;
242+
end;
243+
if last.tr_line then layover='3';
220244

221245

222246
data combine; set routes itins; proc sort; by tr_line it_order;
Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
#############################################################################
2-
# CREATE_SCENARIO_FILES_GTFS.PY #
3-
# Craig Heither & Nick Ferguson, last revised 07/18/2013 #
4-
# #
5-
# This program creates the Emme batchin files needed to model a scenario #
6-
# network. The "Scenario" and "Path" variables are passed to the script #
7-
# as arguments from the tool. The following files are created: #
8-
# - rail.itinerary #
9-
# - rail.network #
10-
# - railnode.extatt #
11-
# - railseg.extatt #
12-
# #
13-
# ------------------------- #
14-
# #
15-
# Revision summary: #
16-
# 04-26-2012: Revised script & tool so that CT-RAMP output flag is #
17-
# available to use expanded list of transit vehicle types. #
18-
# 06-19-2013: Added code to create temporary copy of people mover table. #
19-
# 07-18-2013: Added ability to create link shape file by calling the #
20-
# create function from the linkshape module. #
21-
# 12-20-2016: Updated to use 'all_runs_base' for scenario 200 #
22-
# after base year moved to 2015. #
23-
# #
24-
#############################################################################
1+
###############################################################################
2+
# CREATE_EMME_SCENARIO_FILES.PY #
3+
# Craig Heither # #
4+
# Last revised 6/28/2017 #
5+
# #
6+
# This program creates the Emme batchin files needed to model a scenario #
7+
# network. The "Scenario" and "Path" variables are passed to the script #
8+
# as arguments from the tool. The following files are created: #
9+
# - rail.itinerary #
10+
# - rail.network #
11+
# - railnode.extatt #
12+
# - railseg.extatt #
13+
# ------------------------------ #
14+
# Revision summary: #
15+
# 04-26-2012: Revised script & tool so that CT-RAMP output flag is #
16+
# available to use expanded list of transit vehicle types. #
17+
# 06-19-2013: Added code to create temporary copy of people mover table. #
18+
# 07-18-2013: Added ability to create link shape file by calling the #
19+
# create function from the linkshape module. #
20+
# 12-20-2016: Updated to use 'all_runs_base' for scenario 200 #
21+
# after base year moved to 2015. #
22+
# 06-28-2017: Updated to use ON TO 2050 scenario codes. #
23+
###############################################################################
2524

2625
# ---------------------------------------------------------------
2726
# Import System Modules

geometry_update.sas

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- SECTION 5 - Creates final files for input into geodatabase.
2727
2828
NRF revised 5-30-2017 to take future routes .dbf as parameter.
29+
NRF 8/21/2017: Includes new future coding TOD field in output.
2930
__________________________________________________________________________________________________________________________ */
3031

3132
%let dir=%scan(&sysparm,1,$); ***shapefile storage directory;
@@ -349,10 +350,10 @@ run;
349350
set rt;
350351
id=_n_;
351352
if descriptio='' then descriptio=description;
352-
rename tr_line=line1 descriptio=desc1 mode=mode1 veh_type=type1 headway=hdwy1 speed=speed1 scenario=scen1 action=action1 notes=notes1;
353+
rename tr_line=line1 descriptio=desc1 mode=mode1 veh_type=type1 headway=hdwy1 speed=speed1 tod=tod1 scenario=scen1 action=action1 notes=notes1;
353354
data rt;
354355
set rt;
355-
keep line1 desc1 mode1 type1 hdwy1 speed1 scen1 action1 notes1 id;
356+
keep line1 desc1 mode1 type1 hdwy1 speed1 tod1 scen1 action1 notes1 id;
356357
proc export data=rt outfile="&dir.\Temp\rte_updt.dbf" dbms=dbf replace;
357358
%end;
358359
%else %if &code=3 & %index(&origitin,all_runs) %then %do;
Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
#############################################################################
2-
# IMPORT_ROUTES.PY #
3-
# Craig Heither, last revised 05/17/2012 #
4-
# #
5-
# This program is used to import new or revised rail route coding into #
6-
# "railnet_route_rail_lines". The "xls" variable listed below should be #
7-
# updated to identify the spreadsheet in the Import\ directory that #
8-
# holds the coding. #
9-
# #
10-
# All routes are re-built based on the arc geometry to ensure they are #
11-
# coincident with the underlying links. #
12-
# #
13-
# ------------------------- #
14-
# revision summary: #
15-
# 06-03-2010: added coding to update route geometry when run. #
16-
# 09-14-2010: updated for ArcMap 10 (arcgisscripting replaced by arcpy & #
17-
# revised cursor coding based on ESRI changes). #
18-
# 04-05-2011: SAS call moved to sasrun.bat. #
19-
# 09-26-2011: For Route table update: Index and Table join procedures #
20-
# replaced by more efficient Search and Update cursor code. #
21-
# 01-24-2012: Revised to accept GTFS or spreadsheet coding.
22-
# #
23-
#############################################################################
1+
###############################################################################
2+
# IMPORT_RAIL_CODING.PY #
3+
# Craig Heither #
4+
# Last revised 8/22/2017 #
5+
# #
6+
# This program is used to import new or revised rail route coding into #
7+
# "railnet_route_rail_lines". The "xls" variable listed below should be #
8+
# updated to identify the spreadsheet in the Import\ directory that #
9+
# holds the coding. #
10+
# #
11+
# All routes are re-built based on the arc geometry to ensure they are #
12+
# coincident with the underlying links. #
13+
# ------------------------- #
14+
# Revision summary: #
15+
# 06-03-2010: added coding to update route geometry when run. #
16+
# 09-14-2010: updated for ArcMap 10 (arcgisscripting replaced by arcpy & #
17+
# revised cursor coding based on ESRI changes). #
18+
# 04-05-2011: SAS call moved to sasrun.bat. #
19+
# 09-26-2011: For Route table update: Index and Table join procedures #
20+
# replaced by more efficient Search and Update cursor code. #
21+
# 01-24-2012: Revised to accept GTFS or spreadsheet coding. #
22+
# NRF 8/22/17: Updates new future coding TOD field. #
23+
###############################################################################
2424

2525

2626
# ---------------------------------------------------------------------------
@@ -222,6 +222,7 @@
222222
b_row.HEADWAY = d_row.getValue("hdwy1")
223223
b_row.SPEED = d_row.getValue("speed1")
224224
if flag == "1": # update variables unique to future rail coding
225+
b_row.TOD = string.strip(d_row.getValue("tod1"))
225226
b_row.SCENARIO = string.strip(d_row.getValue("scen1"))
226227
b_row.ACTION = d_row.getValue("action1")
227228
b_row.NOTES = d_row.getValue("notes1")
@@ -266,18 +267,18 @@
266267
# ---------------------------------------------------------------
267268
# Cleanup files if needed
268269
# ---------------------------------------------------------------
269-
# if os.path.exists(temp_route_shp):
270-
# arcpy.Delete_management(temp_route_shp, "ShapeFile")
271-
# if os.path.exists(new_segments_dbf):
272-
# arcpy.Delete_management(new_segments_dbf, "DbaseTable")
273-
# if os.path.exists(rte_updt):
274-
# arcpy.Delete_management(rte_updt, "DbaseTable")
275-
# if os.path.exists(test):
276-
# arcpy.Delete_management(test)
277-
# if os.path.exists(outFl):
278-
# os.remove(outFl)
279-
# if os.path.exists(infl):
280-
# os.remove(infl)
281-
# if os.path.exists(outRtFl):
282-
# os.remove(outRtFl)
270+
if os.path.exists(temp_route_shp):
271+
arcpy.Delete_management(temp_route_shp, "ShapeFile")
272+
if os.path.exists(new_segments_dbf):
273+
arcpy.Delete_management(new_segments_dbf, "DbaseTable")
274+
if os.path.exists(rte_updt):
275+
arcpy.Delete_management(rte_updt, "DbaseTable")
276+
if os.path.exists(test):
277+
arcpy.Delete_management(test)
278+
if os.path.exists(outFl):
279+
os.remove(outFl)
280+
if os.path.exists(infl):
281+
os.remove(infl)
282+
if os.path.exists(outRtFl):
283+
os.remove(outRtFl)
283284

read_rail_spreadsheet_Apr2012.sas

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
1+
/*
2+
Revisions
3+
---------
4+
NRF 8/29/17: Reads updated future coding that includes new TOD field.
5+
*/
26

37
options noxwait;
48

@@ -35,7 +39,16 @@ filename out4 "&dir.\import\link_dictionary.txt";
3539

3640

3741
** READ IN ROUTE TABLE CODING **;
38-
proc import out=rte datafile="&rtefile" dbms=xls replace; sheet="header"; getnames=yes;
42+
proc import out=rte datafile="&rtefile" dbms=xls replace;
43+
sheet="header";
44+
getnames=yes;
45+
run;
46+
data rte(drop=tod rename=(tod2=tod));
47+
set rte;
48+
length tod2 $10.;
49+
tod2=tod;
50+
run;
51+
3952
data rte(drop=i); set rte(where=(tr_line is not null & action>=1));
4053
tr_line=lowcase(tr_line);
4154
description=upcase(compress(description,"'")); len=min(20,length(description)); description=substr(description,1,len);
@@ -54,7 +67,7 @@ data section(drop=layover i); set section(where=(tr_line is not null & order=int
5467
do i=1 to dim(zero);
5568
if zero(i)=. then zero(i)=0;
5669
end;
57-
if dw_code=0 then dw_time=0.01; else dw_time=0;
70+
if dw_code=1 then dw_time=0; else dw_time=0.01;
5871
trv_time=round(trv_time,.1);
5972
group=lag(tr_line);
6073
if layover>0 then lo=put(layover,8.0); else lo='';
@@ -95,7 +108,7 @@ data ver7; set verify(where=(action=7 & lo=''));
95108
proc print; title 'NO CONSOLIDATED STATION CODED FOR ACTION=7';
96109

97110
*** VERIFY SCENARIO IS CODED ***;
98-
data check; set rte(where=(scenario=0));
111+
data check; set rte(where=(scenario=''));
99112
proc print; title 'BAD SCENARIO CODING';
100113

101114
*** VERIFY ONLY ONE MODE IS CODED ***;
@@ -216,7 +229,7 @@ data temp; set sect2 nobs=totobs; call symput('tothold',left(put(totobs,8.))); r
216229
data sect2(rename=(order=it_order)); set sect2;
217230
data section(drop=tr_line); set sect1 sect2 sect4; length ln $8.; ln=tr_line;
218231
data section(rename=(ln=tr_line lo=layover)); set section; proc sort; by tr_line;
219-
data rte(drop=tr_line scenario mode); set rte; length ln scen $8. m $1.; ln=tr_line; scen=put(scenario,8.0); m=substr(mode,1,1);
232+
data rte(drop=tr_line scenario mode); set rte; length ln scen $8. m $1.; ln=tr_line; scen=put(scenario,8.0); m=substr(mode,1,1);
220233
data rte(rename=(ln=tr_line scen=scenario m=mode)); set rte;
221234

222235

0 commit comments

Comments
 (0)