-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrt_scope.py
More file actions
92 lines (70 loc) · 3.23 KB
/
brt_scope.py
File metadata and controls
92 lines (70 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import pandas as pd
import geopandas as gpd
import rasterstats
def get_country_list():
#TODO: authoritative list of countries with known mapping to regions
return ['China','India']
def get_cities_list(country):
#TODO: use Atlas data to get list of urban areas within each country
if country == 'China': return ['Beijing','Guangzhou']
if country == 'India': return ['Delhi','Chennai']
def get_pop_growth_rate(cityname):
return 0.05 #TODO get city specific rate from Atlas
#ensure units are clearly defined (% per year?)
def get_mode_split(worldregion):
#currently just returns % of travel by car
#TODO: base on actual Compact Electrified data (or other source?)
return {'China':0.5, 'India':0.2}[worldregion]
def get_pop_density(cityname):
return 10000 #TODO: add pop density list from atlas by city
class BRTProject:
def __init__(self, countryname, cityname, start_year):
#things that have to be supplied by Sofnux
self.worldregion = countryname #TODO: map country names to regions
self.city_name = cityname
self.start_year = start_year
#things that we can prepopulate with defaults
self.pop_growth_rate = get_pop_growth_rate(cityname)
self.working_days = 260 #TODO -- provide user input option??
self.city_modesplit = get_mode_split(self.worldregion)
self.pop_density = get_pop_density(cityname)
self.occupancy = 1.2 #TODO -- add df of all occupancy rates
def set_pnt_length(self, length_km):
self.pnt = length_km * 1.6 * self.pop_density
self.trip_length = self.length_km
def set_pnt_geo(self, lines):
#TODO: write fxn to calculate avg pop density within buffer area -> PNT
pass
def set_ops_characteristics(self, fleetsize, speed):
self.fleetsize = fleetsize
self.speed = speed
self.trip_length = self.length_km
self.frequency = fleetsize * speed / self.length_km * 2
#RIDERSHIP OPTION 1 ONLY
def calc_ridership_1(self):
self.trip_length = self.length_km
self.ridership = self.frequency * 100 + self.pnt * 0.01
#RIDERSHIP OPTION 2 ONLY
def set_ridership_params(self, current_ridership, brtscore):
self.current_ridership = current_ridership
self.brtscore = brtscore
#RIDERSHIP OPTION 2 ONLY
def calc_ridership_2(self):
self.ridership = self.current_ridership * 20 + self.brtscore * 500 + 350
#OPTIONAL
def set_custom_citylevel_modesplit(self, custom_mode_split):
self.city_modesplit = custom_mode_split
def calc_modal_shift_default(self):
self.modeshift = self.city_modesplit * 0.5
#TODO replace with actual split-to-shift relationship
def set_custom_modal_shift(self, custom_modeshift):
pass
def set_custom_trip_length(self, custom_trip_length):
self.trip_length = custom_trip_length
def get_default_emissions_factors(self):
self.emissions_per_vkt = 0.3
def get_impact(self):
impact = self.ridership * self.trip_length / self.occupancy * self.modeshift * self.emissions_per_vkt
self.impact = impact
return impact
#TODO: unit conversion