flight 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/features/flight_committees.feature +224 -147
- data/features/flight_emissions.feature +3 -4
- data/lib/flight/carbon_model.rb +85 -54
- data/lib/flight/data.rb +1 -3
- metadata +47 -47
@@ -3,13 +3,13 @@ Feature: Flight Committee Calculations
|
|
3
3
|
|
4
4
|
Scenario: Cohort committee from t100 with usable characteristics
|
5
5
|
Given a flight emitter
|
6
|
-
And a characteristic "origin_airport.iata_code" of "
|
6
|
+
And a characteristic "origin_airport.iata_code" of "AIA"
|
7
7
|
When the "cohort" committee is calculated
|
8
|
-
Then the conclusion of the committee should have a record with "count" equal to "
|
8
|
+
Then the conclusion of the committee should have a record with "count" equal to "1"
|
9
9
|
|
10
10
|
Scenario: Cohort committee from t100 with no usable characteristics
|
11
11
|
Given a flight emitter
|
12
|
-
And a characteristic "
|
12
|
+
And a characteristic "origin_airport.iata_code" of "XXX"
|
13
13
|
When the "cohort" committee is calculated
|
14
14
|
Then the conclusion of the committee should be nil
|
15
15
|
|
@@ -18,19 +18,16 @@ Feature: Flight Committee Calculations
|
|
18
18
|
And a characteristic "timeframe" of "<timeframe>"
|
19
19
|
When the "date" committee is calculated
|
20
20
|
Then the committee should have used quorum "from timeframe"
|
21
|
-
And the conclusion of the committee should be "<
|
21
|
+
And the conclusion of the committee should be "<date>"
|
22
22
|
Examples:
|
23
|
-
| timeframe |
|
23
|
+
| timeframe | date |
|
24
24
|
| 2010-07-15/2010-07-20 | 2010-07-15 |
|
25
25
|
|
26
|
-
Scenario
|
26
|
+
Scenario: Date committee from nil timeframe
|
27
27
|
Given a flight emitter
|
28
|
-
And a characteristic "timeframe" of "
|
28
|
+
And a characteristic "timeframe" of ""
|
29
29
|
When the "date" committee is calculated
|
30
|
-
Then the conclusion of the committee should be
|
31
|
-
Examples:
|
32
|
-
| timeframe | from |
|
33
|
-
| | |
|
30
|
+
Then the conclusion of the committee should be nil
|
34
31
|
|
35
32
|
Scenario Outline: Date committee from creation date
|
36
33
|
Given a flight emitter
|
@@ -50,9 +47,7 @@ Feature: Flight Committee Calculations
|
|
50
47
|
And the conclusion of the committee should be "<multiplier>"
|
51
48
|
Examples:
|
52
49
|
| seat_class | multiplier |
|
53
|
-
|
|
54
|
-
| economy | 0.94 |
|
55
|
-
| first | 1.47 |
|
50
|
+
| economy | 1.00 |
|
56
51
|
|
57
52
|
Scenario: Seat class multiplier committee from default
|
58
53
|
Given a flight emitter
|
@@ -60,193 +55,275 @@ Feature: Flight Committee Calculations
|
|
60
55
|
Then the committee should have used quorum "default"
|
61
56
|
And the conclusion of the committee should be "1.0"
|
62
57
|
|
63
|
-
Scenario
|
58
|
+
Scenario: Trips committee
|
64
59
|
Given a flight emitter
|
65
|
-
|
66
|
-
|
67
|
-
Then the committee should have used quorum "from airline"
|
68
|
-
And the conclusion of the committee should have a record with "name" equal to "<domesticity>"
|
69
|
-
Examples:
|
70
|
-
| airline | domesticity |
|
71
|
-
| Midwest Aviation | Domestic Data, US Carriers Only |
|
60
|
+
When the "trips" committee is calculated
|
61
|
+
Then the conclusion of the committee should be "1.941"
|
72
62
|
|
73
|
-
Scenario Outline:
|
63
|
+
Scenario Outline: Freight share committee from cohort
|
74
64
|
Given a flight emitter
|
75
|
-
And a characteristic "
|
76
|
-
When the "
|
77
|
-
|
65
|
+
And a characteristic "origin_airport.iata_code" of "<origin>"
|
66
|
+
When the "cohort" committee is calculated
|
67
|
+
And the "freight_share" committee is calculated
|
68
|
+
Then the committee should have used quorum "from cohort"
|
69
|
+
And the conclusion of the committee should be "<freight share>"
|
78
70
|
Examples:
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
| origin | freight share |
|
72
|
+
| ADA | 0.0099 |
|
73
|
+
| AIA | 0.09091 |
|
82
74
|
|
83
|
-
Scenario
|
75
|
+
Scenario: Freight share committee from default
|
84
76
|
Given a flight emitter
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
And the conclusion of the committee should have a record with "name" equal to "<domesticity>"
|
89
|
-
Examples:
|
90
|
-
| iata_code | domesticity |
|
91
|
-
| ALO | Domestic Data, US Carriers Only |
|
92
|
-
| TXK | Domestic Data, US Carriers Only |
|
77
|
+
When the "freight_share" committee is calculated
|
78
|
+
Then the committee should have used quorum "default"
|
79
|
+
And the conclusion of the committee should be "0.06391"
|
93
80
|
|
94
|
-
Scenario
|
81
|
+
Scenario: Fuel type committee from default
|
95
82
|
Given a flight emitter
|
96
|
-
|
97
|
-
|
98
|
-
Then the conclusion of the committee should be nil
|
99
|
-
Examples:
|
100
|
-
| iata_code |
|
101
|
-
| DTW |
|
102
|
-
| IAD |
|
103
|
-
| GRR |
|
83
|
+
When the "fuel_type" committee is calculated
|
84
|
+
Then the conclusion of the committee should have a record with "emission_factor" equal to "2.52714"
|
104
85
|
|
105
|
-
Scenario
|
86
|
+
Scenario: Emission factor committee
|
106
87
|
Given a flight emitter
|
107
|
-
|
108
|
-
|
109
|
-
Then the
|
110
|
-
And the conclusion of the committee should have a record with "name" equal to "<domesticity>"
|
111
|
-
Examples:
|
112
|
-
| iata_code | domesticity |
|
113
|
-
| ALO | Domestic Data, US Carriers Only |
|
114
|
-
| TXK | Domestic Data, US Carriers Only |
|
88
|
+
When the "fuel_type" committee is calculated
|
89
|
+
And the "emission_factor" committee is calculated
|
90
|
+
Then the conclusion of the committee should be "3.1293"
|
115
91
|
|
116
|
-
Scenario
|
92
|
+
Scenario: Radiative forcing index committee
|
117
93
|
Given a flight emitter
|
118
|
-
|
119
|
-
|
120
|
-
Then the conclusion of the committee should be
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
94
|
+
When the "fuel_type" committee is calculated
|
95
|
+
And the "radiative_forcing_index" committee is calculated
|
96
|
+
Then the conclusion of the committee should be "2"
|
97
|
+
|
98
|
+
Scenario: Emplanements per trip committee from default
|
99
|
+
Given a flight emitter
|
100
|
+
When the "emplanements_per_trip" committee is calculated
|
101
|
+
Then the conclusion of the committee should be "1.67"
|
126
102
|
|
127
|
-
Scenario Outline:
|
103
|
+
Scenario Outline: Distance committee from airports
|
128
104
|
Given a flight emitter
|
129
105
|
And a characteristic "origin_airport.iata_code" of "<origin>"
|
130
106
|
And a characteristic "destination_airport.iata_code" of "<destination>"
|
131
|
-
When the "
|
132
|
-
Then the committee should have used quorum "from
|
133
|
-
And the conclusion of the committee should
|
107
|
+
When the "distance" committee is calculated
|
108
|
+
Then the committee should have used quorum "from airports"
|
109
|
+
And the conclusion of the committee should be "<distance>"
|
134
110
|
Examples:
|
135
|
-
| origin | destination |
|
136
|
-
|
|
111
|
+
| origin | destination | distance |
|
112
|
+
| ADA | AIA | 100.0 |
|
113
|
+
| AIA | WEA | 1000.0 |
|
137
114
|
|
138
|
-
Scenario Outline:
|
115
|
+
Scenario Outline: Distance committee from distance estimate
|
139
116
|
Given a flight emitter
|
140
|
-
And a characteristic "
|
141
|
-
|
142
|
-
|
143
|
-
|
117
|
+
And a characteristic "distance_estimate" of "<distance_estimate>"
|
118
|
+
When the "distance" committee is calculated
|
119
|
+
Then the committee should have used quorum "from distance estimate"
|
120
|
+
And the conclusion of the committee should be "<distance>"
|
144
121
|
Examples:
|
145
|
-
|
|
146
|
-
|
|
122
|
+
| distance_estimate | distance |
|
123
|
+
| 185.2 | 100.0 |
|
147
124
|
|
148
|
-
Scenario:
|
125
|
+
Scenario Outline: Distance committee from distance class
|
149
126
|
Given a flight emitter
|
150
|
-
|
151
|
-
|
127
|
+
And a characteristic "distance_class.name" of "<distance_class>"
|
128
|
+
When the "distance" committee is calculated
|
129
|
+
Then the committee should have used quorum "from distance class"
|
130
|
+
And the conclusion of the committee should be "<distance>"
|
131
|
+
Examples:
|
132
|
+
| distance_class | distance |
|
133
|
+
| petite | 100.0 |
|
152
134
|
|
153
|
-
Scenario:
|
135
|
+
Scenario Outline: Distance committee from cohort
|
154
136
|
Given a flight emitter
|
155
|
-
And a characteristic "
|
137
|
+
And a characteristic "airline.iata_code" of "<airline>"
|
156
138
|
When the "cohort" committee is calculated
|
157
|
-
And the "
|
139
|
+
And the "distance" committee is calculated
|
158
140
|
Then the committee should have used quorum "from cohort"
|
159
|
-
And the conclusion of the committee should be "
|
141
|
+
And the conclusion of the committee should be "<distance>"
|
142
|
+
Examples:
|
143
|
+
| airline | distance |
|
144
|
+
| DA | 100.0 |
|
145
|
+
| IA | 1000.0 |
|
160
146
|
|
161
|
-
Scenario:
|
147
|
+
Scenario: Distance committee from default
|
162
148
|
Given a flight emitter
|
163
|
-
When the "
|
164
|
-
Then the
|
149
|
+
When the "distance" committee is calculated
|
150
|
+
Then the committee should have used quorum "default"
|
151
|
+
And the conclusion of the committee should be "1121.73083"
|
165
152
|
|
166
|
-
Scenario Outline:
|
153
|
+
Scenario Outline: Adjusted distance committee
|
167
154
|
Given a flight emitter
|
168
|
-
And
|
155
|
+
And a characteristic "distance_estimate" of "<distance_estimate>"
|
156
|
+
When the "distance" committee is calculated
|
157
|
+
And the "emplanements_per_trip" committee is calculated
|
158
|
+
And the "adjusted_distance" committee is calculated
|
159
|
+
Then the conclusion of the committee should be "<distance>"
|
160
|
+
Examples:
|
161
|
+
| distance_estimate | distance |
|
162
|
+
| 0 | 0 |
|
163
|
+
| 100 | 67.09227 |
|
169
164
|
|
170
|
-
Scenario Outline:
|
165
|
+
Scenario Outline: Load factor committee from cohort
|
171
166
|
Given a flight emitter
|
172
|
-
And
|
167
|
+
And a characteristic "origin_airport.iata_code" of "<origin>"
|
168
|
+
When the "cohort" committee is calculated
|
169
|
+
And the "load_factor" committee is calculated
|
170
|
+
Then the committee should have used quorum "from cohort"
|
171
|
+
And the conclusion of the committee should be "<load_factor>"
|
172
|
+
Examples:
|
173
|
+
| origin | load_factor |
|
174
|
+
| ADA | 0.8 |
|
173
175
|
|
174
|
-
Scenario
|
176
|
+
Scenario: Load factor committee from default
|
175
177
|
Given a flight emitter
|
176
|
-
|
178
|
+
When the "load_factor" committee is calculated
|
179
|
+
Then the committee should have used quorum "default"
|
180
|
+
And the conclusion of the committee should be "0.86667"
|
177
181
|
|
178
|
-
Scenario:
|
182
|
+
Scenario Outline: Seats committee from aircraft
|
179
183
|
Given a flight emitter
|
180
|
-
|
181
|
-
|
184
|
+
And a characteristic "aircraft.icao_code" of "<code>"
|
185
|
+
When the "seats" committee is calculated
|
186
|
+
Then the committee should have used quorum "from aircraft"
|
187
|
+
And the conclusion of the committee should be "<seats>"
|
188
|
+
Examples:
|
189
|
+
| code | seats |
|
190
|
+
| FM1 | 125 |
|
191
|
+
| BA1 | 125 |
|
192
|
+
| BA2 | 100 |
|
182
193
|
|
183
|
-
Scenario:
|
194
|
+
Scenario: Seats committee from seats estimate
|
184
195
|
Given a flight emitter
|
185
|
-
|
186
|
-
|
187
|
-
|
196
|
+
And a characteristic "seats_estimate" of "100"
|
197
|
+
When the "seats" committee is calculated
|
198
|
+
Then the committee should have used quorum "from seats estimate"
|
199
|
+
And the conclusion of the committee should be "100"
|
188
200
|
|
189
|
-
Scenario Outline:
|
201
|
+
Scenario Outline: Seats committee from cohort
|
190
202
|
Given a flight emitter
|
191
203
|
And a characteristic "origin_airport.iata_code" of "<origin>"
|
192
|
-
And a characteristic "destination_airport.iata_code" of "<destination>"
|
193
|
-
And a characteristic "aircraft.icao_code" of "<craft>"
|
194
|
-
And a characteristic "airline.iata_code" of "<airline>"
|
195
|
-
And a characteristic "propulsion.name" of "<propulsion>"
|
196
|
-
And a characteristic "domesticity.name" of "<domesticity>"
|
197
204
|
When the "cohort" committee is calculated
|
198
|
-
And the "
|
205
|
+
And the "seats" committee is calculated
|
199
206
|
Then the committee should have used quorum "from cohort"
|
200
|
-
And the conclusion of the committee should be "<
|
207
|
+
And the conclusion of the committee should be "<seats>"
|
201
208
|
Examples:
|
202
|
-
| origin |
|
203
|
-
|
|
209
|
+
| origin | seats |
|
210
|
+
| ADA | 125 |
|
204
211
|
|
205
|
-
Scenario
|
212
|
+
Scenario: Seats committee from aircraft class
|
206
213
|
Given a flight emitter
|
207
|
-
And a characteristic "
|
208
|
-
When the "
|
209
|
-
Then the committee should have used quorum "from
|
210
|
-
And the conclusion of the committee should be "
|
214
|
+
And a characteristic "aircraft_class.brighter_planet_aircraft_class_code" of "EX"
|
215
|
+
When the "seats" committee is calculated
|
216
|
+
Then the committee should have used quorum "from aircraft class"
|
217
|
+
And the conclusion of the committee should be "117"
|
218
|
+
|
219
|
+
Scenario: Seats committee from default
|
220
|
+
Given a flight emitter
|
221
|
+
When the "seats" committee is calculated
|
222
|
+
Then the committee should have used quorum "default"
|
223
|
+
And the conclusion of the committee should be "117"
|
224
|
+
|
225
|
+
Scenario: Passengers committee
|
226
|
+
Given a flight emitter
|
227
|
+
And a characteristic "seats" of "100"
|
228
|
+
And a characteristic "load_factor" of "0.9"
|
229
|
+
When the "passengers" committee is calculated
|
230
|
+
Then the conclusion of the committee should be "90"
|
231
|
+
|
232
|
+
Scenario Outline: Fuel use coefficients committee from aircraft
|
233
|
+
Given a flight emitter
|
234
|
+
And a characteristic "aircraft.icao_code" of "<code>"
|
235
|
+
When the "fuel_use_coefficients" committee is calculated
|
236
|
+
Then the committee should have used quorum "from aircraft"
|
237
|
+
And the conclusion of the committee should have a record with "m3" equal to "<m3>"
|
238
|
+
And the conclusion of the committee should have a record with "m2" equal to "<m2>"
|
239
|
+
And the conclusion of the committee should have a record with "m1" equal to "<m1>"
|
240
|
+
And the conclusion of the committee should have a record with "endpoint_fuel" equal to "<b>"
|
211
241
|
Examples:
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
| medium | 868.97408 |
|
216
|
-
| short | 217.24406 |
|
242
|
+
| code | m3 | m2 | m1 | b |
|
243
|
+
| FM1 | 0 | 0 | 1 | 0 |
|
244
|
+
| BA1 | 0 | 0 | 2 | 0 |
|
217
245
|
|
218
|
-
Scenario Outline:
|
246
|
+
Scenario Outline: Fuel use coefficients committee from aircraft class
|
219
247
|
Given a flight emitter
|
220
|
-
And a characteristic "
|
221
|
-
When the "
|
222
|
-
Then the committee should have used quorum "from
|
223
|
-
And the conclusion of the committee should
|
248
|
+
And a characteristic "aircraft_class.brighter_planet_aircraft_class_code" of "<code>"
|
249
|
+
When the "fuel_use_coefficients" committee is calculated
|
250
|
+
Then the committee should have used quorum "from aircraft class"
|
251
|
+
And the conclusion of the committee should have a record with "m3" equal to "<m3>"
|
252
|
+
And the conclusion of the committee should have a record with "m2" equal to "<m2>"
|
253
|
+
And the conclusion of the committee should have a record with "m1" equal to "<m1>"
|
254
|
+
And the conclusion of the committee should have a record with "endpoint_fuel" equal to "<b>"
|
224
255
|
Examples:
|
225
|
-
|
|
226
|
-
|
|
256
|
+
| code | m3 | m2 | m1 | b |
|
257
|
+
| EX | 0 | 0 | 2 | 0 |
|
227
258
|
|
228
|
-
Scenario Outline:
|
259
|
+
Scenario Outline: Fuel use coefficients committee from cohort
|
229
260
|
Given a flight emitter
|
230
261
|
And a characteristic "origin_airport.iata_code" of "<origin>"
|
231
|
-
|
232
|
-
|
233
|
-
Then the committee should have used quorum "from
|
234
|
-
And the conclusion of the committee should
|
262
|
+
When the "cohort" committee is calculated
|
263
|
+
And the "fuel_use_coefficients" committee is calculated
|
264
|
+
Then the committee should have used quorum "from cohort"
|
265
|
+
And the conclusion of the committee should have a record with "m3" equal to "<m3>"
|
266
|
+
And the conclusion of the committee should have a record with "m2" equal to "<m2>"
|
267
|
+
And the conclusion of the committee should have a record with "m1" equal to "<m1>"
|
268
|
+
And the conclusion of the committee should have a record with "endpoint_fuel" equal to "<b>"
|
235
269
|
Examples:
|
236
|
-
| origin |
|
237
|
-
|
|
238
|
-
| IAD | DCA | 20.32743 |
|
239
|
-
| MSP | FRA | 3809.26855 |
|
270
|
+
| origin | m3 | m2 | m1 | b |
|
271
|
+
| AIA | 0 | 0 | 2 | 0 |
|
240
272
|
|
241
|
-
Scenario Outline:
|
273
|
+
Scenario Outline: Fuel use coefficients committee from default
|
242
274
|
Given a flight emitter
|
243
|
-
|
244
|
-
|
245
|
-
And the "
|
246
|
-
And the "
|
247
|
-
|
275
|
+
When the "fuel_use_coefficients" committee is calculated
|
276
|
+
Then the committee should have used quorum "default"
|
277
|
+
And the conclusion of the committee should have a record with "m3" equal to "<m3>"
|
278
|
+
And the conclusion of the committee should have a record with "m2" equal to "<m2>"
|
279
|
+
And the conclusion of the committee should have a record with "m1" equal to "<m1>"
|
280
|
+
And the conclusion of the committee should have a record with "endpoint_fuel" equal to "<b>"
|
281
|
+
Examples:
|
282
|
+
| m3 | m2 | m1 | b |
|
283
|
+
| 0 | 0 | 2 | 0 |
|
284
|
+
|
285
|
+
Scenario: Adjusted distance per segment committee
|
286
|
+
Given a flight emitter
|
287
|
+
And a characteristic "adjusted_distance" of "100"
|
288
|
+
And a characteristic "emplanements_per_trip" of "2"
|
289
|
+
When the "adjusted_distance_per_segment" committee is calculated
|
290
|
+
Then the conclusion of the committee should be "50"
|
291
|
+
|
292
|
+
Scenario: Fuel per segment committee
|
293
|
+
Given a flight emitter
|
294
|
+
And a characteristic "adjusted_distance_per_segment" of "100"
|
295
|
+
And a characteristic "aircraft_class.brighter_planet_aircraft_class_code" of "EX"
|
296
|
+
When the "fuel_use_coefficients" committee is calculated
|
297
|
+
And the "fuel_per_segment" committee is calculated
|
298
|
+
Then the conclusion of the committee should be "200"
|
299
|
+
|
300
|
+
Scenario: Fuel committee
|
301
|
+
Given a flight emitter
|
302
|
+
And a characteristic "fuel_per_segment" of "100"
|
303
|
+
And a characteristic "emplanements_per_trip" of "2"
|
304
|
+
And a characteristic "trips" of "2"
|
305
|
+
When the "fuel" committee is calculated
|
306
|
+
Then the conclusion of the committee should be "400"
|
307
|
+
|
308
|
+
Scenario Outline: Emission committee from fuel and passengers and coefficients
|
309
|
+
Given a flight emitter
|
310
|
+
And a characteristic "fuel" of "<fuel>"
|
311
|
+
And a characteristic "passengers" of "<passengers>"
|
312
|
+
And a characteristic "seat_class_multiplier" of "<seat_mult>"
|
313
|
+
And a characteristic "emission_factor" of "<ef>"
|
314
|
+
And a characteristic "radiative_forcing_index" of "<rfi>"
|
315
|
+
And a characteristic "freight_share" of "<freight>"
|
316
|
+
And a characteristic "date" of "<date>"
|
317
|
+
And a characteristic "timeframe" of "2010-01-01/2010-12-31"
|
318
|
+
When the "emission" committee is calculated
|
319
|
+
Then the committee should have used quorum "from fuel and passengers with coefficients"
|
320
|
+
And the conclusion of the committee should be "<emission>"
|
248
321
|
Examples:
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
252
|
-
|
322
|
+
| fuel | passengers | seat_mult | ef | rfi | freight | date | emission |
|
323
|
+
| 100 | 100 | 1.5 | 10 | 2 | 0.10 | 2010-07-15 | 27 |
|
324
|
+
|
325
|
+
Scenario: Emission committee from default
|
326
|
+
Given a flight emitter
|
327
|
+
When the "emission" committee is calculated
|
328
|
+
Then the committee should have used quorum "default"
|
329
|
+
And the conclusion of the committee should be ""
|
@@ -1,15 +1,14 @@
|
|
1
1
|
Feature: Flight Emissions Calculations
|
2
2
|
The flight model should generate correct emission calculations
|
3
3
|
|
4
|
-
Scenario Outline: Standard Calculations for origin/destination airport, airline, and
|
4
|
+
Scenario Outline: Standard Calculations for origin/destination airport, airline, and aircraft
|
5
5
|
Given a flight has "origin_airport.iata_code" of "<source>"
|
6
6
|
And it has "destination_airport.iata_code" of "<dest>"
|
7
7
|
And it has "airline.iata_code" of "<airline>"
|
8
8
|
And it has "date" of "<date>"
|
9
|
-
And it used "aircraft.
|
9
|
+
And it used "aircraft.bts_aircraft_type_code" "<aircraft>"
|
10
10
|
When emissions are calculated
|
11
11
|
Then the emission value should be within 1 kgs of <emission>
|
12
12
|
Examples:
|
13
13
|
| source | dest | airline | date | aircraft | emission |
|
14
|
-
|
|
15
|
-
| IAD | CDG | AF | 2010-06-25 | A320 | 2070 |
|
14
|
+
| DCA | JFK | AA | 2010-06-25 | 1 | 1153 |
|
data/lib/flight/carbon_model.rb
CHANGED
@@ -33,11 +33,11 @@ module BrighterPlanet
|
|
33
33
|
end
|
34
34
|
|
35
35
|
committee :fuel_per_segment do # returns kg fuel
|
36
|
-
quorum 'from adjusted distance and fuel use
|
37
|
-
characteristics[:fuel_use_coefficients]
|
38
|
-
characteristics[:fuel_use_coefficients]
|
39
|
-
characteristics[:fuel_use_coefficients]
|
40
|
-
characteristics[:
|
36
|
+
quorum 'from adjusted distance per segment and fuel use coefficients', :needs => [:adjusted_distance_per_segment, :fuel_use_coefficients] do |characteristics|
|
37
|
+
characteristics[:fuel_use_coefficients].m3.to_f * characteristics[:adjusted_distance_per_segment].to_f ** 3 +
|
38
|
+
characteristics[:fuel_use_coefficients].m2.to_f * characteristics[:adjusted_distance_per_segment].to_f ** 2 +
|
39
|
+
characteristics[:fuel_use_coefficients].m1.to_f * characteristics[:adjusted_distance_per_segment].to_f +
|
40
|
+
characteristics[:fuel_use_coefficients].endpoint_fuel.to_f
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -47,33 +47,58 @@ module BrighterPlanet
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
committee :
|
50
|
+
committee :fuel_use_coefficients do
|
51
51
|
quorum 'from aircraft', :needs => :aircraft do |characteristics|
|
52
|
-
characteristics[:aircraft]
|
52
|
+
aircraft = characteristics[:aircraft]
|
53
|
+
FuelUseEquation.new aircraft.m3, aircraft.m2, aircraft.m1, aircraft.endpoint_fuel
|
53
54
|
end
|
54
55
|
|
55
56
|
quorum 'from aircraft class', :needs => :aircraft_class do |characteristics|
|
56
|
-
characteristics[:aircraft_class]
|
57
|
-
|
58
|
-
|
59
|
-
quorum 'default' do
|
60
|
-
Aircraft.fallback.andand.endpoint_fuel
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
committee :fuel_use_coefficients do
|
65
|
-
quorum 'from aircraft', :needs => :aircraft do |characteristics|
|
66
|
-
characteristics[:aircraft].attributes.symbolize_keys.slice(:m1, :m2, :m3)
|
57
|
+
aircraft_class = characteristics[:aircraft_class]
|
58
|
+
FuelUseEquation.new aircraft_class.m3, aircraft_class.m2, aircraft_class.m1, aircraft_class.endpoint_fuel
|
67
59
|
end
|
68
60
|
|
69
|
-
quorum 'from
|
70
|
-
characteristics[:
|
61
|
+
quorum 'from cohort', :needs => :cohort do |characteristics|
|
62
|
+
flight_segments = characteristics[:cohort]
|
63
|
+
|
64
|
+
passengers = flight_segments.inject(0) do |passengers, flight_segment|
|
65
|
+
passengers + flight_segment.passengers
|
66
|
+
end
|
67
|
+
|
68
|
+
m3 = flight_segments.inject(0) do |m3, flight_segment|
|
69
|
+
aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
|
70
|
+
m3 + (aircraft.m3 * flight_segment.passengers)
|
71
|
+
end
|
72
|
+
|
73
|
+
m2 = flight_segments.inject(0) do |m2, flight_segment|
|
74
|
+
aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
|
75
|
+
m2 + (aircraft.m2 * flight_segment.passengers)
|
76
|
+
end
|
77
|
+
|
78
|
+
m1 = flight_segments.inject(0) do |m1, flight_segment|
|
79
|
+
aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
|
80
|
+
m1 + (aircraft.m1 * flight_segment.passengers)
|
81
|
+
end
|
82
|
+
|
83
|
+
endpoint_fuel = flight_segments.inject(0) do |endpoint_fuel, flight_segment|
|
84
|
+
aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
|
85
|
+
endpoint_fuel + (aircraft.endpoint_fuel * flight_segment.passengers)
|
86
|
+
end
|
87
|
+
|
88
|
+
if [m3, m2, m1, endpoint_fuel, passengers].any?(&:nonzero?)
|
89
|
+
m3 = m3 / passengers
|
90
|
+
m2 = m2 / passengers
|
91
|
+
m1 = m1 / passengers
|
92
|
+
endpoint_fuel = endpoint_fuel / passengers
|
93
|
+
|
94
|
+
FuelUseEquation.new m3, m2, m1, endpoint_fuel
|
95
|
+
end
|
71
96
|
end
|
72
97
|
|
73
98
|
quorum 'default' do
|
74
99
|
fallback = Aircraft.fallback
|
75
100
|
if fallback
|
76
|
-
fallback.
|
101
|
+
FuelUseEquation.new fallback.m3, fallback.m2, fallback.m1, fallback.endpoint_fuel
|
77
102
|
end
|
78
103
|
end
|
79
104
|
end
|
@@ -205,33 +230,35 @@ module BrighterPlanet
|
|
205
230
|
end
|
206
231
|
end
|
207
232
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
end
|
233
|
+
# Disabling this for now because domesticity is pretty useless
|
234
|
+
# FIXME TODO make domesticity non-us-centric and check that data's ok
|
235
|
+
# committee :domesticity do
|
236
|
+
# quorum 'from airports', :needs => [:origin_airport, :destination_airport] do |characteristics|
|
237
|
+
# if [characteristics[:origin_airport], characteristics[:destination_airport]].all?(&:united_states?)
|
238
|
+
# FlightDomesticity.find_by_name('domestic')
|
239
|
+
# elsif [characteristics[:origin_airport], characteristics[:destination_airport]].any?(&:united_states?)
|
240
|
+
# FlightDomesticity.find_by_name('international')
|
241
|
+
# end
|
242
|
+
# end
|
243
|
+
#
|
244
|
+
# quorum 'from origin', :needs => :origin_airport do |characteristics|
|
245
|
+
# if characteristics[:origin_airport].all_flights_from_here_domestic?
|
246
|
+
# FlightDomesticity.find_by_name('domestic')
|
247
|
+
# end
|
248
|
+
# end
|
249
|
+
#
|
250
|
+
# quorum 'from destination', :needs => :destination_airport do |characteristics|
|
251
|
+
# if characteristics[:destination_airport].all_flights_to_here_domestic?
|
252
|
+
# FlightDomesticity.find_by_name('domestic')
|
253
|
+
# end
|
254
|
+
# end
|
255
|
+
#
|
256
|
+
# quorum 'from airline', :needs => :airline do |characteristics|
|
257
|
+
# if characteristics[:airline].all_flights_domestic?
|
258
|
+
# FlightDomesticity.find_by_name('domestic')
|
259
|
+
# end
|
260
|
+
# end
|
261
|
+
# end
|
235
262
|
|
236
263
|
committee :seat_class_multiplier do
|
237
264
|
quorum 'from seat class', :needs => :seat_class do |characteristics|
|
@@ -249,16 +276,18 @@ module BrighterPlanet
|
|
249
276
|
end
|
250
277
|
|
251
278
|
quorum 'from timeframe' do |characteristics, timeframe|
|
252
|
-
timeframe.
|
279
|
+
timeframe.present? ? timeframe.from : nil
|
253
280
|
end
|
254
281
|
end
|
255
282
|
|
256
283
|
committee :cohort do
|
257
|
-
quorum 'from t100', :appreciates =>
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
284
|
+
quorum 'from t100', :appreciates => [:origin_airport, :destination_airport, :aircraft, :airline] do |characteristics|
|
285
|
+
provided_characteristics = [:origin_airport, :destination_airport, :aircraft, :airline].
|
286
|
+
inject(ActiveSupport::OrderedHash.new) do |memo, characteristic_name|
|
287
|
+
memo[characteristic_name] = characteristics[characteristic_name]
|
288
|
+
memo
|
289
|
+
end
|
290
|
+
cohort = FlightSegment.strict_cohort provided_characteristics
|
262
291
|
if cohort.any?
|
263
292
|
cohort
|
264
293
|
else
|
@@ -268,6 +297,8 @@ module BrighterPlanet
|
|
268
297
|
end
|
269
298
|
end
|
270
299
|
end
|
300
|
+
|
301
|
+
class FuelUseEquation < Struct.new(:m3, :m2, :m1, :endpoint_fuel); end
|
271
302
|
end
|
272
303
|
end
|
273
304
|
end
|
data/lib/flight/data.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 18
|
10
|
+
version: 0.0.18
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -19,31 +19,30 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-08
|
22
|
+
date: 2010-09-08 00:00:00 -05:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
type: :development
|
27
|
-
prerelease: false
|
28
26
|
name: activerecord
|
29
|
-
|
27
|
+
prerelease: false
|
28
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
30
29
|
none: false
|
31
30
|
requirements:
|
32
31
|
- - "="
|
33
32
|
- !ruby/object:Gem::Version
|
34
|
-
hash:
|
33
|
+
hash: 299253624
|
35
34
|
segments:
|
36
35
|
- 3
|
37
36
|
- 0
|
38
37
|
- 0
|
39
38
|
- beta4
|
40
39
|
version: 3.0.0.beta4
|
41
|
-
requirement: *id001
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
40
|
type: :development
|
44
|
-
|
41
|
+
version_requirements: *id001
|
42
|
+
- !ruby/object:Gem::Dependency
|
45
43
|
name: bundler
|
46
|
-
|
44
|
+
prerelease: false
|
45
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
47
46
|
none: false
|
48
47
|
requirements:
|
49
48
|
- - ">="
|
@@ -56,12 +55,12 @@ dependencies:
|
|
56
55
|
- beta
|
57
56
|
- 2
|
58
57
|
version: 1.0.0.beta.2
|
59
|
-
requirement: *id002
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
58
|
type: :development
|
62
|
-
|
59
|
+
version_requirements: *id002
|
60
|
+
- !ruby/object:Gem::Dependency
|
63
61
|
name: cucumber
|
64
|
-
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
65
64
|
none: false
|
66
65
|
requirements:
|
67
66
|
- - "="
|
@@ -72,12 +71,12 @@ dependencies:
|
|
72
71
|
- 8
|
73
72
|
- 3
|
74
73
|
version: 0.8.3
|
75
|
-
requirement: *id003
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
74
|
type: :development
|
78
|
-
|
75
|
+
version_requirements: *id003
|
76
|
+
- !ruby/object:Gem::Dependency
|
79
77
|
name: jeweler
|
80
|
-
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
81
80
|
none: false
|
82
81
|
requirements:
|
83
82
|
- - "="
|
@@ -88,12 +87,12 @@ dependencies:
|
|
88
87
|
- 4
|
89
88
|
- 0
|
90
89
|
version: 1.4.0
|
91
|
-
requirement: *id004
|
92
|
-
- !ruby/object:Gem::Dependency
|
93
90
|
type: :development
|
94
|
-
|
91
|
+
version_requirements: *id004
|
92
|
+
- !ruby/object:Gem::Dependency
|
95
93
|
name: rake
|
96
|
-
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
97
96
|
none: false
|
98
97
|
requirements:
|
99
98
|
- - ">="
|
@@ -102,12 +101,12 @@ dependencies:
|
|
102
101
|
segments:
|
103
102
|
- 0
|
104
103
|
version: "0"
|
105
|
-
requirement: *id005
|
106
|
-
- !ruby/object:Gem::Dependency
|
107
104
|
type: :development
|
108
|
-
|
105
|
+
version_requirements: *id005
|
106
|
+
- !ruby/object:Gem::Dependency
|
109
107
|
name: rdoc
|
110
|
-
|
108
|
+
prerelease: false
|
109
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
111
110
|
none: false
|
112
111
|
requirements:
|
113
112
|
- - ">="
|
@@ -116,12 +115,12 @@ dependencies:
|
|
116
115
|
segments:
|
117
116
|
- 0
|
118
117
|
version: "0"
|
119
|
-
requirement: *id006
|
120
|
-
- !ruby/object:Gem::Dependency
|
121
118
|
type: :development
|
122
|
-
|
119
|
+
version_requirements: *id006
|
120
|
+
- !ruby/object:Gem::Dependency
|
123
121
|
name: rspec
|
124
|
-
|
122
|
+
prerelease: false
|
123
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
125
124
|
none: false
|
126
125
|
requirements:
|
127
126
|
- - "="
|
@@ -134,39 +133,40 @@ dependencies:
|
|
134
133
|
- beta
|
135
134
|
- 17
|
136
135
|
version: 2.0.0.beta.17
|
137
|
-
requirement: *id007
|
138
|
-
- !ruby/object:Gem::Dependency
|
139
136
|
type: :development
|
140
|
-
|
137
|
+
version_requirements: *id007
|
138
|
+
- !ruby/object:Gem::Dependency
|
141
139
|
name: sniff
|
142
|
-
|
140
|
+
prerelease: false
|
141
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
143
142
|
none: false
|
144
143
|
requirements:
|
145
144
|
- - "="
|
146
145
|
- !ruby/object:Gem::Version
|
147
|
-
hash:
|
146
|
+
hash: 11
|
148
147
|
segments:
|
149
148
|
- 0
|
150
149
|
- 1
|
151
|
-
-
|
152
|
-
version: 0.1.
|
153
|
-
|
150
|
+
- 8
|
151
|
+
version: 0.1.8
|
152
|
+
type: :development
|
153
|
+
version_requirements: *id008
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
|
-
type: :runtime
|
156
|
-
prerelease: false
|
157
155
|
name: emitter
|
158
|
-
|
156
|
+
prerelease: false
|
157
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
159
158
|
none: false
|
160
159
|
requirements:
|
161
160
|
- - ">="
|
162
161
|
- !ruby/object:Gem::Version
|
163
|
-
hash:
|
162
|
+
hash: 23
|
164
163
|
segments:
|
165
164
|
- 0
|
166
165
|
- 0
|
167
|
-
-
|
168
|
-
version: 0.0.
|
169
|
-
|
166
|
+
- 4
|
167
|
+
version: 0.0.4
|
168
|
+
type: :runtime
|
169
|
+
version_requirements: *id009
|
170
170
|
description: A software model in Ruby for the greenhouse gas emissions of a flight
|
171
171
|
email: andy@rossmeissl.net
|
172
172
|
executables: []
|