Commit 3835f60ea663f8960f274b14e6f01aa0bf0d5cf6
1 parent
cd21cb1e
Exists in
master
Add the python functions from Dr. Barret,
after some PEP conformance cleanup.
Showing
2 changed files
with
100 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,99 @@ |
1 | +import numpy as np | |
2 | + | |
3 | + | |
4 | +def correct_gcd_from_icao(d): | |
5 | + if d <= 550.: | |
6 | + return d + 50. | |
7 | + elif 550. < d < 5500.: | |
8 | + return d + 100. | |
9 | + elif d >= 5500.: | |
10 | + return d + 125. | |
11 | + | |
12 | + | |
13 | +def db_def_seat_class_coeff_from_defra(category="economy"): | |
14 | + seat_coeff_defra = [0.073195, 0.11711, 0.21226, 0.29276] | |
15 | + seat_category = ["economy", "premium ", "business ", "first"] | |
16 | + assert category in seat_category | |
17 | + | |
18 | + if category.lower() == "economy": | |
19 | + return 1. | |
20 | + elif category.lower() == "premium": | |
21 | + return seat_coeff_defra[1] / seat_coeff_defra[0] | |
22 | + elif category.lower() == "business": | |
23 | + return seat_coeff_defra[2] / seat_coeff_defra[0] | |
24 | + elif category.lower() == "first": | |
25 | + return seat_coeff_defra[3] / seat_coeff_defra[0] | |
26 | + | |
27 | + | |
28 | +def db_direct_emission(method, dist_min, x): | |
29 | + if x < dist_min: | |
30 | + return 0. | |
31 | + | |
32 | + # x is the GCD I calculate | |
33 | + if method == "ICAO": | |
34 | + if x < 1000.: | |
35 | + return 23.339 + 0.10108 * x | |
36 | + if 1000. <= x < 4000.: | |
37 | + return 70.851 + 0.050821 * x | |
38 | + if x > 4000.: | |
39 | + return 121.08 + 0.035461 * x | |
40 | + | |
41 | + if method == "DEFRA": | |
42 | + if x < 500.: | |
43 | + return x * 0.13483 | |
44 | + if 500. <= x < 3700.: | |
45 | + return x * 0.08233 | |
46 | + if x >= 3700.: | |
47 | + return x * 0.5 * (0.0792 + 0.073195) | |
48 | + | |
49 | + if method == "ATMOSFAIR": | |
50 | + x += 50. | |
51 | + if x < 1000.: | |
52 | + return 25.922 + 0.079107 * x | |
53 | + if 1000. <= x < 4000.: | |
54 | + return 35.041 + 0.066183 * x | |
55 | + if x > 4000.: | |
56 | + return (-80.835) + 0.095998 * x | |
57 | + | |
58 | + if method == "ADEME": | |
59 | + | |
60 | + d_corr = correct_gcd_from_icao(x) | |
61 | + | |
62 | + # This is from table 21 | |
63 | + | |
64 | + if x < 1000.: | |
65 | + coeff_emission = [117., 187, 141, 223.] | |
66 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
67 | + elif 1000. <= x < 2000.: | |
68 | + coeff_emission = [95, 254, 123, 117, 161] | |
69 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
70 | + elif 2000. <= x < 3000.: | |
71 | + coeff_emission = [91, 101, 109] | |
72 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
73 | + elif 3000. <= x < 4000.: | |
74 | + coeff_emission = [99, 99, 105] | |
75 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
76 | + elif 4000. <= x < 5000.: | |
77 | + coeff_emission = [90, 126, 153] | |
78 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
79 | + elif 5000. <= x < 6000.: | |
80 | + coeff_emission = [88, 98, 150] | |
81 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
82 | + elif 6000. <= x < 7000.: | |
83 | + coeff_emission = [82, 100] | |
84 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
85 | + elif 7000. <= x < 8000.: | |
86 | + coeff_emission = [87, 91] | |
87 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
88 | + elif 8000. <= x < 9000.: | |
89 | + coeff_emission = [87, 95] | |
90 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
91 | + elif 9000. <= x < 10000.: | |
92 | + coeff_emission = [73, 83] | |
93 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
94 | + elif 10000. <= x < 11000.: | |
95 | + coeff_emission = [95] | |
96 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | |
97 | + elif x >= 11000.: | |
98 | + coeff_emission = [94] | |
99 | + return np.mean(np.multiply(coeff_emission, d_corr / 1000.)) | ... | ... |