Breakthrough-Energy / PreREISE

Generate input data for scenario framework
https://breakthrough-energy.github.io/docs/
MIT License
21 stars 28 forks source link

Calculate urban and rural annual VMT fractions #333

Closed rouille closed 1 year ago

rouille commented 1 year ago

Pull Request doc

Purpose

Calculate urban and rural Vehicle Miles Traveled (VMT) fractions. Closes #316 and #317.

What the code is doing

Testing

Existing unit tests

Where to look

New module generate_scaling_factors

Usage Example/Visuals

>>> from prereise.gather.demanddata.transportation_electrification.generate_scaling_factors import census_ua_url, census_state_url, tht_data_url, load_census_ua, load_census_state, load_dot_vmt_per_capita, calculate_vmt_for_ua, calculate_vmt_for_state, calculate_urban_rural_fraction
>>> census_ua = load_census_ua(census_ua_url)
>>> census_state = load_census_state(census_state_url)
>>> tht_ua, tht_state = load_dot_vmt_per_capita(tht_data_url)
>>> vmt_ua = calculate_vmt_for_ua(census_ua, tht_ua)
>>> vmt_state = calculate_vmt_for_state(census_state, tht_state)
>>> vmt_ua_perc, vmt_ra_perc = calculate_urban_rural_fraction(vmt_ua, vmt_state)
>>> vmt_ra_perc
{'AL': 0.5948209907004509, 'AZ': 0.4072678991599876, 'AR': 0.6782718495006606, 'CA': 0.2522036919615287, 'CO': 0.4365774632878532, 'CT': 0.18269470942707955, 'DE': 0.559915703167249, 'DC': 0, 'FL': 0.2923051798349785, 'GA': 0.42402572834199637, 'ID': 0.6723734528747444, 'IL': 0.28372082436406665, 'IN': 0.5298558463320291, 'IA': 0.7022578956589101, 'KS': 0.5763025206199697, 'KY': 0.8477578601781653, 'LA': 0.5246373942279056, 'ME': 0.7882474490409153, 'MD': 0.3333401978676642, 'MA': 0.11947580340547559, 'MI': 0.3789053832349696, 'MN': 0.5432410752038628, 'MS': 0.7266752412880431, 'MO': 0.5071803635012153, 'MT': 0.8600569689974888, 'NE': 0.6739144929625285, 'NV': 0.399831570902325, 'NH': 0.6009439272679777, 'NJ': 0.33585021596160347, 'NM': 0.6848299106793774, 'NY': 0.19194166956193792, 'NC': 0.5092809432132339, 'ND': 0.8361712780525931, 'OH': 0.40514557017474595, 'OK': 0.5972732841621138, 'OR': 0.5636801026484732, 'PA': 0.3984935379624328, 'RI': 0.05679462197338614, 'SC': 0.588343323457865, 'SD': 0.8225877011609205, 'TN': 0.5049657185947951, 'TX': 0.4028581131849771, 'UT': 0.38149202467572874, 'VT': 0.8391650467810423, 'VA': 0.4227252560298854, 'WA': 0.364071745825326, 'WV': 0.7005357353635477, 'WI': 0.6074652247653839, 'WY': 0.8867296939626887}
>>> vmt_ua_perc["AL"]
Birmingham, AL         0.144348
Florence, AL           0.011524
Mobile, AL             0.060350
Pensacola, FL-AL       0.001210
Gadsden, AL            0.013453
Auburn, AL             0.013323
Montgomery, AL         0.049128
Decatur, AL            0.006910
Anniston-Oxford, AL    0.015453
Huntsville, AL         0.045015
Tuscaloosa, AL         0.021803
Dothan, AL             0.014312
Columbus, GA-AL        0.008350
Name: Annual VMT, dtype: float64

Note

We will need to go over the data intake procedure for the input files

Time estimate

20min