Skip to content

Commit b1eb690

Browse files
committed
updating test dataset
1 parent 66cd1bc commit b1eb690

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

ssim/ssim_old.py

+39-39
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
'(?P<aircraft_type_3_letter>\w{3})'
5454
'\s'
5555
'(?P<origin_of_flight>[A-Z]{3})'
56-
'(?P<scheduled_time_of_arrival_utc>\d{4})'
56+
'(?P<scheduled_time_of_arrival_utc_utc>\d{4})'
5757
'\s'
58-
'(?P<scheduled_time_of_departure_utc>\d{4})'
58+
'(?P<scheduled_time_of_departure_utc_utc>\d{4})'
5959
'(?P<overnight_indicator>[0-6])*'
6060
'(?P<destination_of_flight>[A-Z]{3})'
6161
'\s'
@@ -82,7 +82,7 @@
8282
'(?P<seat_number>\d{3})'
8383
'(?P<aircraft_type_3_letter>\w{3})'
8484
'\s'
85-
'(?P<scheduled_time_of_departure_utc>\d{4})'
85+
'(?P<scheduled_time_of_departure_utc_utc>\d{4})'
8686
'(?P<destination_of_flight>[A-Z]{3})'
8787
'\s'
8888
'(?P<type_of_flight>[A-Z])'
@@ -106,7 +106,7 @@
106106
'(?P<aircraft_type_3_letter>\w{3})'
107107
'\s'
108108
'(?P<origin_of_flight>[A-Z]{3})'
109-
'(?P<scheduled_time_of_arrival_utc>\d{4})'
109+
'(?P<scheduled_time_of_arrival_utc_utc>\d{4})'
110110
'\s'
111111
'(?P<type_of_flight>[A-Z])'
112112
'(?P<frequency_rate>\d){0,1}'
@@ -130,7 +130,7 @@
130130
'\s'
131131
'(?P<previous_stop_of_flight>[A-Z0-9]{3})'
132132
'(?P<origin_of_flight>[A-Z0-9]{3})'
133-
'(?P<scheduled_time_of_arrival_utc>\d{4}){0,1}'
133+
'(?P<scheduled_time_of_arrival_utc_utc>\d{4}){0,1}'
134134
'\s'
135135
'(?P<type_of_flight>[A-Z])'
136136
'(?P<frequency_rate>\d){0,1}'
@@ -152,7 +152,7 @@
152152
'(?P<seat_number>\d{3}){0,1}'
153153
'(?P<aircraft_type_3_letter>\w{3})'
154154
'\s'
155-
'(?P<scheduled_time_of_departure_utc>\d{4}){0,1}'
155+
'(?P<scheduled_time_of_departure_utc_utc>\d{4}){0,1}'
156156
'(?P<next_stop_of_flight>[A-Z0-9]{3})'
157157
'(?P<destination_of_flight>[A-Z0-9]{3})'
158158
'\s'
@@ -173,12 +173,12 @@
173173
'(?P<end_date_of_operation>[0-9]{2}[A-Z]{3}[0-9]{2}|\s{5})'
174174
'(?P<days_of_operation>[0-9 ]{8})'
175175
'(?P<origin_of_flight>[A-Z]{3})'
176-
'(?P<scheduled_time_of_departure_local>\d{4})'
177-
'(?P<scheduled_time_of_departure_utc>\d{4})[+-]\d{4}'
176+
'(?P<scheduled_time_of_departure_utc_local>\d{4})'
177+
'(?P<scheduled_time_of_departure_utc_utc>\d{4})[+-]\d{4}'
178178
'(?P<some_code_3>\w|\s)\s'
179179
'(?P<destination_of_flight>[A-Z]{3})'
180-
'(?P<scheduled_time_of_arrival_local>\d{4})'
181-
'(?P<scheduled_time_of_arrival_utc>\d{4})[+-]\d{4}'
180+
'(?P<scheduled_time_of_arrival_utc_local>\d{4})'
181+
'(?P<scheduled_time_of_arrival_utc_utc>\d{4})[+-]\d{4}'
182182
'(?P<some_code_4>\w|\s)\s'
183183
'(?P<aircraft_type_3_letter>\w{3})[A-Z ]'
184184
'\s{52}'
@@ -332,28 +332,28 @@ def _fix_bad_midnight(row):
332332
:return row: dict, describing a slot.
333333
"""
334334
#for SIR
335-
if 'scheduled_time_of_arrival_utc' in row:
336-
if row['scheduled_time_of_arrival_utc'] == '2400':
337-
row = _update_dict(row, {'scheduled_time_of_arrival_utc': '0000'})
335+
if 'scheduled_time_of_arrival_utc_utc' in row:
336+
if row['scheduled_time_of_arrival_utc_utc'] == '2400':
337+
row = _update_dict(row, {'scheduled_time_of_arrival_utc_utc': '0000'})
338338

339339
logging.warning('Slot with invalid time notation. Adjusting time to 0000.\n(%s)' % row)
340340

341-
if 'scheduled_time_of_departure_utc' in row:
342-
if row['scheduled_time_of_departure_utc'] == '2400':
343-
row = _update_dict(row, {'scheduled_time_of_departure_utc': '0000'})
341+
if 'scheduled_time_of_departure_utc_utc' in row:
342+
if row['scheduled_time_of_departure_utc_utc'] == '2400':
343+
row = _update_dict(row, {'scheduled_time_of_departure_utc_utc': '0000'})
344344

345345
logging.warning('Slot with invalid time notation. Adjusting time to 0000.\n(%s)' % row)
346346

347347
#for SSIM
348-
if 'scheduled_time_of_arrival_local' in row:
349-
if row['scheduled_time_of_arrival_utc'] == '2400':
350-
row = _update_dict(row, {'scheduled_time_of_arrival_utc': '0000'})
348+
if 'scheduled_time_of_arrival_utc_local' in row:
349+
if row['scheduled_time_of_arrival_utc_utc'] == '2400':
350+
row = _update_dict(row, {'scheduled_time_of_arrival_utc_utc': '0000'})
351351

352352
logging.warning('Slot with invalid time notation. Adjusting time to 0000.\n(%s)' % row)
353353

354-
if 'scheduled_time_of_departure_local' in row:
355-
if row['scheduled_time_of_departure_utc'] == '2400':
356-
row = _update_dict(row, {'scheduled_time_of_departure_utc': '0000'})
354+
if 'scheduled_time_of_departure_utc_local' in row:
355+
if row['scheduled_time_of_departure_utc_utc'] == '2400':
356+
row = _update_dict(row, {'scheduled_time_of_departure_utc_utc': '0000'})
357357

358358
logging.warning('Slot with invalid time notation. Adjusting time to 0000.\n(%s)' % row)
359359

@@ -514,7 +514,7 @@ def _expand_slot(slot):
514514
# Expand ssim legs
515515
flight_leg_slot_fields = {'action_code', 'flight_prefix', 'flight_suffix', 'aircraft_type_3_letter',
516516
'type_of_flight', 'origin_of_flight', 'seat_number', 'additional_information', 'raw',
517-
'scheduled_time_of_departure_local', 'scheduled_time_of_arrival_local', 'destination_of_flight',
517+
'scheduled_time_of_departure_utc_local', 'scheduled_time_of_arrival_utc_local', 'destination_of_flight',
518518
'connecting_flight_prefix','connecting_flight_suffix','frequency_rate'}
519519

520520
if flight_leg_slot_fields <= set(slot):
@@ -535,16 +535,16 @@ def _expand_slot(slot):
535535
}
536536

537537
#determine flight times
538-
if slot['scheduled_time_of_arrival_utc'] is not None:
538+
if slot['scheduled_time_of_arrival_utc_utc'] is not None:
539539
departure_start_date = \
540-
datetime.strptime(slot['start_date_of_operation'] + slot['scheduled_time_of_departure_utc'],
540+
datetime.strptime(slot['start_date_of_operation'] + slot['scheduled_time_of_departure_utc_utc'],
541541
'%Y-%m-%d%H%M')
542542
departure_end_date = \
543-
datetime.strptime(slot['end_date_of_operation'] + slot['scheduled_time_of_departure_utc'], '%Y-%m-%d%H%M')
543+
datetime.strptime(slot['end_date_of_operation'] + slot['scheduled_time_of_departure_utc_utc'], '%Y-%m-%d%H%M')
544544

545545
#determine flight time
546-
departure_time = datetime.strptime(slot['scheduled_time_of_departure_utc'],'%H%M')
547-
arrival_time = datetime.strptime(slot['scheduled_time_of_arrival_utc'],'%H%M')
546+
departure_time = datetime.strptime(slot['scheduled_time_of_departure_utc_utc'],'%H%M')
547+
arrival_time = datetime.strptime(slot['scheduled_time_of_arrival_utc_utc'],'%H%M')
548548
flight_leg_slot['flight_time_seconds'] = (arrival_time - departure_time).seconds #if we take seconds, overnight flights will also get correct flight time because the -1 day gets removed
549549

550550
if slot['frequency_rate']:
@@ -553,7 +553,7 @@ def _expand_slot(slot):
553553
else:
554554
dates = rrule(freq=WEEKLY, dtstart=departure_start_date, until=departure_end_date, byweekday=weekdays)
555555

556-
if slot['scheduled_time_of_departure_utc'] is not None:
556+
if slot['scheduled_time_of_departure_utc_utc'] is not None:
557557
flight_leg_slot['flight_datetime'] = [x.strftime('%Y-%m-%d %H:%M') for x in dates]
558558
else:
559559
flight_leg_slot['flight_datetime'] = [x.strftime('%Y-%m-%d') for x in dates]
@@ -582,12 +582,12 @@ def _expand_slot(slot):
582582
'raw': slot['raw']
583583
}
584584

585-
if slot['scheduled_time_of_arrival_utc'] is not None:
585+
if slot['scheduled_time_of_arrival_utc_utc'] is not None:
586586
arrival_start_date = \
587-
datetime.strptime(slot['start_date_of_operation'] + slot['scheduled_time_of_arrival_utc'],
587+
datetime.strptime(slot['start_date_of_operation'] + slot['scheduled_time_of_arrival_utc_utc'],
588588
'%Y-%m-%d%H%M')
589589
arrival_end_date = \
590-
datetime.strptime(slot['end_date_of_operation'] + slot['scheduled_time_of_arrival_utc'], '%Y-%m-%d%H%M')
590+
datetime.strptime(slot['end_date_of_operation'] + slot['scheduled_time_of_arrival_utc_utc'], '%Y-%m-%d%H%M')
591591
else:
592592
arrival_start_date = \
593593
datetime.strptime(slot['start_date_of_operation'], '%Y-%m-%d')
@@ -600,7 +600,7 @@ def _expand_slot(slot):
600600
else:
601601
dates = rrule(freq=WEEKLY, dtstart=arrival_start_date, until=arrival_end_date, byweekday=weekdays)
602602

603-
if slot['scheduled_time_of_arrival_utc'] is not None:
603+
if slot['scheduled_time_of_arrival_utc_utc'] is not None:
604604
arrival_slot['flight_datetime'] = [x.strftime('%Y-%m-%d %H:%M') for x in dates]
605605
else:
606606
arrival_slot['flight_datetime'] = [x.strftime('%Y-%m-%d') for x in dates]
@@ -630,12 +630,12 @@ def _expand_slot(slot):
630630
else:
631631
overnight_time = relativedelta(days=0)
632632

633-
if slot['scheduled_time_of_departure_utc']:
633+
if slot['scheduled_time_of_departure_utc_utc']:
634634
departure_start_date = \
635-
datetime.strptime(slot['start_date_of_operation'] + slot['scheduled_time_of_departure_utc'],
635+
datetime.strptime(slot['start_date_of_operation'] + slot['scheduled_time_of_departure_utc_utc'],
636636
'%Y-%m-%d%H%M') + overnight_time
637637
departure_end_date = \
638-
datetime.strptime(slot['end_date_of_operation'] + slot['scheduled_time_of_departure_utc'],
638+
datetime.strptime(slot['end_date_of_operation'] + slot['scheduled_time_of_departure_utc_utc'],
639639
'%Y-%m-%d%H%M') + overnight_time
640640

641641
else:
@@ -648,7 +648,7 @@ def _expand_slot(slot):
648648
else:
649649
dates = rrule(freq=WEEKLY, dtstart=departure_start_date, until=departure_end_date, byweekday=weekdays)
650650

651-
if slot['scheduled_time_of_departure_utc'] is not None:
651+
if slot['scheduled_time_of_departure_utc_utc'] is not None:
652652
departure_slot['flight_datetime'] = [x.strftime('%Y-%m-%d %H:%M') for x in dates]
653653
else:
654654
departure_slot['flight_datetime'] = [x.strftime('%Y-%m-%d') for x in dates]
@@ -731,14 +731,14 @@ def read_csv(slotfile):
731731
flightnumber_regex = '([A-Z]{2,3}|\w{2})\s*(\d+[A-Z]*|\w+)'
732732
arrival_header = \
733733
('action_code', 'origin', 'arrival_flight_prefix', 'arrival_flight_suffix',
734-
'ad', 'scheduled_time_of_arrival_utc', 'start_date_of_operation',
734+
'ad', 'scheduled_time_of_arrival_utc_utc', 'start_date_of_operation',
735735
'end_date_of_operation', 'days_of_operation', 'previous_stop_of_flight',
736736
'origin_of_flight', 'aircraft_type_3_letter', 'type_of_flight',
737737
'frequency_rate', 'unknown_2', 'unknown_3', 'unknown_4', 'season',
738738
'additional_information', 'seat_number', 'raw')
739739
departure_header = \
740740
('action_code', 'origin', 'departure_flight_prefix', 'departure_flight_suffix',
741-
'ad', 'scheduled_time_of_departure_utc', 'start_date_of_operation',
741+
'ad', 'scheduled_time_of_departure_utc_utc', 'start_date_of_operation',
742742
'end_date_of_operation', 'days_of_operation', 'next_stop_of_flight',
743743
'destination_of_flight', 'aircraft_type_3_letter', 'type_of_flight',
744744
'frequency_rate', 'unknown_2', 'unknown_3', 'unknown_4', 'season',

test/data/sir_records.yml

+25-25
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
arrival_service_type: "J"
99
days_of_operation: "0004000"
1010
frequency_rate: null
11-
number_of_seats: "174"
11+
seats: "174"
1212
origin_station: "FEZ"
1313
period_of_operation_from: "02NOV17"
1414
period_of_operation_to: "22MAR18"
1515
previous_station: "FEZ"
1616
raw: "\nU3O125 02NOV22MAR 0004000 174320 FEZFEZ J\n/ RA.1640 /"
17-
scheduled_time_of_arrival: null
17+
scheduled_time_of_arrival_utc: null
1818
raw_data: |
1919
SIR
2020
/
@@ -37,11 +37,11 @@
3737
destination_station: "FEZ"
3838
frequency_rate: null
3939
next_station: "FEZ"
40-
number_of_seats: "174"
40+
seats: "174"
4141
period_of_operation_from: "02NOV17"
4242
period_of_operation_to: "22MAR18"
4343
raw: "\nU 3O125 02NOV22MAR 0004000 174320 FEZFEZ J\n/ RA.1640 /"
44-
scheduled_time_of_departure: null
44+
scheduled_time_of_departure_utc: null
4545
raw_data: |
4646
SIR
4747
/
@@ -64,11 +64,11 @@
6464
destination_station: "OSL"
6565
frequency_rate: null
6666
next_station: "OSL"
67-
number_of_seats: "000"
67+
seats: "000"
6868
period_of_operation_from: "21FEB18"
6969
period_of_operation_to: "21FEB18"
7070
raw: "\nH N1 21FEB 000GR4 0900OSLOSL D"
71-
scheduled_time_of_departure: "0900"
71+
scheduled_time_of_departure_utc: "0900"
7272
raw_data: |
7373
SIR
7474
/
@@ -88,13 +88,13 @@
8888
arrival_service_type: "J"
8989
days_of_operation: "0000007"
9090
frequency_rate: null
91-
number_of_seats: null
91+
seats: null
9292
origin_station: "TFS"
9393
period_of_operation_from: "19FEB18"
9494
period_of_operation_to: "05MAR18"
9595
previous_station: "TFS"
9696
raw: "\nULLX5066 19FEB05MAR 0000007 320 TFSTFS J"
97-
scheduled_time_of_arrival: null
97+
scheduled_time_of_arrival_utc: null
9898
raw_data: |
9999
SIR
100100
/
@@ -115,13 +115,13 @@
115115
arrival_service_type: "J"
116116
days_of_operation: null
117117
frequency_rate: null
118-
number_of_seats: "316"
118+
seats: "316"
119119
origin_station: "061"
120120
period_of_operation_from: "17NOV17"
121121
period_of_operation_to: "17NOV17"
122122
previous_station: "DPS"
123123
raw: "\nHKL8836 17NOV 316772 061DPS0615 J"
124-
scheduled_time_of_arrival: "0615"
124+
scheduled_time_of_arrival_utc: "0615"
125125
raw_data: |
126126
SIR
127127
/
@@ -143,11 +143,11 @@
143143
destination_station: "DPS"
144144
frequency_rate: null
145145
next_station: "061"
146-
number_of_seats: "316"
146+
seats: "316"
147147
period_of_operation_from: "17NOV17"
148148
period_of_operation_to: "17NOV17"
149149
raw: "\nH KL8836 17NOV 316772 0615061DPS J"
150-
scheduled_time_of_departure: "0615"
150+
scheduled_time_of_departure_utc: "0615"
151151
raw_data: |
152152
SIR
153153
/
@@ -167,13 +167,13 @@
167167
arrival_service_type: "D"
168168
days_of_operation: null
169169
frequency_rate: null
170-
number_of_seats: "000"
170+
seats: "000"
171171
origin_station: "ANR"
172172
period_of_operation_from: "04NOV17"
173173
period_of_operation_to: "04NOV17"
174174
previous_station: "ANR"
175175
raw: "\nH 04NOV 000D22 ANRANR1510 D"
176-
scheduled_time_of_arrival: "1510"
176+
scheduled_time_of_arrival_utc: "1510"
177177
raw_data: |
178178
SIR
179179
/
@@ -195,11 +195,11 @@
195195
destination_station: "ANR"
196196
frequency_rate: null
197197
next_station: "ANR"
198-
number_of_seats: "000"
198+
seats: "000"
199199
period_of_operation_from: "04NOV17"
200200
period_of_operation_to: "04NOV17"
201201
raw: "\nH 04NOV 000D22 1510ANRANR D"
202-
scheduled_time_of_departure: "1510"
202+
scheduled_time_of_departure_utc: "1510"
203203
raw_data: |
204204
SIR
205205
/
@@ -221,11 +221,11 @@
221221
destination_station: "DPS"
222222
frequency_rate: null
223223
next_station: "061"
224-
number_of_seats: "316"
224+
seats: "316"
225225
period_of_operation_from: "17NOV17"
226226
period_of_operation_to: "17NOV17"
227227
raw: "\nH Y88836 17NOV 316772 0615061DPS J"
228-
scheduled_time_of_departure: "0615"
228+
scheduled_time_of_departure_utc: "0615"
229229
raw_data: |
230230
SIR
231231
/
@@ -247,11 +247,11 @@
247247
destination_station: "DPS"
248248
frequency_rate: null
249249
next_station: "061"
250-
number_of_seats: "316"
250+
seats: "316"
251251
period_of_operation_from: "17NOV17"
252252
period_of_operation_to: "17NOV17"
253253
raw: "\nH 5Y123 17NOV 316772 0615061DPS J"
254-
scheduled_time_of_departure: "0615"
254+
scheduled_time_of_departure_utc: "0615"
255255
raw_data: |
256256
SIR
257257
/
@@ -271,13 +271,13 @@
271271
arrival_service_type: "D"
272272
days_of_operation: null
273273
frequency_rate: null
274-
number_of_seats: "000"
274+
seats: "000"
275275
origin_station: "FAB"
276276
period_of_operation_from: "29MAR18"
277277
period_of_operation_to: "29MAR18"
278278
previous_station: "FAB"
279279
raw: "\nH8PMSD 29MAR 000GR5 FABFAB0945 D"
280-
scheduled_time_of_arrival: 0945
280+
scheduled_time_of_arrival_utc: 0945
281281
raw_data: |
282282
SIR
283283
/
@@ -293,17 +293,17 @@
293293
aircraft_type: "CL6"
294294
days_of_operation: null
295295
departure_airline_designator: "9H"
296-
departure_flight_number: "123"
296+
departure_flight_number: "OWL"
297297
departure_operational_suffix: null
298298
departure_service_type: "D"
299299
destination_station: "OXF"
300300
frequency_rate: null
301301
next_station: "OXF"
302-
number_of_seats: "000"
302+
seats: "000"
303303
period_of_operation_from: "27MAR18"
304304
period_of_operation_to: "27MAR18"
305305
raw: "\nH 9HOWL 27MAR 000CL6 1230OXFOXF D"
306-
scheduled_time_of_departure: "1230"
306+
scheduled_time_of_departure_utc: "1230"
307307
raw_data: |
308308
SIR
309309
/

0 commit comments

Comments
 (0)