Commit f2b1aca2a56daab88c362317ce7f1ec34dcabbae
1 parent
d5af76e8
Exists in
master
Add the footprint function used by Didier in the prototype.
We're not using this as-is. (not while I'm breathing) But it's useful for informational purposes. Once the project is completed, this file should be safe to remove.
Showing
1 changed file
with
83 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,83 @@ |
1 | +from db_scaling_laws import * | |
2 | +import numpy as np | |
3 | +from geopy.distance import great_circle | |
4 | + | |
5 | + | |
6 | +# Sample function used by Didier in the prototype. | |
7 | +# We do not use this in the project right now. | |
8 | + | |
9 | + | |
10 | +def db_get_co2eq_per_city_pairs(in_methods, lat_city1, long_city1, lat_city2, | |
11 | + long_city2, rfiatmosfair, dist_min, | |
12 | + coeff_connecting_flight, all_economy, | |
13 | + seat_category_non_economy, | |
14 | + gcd_min_for_business, | |
15 | + frac_flights_in_non_economy): | |
16 | + gcd = great_circle((np.float(lat_city1), np.float(long_city1)), | |
17 | + (np.float(lat_city2), np.float(long_city2))).km | |
18 | + round_trip_distance = gcd * coeff_connecting_flight * 2. | |
19 | + verbose = True | |
20 | + co2eq = [] | |
21 | + | |
22 | + co2eq_train = 0. | |
23 | + by_train = False | |
24 | + if gcd * coeff_connecting_flight < dist_min: | |
25 | + co2eq_train = 2. * db_get_train_footprint(type_train="mixed", | |
26 | + distance=gcd * coeff_connecting_flight) | |
27 | + seat_factor = 0 | |
28 | + seat_cat = "Train seat" | |
29 | + rfi = 0. | |
30 | + eq_seat_factor = 0. | |
31 | + by_train = True | |
32 | + if verbose: | |
33 | + print "Minimum distance=", dist_min | |
34 | + print "Coeff_connecting flight=", coeff_connecting_flight | |
35 | + print "Selected rfi", rfi | |
36 | + print "GCD=", gcd | |
37 | + print "Corrected GCD=", coeff_connecting_flight * gcd | |
38 | + print "Round trip corrected distance=", 2. * coeff_connecting_flight * gcd | |
39 | + print "CO2 by train", co2eq_train | |
40 | + co2eq = np.zeros(len(in_methods)) | |
41 | + return rfi, round_trip_distance, co2eq, co2eq_train, by_train, seat_factor, eq_seat_factor, seat_cat | |
42 | + | |
43 | + seat_factor = 1. | |
44 | + seat_cat = "economy" | |
45 | + eq_seat_factor = 1. | |
46 | + | |
47 | + if all_economy: frac_flights_in_non_economy = 0. | |
48 | + if gcd * coeff_connecting_flight > gcd_min_for_business and not all_economy and not by_train: | |
49 | + seat_cat = seat_category_non_economy | |
50 | + seat_factor = db_def_seat_class_coeff_from_defra( | |
51 | + seat_category_non_economy) | |
52 | + | |
53 | + rfi = 1.9 | |
54 | + if rfiatmosfair: rfi = get_rfi_from_atmosfair(gcd) | |
55 | + for m in in_methods: | |
56 | + if verbose: | |
57 | + print "-------------------------------------------------------------------------------------------" | |
58 | + print "Method=", m | |
59 | + print "Minimum distance=", dist_min | |
60 | + print "Coeff_connecting flight=", coeff_connecting_flight | |
61 | + print "Selected rfi", rfi | |
62 | + print "GCD=", gcd | |
63 | + print "Corrected GCD=", coeff_connecting_flight * gcd | |
64 | + print "Round trip corrected distance=", 2. * coeff_connecting_flight * gcd | |
65 | + print "CO2eq per leg without RFI=", db_direct_emission(m, dist_min, | |
66 | + coeff_connecting_flight * gcd) | |
67 | + print "CO2eq=", rfi * 2. * db_direct_emission(m, dist_min, | |
68 | + coeff_connecting_flight * gcd) | |
69 | + print "CO2 by train", co2eq_train | |
70 | + print "Fraction of flights in non economy seating (%)=", frac_flights_in_non_economy | |
71 | + print "Business correction factor=", seat_factor | |
72 | + eq_seat_factor = ( | |
73 | + frac_flights_in_non_economy / 100. * seat_factor + ( | |
74 | + 1. - frac_flights_in_non_economy / 100.)) | |
75 | + print "Equivalent seat factor=", eq_seat_factor | |
76 | + print "Seat catagory=", seat_cat | |
77 | + print "CO2eq after correcting for non economy seating=", eq_seat_factor * rfi * 2. * db_direct_emission( | |
78 | + m, dist_min, coeff_connecting_flight * gcd) | |
79 | + co2eq.append( | |
80 | + eq_seat_factor * rfi * 2. * db_direct_emission(m, dist_min, | |
81 | + coeff_connecting_flight * gcd)) | |
82 | + | |
83 | + return rfi, round_trip_distance, co2eq, co2eq_train, by_train, seat_factor, eq_seat_factor, seat_cat | ... | ... |