├── .gitignore ├── AUTHORS.txt ├── LICENSE.txt ├── MANIFEST.in ├── README.md ├── changelog.md ├── energy-usage-report.pdf ├── energyusage ├── RAPLFile.py ├── __init__.py ├── convert.py ├── data │ ├── README.md │ ├── csv │ │ ├── egrid_emissions_2016.csv │ │ ├── egrid_resource_mix_2016.csv │ │ ├── emissions-us.csv │ │ ├── energy-mix-intl.csv │ │ └── energy-mix-us.csv │ ├── json │ │ ├── energy-mix-intl_2016.json │ │ ├── energy-mix-us_2016.json │ │ └── us-emissions_2016.json │ └── raw │ │ └── 2016 │ │ ├── egrid.xlsx │ │ └── international_data.csv ├── evaluate.py ├── graph.py ├── locate.py ├── raw_to_json.py ├── report.py ├── test.py └── utils.py ├── get-country-averages.py ├── get_top_countries.py ├── requirements.txt ├── sample.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | * Sorelle Friedler 2 | * Kadan Lottick 3 | * Silvia Susai 4 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2019 by authors list (see AUTHORS.txt) 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include energyusage *.py *.md *.txt 2 | 3 | include requirements*.* 4 | include README.* 5 | 6 | graft energyusage/data/json 7 | graft energyusage/data/csv 8 | 9 | recursive-exclude ./dist *.py *.R *.Rmd *.md *.txt 10 | recursive-exclude ./build *.py *.R *.Rmd *.md *.txt 11 | 12 | prune venv 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # See [CodeCarbon](https://codecarbon.io/) instead! 2 | We are no longer actively maintaining this project, since we have merged its functionality into another project that is being actively maintained and has more features than this one. We recommend using that project instead! 3 | 4 | # energyusage 5 | 6 | A Python package that measures the environmental impact of computation. Provides a function to 7 | evaluate the energy usage and related carbon emissions of another function. 8 | Emissions are calculated based on the user's location via the GeoJS API and that location's 9 | energy mix data (sources: US E.I.A and eGRID for the year 2016). 10 | 11 | ## Installation 12 | 13 | To install, simply `$ pip install energyusage`. 14 | 15 | ## Usage 16 | 17 | To evaluate the emissions of a function, just call `energyusage.evaluate` with the function 18 | name and the arguments it requires. Use `python3` to run your code. 19 | 20 | ```python 21 | import energyusage 22 | 23 | # user function to be evaluated 24 | def recursive_fib(n): 25 | if (n <= 2): return 1 26 | else: return recursive_fib(n-1) + recursive_fib(n-2) 27 | 28 | energyusage.evaluate(recursive_fib, 40, pdf=True) 29 | # returns 102,334,155 30 | ``` 31 | It will return the value of your function, while also printing out the energy usage report on the command line. 32 | Optional keyword arguments: 33 | * `pdf`(default = `False`): generates a PDF report, alongside the command-line utility 34 | * `powerLoss` (default = `0.8`): accounts for PSU loss, can be set by user if known for higher accuracy of results 35 | * `energyOutput` (default = `False`): prints amount of energy used by the process and time taken. The order is time, energy used, return of function 36 | * `printToScreen` (default = `True`): controls whether there is a terminal printout of the package running 37 | * `energyOutput` (default = `False`): determines whether the energy used and time taken are output. When set to true the order is `time used`, `energy used`, `return value of function`. 38 | * `locations` (default = `["Mongolia", "Iceland", "Switzerland"]`): allows selecting the countries in the emissions comparison section for the terminal printout and pdf. These can be set to the name of any country or US state. 39 | * `year` (default = `2016`): controls the year for the data. Default is `2016` as that is currently the most recent year of data from both of our sources. Note that only this year of data is included in the package installation but more can be added in a process described later. 40 | 41 | ### Energy Report 42 | The report that will be printed out will look like the one below. The second and third lines will show a real-time reading that disappears once the process has finished evaluating. 43 | ``` 44 | Location: Pennsylvania 45 | -------------------------------------------------------------------------------- 46 | ------------------------------- Final Readings ------------------------------- 47 | -------------------------------------------------------------------------------- 48 | Average baseline wattage: 1.86 watts 49 | Average total wattage: 19.42 watts 50 | Average process wattage: 17.56 watts 51 | Process duration: 0:00:01 52 | -------------------------------------------------------------------------------- 53 | ------------------------------- Energy Data ------------------------------- 54 | -------------------------------------------------------------------------------- 55 | Energy mix in Pennsylvania 56 | Coal: 25.42% 57 | Oil: 0.17% 58 | Natural Gas: 31.64% 59 | Low Carbon: 42.52% 60 | -------------------------------------------------------------------------------- 61 | ------------------------------- Emissions ------------------------------- 62 | -------------------------------------------------------------------------------- 63 | Effective emission: 4.05e-06 kg CO2 64 | Equivalent miles driven: 1.66e-12 miles 65 | Equivalent minutes of 32-inch LCD TV watched: 2.51e-03 minutes 66 | Percentage of CO2 used in a US household/day: 1.33e-12% 67 | -------------------------------------------------------------------------------- 68 | ------------------------- Assumed Carbon Equivalencies ------------------------- 69 | -------------------------------------------------------------------------------- 70 | Coal: 995.725971 kg CO2/MWh 71 | Petroleum: 816.6885263 kg CO2/MWh 72 | Natural gas: 743.8415916 kg CO2/MWh 73 | Low carbon: 0 kg CO2/MWh 74 | -------------------------------------------------------------------------------- 75 | ------------------------- Emissions Comparison ------------------------- 76 | -------------------------------------------------------------------------------- 77 | Quantities below expressed in kg CO2 78 | US Europe Global minus US/Europe 79 | Max: Wyoming 9.59e-06 Kosovo 9.85e-06 Mongolia 9.64e-06 80 | Median: Tennessee 4.70e-06 Ukraine 6.88e-06 Korea, South 7.87e-06 81 | Min: Vermont 2.69e-07 Iceland 1.77e-06 Bhutan 1.10e-06 82 | -------------------------------------------------------------------------------- 83 | -------------------------------------------------------------------------------- 84 | Process used: 1.04e-05 kWh 85 | ``` 86 | The report is divided into several sections. 87 | * **Final Readings**: Presents an average of: 88 | * *Average baseline wattage*: your computer's average power usage minus the process, ran for 10 seconds before starting your process 89 | * *Average total wattage*: your computer's average power usage while the process runs 90 | * *Average process usage*: the difference between the baseline and total, highlighting the usage solely from the specific process you evaluated 91 | * *Process duration*: how long your program ran for 92 | 93 | * **Energy Data**: The energy mix of the location. 94 | 95 | * **Emissions**: The effective CO2 emissions of running the program one time and some real-world equivalents to those emissions. 96 | 97 | * **Assumed Carbon Equivalencies**: The formulas used to convert from kWh to CO2 based on the energy mix of the location (for international locations, see below for more information). 98 | 99 | * **Emissions Comparison**: What the emissions would be for the same energy used in a representative group of US states and countries. Note that if these locations are specified as described below these default values are not shown. 100 | 101 | * **Process used**: The amount of energy running the program used in total. 102 | 103 | The PDF report contains the same sections, but does not include the process duration or the emissions comparison momentarily. 104 | 105 | ## Methodology 106 | ### Power Measurement 107 | #### CPU 108 | We calculate CPU power usage via the RAPL (Running Average Power Limit) interfaces found on Intel processors. These are non-architectural model-specific registers that provide power-related information 109 | about the CPU. They are used primarily for limiting power consumption, but the Energy Status 110 | register (MSR_PKG_ENERGY_STATUS) allows for power measurement. 111 | 112 | The RAPL interface differentiates between several domains, based on the number of processors. For a single processor machine: 113 | * Package 114 | * Power planes: 115 | * Core 116 | * Uncore 117 | * DRAM 118 | 119 | For a machine with multiple processors: 120 | * Package 0 121 | * Package 1 122 | * ... 123 | * Package n 124 | * DRAM 125 | 126 | Presently, we use the Package domain (or a sum of all of the domains, for a multi-processor machine), which represents the complete processor package. 127 | 128 | As outlined by [Vince Weaver](http://web.eece.maine.edu/~vweaver/projects/rapl/), there are multiple ways to access the RAPL interface data, namely: 129 | * Using perf_event interface 130 | * Reading the underlying MSR 131 | * Reading the files under `/sys/class/powercap/intel-rapl/` 132 | 133 | We elected to use the final method because it is the only one that does not require sudo access. We read the `energy_uj.txt` files inside the package folder(s) `intel-rapl:*`. These files represent the energy used in microjoules, and they update roughly every millisecond. The value in the file increases to the point of overflow and then resets. We take 2 readings with a delay in-between, and then calculate the wattage based on the difference (energy) and the delay (time). To avoid errors due to the reset of the file, we discard negative values. 134 | 135 | For more information on the RAPL interface, consult the [Intel® 64 and IA-32 Architectures Software Developer's Manual](https://software.intel.com/sites/default/files/managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf). 136 | 137 | #### GPU 138 | To the package measurement we also add the power usage of the GPU for machines that have an Nvidia GPU that support the NVIDIA-smi program. 139 | 140 | The NVIDIA-smi is a command-line utility that allows for the querying of information about the GPU. If the GPU is identified as valid, we use the built-in method to query the current wattage, and then convert the output into a float. 141 | 142 | More information on NVIDIA-smi can be found on the [Nvidia website](https://developer.nvidia.com/nvidia-system-management-interface). 143 | 144 | 145 | ### Calculating CO2 Emissions 146 | #### Location 147 | In order to accurately calculate the CO₂ emissions associated with the computational power used, we determine the geographical location of the user via their IP address with the help of the [GeoJS](https://www.geojs.io/) API. If the location cannot be determined, we use the United States as the default. 148 | 149 | Location is especially important as the emissions differ based on the country's (and, in the case of the United States, the state's) energy mix. 150 | 151 | #### Energy Mix Information 152 | We obtained international energy mix data from the [U.S. Energy Information Administration data](https://www.eia.gov/beta/international/data/browser/#/?pa=0000000010000000000000000000000000000000000000000000000000u&c=ruvvvvvfvsujvv1vrvvvvfvvvvvvfvvvou20evvvfvrvvvvvvurs&ct=0&vs=INTL.44-2-AFG-QBTU.A&cy=2016&vo=0&v=H&start=2014&end=2016) for the year 2016. Specifically, we looked at the energy consumption of countries worldwide, broken down by energy source. For the data points labeled *(s)* (meaning that the value is too small for the number of decimal places shown), we approximated those amounts to 0. No data was available for, and thus we removed from consideration, the following: Former Czechoslovakia, Former Serbia and Montenegro, Former U.S.S.R., Former Yugoslavia, Hawaiian Trade Zone, East Germany and West Germany. 153 | 154 | Our United States energy mix and emissions data was obtained from the [U.S. Environmental Protection Agency eGRID data](https://www.epa.gov/sites/production/files/2018-02/egrid2016_summarytables.xlsx) for the year 2016. We used the *State Resource Mix* section for displaying the energy mix, and the *State Output Emission Rates* section for calculating emissions in the United States. We did not use the *otherFossil* data as the values were predominantly 0 (and in cases in which the value was nonzero, it was below 1%). 155 | 156 | As of July 2019, the most recent eGRID data was from the year 2016. We elected to use 2016 U.S. E.I.A. data for consistency between the data sources. 157 | 158 | #### Conversion to CO2 159 | Since the international data only contained an energy mix, and no emission data, we reverse-engineered the formulas used in the eGRID data. This gives us additionally consistency between the separate datasets. 160 | * *Coal*: 2195.20 lbs CO2/MWh = 995.725971 kg CO2/MWh 161 | * *Petroleum*: 1800.49 lbs CO2/MWh = 816.6885263 kg CO2/MWh 162 | * *Natural gas*: 1639.89 lbs CO2/MWh = 743.8415916 kg CO2/MWh 163 | 164 | #### Using Different Years of Data 165 | In case one wishes to compare energy usage between different years of data, we have included a script to allow for adding other years. If you navigate to the package directory and go into the `data` folder, you can use `raw_to_json.py`. First, you need to download the US and international data in the years of your choice from the links above and place them in `data/raw/"year of the data"` after creating the required year folder. Then, run the script with a flag for that year (for example, `python raw_to_json.py -2016`). This will allow selecting that year when using package in the future by using the `year` optional argument for `evaluate`. 166 | 167 | ## Related Work 168 | * In their paper [*Energy and Policy Considerations for Deep Learning in NLP*](https://arxiv.org/abs/1906.02243), Strubell et. al not only analyze the computational power needed for training deep learning models in NLP, but further convert the data into carbon emissions and cost. Our tool aims to facilitate this analysis for developers in a single package. We do not consider cost, instead choosing to focus solely on the environmental impact. Further, we do not focus on a specific computational area. We also extend their analysis of carbon emissions by including international data on energy consumption and CO2 emissions for localized analysis of the carbon footprint of the tested program. 169 | 170 | ## Limitations 171 | * Due to the methods in which the energy measurement is being done (through the Intel RAPL 172 | interface and NVIDIA-smi), our package is only available on Linux kernels that have the 173 | RAPL interface and/or machines with an Nvidia GPU. 174 | 175 | * A country’s overall energy consumption mix is not necessarily representative of the mix of energy sources used to produce electricity (and even electricity production is not necessarily representative of electricity consumption due to imports/exports). However, the E.I.A. data is the most geographically comprehensive that we have found. We are working on obtaining even more accurate data. 176 | 177 | 178 | ## Acknowledgements 179 | We would like to thank [Jon Wilson](https://www.haverford.edu/users/jwilson) for all his valuable insight with regards to the environmental aspect of our project. 180 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # changelog 2 | 3 | v0.0.2 4 | * removed emissions from return of `evaluate`, now just returns value of user function 5 | * added `Average total wattage` to report to distinguish between baseline+process and just process 6 | * added to README to make it comprehensive 7 | * added new carbon equivalent: minutes of TV watched 8 | 9 | v0.0.3 10 | * minor bug fixes 11 | 12 | v0.0.4 13 | * updated conversion formulas 14 | * added powerLoss parameter 15 | 16 | v0.0.5 17 | * added Emissions Comparison section to command-line report 18 | * minor bug fixes 19 | 20 | v.0.0.6 21 | * fixed multiprocessing bug that would cause deadlock 22 | 23 | v.0.0.7 24 | * added option of getting emissions value from `evaluate` via energyOutput parameter 25 | 26 | v.0.0.8 - 0.0.12 27 | * Added methods for accessing other years of data 28 | * Fleshed out the pdf report 29 | * Added several new flags for the evaluate function 30 | * General bug fixes 31 | 32 | v.0.0.13 33 | * Added default graphs to pdf when locations optional parameter is not set 34 | -------------------------------------------------------------------------------- /energy-usage-report.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/responsibleproblemsolving/energy-usage/b6cd5d4ee07f7c4f0f1499405c385a05654a2b3a/energy-usage-report.pdf -------------------------------------------------------------------------------- /energyusage/RAPLFile.py: -------------------------------------------------------------------------------- 1 | class RAPLFile: 2 | def __init__(self, name, path): 3 | self.name = name 4 | self.path = path 5 | self.baseline = [] 6 | self.process = [] 7 | self.recent = 0 8 | self.num_process_checks =0 9 | self.process_average = 0 10 | self.baseline_average = 0 11 | 12 | def set_recent(val): 13 | self.recent = val 14 | 15 | def create_gpu(baseline_average, process_average): 16 | self.baseline_average = baseline_average 17 | self.process_average = process_average 18 | 19 | def average(baseline_checks): 20 | self.process_average = sum(self.process)/self.num_process_checks 21 | self.baseline_average = sum(self.baseline)/baseline_checks 22 | 23 | def __repr__(): 24 | print(name,path,recent) 25 | -------------------------------------------------------------------------------- /energyusage/__init__.py: -------------------------------------------------------------------------------- 1 | name = "energy_usage" 2 | from .evaluate import evaluate 3 | -------------------------------------------------------------------------------- /energyusage/convert.py: -------------------------------------------------------------------------------- 1 | """ UNIT OF MEASUREMENT CONVERSIONS """ 2 | 3 | 4 | def to_joules(ujoules): 5 | """ Converts from microjoules to joules """ 6 | return ujoules*10**(-6) 7 | 8 | 9 | def to_kwh(joules): 10 | """ Converts from watts used in a timeframe (in seconds) to kwh """ 11 | watt_hours = joules / 3600 12 | return watt_hours / 1000 13 | 14 | 15 | def to_MWh(kwh): 16 | """ Converts from kilowatt-hours to megawatt-hours """ 17 | return (kwh / 1000) 18 | 19 | 20 | def kwh_to_mmbtu(kwh): 21 | ''' Convert from kilowatt hour to million British thermal unit ''' 22 | # https://en.wikipedia.org/wiki/British_thermal_unit#As_a_unit_of_power 23 | return kwh * 0.003412142 24 | 25 | 26 | def coal_to_carbon(kwh): 27 | ''' 28 | 2195.2 lbs CO2/MWh 29 | source: reverse-engineered from eGRID data 30 | ''' 31 | MWh = to_MWh(kwh) 32 | lbs_carbon = 2195.2 * MWh 33 | return lbs_to_kgs(lbs_carbon) 34 | 35 | 36 | def natural_gas_to_carbon(kwh): 37 | ''' 38 | 1639.89 lbs CO2/MWh 39 | source: reverse-engineered from eGRID data 40 | ''' 41 | MWh = to_MWh(kwh) 42 | lbs_carbon = 1639.89 * MWh 43 | return lbs_to_kgs(lbs_carbon) 44 | 45 | 46 | def petroleum_to_carbon(kwh): 47 | ''' 48 | Oil: 1800.49 lbs CO2/MWh 49 | source: reverse-engineered from eGRID data 50 | ''' 51 | MWh = to_MWh(kwh) 52 | lbs_carbon = 1800.49 * MWh 53 | return lbs_to_kgs(lbs_carbon) 54 | 55 | 56 | def lbs_to_kgs(lbs): 57 | '''Convert from pounds to kilograms''' 58 | return lbs * 0.45359237 59 | 60 | 61 | """ CARBON EQUIVALENCY """ 62 | 63 | 64 | def carbon_to_miles(kg_carbon): 65 | ''' 66 | 8.89 × 10-3 metric tons CO2/gallon gasoline × 67 | 1/22.0 miles per gallon car/truck average × 68 | 1 CO2, CH4, and N2O/0.988 CO2 = 4.09 x 10-4 metric tons CO2E/mile 69 | Source: EPA 70 | ''' 71 | return 4.09 * 10**(-7) * kg_carbon # number of miles driven by avg car 72 | 73 | 74 | def carbon_to_home(kg_carbon): 75 | ''' 76 | Total CO2 emissions for energy use per home: 5.734 metric tons CO2 for electricity 77 | + 2.06 metric tons CO2 for natural gas + 0.26 metric tons CO2 for liquid petroleum gas 78 | + 0.30 metric tons CO2 for fuel oil = 8.35 metric tons CO2 per home per year / 52 weeks 79 | = 160.58 kg CO2/week on average 80 | Source: EPA 81 | ''' 82 | return kg_carbon * 10**(-3) / 8.35 / 52 / 7 #percent of CO2 used in an avg US household in a week 83 | 84 | 85 | def carbon_to_tv(kg_carbon): 86 | ''' 87 | Gives the amount of minutes of watching a 32-inch LCD flat screen tv required to emit and 88 | equivalent amount of carbon. Ratio is 0.097 kg CO2 / 1 hour tv 89 | ''' 90 | return kg_carbon * (1 / .097) * 60 91 | -------------------------------------------------------------------------------- /energyusage/data/README.md: -------------------------------------------------------------------------------- 1 | # energyusage data 2 | 3 | ### International data source: U.S. EIA (2016) 4 | 1. Data points labeled *(s)* (value is too small for the number of decimal places shown) have been approximated to 0 5 | 2. Removed following countries due to no data: Former Czechoslovakia, Former Serbia and Montenegro, Former U.S.S.R., Former Yugoslavia, Hawaiian Trade Zone, East Germany and West Germany 6 | 7 | ### US data source: eGRID (2016) 8 | 1. Energy mix data is from State Resource Mix section 9 | 2. Did not use otherFossil data, as values were predominantly 0%, and 0-1% otherwise 10 | -------------------------------------------------------------------------------- /energyusage/data/csv/egrid_emissions_2016.csv: -------------------------------------------------------------------------------- 1 | ,Unnamed: 0,3. State Output Emission Rates (eGRID2016),Unnamed: 2,Unnamed: 3,Unnamed: 4,Unnamed: 5,Unnamed: 6,Unnamed: 7,Unnamed: 8 2 | 0,,State,Total output emission rates,,,,,, 3 | 1,,,(lb/MWh),,,,,, 4 | 2,,,CO2,CH4,N2O,CO2e,Annual NOx,Ozone Season NOx,SO2 5 | 3,,AK,925.862,0.063,0.009,930.013,6.632,6.498,0.552 6 | 4,,AL,912.917,0.069,0.01,917.468,0.418,0.389,0.404 7 | 5,,AR,1115.65,0.105,0.015,1122.593,0.924,0.948,1.611 8 | 6,,AZ,932.225,0.067,0.011,937.072,0.625,0.603,0.238 9 | 7,,CA,452.541,0.026,0.003,454.059,0.475,0.446,0.037 10 | 8,,CO,1468.373,0.146,0.021,1477.945,1.12,1.127,0.705 11 | 9,,CT,498.467,0.061,0.008,502.135,0.321,0.346,0.035 12 | 10,,DC,481.786,0.023,0.002,483.042,4.578,4.551,0.098 13 | 11,,DE,887.415,0.033,0.004,889.337,0.397,0.393,0.121 14 | 12,,FL,1024.205,0.077,0.01,1028.967,0.546,0.56,0.374 15 | 13,,GA,1001.754,0.086,0.013,1007.448,0.446,0.334,0.359 16 | 14,,HI,1522.102,0.157,0.024,1532.882,4.492,4.229,7.505 17 | 15,,IA,997.858,0.051,0.016,1003.87,0.772,0.903,1.048 18 | 16,,ID,188.695,0.008,0.001,189.273,0.267,0.254,0.067 19 | 17,,IL,811.318,0.048,0.012,816.041,0.357,0.395,0.954 20 | 18,,IN,1812.703,0.185,0.027,1824.905,1.708,1.672,1.733 21 | 19,,KS,1195.553,0.129,0.019,1204.056,0.759,0.89,0.301 22 | 20,,KY,1954.301,0.189,0.032,1968.084,1.458,1.442,1.905 23 | 21,,LA,878.85,0.049,0.007,882.134,0.82,0.896,0.723 24 | 22,,MA,821.327,0.101,0.013,827.514,0.523,0.45,0.227 25 | 23,,MD,1012.682,0.078,0.017,1019.454,0.621,0.674,0.944 26 | 24,,ME,336.964,0.164,0.023,347.62,0.578,0.566,0.289 27 | 25,,MI,1099.854,0.063,0.016,1106.015,0.832,0.824,1.539 28 | 26,,MN,1012.67,0.123,0.018,1020.283,0.67,0.661,0.582 29 | 27,,MO,1687.742,0.122,0.028,1698.955,1.457,1.424,2.545 30 | 28,,MS,940.716,0.029,0.006,943.029,0.428,0.494,0.162 31 | 29,,MT,1251.022,0.135,0.02,1260.078,1.123,1.147,1.022 32 | 30,,NC,867.441,0.08,0.011,872.658,0.558,0.57,0.445 33 | 31,,ND,1663.754,0.13,0.027,1674.823,1.98,1.899,2.394 34 | 32,,NE,1281.153,0.139,0.021,1290.709,1.129,1.124,2.771 35 | 33,,NH,310.564,0.101,0.013,316.792,0.236,0.227,0.079 36 | 34,,NJ,557.822,0.034,0.004,559.824,0.235,0.268,0.054 37 | 35,,NM,1572.786,0.15,0.022,1582.602,2.353,2.363,0.502 38 | 36,,NV,769.912,0.027,0.003,771.539,0.477,0.525,0.159 39 | 37,,NY,464.02,0.031,0.004,465.876,0.341,0.383,0.137 40 | 38,,OH,1465.96,0.125,0.022,1475.334,1.007,1.007,1.786 41 | 39,,OK,1043.716,0.063,0.011,1048.311,0.691,0.751,1.276 42 | 40,,OR,305.891,0.02,0.003,307.162,0.352,0.448,0.139 43 | 41,,PA,855.444,0.052,0.011,860.046,0.821,0.762,0.959 44 | 42,,RI,870.822,0.017,0.002,871.69,0.244,0.195,0.023 45 | 43,,SC,629.428,0.025,0.009,632.802,0.282,0.311,0.24 46 | 44,,SD,513.316,0.049,0.007,516.562,0.207,0.234,0.142 47 | 45,,TN,992.271,0.074,0.015,998.407,0.513,0.562,0.803 48 | 46,,TX,1049.527,0.079,0.011,1054.602,0.605,0.633,1.09 49 | 47,,UT,1627.372,0.166,0.024,1638.384,1.777,1.676,0.878 50 | 48,,VA,813.802,0.083,0.012,818.98,0.557,0.55,0.255 51 | 49,,VT,56.89,0.161,0.021,66.825,0.356,0.473,0.013 52 | 50,,WA,186.844,0.01,0.003,187.93,0.149,0.173,0.05 53 | 51,,WI,1388.88,0.072,0.02,1396.49,0.673,0.69,0.504 54 | 52,,WV,1975.757,0.211,0.033,1990.559,1.33,1.289,1.181 55 | 53,,WY,2026.26,0.223,0.032,2040.967,1.58,1.614,1.394 56 | 54,,U.S.,998.443,0.08,0.013,1004.167,0.721,0.719,0.798 57 | 55,,,,,,,,Created:,2018-02-15 00:00:00 58 | -------------------------------------------------------------------------------- /energyusage/data/csv/egrid_resource_mix_2016.csv: -------------------------------------------------------------------------------- 1 | ,Unnamed: 0,4. State Resource Mix (eGRID2016),Unnamed: 2,Unnamed: 3,Unnamed: 4,Unnamed: 5,Unnamed: 6,Unnamed: 7,Unnamed: 8,Unnamed: 9,Unnamed: 10,Unnamed: 11,Unnamed: 12,Unnamed: 13,Unnamed: 14 2 | 0,,State,Nameplate Capacity (MW),Net Generation (MWh),Generation Resource Mix (percent)*,,,,,,,,,, 3 | 1,,,,,Coal,Oil,Gas,Other Fossil,Nuclear,Hydro,Biomass,Wind,Solar,Geo- thermal,Other unknown/ purchased fuel 4 | 2,,AK,3439.3,6335033.511,9.37508349654355,13.1177817525334,47.9766949320682,0,0,26.1802209374103,0.678771307669188,2.67144757377534,0,0,0 5 | 3,,AL,38353.5,142863240.209,23.9798603432318,0.0320812876526775,40.4608060090415,0.0168364122124984,27.9301232266998,5.22383854364561,2.33457241144212,0,0.0218817660739702,0,0 6 | 4,,AR,19535.8,60445059.072,39.3747160179087,0.0700855395293054,30.0623197082992,0.00932544868986719,22.2036707929482,5.9703969782852,2.2662363220001,0,0.0432491923393949,0,0 7 | 5,,AZ,40134.7,108734630.779,27.9609257579863,0.0474497764901804,31.4367212370378,0,29.7764221046636,6.64585842381067,0.197155599400995,0.498073838066132,3.43739326254438,0,0 8 | 6,,CA,106792.9,197323836.964,0.161600251206906,0.0885926066314154,49.1612356206819,0.723083279462725,9.58200406171968,14.5358883353839,3.1025378432278,6.81259009984281,9.78143414455527,5.80634312625006,0.244690631037569 9 | 7,,CO,19872.6,54418479.931,55.0340160825281,0.0128164274462212,23.2998778886932,0,0,2.95558604633453,0.298253461236163,17.3125085611163,0.988835153985018,0,0.0981063786604004 10 | 8,,CT,11788.5,36496559.656,0.485992324632169,0.251351199081465,49.186836961912,0,45.4165872979648,0.629461791630518,3.92767852879067,0.0349128795302527,0.0671790164581009,0,0 11 | 9,,DC,24.9,76473.999,0,1.30841462457829,29.6859403195857,0,0,0,69.005645055836,0,0,0,0 12 | 10,,DE,4010.7,8731261.003,5.49004150218474,0.716636049997522,89.1906553311554,3.17797535844454,0,0,0.778661904624091,0.0609419447027341,0.585087908890953,0,0 13 | 11,,FL,100751.4,238226428.16,16.5512567857852,1.1838750530123,66.5164332900752,0.00998623795896645,12.3076277569261,0.073271047770674,2.56014508230251,0,0.0940210545503543,0,0.703383691618647 14 | 12,,GA,51336.4,132902274.317,28.5100273720157,0.159399416679368,39.7754400305443,0.0733993681054065,25.9443730491926,1.43075880448999,3.44118703930145,0,0.662835154951894,0,0.00257976471936003 15 | 13,,HI,3501.8,9948844.667,15.0507873675246,66.7445925896695,0,0.637059353939782,0,0.913161271920704,5.5918934228451,6.42413261828819,0.88966025257374,2.61439391902078,1.13431920421758 16 | 14,,IA,22303.9,54396530.724,46.3234452100955,0.510644158571517,5.44326436643707,0.022283274071317,8.64515612980608,1.68538138334089,0.462740086914409,36.9068077995302,0.000277591232971245,0,0 17 | 15,,ID,6212.4,15660938.441,0.1863762010766,0.0011707152891251,21.20857824125,0,0,57.680273573303,3.394262132981,16.4639879037307,0.190288725251396,0.459710639725991,0.415351867392129 18 | 16,,IL,62747.6,187437381.035,31.6573998349036,0.0370806331138922,9.32601520615151,0.110479676254971,52.6079893239325,0.0708684673588436,0.249156281206178,5.68906473013071,0.026040696597145,0,0.225905150350681 19 | 17,,IN,40933.2,101397209.392,71.2792363847568,0.599855432825697,19.6500043434276,2.2332087632537,0,0.418896366328742,0.44439506324001,4.81477919961092,0.221936575000556,0,0.337687871555988 20 | 18,,KS,19888.2,47599990.322,48.5211521866395,0.0595035411749648,4.2588391507495,0,17.3236210717495,0.0641554748677105,0.123596663089172,29.6447138436294,0.00441596725954311,0,2.10084075144772e-06 21 | 19,,KY,31178.5,80273501.005,83.2429848118192,1.51782791134958,10.2506072340467,0.0622262907237682,0,4.33260037756264,0.579138339799489,0,0.0146150346986756,0,0 22 | 20,,LA,36571.7,106842115.053,11.2443007965254,4.51060385878939,61.8224879113802,1.995293152188,16.0534315224573,1.03238595110488,2.69207760273855,0,0,0,0.649419204816255 23 | 21,,MA,19517.4,31951671.137,5.86802379880449,1.32162439213174,66.1747420653558,0.00165159746509087,16.9453355971823,0.663708684576483,6.45211987271173,0.676406392655579,1.89638759911684,0,0 24 | 22,,MD,18265.2,37166746.524,37.1991610016348,0.432115094511355,14.5906019191779,0,39.7119725771528,3.74565237031159,2.34091930077492,1.4181900876279,0.561387648808749,0,0 25 | 23,,ME,5717.6,11514427.426,0.606396623673887,0.953425587860634,30.38346418909,1.29038174518737,0,26.0515580257956,25.3457416660948,14.4783842876034,0,0,0.89064787469436 26 | 24,,MI,36977.2,112121789.925,36.1454028370175,0.730436865892991,26.1279754752842,1.58249105030814,28.1405691783868,0.724841261349094,2.35007655237637,4.18810918198071,0.00823657913825913,0,0.00186101826593887 27 | 25,,MN,21832.4,60036475.896,38.6536500501645,0.0511445406080547,14.8732883646442,0,23.0873250830994,2.01294568547713,3.63516628663332,17.4747253478972,0.0168347660494798,0,0.19491987542677 28 | 26,,MO,24747.7,78611512.544,76.7341676411401,0.0938663714822434,7.67800313308529,0.0114222354425749,11.9959262262824,1.84155470470997,0.176360042251555,1.42712303791056,0.0415766076953379,0,0 29 | 27,,MS,19599.7,62881294.963,8.49541348114511,0.0282839006551713,79.6655646021598,0.00838461422035819,9.37842008949327,0,2.42393331232631,0,0,0,0 30 | 28,,MT,7258.5,27783529.992,51.3585643202464,1.65537902584312,1.71346364878582,0.0309021940007306,0,36.2895909924844,0.0725249844060513,7.70309361324901,0,0,1.17648122098447 31 | 29,,NC,48223.6,130768152.699,28.6275972168915,0.192090640609279,30.015795849519,0.277544220702755,32.719042179998,3.3778759682066,1.95453554524712,0.00476645106405565,2.60776261862837,0,0.222989309133253 32 | 30,,ND,9442.3,37856451.758,70.2135259347657,0.0795164301827238,2.82940866719082,0.121430683315052,0,5.05067145289499,0.0148085722395754,21.5866031525464,0,0,0.104035106864687 33 | 31,,NE,10004.2,37197843.2,58.8398611578095,0,1.44525156238933,0,25.1253372451846,4.10962735327667,0.262838185793249,10.2063874211507,0.0106970743959478,0,0 34 | 32,,NH,4650.3,19282493.05,2.18860205904539,0.201210252226213,24.6048890391982,0,55.8079442567418,5.94003080472722,9.01526911004134,2.24205447801986,0,0,0 35 | 33,,NJ,28577,77598196.669,1.68979931987715,0.187840466788286,56.3130407877612,0.266307331208533,38.4164253009358,0,1.95655985151755,0.0267904202739907,1.05623353593692,0,0.0870029857005057 36 | 34,,NM,13285.9,32922552.001,55.7832509209687,0.156982687189679,30.2453863150808,0,0,0.449454836765536,0.0541069607331151,10.9512198728546,2.31556475971366,0.0431862032623226,0.000847443431578843 37 | 35,,NV,19953.8,39228694.003,5.52358623029987,0.0280029332624738,73.7256550485074,0.00189263501873871,0,4.56099558168115,0.14087647170415,0.876564996065205,6.54049048925975,8.54833199435843,0.0536036198428428 38 | 36,,NY,51335.7,134090832.639,1.32017813965061,0.476908093068945,42.1136349819461,0,31.0021119092066,19.7010500097137,2.32282244229962,2.938440997013,0.104116737315042,0,0.0207366897864929 39 | 37,,OH,46930.8,118922077.758,57.8029332194481,0.993395739314884,24.324397094141,0.615739256244761,14.1343791607182,0.420500105170361,0.606897806174076,1.04665881730201,0.0550988014865089,0,0 40 | 38,,OK,33525.2,78655008.003,24.3570561777216,0.0219455716971364,46.4421617810863,0.0283195295391412,0,3.16063158376871,0.467638568809724,25.5153355935538,0.0069111938235462,0,0 41 | 39,,OR,19278.2,60181811.826,3.15408787957563,0.00805865072291105,25.4338325843189,0,0,57.4078691171161,1.73047554638906,11.8924168703487,0.0680200182258296,0.305239333302836,0 42 | 40,,PA,68558.5,215066508.488,25.4209872038413,0.168652292280365,31.6409820032753,0.249873539132601,38.557379978375,0.842847642902135,1.46520187301296,1.61635859510349,0.0347824309890067,0,0.00293444108779934 43 | 41,,RI,2398,6564885.1,0,0.400354469935055,95.8204613449386,0,0,0.0324148856080043,3.11926403042916,0.404150256086264,0.223355013002898,0,0 44 | 42,,SC,31484.7,96985763.86,21.6556663760401,0.117400600775043,16.8755224308708,0.0468312083825458,57.5609388356085,1.28830660818325,2.45020844561225,0,0.00512549452752034,0,0 45 | 43,,SD,5438,10289415.719,20.2409986596975,0.0271428920094766,8.9272453276606,0,0,40.162669178107,0,30.6384063266924,0.00353761583311981,0,0 46 | 44,,TN,27972.7,79340633.31,39.2833183196113,0.153239840698565,14.2657227280735,0.0432340184282968,37.2798713455855,7.65070147719864,1.17640505095384,0.047575874371378,0.099087941172931,0,0.000843403906167379 47 | 45,,TX,182433.5,453941342.056,26.7062991106578,0.0432703346914266,49.7809385301747,0.554282657036034,9.26979790200154,0.295634011652853,0.370685631863286,12.6736163184591,0.160992166240827,0,0.144483337222404 48 | 46,,UT,11043.7,38133928.003,68.021954394508,0.0827400208531232,22.7915679163765,0.141865959794474,0,1.99177488220478,0.233006856628429,2.15630028844898,2.7630539379768,1.27207981218714,0.545655931021808 49 | 47,,VA,34581.2,92554816.451,17.8266381936999,0.578425695153699,44.1952612873437,0,32.1235522890339,0.333668209147557,4.91986446946641,0,0.0225898561547833,0,0 50 | 48,,VT,796.3,1911207.085,0,0.210167648111503,0.102837207237784,0,0,56.3788719381972,24.9839446755423,15.2355022600183,3.08867627089291,0,0 51 | 49,,WA,34016.1,114086582.682,4.03352910743163,0.0192530893353324,9.62621748446973,0.352049603218519,8.43710038965381,68.6700452649127,1.81228615931981,7.04888166782742,0.000637233831047834,0,0 52 | 50,,WI,23413.6,64966610.542,51.3538262497966,0.226441317247121,23.8164789671229,0.0110326487344699,15.6255556883278,4.302606618444,2.28197931114237,2.33236884883508,0.00411154276602436,0,0.0455988075835716 53 | 51,,WV,20625.5,75942967.562,94.1514409510465,0.161501361424458,1.61222125291139,0.0324548406679132,0,2.1568581820887,0,1.88552341186101,0,0,0 54 | 52,,WY,13744.3,46656629.978,85.7903235585195,0.119244714935337,1.68924032896151,0.767604330633421,0,2.08649484593123,0,9.40774752906873,0,0,0.139344691950248 55 | 53,,U.S.,1515006.8,4075322641.089,30.4034440970752,0.593638604155216,33.7969267585496,0.340778750119991,19.7683069304823,6.40692342781077,1.71112161020832,5.56780957737731,0.881937072788413,0.388298076428613,0.140815095004277 56 | 54,,,,,,,,,,,,,,Created:,2018-02-15 00:00:00 57 | -------------------------------------------------------------------------------- /energyusage/data/csv/emissions-us.csv: -------------------------------------------------------------------------------- 1 | State,CO2 (lbs/MWh) 2 | AK,925.9 3 | AL,912.9 4 | AR,"1,115.70" 5 | AZ,932.2 6 | CA,452.5 7 | CO,"1,468.40" 8 | CT,498.5 9 | DC,481.8 10 | DE,887.4 11 | FL,"1,024.20" 12 | GA,"1,001.80" 13 | HI,"1,522.10" 14 | IA,997.9 15 | ID,188.7 16 | IL,811.3 17 | IN,"1,812.70" 18 | KS,"1,195.60" 19 | KY,"1,954.30" 20 | LA,878.9 21 | MA,821.3 22 | MD,"1,012.70" 23 | ME,337 24 | MI,"1,099.90" 25 | MN,"1,012.70" 26 | MO,"1,687.70" 27 | MS,940.7 28 | MT,"1,251.00" 29 | NC,867.4 30 | ND,"1,663.80" 31 | NE,"1,281.20" 32 | NH,310.6 33 | NJ,557.8 34 | NM,"1,572.80" 35 | NV,769.9 36 | NY,464 37 | OH,"1,466.00" 38 | OK,"1,043.70" 39 | OR,305.9 40 | PA,855.4 41 | RI,870.8 42 | SC,629.4 43 | SD,513.3 44 | TN,992.3 45 | TX,"1,049.50" 46 | UT,"1,627.40" 47 | VA,813.8 48 | VT,56.9 49 | WA,186.8 50 | WI,"1,388.90" 51 | WV,"1,975.80" 52 | WY,"2,026.30" 53 | U.S.,998.4 -------------------------------------------------------------------------------- /energyusage/data/csv/energy-mix-intl.csv: -------------------------------------------------------------------------------- 1 | COUNTRY,UNITS,TOTAL 2016,COAL,NATURAL GAS,PETROLEUM +OTHER LIQUIDS,"NUCLEAR, RENEWABLES + OTHERS" 2 | Afghanistan,Quad Btu,0.1371617897,0.03537612045,0.006111883346,0.07018891507,0.02548487087 3 | Albania,Quad Btu,0.1238306478,0.002335653683,0.001576448208,0.054625866,0.06529267989 4 | Algeria,Quad Btu,2.355316377,0.000697223845,1.491480102,0.855327726,0.007811324581 5 | American Samoa,Quad Btu,0.004986387685,0,0,0.004986387685,0 6 | Angola,Quad Btu,0.360949782,0,0.02969075899,0.276411252,0.05484777099 7 | Antarctica,Quad Btu,0.000415339744,0,0,0.000203053872,0.000212285872 8 | Antigua and Barbuda,Quad Btu,0.0108941898,0,0,0.0104193989,0.000474790898 9 | Argentina,Quad Btu,3.693696135,0.03524529941,1.78723184,1.455311526,0.41590747 10 | Armenia,Quad Btu,0.1381311067,2.72E-05,0.08193547183,0.012106914,0.04406149685 11 | Aruba,Quad Btu,0.0184263244,0,0,0.0170715382,0.001354786202 12 | Australia,Quad Btu,5.988489399,1.850510519,1.561518923,2.253542905,0.322917052 13 | Austria,Quad Btu,1.477954401,0.09836699417,0.3166514243,0.560111435,0.5028245479 14 | Azerbaijan,Quad Btu,0.6087905764,4.01E-06,0.3945951843,0.197450046,0.0167413322 15 | "Bahamas, The",Quad Btu,0.04261468652,0,0,0.04229811126,0.00031657526 16 | Bahrain,Quad Btu,0.69337783,0,0.566823814,0.126554016,0 17 | Bangladesh,Quad Btu,1.373454067,0.0421590789,1.083876497,0.240821778,0.006596713582 18 | Barbados,Quad Btu,0.02551935411,0,0.00073923435,0.0233819627,0.001398157054 19 | Belarus,Quad Btu,0.9453133046,0.01423629971,0.6303685839,0.284674068,0.01603435301 20 | Belgium,Quad Btu,2.682610218,0.1017595115,0.6228861091,1.366870113,0.5910944844 21 | Belize,Quad Btu,0.01119531062,0,0,0.007955241312,0.003240069312 22 | Benin,Quad Btu,0.07841434557,0.001985751183,0,0.072772512,0.003656082383 23 | Bermuda,Quad Btu,0.01081502953,0,0,0.01081502953,0 24 | Bhutan,Quad Btu,0.06158056065,0.001458186469,0,0.006138540654,0.05398383352 25 | Bolivia,Quad Btu,0.3123626698,0,0.1176503569,0.17660049,0.01811182291 26 | Bosnia and Herzegovina,Quad Btu,0.2551103139,0.1458545378,0.007498925617,0.072039414,0.02971743654 27 | Botswana,Quad Btu,0.07679995612,0.02885917806,0,0.04267743,0.005263348062 28 | Brazil,Quad Btu,12.4779307,0.6143491475,1.256183254,6.020299596,4.587098704 29 | Brunei,Quad Btu,0.1726618569,0,0.1405808589,0.032080998,0 30 | Bulgaria,Quad Btu,0.7556280208,0.2335324937,0.1154451669,0.19425999,0.2123903702 31 | Burkina Faso,Quad Btu,0.05044477534,0,0,0.04692751167,0.00351726367 32 | Burma (Myanmar),Quad Btu,0.5112152029,0.009931483126,0.163999918,0.2474606381,0.08982316367 33 | Burundi,Quad Btu,0.006079994712,0,0,0.003072301356,0.003007693356 34 | Cambodia,Quad Btu,0.1556281708,0.02884057061,0,0.096492972,0.03029462821 35 | Cameroon,Quad Btu,0.1496908741,0,0.02662184704,0.08098848,0.04208054704 36 | Canada,Quad Btu,14.67619333,0.712861574,4.071426084,5.031087482,4.860818188 37 | Cape Verde,Quad Btu,0.01235231116,0,0,0.01182995558,0.000522355578 38 | Cayman Islands,Quad Btu,0.009151671912,0,0,0.009075835956,7.58E-05 39 | Central African Republic,Quad Btu,0.007118847288,0,0,0.005772857244,0.001345990044 40 | Chad,Quad Btu,0.004800311796,0,0,0.004800311796,0 41 | Chile,Quad Btu,1.479969112,0.281820625,0.1775543071,0.713098403,0.3074957766 42 | China,Quad Btu,139.1977546,89.94169511,7.642407508,25.69392108,15.91973086 43 | Colombia,Quad Btu,1.767697578,0.2746070413,0.3576794557,0.721918164,0.4134929171 44 | Comoros,Quad Btu,0.002694822132,0,0,0.002694822132,0 45 | Congo (Brazzaville),Quad Btu,0.09563288611,0,0.05176475841,0.03517515505,0.008692972656 46 | Congo (Kinshasa),Quad Btu,0.126007595,0.0002947017556,0,0.04319516774,0.0825177255 47 | Cook Islands,Quad Btu,0.001519243944,0,0,0.001241157972,0.000278085972 48 | Costa Rica,Quad Btu,0.2085499511,2.91E-06,0,0.110030214,0.09851682536 49 | Cote dIvoire (IvoryCoast),Quad Btu,0.193374929,0,0.08165915348,0.102387787,0.009327988508 50 | Croatia,Quad Btu,0.3463333966,0.02634949547,0.08141847412,0.141736062,0.09682936498 51 | Cuba,Quad Btu,0.3795769335,4.87E-05,0.04172370124,0.330716136,0.007088436915 52 | Cyprus,Quad Btu,0.1148323212,3.74E-06,0,0.110959854,0.003868728594 53 | Czech Republic,Quad Btu,1.657550802,0.6733398896,0.3084634889,0.369628846,0.3061185777 54 | Denmark,Quad Btu,0.736335999,0.08412404515,0.1286902203,0.32958992,0.1939318136 55 | Djibouti,Quad Btu,0.01356072468,0,0,0.01327805434,0.000282670342 56 | Dominica,Quad Btu,0.002792129044,0,0,0.002728042122,6.41E-05 57 | Dominican Republic,Quad Btu,0.3559744198,0.02888428413,0.03856474203,0.264813444,0.02371194963 58 | Ecuador,Quad Btu,0.6889402175,0.0003593385217,0.02039905824,0.518572224,0.1496095968 59 | Egypt,Quad Btu,3.81530152,0.01641822902,1.873031843,1.782496128,0.1433553201 60 | El Salvador,Quad Btu,0.1388485482,0,0,0.103190772,0.03565777624 61 | Equatorial Guinea,Quad Btu,0.05448617413,0,0.04363027304,0.01051273402,0.000343167063 62 | Eritrea,Quad Btu,0.006564942,0,0,0.006564942,0 63 | Estonia,Quad Btu,0.08810423818,0.0004063049668,0.018933423,0.060055553,0.008708957215 64 | Ethiopia,Quad Btu,0.2682179543,0.01073853556,0,0.155239266,0.1022401528 65 | Falkland Islands (Islas Malvinas),Quad Btu,0.001299812544,0,0,0.000608362272,0.000691450272 66 | Faroe Islands,Quad Btu,0.0114782865,0,0,0.01000981525,0.001468471252 67 | Fiji,Quad Btu,0.03779137231,0,0,0.03306922216,0.004722150156 68 | Finland,Quad Btu,1.230947085,0.1271616688,0.09052694583,0.430688971,0.5825694998 69 | France,Quad Btu,10.1504119,0.3164766775,1.629960521,3.406617337,4.797357365 70 | French Guiana,Quad Btu,0.0148232155,0,0,0.01063130375,0.004191911748 71 | French Polynesia,Quad Btu,0.01610390521,0,0,0.01400273581,0.002101169406 72 | Gabon,Quad Btu,0.06827780556,0,0.01401345078,0.044125692,0.01013866278 73 | "Gambia, The",Quad Btu,0.00829480626,0,0,0.00812847753,0.00016632873 74 | Georgia,Quad Btu,0.263159289,0.00721535699,0.08279599593,0.066662142,0.1064857941 75 | Germany,Quad Btu,13.86450971,3.221532707,3.201450165,4.974866208,2.466660635 76 | Ghana,Quad Btu,0.2547728718,3.65E-07,0.02752671673,0.17643945,0.05080633992 77 | Gibraltar,Quad Btu,0.170679388,0,0,0.170339694,0.000339694 78 | Greece,Quad Btu,1.119107092,0.1820317242,0.151439482,0.615374764,0.1702611222 79 | Greenland,Quad Btu,0.0125101557,0,0,0.008482533852,0.004027621852 80 | Grenada,Quad Btu,0.004102019936,0,0,0.004041316368,6.07E-05 81 | Guadeloupe,Quad Btu,0.02863531962,0,0,0.02763910781,0.000996211808 82 | Guam,Quad Btu,0.0279650321,0,0,0.02717786005,0.0007871720495 83 | Guatemala,Quad Btu,0.2933260943,0.04203623115,0,0.184920768,0.06636909515 84 | Guinea,Quad Btu,0.0432406624,0,0,0.0392831632,0.003957499202 85 | Guinea-Bissau,Quad Btu,0.005754190146,0,0,0.005754190146,0 86 | Guyana,Quad Btu,0.02982853304,0,0,0.02936764492,0.000460888122 87 | Haiti,Quad Btu,0.0477269,0,0,0.047535714,0.000191186 88 | Honduras,Quad Btu,0.167249575,0.004221472658,0,0.121565802,0.04146230033 89 | Hong Kong,Quad Btu,1.325685795,0.28729626,0.1250353885,0.8762614891,0.03709265761 90 | Hungary,Quad Btu,1.002535841,0.1066011968,0.3633217643,0.316083822,0.2165290574 91 | Iceland,Quad Btu,0.2119905277,0.003470203777,0,0.039825179,0.1686951449 92 | India,Quad Btu,29.03814023,15.47125777,2.036108777,8.92909155,2.601682127 93 | Indonesia,Quad Btu,7.248372206,2.110575804,1.613943201,3.214650468,0.3092027326 94 | Iran,Quad Btu,11.2601455,0.03710279093,7.407321196,3.607034366,0.2086871445 95 | Iraq,Quad Btu,1.90188282,0,0.04075522999,1.789107186,0.07202040399 96 | Ireland,Quad Btu,0.6321237008,0.05600247025,0.1921607377,0.315382923,0.06857756985 97 | Israel,Quad Btu,1.03758176,0.2289197836,0.3598648857,0.448797091,0 98 | Italy,Quad Btu,6.724000904,0.4615559108,2.560762394,2.544079798,1.157602801 99 | Jamaica,Quad Btu,0.1236647838,0.002030706741,0.0006349911765,0.11570175,0.005297335918 100 | Japan,Quad Btu,19.64949675,4.798355621,4.830426471,8.118245358,1.902469303 101 | Jordan,Quad Btu,0.3952796257,0.004506032202,0.1494490072,0.230370648,0.01095393826 102 | Kazakhstan,Quad Btu,3.471685036,2.143404964,0.536060444,0.663194562,0.1290250669 103 | Kenya,Quad Btu,0.3171182991,0.01107448164,0,0.234003198,0.07204061944 104 | Kiribati,Quad Btu,0.001696000892,0,0,0.000824920446,0.000871080446 105 | "Korea, North",Quad Btu,0.3833638176,0.2277739817,0,0.03881424181,0.1167755941 106 | "Korea, South",Quad Btu,12.96115765,3.811903527,1.814689881,5.667827666,1.666736579 107 | Kosovo,Quad Btu,0.09954921396,0.07060680689,0,0.02889720609,4.52E-05 108 | Kuwait,Quad Btu,1.598493656,0.008278958391,0.8230957094,0.766062888,0.001056099832 109 | Kyrgyzstan,Quad Btu,0.2298042236,0.03632284228,0.006944832939,0.080379822,0.1061567264 110 | Laos,Quad Btu,0.1984399804,0.06888643559,0,0.03750019859,0.09205334618 111 | Latvia,Quad Btu,0.1654622513,0.001455264949,0.05015841209,0.077821013,0.03602756124 112 | Lebanon,Quad Btu,0.3239291561,0.002990586067,0,0.317083734,0.003854836067 113 | Lesotho,Quad Btu,0.01591282676,0,0,0.009965915382,0.005946911382 114 | Liberia,Quad Btu,0.0165399964,0,0,0.0162699982,0.000269998202 115 | Libya,Quad Btu,0.6460757193,0,0.1880515377,0.456307938,0.001716243667 116 | Lithuania,Quad Btu,0.2629296814,0.006440208403,0.08037039496,0.126175206,0.04994387199 117 | Luxembourg,Quad Btu,0.1779172239,0.001995132783,0.03132567528,0.117509249,0.0270871668 118 | Macau,Quad Btu,0.05080576494,0,0.0003708838081,0.03518596266,0.01524891847 119 | Macedonia,Quad Btu,0.1106609247,0.03627729765,0.004992952121,0.04313141237,0.02625926257 120 | Madagascar,Quad Btu,0.05816875468,0.01209440566,0,0.03764631568,0.008428033341 121 | Malawi,Quad Btu,0.02739283864,0.001936919644,0,0.01229709968,0.01315881932 122 | Malaysia,Quad Btu,3.306376499,0.6326121611,1.10091277,1.38236736,0.1904842076 123 | Maldives,Quad Btu,0.0229276469,0,0,0.0229276469,0 124 | Mali,Quad Btu,0.05979021448,0,0,0.04621267524,0.01357753924 125 | Malta,Quad Btu,0.1112415088,0,0,0.10440333,0.0068381788 126 | Martinique,Quad Btu,0.03655888246,0,0,0.03655888246,0 127 | Mauritania,Quad Btu,0.03828410589,0,0,0.03566954894,0.002614556944 128 | Mauritius,Quad Btu,0.08281664239,0.0180500132,0,0.0587979,0.005968729197 129 | Mexico,Quad Btu,7.941203635,0.4893964727,2.844381592,4.04942179,0.5580037799 130 | Micronesia,Quad Btu,0,0,0,0,0 131 | Moldova,Quad Btu,0.1300808438,0.003250423718,0.08856757536,0.0360809549,0.002181889868 132 | Mongolia,Quad Btu,0.1927715811,0.1436393745,0,0.042830052,0.006302154543 133 | Montenegro,Quad Btu,0.04503671941,0.01249075771,0,0.014084778,0.01846118371 134 | Montserrat,Quad Btu,0.001627139376,0,0,0.000813569688,0.000813569688 135 | Morocco,Quad Btu,0.7813424548,0.1376884762,0.04652415119,0.537733788,0.05939603941 136 | Mozambique,Quad Btu,0.280868842,0.0002746419357,0.06949317908,0.082241298,0.128859723 137 | Namibia,Quad Btu,0.07618120673,0.0001179737641,0,0.053690004,0.02237322896 138 | Nauru,Quad Btu,0.001046235728,0,0,0.001023117864,2.31E-05 139 | Nepal,Quad Btu,0.1341683616,0.004074318781,0,0.083214126,0.04687991678 140 | Netherlands,Quad Btu,3.974047621,0.4271669483,1.313684434,2.027681102,0.2055151359 141 | Netherlands Antilles,Quad Btu,0.1940919055,0,0,0.1914611928,0.002630712758 142 | New Caledonia,Quad Btu,0.07285020448,0.0269470269,0,0.04320867534,0.002694502238 143 | New Zealand,Quad Btu,0.8976168708,0.05001811972,0.182217134,0.331752073,0.3336295441 144 | Nicaragua,Quad Btu,0.09905706,0,0,0.076172652,0.022884408 145 | Niger,Quad Btu,0.0326101502,0.005384129101,0,0.024068892,0.003157129101 146 | Nigeria,Quad Btu,1.588491269,0.004124309214,0.6836642475,0.849796734,0.05090597869 147 | Niue,Quad Btu,0.000208365996,0,0,0.000104182998,0.000104182998 148 | Northern Mariana Islands,Quad Btu,0,0,0,0,0 149 | Norway,Quad Btu,1.946497853,0.02005935382,0.1859641996,0.440283702,1.300190597 150 | Oman,Quad Btu,1.165942761,0.002371841263,0.786275821,0.376823718,0.0004713802869 151 | Pakistan,Quad Btu,3.1148265,0.2099870588,1.332119527,1.163000868,0.4097190462 152 | Palestinian Territories,Quad Btu,0.07025437794,0,0,0.04657604297,0.02367833497 153 | Panama,Quad Btu,0.4058629608,0.007722348409,0,0.333161748,0.06497886441 154 | Papua New Guinea,Quad Btu,0.09076967016,0,0.0036974805,0.07962065858,0.007451531078 155 | Paraguay,Quad Btu,0.521049076,0,0,0.103203216,0.41784586 156 | Peru,Quad Btu,1.103576633,0.02833270118,0.3539504075,0.4826442,0.2386493242 157 | Philippines,Quad Btu,1.629222171,0.4451861617,0.1135273265,0.868557162,0.201951521 158 | Poland,Quad Btu,4.131291966,2.290902991,0.6410254804,1.173931782,0.02543171223 159 | Portugal,Quad Btu,1.085083137,0.1184922529,0.1909226362,0.49387699,0.2817912577 160 | Puerto Rico,Quad Btu,0.2858581097,0.02377683992,0.06421769684,0.1946758221,0.003187750852 161 | Qatar,Quad Btu,1.84803672,0,1.510507472,0.33747396,5.53E-05 162 | Reunion,Quad Btu,0.0444082425,0,0,0.03776981725,0.006638425252 163 | Romania,Quad Btu,1.370460754,0.2014847964,0.3829039909,0.410182056,0.3758899104 164 | Russia,Quad Btu,31.48513173,4.751306138,15.89347181,7.23040342,3.609950362 165 | Rwanda,Quad Btu,0.01669824121,0,0,0.0137823866,0.002915854604 166 | Saint Helena,Quad Btu,0.00029219244,0,0,0.00014609622,0.00014609622 167 | Saint Kitts and Nevis,Quad Btu,0.00406960196,0,0,0.00349787298,0.00057172898 168 | Saint Lucia,Quad Btu,0.006537024772,0,0,0.006263896386,0.000273128386 169 | Saint Pierre and Miquelon,Quad Btu,0.0017723036,0,0,0.0013861518,0.0003861518 170 | Saint Vincent/Grenadines,Quad Btu,0.003718379148,0,0,0.003234557574,0.000483821574 171 | Samoa,Quad Btu,0.005074160188,0,0,0.004843208094,0.000230952094 172 | Sao Tome and Principe,Quad Btu,0.002202469924,0,0,0.002073538962,0.000128930962 173 | Saudi Arabia,Quad Btu,10.83475545,0.002686375934,3.914854267,6.917214804,0 174 | Senegal,Quad Btu,0.1186776671,0.0095818999,0.001904891639,0.103390242,0.00380063354 175 | Serbia,Quad Btu,0.6558007882,0.3098829788,0.08273797749,0.1513052235,0.1118746085 176 | Seychelles,Quad Btu,0.01559496354,0,0,0.01559496354,0 177 | Sierra Leone,Quad Btu,0.01517514232,0,0,0.01357205116,0.001603091162 178 | Singapore,Quad Btu,3.51161312,0.01520505077,0.4577375478,3.024075732,0.01459478988 179 | Slovakia,Quad Btu,0.7104875427,0.1285292757,0.1738854351,0.169278605,0.2387942269 180 | Slovenia,Quad Btu,0.2818039074,0.04430879855,0.03108520701,0.108242008,0.0981678938 181 | Solomon Islands,Quad Btu,0.003598341744,0,0,0.003285322872,0.000313018872 182 | Somalia,Quad Btu,0.01167056843,0,0,0.01167056843,0 183 | South Africa,Quad Btu,6.073816073,4.345631775,0.1843193762,1.317879624,0.2259852978 184 | South Sudan,Quad Btu,0.01680949648,0,0,0.01680949648,0 185 | Spain,Quad Btu,5.738094178,0.4025741025,1.103254125,2.69505513,1.537210821 186 | Sri Lanka,Quad Btu,0.3618804689,0.05694324847,0,0.262175682,0.04276153847 187 | Sudan,Quad Btu,0.357253632,0,0,0.283735278,0.073518354 188 | Suriname,Quad Btu,0.038350384,0,0,0.027876024,0.01047436 189 | Swaziland,Quad Btu,0.01906967379,0.003382936306,0,0.01070984259,0.004976894896 190 | Sweden,Quad Btu,2.169875924,0.07061168835,0.03602991996,0.655395433,1.407838882 191 | Switzerland,Quad Btu,1.184681095,0.002517522489,0.1331689639,0.46927975,0.5797148585 192 | Syria,Quad Btu,0.4386540028,9.21E-05,0.1386556915,0.291880974,0.008025199736 193 | Taiwan,Quad Btu,4.764669176,1.528713489,0.802704373,2.010851722,0.4223995915 194 | Tajikistan,Quad Btu,0.2166923085,0.03101435694,0.0007023562289,0.03684339,0.1481322054 195 | Tanzania,Quad Btu,0.2343458401,0.007429958784,0.05556429,0.1489814939,0.02237009739 196 | Thailand,Quad Btu,5.418604501,0.6809291713,1.79307402,2.613536094,0.331065216 197 | Timor-Leste (East Timor),Quad Btu,0.007698704204,0,0,0.007349352102,0.000349352102 198 | Togo,Quad Btu,0.04099832215,0.003439601075,0,0.031140744,0.006417977075 199 | Tonga,Quad Btu,0.001895233278,0,0,0.001895233278,0 200 | Trinidad and Tobago,Quad Btu,0.8930771944,5.61E-06,0.7746757419,0.11833878,5.71E-05 201 | Tunisia,Quad Btu,0.3824600375,4.85E-05,0.1832805645,0.193889964,0.005241059029 202 | Turkey,Quad Btu,5.969057701,1.510736924,1.684133298,1.915974989,0.8582124902 203 | Turkmenistan,Quad Btu,1.766416641,0,1.473889677,0.292526964,0 204 | Turks and Caicos Islands,Quad Btu,0.003054738,0,0,0.003027369,2.74E-05 205 | Tuvalu,Quad Btu,0,0,0,0,0 206 | U.S. Pacific Islands,Quad Btu,0.004256860448,0,0,0.004128430224,0.000128430224 207 | U.S. Territories,Quad Btu,0,0,0,0,0 208 | Uganda,Quad Btu,0.09517695571,0,0,0.06529189985,0.02988505585 209 | Ukraine,Quad Btu,3.889533171,1.330201965,1.133836995,0.48436074,0.941133471 210 | United Arab Emirates,Quad Btu,4.709657254,0.05391558437,2.761756479,1.888920726,0.005064465226 211 | United Kingdom,Quad Btu,8.769488138,0.9828903746,3.047646949,3.242847522,1.496103293 212 | United States,Quad Btu,99.16161476,14.22597264,28.400352,39.12361956,17.41167056 213 | Uruguay,Quad Btu,0.2251153033,1.07E-05,0.002354870777,0.107775654,0.114974044 214 | Uzbekistan,Quad Btu,1.764057936,0.0684403599,1.490848412,0.100542396,0.1042267678 215 | Vanuatu,Quad Btu,0.002670927296,0,0,0.002289303648,0.000381623648 216 | Venezuela,Quad Btu,2.752176731,0.004929681217,0.9463269117,1.181218152,0.6197019864 217 | Vietnam,Quad Btu,3.19915582,1.317919928,0.3293502569,0.95555463,0.5963310049 218 | "Virgin Islands, U.S.",Quad Btu,0.03413985607,0,0,0.03393144803,0.0002084080326 219 | "Virgin Islands, British",Quad Btu,0.002566913916,0,0,0.002566913916,0 220 | Wake Island,Quad Btu,0.019746224,0,0,0.019373112,0.000373112 221 | Western Sahara,Quad Btu,0.003654737652,0,0,0.003654737652,0 222 | Yemen,Quad Btu,0.1437878763,0.003114623119,0.01869869101,0.115210944,0.00676361813 223 | Zambia,Quad Btu,0.1551430752,0.004091181602,0,0.04570059,0.1053513036 224 | Zimbabwe,Quad Btu,0.1580888191,0.07584684063,0,0.048758154,0.03348382451 -------------------------------------------------------------------------------- /energyusage/data/csv/energy-mix-us.csv: -------------------------------------------------------------------------------- 1 | State,Nameplate Capacity (MW),Net Generation (MWh),Coal,Oil,Gas,Other Fossil,Nuclear,Hydro,Biomass,Wind,Solar,Geo- thermal,Other unknown/ purchased fuel 2 | AK,"3,439","6,335,034",9.4,13.1,48,0,0,26.2,0.7,2.7,0,0,0 3 | AL,"38,354","142,863,240",24,0,40.5,0,27.9,5.2,2.3,0,0,0,0 4 | AR,"19,536","60,445,059",39.4,0.1,30.1,0,22.2,6,2.3,0,0,0,0 5 | AZ,"40,135","108,734,631",28,0,31.4,0,29.8,6.6,0.2,0.5,3.4,0,0 6 | CA,"106,793","197,323,837",0.2,0.1,49.2,0.7,9.6,14.5,3.1,6.8,9.8,5.8,0.2 7 | CO,"19,873","54,418,480",55,0,23.3,0,0,3,0.3,17.3,1,0,0.1 8 | CT,"11,789","36,496,560",0.5,0.3,49.2,0,45.4,0.6,3.9,0,0.1,0,0 9 | DC,25,"76,474",0,1.3,29.7,0,0,0,69,0,0,0,0 10 | DE,"4,011","8,731,261",5.5,0.7,89.2,3.2,0,0,0.8,0.1,0.6,0,0 11 | FL,"100,751","238,226,428",16.6,1.2,66.5,0,12.3,0.1,2.6,0,0.1,0,0.7 12 | GA,"51,336","132,902,274",28.5,0.2,39.8,0.1,25.9,1.4,3.4,0,0.7,0,0 13 | HI,"3,502","9,948,845",15.1,66.7,0,0.6,0,0.9,5.6,6.4,0.9,2.6,1.1 14 | IA,"22,304","54,396,531",46.3,0.5,5.4,0,8.6,1.7,0.5,36.9,0,0,0 15 | ID,"6,212","15,660,938",0.2,0,21.2,0,0,57.7,3.4,16.5,0.2,0.5,0.4 16 | IL,"62,748","187,437,381",31.7,0,9.3,0.1,52.6,0.1,0.2,5.7,0,0,0.2 17 | IN,"40,933","101,397,209",71.3,0.6,19.7,2.2,0,0.4,0.4,4.8,0.2,0,0.3 18 | KS,"19,888","47,599,990",48.5,0.1,4.3,0,17.3,0.1,0.1,29.6,0,0,0 19 | KY,"31,179","80,273,501",83.2,1.5,10.3,0.1,0,4.3,0.6,0,0,0,0 20 | LA,"36,572","106,842,115",11.2,4.5,61.8,2,16.1,1,2.7,0,0,0,0.6 21 | MA,"19,517","31,951,671",5.9,1.3,66.2,0,16.9,0.7,6.5,0.7,1.9,0,0 22 | MD,"18,265","37,166,747",37.2,0.4,14.6,0,39.7,3.7,2.3,1.4,0.6,0,0 23 | ME,"5,718","11,514,427",0.6,1,30.4,1.3,0,26.1,25.3,14.5,0,0,0.9 24 | MI,"36,977","112,121,790",36.1,0.7,26.1,1.6,28.1,0.7,2.4,4.2,0,0,0 25 | MN,"21,832","60,036,476",38.7,0.1,14.9,0,23.1,2,3.6,17.5,0,0,0.2 26 | MO,"24,748","78,611,513",76.7,0.1,7.7,0,12,1.8,0.2,1.4,0,0,0 27 | MS,"19,600","62,881,295",8.5,0,79.7,0,9.4,0,2.4,0,0,0,0 28 | MT,"7,259","27,783,530",51.4,1.7,1.7,0,0,36.3,0.1,7.7,0,0,1.2 29 | NC,"48,224","130,768,153",28.6,0.2,30,0.3,32.7,3.4,2,0,2.6,0,0.2 30 | ND,"9,442","37,856,452",70.2,0.1,2.8,0.1,0,5.1,0,21.6,0,0,0.1 31 | NE,"10,004","37,197,843",58.8,0,1.4,0,25.1,4.1,0.3,10.2,0,0,0 32 | NH,"4,650","19,282,493",2.2,0.2,24.6,0,55.8,5.9,9,2.2,0,0,0 33 | NJ,"28,577","77,598,197",1.7,0.2,56.3,0.3,38.4,0,2,0,1.1,0,0.1 34 | NM,"13,286","32,922,552",55.8,0.2,30.2,0,0,0.4,0.1,11,2.3,0,0 35 | NV,"19,954","39,228,694",5.5,0,73.7,0,0,4.6,0.1,0.9,6.5,8.5,0.1 36 | NY,"51,336","134,090,833",1.3,0.5,42.1,0,31,19.7,2.3,2.9,0.1,0,0 37 | OH,"46,931","118,922,078",57.8,1,24.3,0.6,14.1,0.4,0.6,1,0.1,0,0 38 | OK,"33,525","78,655,008",24.4,0,46.4,0,0,3.2,0.5,25.5,0,0,0 39 | OR,"19,278","60,181,812",3.2,0,25.4,0,0,57.4,1.7,11.9,0.1,0.3,0 40 | PA,"68,559","215,066,508",25.4,0.2,31.6,0.2,38.6,0.8,1.5,1.6,0,0,0 41 | RI,"2,398","6,564,885",0,0.4,95.8,0,0,0,3.1,0.4,0.2,0,0 42 | SC,"31,485","96,985,764",21.7,0.1,16.9,0,57.6,1.3,2.5,0,0,0,0 43 | SD,"5,438","10,289,416",20.2,0,8.9,0,0,40.2,0,30.6,0,0,0 44 | TN,"27,973","79,340,633",39.3,0.2,14.3,0,37.3,7.7,1.2,0,0.1,0,0 45 | TX,"182,434","453,941,342",26.7,0,49.8,0.6,9.3,0.3,0.4,12.7,0.2,0,0.1 46 | UT,"11,044","38,133,928",68,0.1,22.8,0.1,0,2,0.2,2.2,2.8,1.3,0.5 47 | VA,"34,581","92,554,816",17.8,0.6,44.2,0,32.1,0.3,4.9,0,0,0,0 48 | VT,796,"1,911,207",0,0.2,0.1,0,0,56.4,25,15.2,3.1,0,0 49 | WA,"34,016","114,086,583",4,0,9.6,0.4,8.4,68.7,1.8,7,0,0,0 50 | WI,"23,414","64,966,611",51.4,0.2,23.8,0,15.6,4.3,2.3,2.3,0,0,0 51 | WV,"20,626","75,942,968",94.2,0.2,1.6,0,0,2.2,0,1.9,0,0,0 52 | WY,"13,744","46,656,630",85.8,0.1,1.7,0.8,0,2.1,0,9.4,0,0,0.1 53 | U.S.,"1,515,007","4,075,322,641",30.4,0.6,33.8,0.3,19.8,6.4,1.7,5.6,0.9,0.4,0.1 54 | ,,,,,,,,,,,,Created:,2/15/2018 -------------------------------------------------------------------------------- /energyusage/data/json/energy-mix-intl_2016.json: -------------------------------------------------------------------------------- 1 | {"Kazakhstan": {"lowCarbon": 0.12902506687864, "naturalGas": 0.5360604439692, "petroleum": 0.663194562, "coal": 2.1434049635551, "total": 3.4716850364029}, "Hong Kong": {"lowCarbon": 0.037092657608551, "naturalGas": 0.1250353884912, "petroleum": 0.876261489084, "coal": 0.28729626003335, "total": 1.3256857952171}, "Burkina Faso": {"lowCarbon": 0.00351726367, "naturalGas": 0.0, "petroleum": 0.04692751167, "coal": 0.0, "total": 0.05044477534}, "Bolivia": {"lowCarbon": 0.018111822912, "naturalGas": 0.117650356912, "petroleum": 0.17660049, "coal": 0.0, "total": 0.312362669824}, "Guyana": {"lowCarbon": 0.000460888122, "naturalGas": 0.0, "petroleum": 0.029367644922, "coal": 0.0, "total": 0.029828533044}, "Ghana": {"lowCarbon": 0.050806339922129, "naturalGas": 0.027526716726966, "petroleum": 0.17643945, "coal": 3.6519516278844e-07, "total": 0.25477287184426}, "Antigua and Barbuda": {"lowCarbon": 0.000474790898, "naturalGas": 0.0, "petroleum": 0.010419398898, "coal": 0.0, "total": 0.010894189796}, "Kosovo": {"lowCarbon": 4.5200978906862e-05, "naturalGas": 0.0, "petroleum": 0.02889720609, "coal": 0.070606806888907, "total": 0.099549213957814}, "Equatorial Guinea": {"lowCarbon": 0.000343167063, "naturalGas": 0.043630273041, "petroleum": 0.010512734022, "coal": 0.0, "total": 0.054486174126}, "French Guiana": {"lowCarbon": 0.004191911748, "naturalGas": 0.0, "petroleum": 0.010631303748, "coal": 0.0, "total": 0.014823215496}, "Brazil": {"lowCarbon": 4.5870987036196, "naturalGas": 1.2561832538982, "petroleum": 6.020299596, "coal": 0.61434914752064, "total": 12.477930701038}, "Micronesia": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.0, "coal": 0.0, "total": 0.0}, "Malta": {"lowCarbon": 0.0068381788, "naturalGas": 0.0, "petroleum": 0.10440333, "coal": 0.0, "total": 0.1112415088}, "Guatemala": {"lowCarbon": 0.06636909514639, "naturalGas": 0.0, "petroleum": 0.184920768, "coal": 0.04203623114639, "total": 0.29332609429278}, "Mozambique": {"lowCarbon": 0.12885972301127, "naturalGas": 0.069493179075601, "petroleum": 0.082241298, "coal": 0.00027464193566597, "total": 0.28086884202253}, "Slovakia": {"lowCarbon": 0.23879422693342, "naturalGas": 0.17388543508013, "petroleum": 0.169278605, "coal": 0.12852927565261, "total": 0.71048754266615}, "France": {"lowCarbon": 4.7973573649744, "naturalGas": 1.6299605210559, "petroleum": 3.406617337, "coal": 0.3164766775216, "total": 10.150411900552}, "Pakistan": {"lowCarbon": 0.40971904615667, "naturalGas": 1.3321195270382, "petroleum": 1.163000868, "coal": 0.20998705879922, "total": 3.1148264999941}, "Saint Helena": {"lowCarbon": 0.00014609622, "naturalGas": 0.0, "petroleum": 0.00014609622, "coal": 0.0, "total": 0.00029219244}, "Kenya": {"lowCarbon": 0.072040619436487, "naturalGas": 0.0, "petroleum": 0.234003198, "coal": 0.011074481635343, "total": 0.31711829907183}, "Tuvalu": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.0, "coal": 0.0, "total": 0.0}, "Nauru": {"lowCarbon": 2.3117864e-05, "naturalGas": 0.0, "petroleum": 0.001023117864, "coal": 0.0, "total": 0.001046235728}, "Egypt": {"lowCarbon": 0.14335532005807, "naturalGas": 1.8730318428471, "petroleum": 1.782496128, "coal": 0.016418229016207, "total": 3.8153015199214}, "U.S. Pacific Islands": {"lowCarbon": 0.000128430224, "naturalGas": 0.0, "petroleum": 0.004128430224, "coal": 0.0, "total": 0.004256860448}, "Brunei": {"lowCarbon": 0.0, "naturalGas": 0.1405808588844, "petroleum": 0.032080998, "coal": 0.0, "total": 0.1726618568844}, "Moldova": {"lowCarbon": 0.0021818898678212, "naturalGas": 0.0885675753567, "petroleum": 0.036080954904, "coal": 0.0032504237177508, "total": 0.13008084384627}, "Slovenia": {"lowCarbon": 0.098167893797189, "naturalGas": 0.031085207007386, "petroleum": 0.108242008, "coal": 0.044308798552235, "total": 0.28180390735681}, "Ecuador": {"lowCarbon": 0.14960959676165, "naturalGas": 0.02039905824, "petroleum": 0.518572224, "coal": 0.00035933852165294, "total": 0.68894021752331}, "Macedonia": {"lowCarbon": 0.026259262574532, "naturalGas": 0.0049929521208, "petroleum": 0.043131412374, "coal": 0.036277297650045, "total": 0.11066092471938}, "Djibouti": {"lowCarbon": 0.000282670342, "naturalGas": 0.0, "petroleum": 0.013278054342, "coal": 0.0, "total": 0.013560724684}, "Czech Republic": {"lowCarbon": 0.30611857768714, "naturalGas": 0.30846348890485, "petroleum": 0.369628846, "coal": 0.67333988957213, "total": 1.6575508021641}, "Cambodia": {"lowCarbon": 0.030294628209788, "naturalGas": 0.0, "petroleum": 0.096492972, "coal": 0.028840570609788, "total": 0.15562817081958}, "Albania": {"lowCarbon": 0.065292679891197, "naturalGas": 0.001576448208, "petroleum": 0.054625866, "coal": 0.0023356536831972, "total": 0.12383064778239}, "Guinea": {"lowCarbon": 0.003957499202, "naturalGas": 0.0, "petroleum": 0.039283163202, "coal": 0.0, "total": 0.043240662404}, "Lebanon": {"lowCarbon": 0.0038548360667966, "naturalGas": 0.0, "petroleum": 0.317083734, "coal": 0.0029905860667966, "total": 0.32392915613359}, "Dominican Republic": {"lowCarbon": 0.023711949633831, "naturalGas": 0.0385647420315, "petroleum": 0.264813444, "coal": 0.028884284134208, "total": 0.35597441979954}, "Guinea-Bissau": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.005754190146, "coal": 0.0, "total": 0.005754190146}, "Eritrea": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.006564942, "coal": 0.0, "total": 0.006564942}, "Uruguay": {"lowCarbon": 0.1149740439823, "naturalGas": 0.002354870777459, "petroleum": 0.107775654, "coal": 1.0734497853472e-05, "total": 0.22511530325761}, "Norway": {"lowCarbon": 1.3001905971181, "naturalGas": 0.1859641996226, "petroleum": 0.440283702, "coal": 0.020059353824374, "total": 1.9464978525651}, "Venezuela": {"lowCarbon": 0.61970198641222, "naturalGas": 0.9463269116711, "petroleum": 1.181218152, "coal": 0.0049296812173809, "total": 2.7521767313007}, "Solomon Islands": {"lowCarbon": 0.000313018872, "naturalGas": 0.0, "petroleum": 0.003285322872, "coal": 0.0, "total": 0.003598341744}, "Antarctica": {"lowCarbon": 0.000212285872, "naturalGas": 0.0, "petroleum": 0.000203053872, "coal": 0.0, "total": 0.000415339744}, "Sierra Leone": {"lowCarbon": 0.001603091162, "naturalGas": 0.0, "petroleum": 0.013572051162, "coal": 0.0, "total": 0.015175142324}, "_define": {"units": "Quad Btu", "naturalGas": "NATURAL GAS", "lowCarbon": "NUCLEAR, RENEWABLES + OTHERS", "coal": "COAL", "total": "TOTAL EMISSIONS", "petroleum": "PETROLEUM + OTHER LIQUIDS"}, "Turkmenistan": {"lowCarbon": 0.0, "naturalGas": 1.47388967691, "petroleum": 0.292526964, "coal": 0.0, "total": 1.76641664091}, "Puerto Rico": {"lowCarbon": 0.0031877508515211, "naturalGas": 0.064217696838, "petroleum": 0.1946758220899, "coal": 0.023776839923618, "total": 0.28585810970304}, "Dominica": {"lowCarbon": 6.4086922e-05, "naturalGas": 0.0, "petroleum": 0.002728042122, "coal": 0.0, "total": 0.002792129044}, "Cameroon": {"lowCarbon": 0.042080547036, "naturalGas": 0.026621847036, "petroleum": 0.08098848, "coal": 0.0, "total": 0.149690874072}, "Timor-Leste (East Timor)": {"lowCarbon": 0.000349352102, "naturalGas": 0.0, "petroleum": 0.007349352102, "coal": 0.0, "total": 0.007698704204}, "Chad": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.004800311796, "coal": 0.0, "total": 0.004800311796}, "Swaziland": {"lowCarbon": 0.0049768948962018, "naturalGas": 0.0, "petroleum": 0.01070984259, "coal": 0.0033829363062018, "total": 0.019069673792404}, "Kiribati": {"lowCarbon": 0.000871080446, "naturalGas": 0.0, "petroleum": 0.000824920446, "coal": 0.0, "total": 0.001696000892}, "Luxembourg": {"lowCarbon": 0.027087166801927, "naturalGas": 0.031325675280519, "petroleum": 0.117509249, "coal": 0.001995132782749, "total": 0.1779172238652}, "Bosnia and Herzegovina": {"lowCarbon": 0.029717436537623, "naturalGas": 0.0074989256168, "petroleum": 0.072039414, "coal": 0.14585453775867, "total": 0.25511031391309}, "Tajikistan": {"lowCarbon": 0.1481322053523, "naturalGas": 0.00070235622890625, "petroleum": 0.03684339, "coal": 0.031014356941, "total": 0.2166923085222}, "Burma (Myanmar)": {"lowCarbon": 0.089823163668661, "naturalGas": 0.1639999180408, "petroleum": 0.247460638092, "coal": 0.009931483125935, "total": 0.5112152029274}, "Tanzania": {"lowCarbon": 0.022370097386276, "naturalGas": 0.05556429, "petroleum": 0.148981493892, "coal": 0.0074299587836745, "total": 0.23434584006195}, "Ethiopia": {"lowCarbon": 0.10224015275786, "naturalGas": 0.0, "petroleum": 0.155239266, "coal": 0.010738535557857, "total": 0.26821795431571}, "Yemen": {"lowCarbon": 0.0067636181302757, "naturalGas": 0.018698691011, "petroleum": 0.115210944, "coal": 0.0031146231192757, "total": 0.14378787626055}, "Greenland": {"lowCarbon": 0.004027621852, "naturalGas": 0.0, "petroleum": 0.008482533852, "coal": 0.0, "total": 0.012510155704}, "Netherlands Antilles": {"lowCarbon": 0.002630712758, "naturalGas": 0.0, "petroleum": 0.191461192758, "coal": 0.0, "total": 0.194091905516}, "Ireland": {"lowCarbon": 0.068577569849519, "naturalGas": 0.19216073768984, "petroleum": 0.315382923, "coal": 0.056002470253822, "total": 0.63212370079318}, "Estonia": {"lowCarbon": 0.0087089572150986, "naturalGas": 0.018933422995349, "petroleum": 0.060055553, "coal": 0.00040630496676357, "total": 0.088104238177211}, "Hungary": {"lowCarbon": 0.21652905744761, "naturalGas": 0.36332176432901, "petroleum": 0.316083822, "coal": 0.10660119684609, "total": 1.0025358406227}, "United Arab Emirates": {"lowCarbon": 0.005064465225645, "naturalGas": 2.7617564792775, "petroleum": 1.888920725574, "coal": 0.053915584374145, "total": 4.7096572544513}, "Sweden": {"lowCarbon": 1.4078388824803, "naturalGas": 0.036029919961974, "petroleum": 0.655395433, "coal": 0.070611688348258, "total": 2.1698759237906}, "Algeria": {"lowCarbon": 0.0078113245813444, "naturalGas": 1.4914801022058, "petroleum": 0.855327726, "coal": 0.00069722384495542, "total": 2.3553163766321}, "Germany": {"lowCarbon": 2.4666606345477, "naturalGas": 3.2014501646832, "petroleum": 4.974866208, "coal": 3.2215327072368, "total": 13.864509714468}, "Belize": {"lowCarbon": 0.003240069312, "naturalGas": 0.0, "petroleum": 0.007955241312, "coal": 0.0, "total": 0.011195310624}, "South Africa": {"lowCarbon": 0.2259852978054, "naturalGas": 0.1843193762265, "petroleum": 1.317879624, "coal": 4.3456317753066, "total": 6.0738160733385}, "Argentina": {"lowCarbon": 0.41590747001233, "naturalGas": 1.7872318399485, "petroleum": 1.455311526, "coal": 0.03524529941099, "total": 3.6936961353718}, "Virgin Islands, British": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.002566913916, "coal": 0.0, "total": 0.002566913916}, "Australia": {"lowCarbon": 0.32291705202615, "naturalGas": 1.5615189232431, "petroleum": 2.253542905, "coal": 1.8505105191674, "total": 5.9884893994367}, "Togo": {"lowCarbon": 0.0064179770745496, "naturalGas": 0.0, "petroleum": 0.031140744, "coal": 0.0034396010745496, "total": 0.040998322149099}, "Mexico": {"lowCarbon": 0.55800377990172, "naturalGas": 2.8443815921794, "petroleum": 4.04942179, "coal": 0.48939647268377, "total": 7.9412036347649}, "Indonesia": {"lowCarbon": 0.30920273261773, "naturalGas": 1.6139432014149, "petroleum": 3.214650468, "coal": 2.1105758039038, "total": 7.2483722059365}, "Angola": {"lowCarbon": 0.054847770992, "naturalGas": 0.029690758992, "petroleum": 0.276411252, "coal": 0.0, "total": 0.360949781984}, "Barbados": {"lowCarbon": 0.001398157054, "naturalGas": 0.00073923435, "petroleum": 0.023381962704, "coal": 0.0, "total": 0.025519354108}, "Comoros": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.002694822132, "coal": 0.0, "total": 0.002694822132}, "Palestinian Territories": {"lowCarbon": 0.023678334968, "naturalGas": 0.0, "petroleum": 0.046576042968, "coal": 0.0, "total": 0.070254377936}, "Burundi": {"lowCarbon": 0.003007693356, "naturalGas": 0.0, "petroleum": 0.003072301356, "coal": 0.0, "total": 0.006079994712}, "New Zealand": {"lowCarbon": 0.33362954413384, "naturalGas": 0.18221713395153, "petroleum": 0.331752073, "coal": 0.050018119724957, "total": 0.89761687081033}, "Iceland": {"lowCarbon": 0.1686951449064, "naturalGas": 0.0, "petroleum": 0.039825179, "coal": 0.0034702037773154, "total": 0.21199052768371}, "Qatar": {"lowCarbon": 5.52881462e-05, "naturalGas": 1.5105074721462, "petroleum": 0.33747396, "coal": 0.0, "total": 1.8480367202924}, "Macau": {"lowCarbon": 0.015248918468075, "naturalGas": 0.000370883808075, "petroleum": 0.03518596266, "coal": 0.0, "total": 0.05080576493615}, "Croatia": {"lowCarbon": 0.096829364980883, "naturalGas": 0.0814184741232, "petroleum": 0.141736062, "coal": 0.026349495473524, "total": 0.34633339657761}, "India": {"lowCarbon": 2.6016821274411, "naturalGas": 2.0361087770686, "petroleum": 8.92909155, "coal": 15.471257771568, "total": 29.038140226078}, "Denmark": {"lowCarbon": 0.19393181361676, "naturalGas": 0.12869022026067, "petroleum": 0.32958992, "coal": 0.08412404514705, "total": 0.73633599902448}, "Sri Lanka": {"lowCarbon": 0.042761538468458, "naturalGas": 0.0, "petroleum": 0.262175682, "coal": 0.056943248468458, "total": 0.36188046893692}, "Grenada": {"lowCarbon": 6.0703568e-05, "naturalGas": 0.0, "petroleum": 0.004041316368, "coal": 0.0, "total": 0.004102019936}, "Zimbabwe": {"lowCarbon": 0.033483824511727, "naturalGas": 0.0, "petroleum": 0.048758154, "coal": 0.075846840632876, "total": 0.1580888191446}, "Botswana": {"lowCarbon": 0.0052633480621975, "naturalGas": 0.0, "petroleum": 0.04267743, "coal": 0.028859178062197, "total": 0.076799956124395}, "Japan": {"lowCarbon": 1.902469303177, "naturalGas": 4.8304264708811, "petroleum": 8.118245358, "coal": 4.7983556213702, "total": 19.649496753428}, "American Samoa": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.0049863876851632, "coal": 0.0, "total": 0.0049863876851632}, "New Caledonia": {"lowCarbon": 0.0026945022378514, "naturalGas": 0.0, "petroleum": 0.04320867534, "coal": 0.026947026897851, "total": 0.072850204475703}, "Congo (Kinshasa)": {"lowCarbon": 0.08251772549955, "naturalGas": 0.0, "petroleum": 0.043195167744, "coal": 0.00029470175555021, "total": 0.1260075949991}, "Northern Mariana Islands": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.0, "coal": 0.0, "total": 0.0}, "Libya": {"lowCarbon": 0.00171624366653, "naturalGas": 0.18805153766653, "petroleum": 0.456307938, "coal": 0.0, "total": 0.64607571933306}, "Panama": {"lowCarbon": 0.064978864408526, "naturalGas": 0.0, "petroleum": 0.333161748, "coal": 0.0077223484085265, "total": 0.40586296081705}, "Namibia": {"lowCarbon": 0.022373228964139, "naturalGas": 0.0, "petroleum": 0.053690004, "coal": 0.00011797376413873, "total": 0.076181206728277}, "Haiti": {"lowCarbon": 0.000191186, "naturalGas": 0.0, "petroleum": 0.047535714, "coal": 0.0, "total": 0.0477269}, "Madagascar": {"lowCarbon": 0.0084280333406172, "naturalGas": 0.0, "petroleum": 0.037646315676, "coal": 0.012094405664617, "total": 0.058168754681234}, "Trinidad and Tobago": {"lowCarbon": 5.7061191721963e-05, "naturalGas": 0.77467574189748, "petroleum": 0.11833878, "coal": 5.611294241963e-06, "total": 0.89307719438344}, "Guadeloupe": {"lowCarbon": 0.000996211808, "naturalGas": 0.0, "petroleum": 0.027639107808, "coal": 0.0, "total": 0.028635319616}, "Samoa": {"lowCarbon": 0.000230952094, "naturalGas": 0.0, "petroleum": 0.004843208094, "coal": 0.0, "total": 0.005074160188}, "Wake Island": {"lowCarbon": 0.000373112, "naturalGas": 0.0, "petroleum": 0.019373112, "coal": 0.0, "total": 0.019746224}, "Senegal": {"lowCarbon": 0.003800633539793, "naturalGas": 0.0019048916394, "petroleum": 0.103390242, "coal": 0.009581899900393, "total": 0.11867766707959}, "Saint Kitts and Nevis": {"lowCarbon": 0.00057172898, "naturalGas": 0.0, "petroleum": 0.00349787298, "coal": 0.0, "total": 0.00406960196}, "Vanuatu": {"lowCarbon": 0.000381623648, "naturalGas": 0.0, "petroleum": 0.002289303648, "coal": 0.0, "total": 0.002670927296}, "Falkland Islands (Islas Malvinas)": {"lowCarbon": 0.000691450272, "naturalGas": 0.0, "petroleum": 0.000608362272, "coal": 0.0, "total": 0.001299812544}, "Tunisia": {"lowCarbon": 0.0052410590285987, "naturalGas": 0.1832805644942, "petroleum": 0.193889964, "coal": 4.8450020224269e-05, "total": 0.38246003754302}, "Canada": {"lowCarbon": 4.8608181881896, "naturalGas": 4.0714260840747, "petroleum": 5.031087482, "coal": 0.7128615739967, "total": 14.676193328261}, "Azerbaijan": {"lowCarbon": 0.016741332195755, "naturalGas": 0.3945951842928, "petroleum": 0.197450046, "coal": 4.0139029550335e-06, "total": 0.60879057639151}, "Taiwan": {"lowCarbon": 0.42239959151403, "naturalGas": 0.802704372964, "petroleum": 2.010851722374, "coal": 1.5287134891449, "total": 4.764669175997}, "Benin": {"lowCarbon": 0.0036560823827112, "naturalGas": 0.0, "petroleum": 0.072772512, "coal": 0.0019857511827112, "total": 0.078414345565422}, "Western Sahara": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.003654737652, "coal": 0.0, "total": 0.003654737652}, "El Salvador": {"lowCarbon": 0.035657776237372, "naturalGas": 0.0, "petroleum": 0.103190772, "coal": 0.0, "total": 0.13884854823737}, "Cape Verde": {"lowCarbon": 0.000522355578, "naturalGas": 0.0, "petroleum": 0.011829955578, "coal": 0.0, "total": 0.012352311156}, "Armenia": {"lowCarbon": 0.044061496845146, "naturalGas": 0.0819354718344, "petroleum": 0.012106914, "coal": 2.7224010746056e-05, "total": 0.13813110669029}, "Reunion": {"lowCarbon": 0.006638425252, "naturalGas": 0.0, "petroleum": 0.037769817252, "coal": 0.0, "total": 0.044408242504}, "Tonga": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.001895233278, "coal": 0.0, "total": 0.001895233278}, "Cote dIvoire (IvoryCoast)": {"lowCarbon": 0.0093279885079, "naturalGas": 0.0816591534759, "petroleum": 0.102387787032, "coal": 0.0, "total": 0.1933749290158}, "Costa Rica": {"lowCarbon": 0.098516825356774, "naturalGas": 0.0, "petroleum": 0.110030214, "coal": 2.9117811610009e-06, "total": 0.20854995113793}, "Gambia, The": {"lowCarbon": 0.00016632873, "naturalGas": 0.0, "petroleum": 0.00812847753, "coal": 0.0, "total": 0.00829480626}, "Israel": {"lowCarbon": 0.0, "naturalGas": 0.35986488574228, "petroleum": 0.448797091, "coal": 0.22891978358273, "total": 1.037581760325}, "Central African Republic": {"lowCarbon": 0.001345990044, "naturalGas": 0.0, "petroleum": 0.005772857244, "coal": 0.0, "total": 0.007118847288}, "Uzbekistan": {"lowCarbon": 0.10422676781543, "naturalGas": 1.490848411914, "petroleum": 0.100542396, "coal": 0.068440359901428, "total": 1.7640579356309}, "Somalia": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.011670568434, "coal": 0.0, "total": 0.011670568434}, "Thailand": {"lowCarbon": 0.33106521599002, "naturalGas": 1.7930740198668, "petroleum": 2.613536094, "coal": 0.68092917126946, "total": 5.4186045011263}, "Afghanistan": {"lowCarbon": 0.025484870871233, "naturalGas": 0.00611188334577, "petroleum": 0.070188915072, "coal": 0.035376120453463, "total": 0.13716178974247}, "Hawaiian Trade Zone": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.0, "coal": 0.0, "total": 0.0}, "Bahamas, The": {"lowCarbon": 0.00031657526, "naturalGas": 0.0, "petroleum": 0.04229811126, "coal": 0.0, "total": 0.04261468652}, "Syria": {"lowCarbon": 0.0080251997364348, "naturalGas": 0.138655691505, "petroleum": 0.291880974, "coal": 9.2137597955018e-05, "total": 0.43865400283939}, "Saudi Arabia": {"lowCarbon": 0.0, "naturalGas": 3.9148542669951, "petroleum": 6.917214804, "coal": 0.002686375934148, "total": 10.834755446929}, "Bermuda": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.010815029526, "coal": 0.0, "total": 0.010815029526}, "Jordan": {"lowCarbon": 0.010953938256408, "naturalGas": 0.1494490072358, "petroleum": 0.230370648, "coal": 0.0045060322015808, "total": 0.39527962569379}, "Turks and Caicos Islands": {"lowCarbon": 2.7369e-05, "naturalGas": 0.0, "petroleum": 0.003027369, "coal": 0.0, "total": 0.003054738}, "Singapore": {"lowCarbon": 0.014594789876691, "naturalGas": 0.45773754778744, "petroleum": 3.024075732, "coal": 0.015205050769448, "total": 3.5116131204336}, "Lesotho": {"lowCarbon": 0.005946911382, "naturalGas": 0.0, "petroleum": 0.009965915382, "coal": 0.0, "total": 0.015912826764}, "Peru": {"lowCarbon": 0.23864932416147, "naturalGas": 0.35395040753241, "petroleum": 0.4826442, "coal": 0.028332701182218, "total": 1.1035766328761}, "Malawi": {"lowCarbon": 0.013158819322153, "naturalGas": 0.0, "petroleum": 0.012297099678, "coal": 0.0019369196441526, "total": 0.027392838644305}, "Serbia": {"lowCarbon": 0.11187460846178, "naturalGas": 0.0827379774886, "petroleum": 0.1513052235, "coal": 0.30988297879486, "total": 0.65580078824525}, "Spain": {"lowCarbon": 1.5372108205667, "naturalGas": 1.1032541246895, "petroleum": 2.69505513, "coal": 0.40257410245661, "total": 5.7380941777128}, "Latvia": {"lowCarbon": 0.036027561241689, "naturalGas": 0.050158412092881, "petroleum": 0.077821013, "coal": 0.0014552649488079, "total": 0.16546225128338}, "Zambia": {"lowCarbon": 0.10535130360171, "naturalGas": 0.0, "petroleum": 0.04570059, "coal": 0.004091181601714, "total": 0.15514307520343}, "Gibraltar": {"lowCarbon": 0.000339694, "naturalGas": 0.0, "petroleum": 0.170339694, "coal": 0.0, "total": 0.170679388}, "Montenegro": {"lowCarbon": 0.018461183706409, "naturalGas": 0.0, "petroleum": 0.014084778, "coal": 0.012490757706409, "total": 0.045036719412818}, "Seychelles": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.01559496354, "coal": 0.0, "total": 0.01559496354}, "Belgium": {"lowCarbon": 0.59109448439486, "naturalGas": 0.62288610905623, "petroleum": 1.366870113, "coal": 0.10175951146345, "total": 2.6826102179145}, "Montserrat": {"lowCarbon": 0.000813569688, "naturalGas": 0.0, "petroleum": 0.000813569688, "coal": 0.0, "total": 0.001627139376}, "South Sudan": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.016809496476, "coal": 0.0, "total": 0.016809496476}, "Finland": {"lowCarbon": 0.58256949980587, "naturalGas": 0.090526945831532, "petroleum": 0.430688971, "coal": 0.12716166883571, "total": 1.2309470854731}, "Cuba": {"lowCarbon": 0.0070884369154522, "naturalGas": 0.0417237012384, "petroleum": 0.330716136, "coal": 4.8659346281927e-05, "total": 0.37957693350013}, "Bahrain": {"lowCarbon": 0.0, "naturalGas": 0.566823814047, "petroleum": 0.126554016, "coal": 0.0, "total": 0.693377830047}, "Mongolia": {"lowCarbon": 0.0063021545425656, "naturalGas": 0.0, "petroleum": 0.042830052, "coal": 0.14363937454257, "total": 0.19277158108513}, "Honduras": {"lowCarbon": 0.041462300334878, "naturalGas": 0.0, "petroleum": 0.121565802, "coal": 0.0042214726575307, "total": 0.16724957499241}, "Cyprus": {"lowCarbon": 0.0038687285943874, "naturalGas": 0.0, "petroleum": 0.110959854, "coal": 3.7385943874387e-06, "total": 0.11483232118877}, "Fiji": {"lowCarbon": 0.004722150156, "naturalGas": 0.0, "petroleum": 0.033069222156, "coal": 0.0, "total": 0.037791372312}, "Niger": {"lowCarbon": 0.0031571291008242, "naturalGas": 0.0, "petroleum": 0.024068892, "coal": 0.0053841291008242, "total": 0.032610150201648}, "Oman": {"lowCarbon": 0.00047138028686415, "naturalGas": 0.78627582102429, "petroleum": 0.376823718, "coal": 0.0023718412625742, "total": 1.1659427605737}, "Malaysia": {"lowCarbon": 0.19048420758354, "naturalGas": 1.1009127704445, "petroleum": 1.38236736, "coal": 0.63261216113904, "total": 3.3063764991671}, "Martinique": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.036558882462, "coal": 0.0, "total": 0.036558882462}, "Austria": {"lowCarbon": 0.50282454788642, "naturalGas": 0.31665142433356, "petroleum": 0.560111435, "coal": 0.09836699416625, "total": 1.4779544013862}, "Switzerland": {"lowCarbon": 0.57971485854532, "naturalGas": 0.1331689638516, "petroleum": 0.46927975, "coal": 0.0025175224894365, "total": 1.1846810948864}, "Gabon": {"lowCarbon": 0.0101386627809, "naturalGas": 0.0140134507809, "petroleum": 0.044125692, "coal": 0.0, "total": 0.0682778055618}, "Russia": {"lowCarbon": 3.6099503623004, "naturalGas": 15.893471808659, "petroleum": 7.2304034196, "coal": 4.7513061378308, "total": 31.48513172839}, "Lithuania": {"lowCarbon": 0.049943871991733, "naturalGas": 0.0803703949598, "petroleum": 0.126175206, "coal": 0.0064402084027089, "total": 0.26292968135424}, "China": {"lowCarbon": 15.919730858417, "naturalGas": 7.6424075079, "petroleum": 25.693921084782, "coal": 89.941695111949, "total": 139.19775456305}, "Rwanda": {"lowCarbon": 0.002915854604, "naturalGas": 0.0, "petroleum": 0.013782386604, "coal": 0.0, "total": 0.016698241208}, "French Polynesia": {"lowCarbon": 0.002101169406, "naturalGas": 0.0, "petroleum": 0.014002735806, "coal": 0.0, "total": 0.016103905212}, "Cayman Islands": {"lowCarbon": 7.5835956e-05, "naturalGas": 0.0, "petroleum": 0.009075835956, "coal": 0.0, "total": 0.009151671912}, "Congo (Brazzaville)": {"lowCarbon": 0.008692972656, "naturalGas": 0.05176475841, "petroleum": 0.035175155046, "coal": 0.0, "total": 0.095632886112}, "Uganda": {"lowCarbon": 0.029885055854, "naturalGas": 0.0, "petroleum": 0.065291899854, "coal": 0.0, "total": 0.095176955708}, "Poland": {"lowCarbon": 0.025431712228001, "naturalGas": 0.64102548035373, "petroleum": 1.173931782, "coal": 2.2909029913584, "total": 4.1312919659401}, "United Kingdom": {"lowCarbon": 1.4961032928814, "naturalGas": 3.0476469487863, "petroleum": 3.242847522, "coal": 0.98289037461205, "total": 8.7694881382798}, "Mali": {"lowCarbon": 0.01357753924, "naturalGas": 0.0, "petroleum": 0.04621267524, "coal": 0.0, "total": 0.05979021448}, "Nepal": {"lowCarbon": 0.046879916780617, "naturalGas": 0.0, "petroleum": 0.083214126, "coal": 0.004074318780617, "total": 0.13416836156123}, "Belarus": {"lowCarbon": 0.016034353012278, "naturalGas": 0.6303685839137, "petroleum": 0.284674068, "coal": 0.014236299706254, "total": 0.94531330463223}, "Kyrgyzstan": {"lowCarbon": 0.10615672640486, "naturalGas": 0.0069448329391305, "petroleum": 0.080379822, "coal": 0.036322842278938, "total": 0.22980422362293}, "Philippines": {"lowCarbon": 0.20195152100634, "naturalGas": 0.113527326537, "petroleum": 0.868557162, "coal": 0.44518616174495, "total": 1.6292221712883}, "Saint Vincent/Grenadines": {"lowCarbon": 0.000483821574, "naturalGas": 0.0, "petroleum": 0.003234557574, "coal": 0.0, "total": 0.003718379148}, "Turkey": {"lowCarbon": 0.85821249024803, "naturalGas": 1.6841332976694, "petroleum": 1.915974989, "coal": 1.5107369241704, "total": 5.9690577010878}, "Maldives": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.022927646904, "coal": 0.0, "total": 0.022927646904}, "Laos": {"lowCarbon": 0.092053346183116, "naturalGas": 0.0, "petroleum": 0.037500198594, "coal": 0.068886435589116, "total": 0.19843998036623}, "Korea, South": {"lowCarbon": 1.666736578782, "naturalGas": 1.8146898807688, "petroleum": 5.667827666, "coal": 3.8119035271016, "total": 12.961157652652}, "Sao Tome and Principe": {"lowCarbon": 0.000128930962, "naturalGas": 0.0, "petroleum": 0.002073538962, "coal": 0.0, "total": 0.002202469924}, "Papua New Guinea": {"lowCarbon": 0.007451531078, "naturalGas": 0.0036974805, "petroleum": 0.079620658578, "coal": 0.0, "total": 0.090769670156}, "Saint Pierre and Miquelon": {"lowCarbon": 0.0003861518, "naturalGas": 0.0, "petroleum": 0.0013861518, "coal": 0.0, "total": 0.0017723036}, "Netherlands": {"lowCarbon": 0.20551513591495, "naturalGas": 1.3136844343206, "petroleum": 2.027681102, "coal": 0.42716694829576, "total": 3.9740476205313}, "Kuwait": {"lowCarbon": 0.0010560998323285, "naturalGas": 0.8230957094418, "petroleum": 0.766062888, "coal": 0.0082789583905285, "total": 1.5984936556647}, "Bhutan": {"lowCarbon": 0.053983833523062, "naturalGas": 0.0, "petroleum": 0.006138540654, "coal": 0.0014581864690615, "total": 0.061580560646123}, "Nigeria": {"lowCarbon": 0.050905978689176, "naturalGas": 0.6836642474748, "petroleum": 0.849796734, "coal": 0.0041243092143758, "total": 1.5884912693784}, "Greece": {"lowCarbon": 0.17026112222, "naturalGas": 0.15143948203345, "petroleum": 0.615374764, "coal": 0.18203172418655, "total": 1.11910709244}, "Sudan": {"lowCarbon": 0.073518354, "naturalGas": 0.0, "petroleum": 0.283735278, "coal": 0.0, "total": 0.357253632}, "Bangladesh": {"lowCarbon": 0.0065967135818162, "naturalGas": 1.0838764966769, "petroleum": 0.240821778, "coal": 0.042159078904916, "total": 1.3734540671636}, "Ukraine": {"lowCarbon": 0.94113347100558, "naturalGas": 1.1338369952726, "petroleum": 0.48436074, "coal": 1.3302019647554, "total": 3.8895331710336}, "Suriname": {"lowCarbon": 0.01047436, "naturalGas": 0.0, "petroleum": 0.027876024, "coal": 0.0, "total": 0.038350384}, "Paraguay": {"lowCarbon": 0.41784586, "naturalGas": 0.0, "petroleum": 0.103203216, "coal": 0.0, "total": 0.521049076}, "Bulgaria": {"lowCarbon": 0.21239037022988, "naturalGas": 0.115445166888, "petroleum": 0.19425999, "coal": 0.23353249370026, "total": 0.75562802081814}, "Romania": {"lowCarbon": 0.37588991036028, "naturalGas": 0.3829039908867, "petroleum": 0.410182056, "coal": 0.20148479638377, "total": 1.3704607536307}, "Iran": {"lowCarbon": 0.20868714446599, "naturalGas": 7.4073211964928, "petroleum": 3.607034365998, "coal": 0.037102790929265, "total": 11.260145497886}, "Virgin Islands, U.S.": {"lowCarbon": 0.00020840803255366, "naturalGas": 0.0, "petroleum": 0.033931448032554, "coal": 0.0, "total": 0.034139856065107}, "Aruba": {"lowCarbon": 0.001354786202, "naturalGas": 0.0, "petroleum": 0.017071538202, "coal": 0.0, "total": 0.018426324404}, "Chile": {"lowCarbon": 0.30749577657131, "naturalGas": 0.17755430714054, "petroleum": 0.713098403, "coal": 0.28182062499035, "total": 1.4799691117022}, "Georgia": {"lowCarbon": 0.10648579406484, "naturalGas": 0.0827959959306, "petroleum": 0.066662142, "coal": 0.0072153569902166, "total": 0.26315928898566}, "Mauritania": {"lowCarbon": 0.002614556944, "naturalGas": 0.0, "petroleum": 0.035669548944, "coal": 0.0, "total": 0.038284105888}, "Guam": {"lowCarbon": 0.00078717204949526, "naturalGas": 0.0, "petroleum": 0.027177860049495, "coal": 0.0, "total": 0.027965032098991}, "U.S. Territories": {"lowCarbon": 0.0, "naturalGas": 0.0, "petroleum": 0.0, "coal": 0.0, "total": 0.0}, "Iraq": {"lowCarbon": 0.072020403988429, "naturalGas": 0.040755229988429, "petroleum": 1.789107186, "coal": 0.0, "total": 1.9018828199769}, "Portugal": {"lowCarbon": 0.28179125768402, "naturalGas": 0.19092263616233, "petroleum": 0.49387699, "coal": 0.11849225288294, "total": 1.0850831367293}, "Mauritius": {"lowCarbon": 0.0059687291968106, "naturalGas": 0.0, "petroleum": 0.0587979, "coal": 0.018050013196811, "total": 0.082816642393621}, "Nicaragua": {"lowCarbon": 0.022884408, "naturalGas": 0.0, "petroleum": 0.076172652, "coal": 0.0, "total": 0.09905706}, "Cook Islands": {"lowCarbon": 0.000278085972, "naturalGas": 0.0, "petroleum": 0.001241157972, "coal": 0.0, "total": 0.001519243944}, "Colombia": {"lowCarbon": 0.41349291706112, "naturalGas": 0.35767945571901, "petroleum": 0.721918164, "coal": 0.27460704131425, "total": 1.7676975780944}, "Niue": {"lowCarbon": 0.000104182998, "naturalGas": 0.0, "petroleum": 0.000104182998, "coal": 0.0, "total": 0.000208365996}, "Italy": {"lowCarbon": 1.1576028011613, "naturalGas": 2.5607623942284, "petroleum": 2.544079798, "coal": 0.46155591077465, "total": 6.7240009041643}, "Liberia": {"lowCarbon": 0.000269998202, "naturalGas": 0.0, "petroleum": 0.016269998202, "coal": 0.0, "total": 0.016539996404}, "Korea, North": {"lowCarbon": 0.11677559405865, "naturalGas": 0.0, "petroleum": 0.038814241806, "coal": 0.22777398168979, "total": 0.38336381755444}, "United States": {"lowCarbon": 17.411670558999, "naturalGas": 28.400352, "petroleum": 39.123619559, "coal": 14.225972641795, "total": 99.161614759795}, "Saint Lucia": {"lowCarbon": 0.000273128386, "naturalGas": 0.0, "petroleum": 0.006263896386, "coal": 0.0, "total": 0.006537024772}, "Vietnam": {"lowCarbon": 0.59633100494592, "naturalGas": 0.3293502569224, "petroleum": 0.95555463, "coal": 1.317919928032, "total": 3.1991558199004}, "Morocco": {"lowCarbon": 0.059396039414313, "naturalGas": 0.046524151185, "petroleum": 0.537733788, "coal": 0.13768847622931, "total": 0.78134245482863}, "Faroe Islands": {"lowCarbon": 0.001468471252, "naturalGas": 0.0, "petroleum": 0.010009815252, "coal": 0.0, "total": 0.011478286504}, "Jamaica": {"lowCarbon": 0.0052973359175368, "naturalGas": 0.00063499117647058, "petroleum": 0.11570175, "coal": 0.0020307067410662, "total": 0.12366478383507}} -------------------------------------------------------------------------------- /energyusage/data/json/energy-mix-us_2016.json: -------------------------------------------------------------------------------- 1 | {"Rhode Island": {"netGeneration": 6564885.1, "mix": {"oil": 0.400354469935055, "solar": 0.223355013002898, "coal": 0.0, "wind": 0.404150256086264, "biomass": 3.11926403042916, "hydro": 0.0324148856080043, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 0.0, "gas": 95.8204613449386}, "nameplateCapacity": 2398.0}, "North Dakota": {"netGeneration": 37856451.758, "mix": {"oil": 0.0795164301827238, "solar": 0.0, "coal": 70.2135259347657, "wind": 21.5866031525464, "biomass": 0.0148085722395754, "hydro": 5.05067145289499, "geothermal": 0.0, "unknown": 0.104035106864687, "otherFossil": 0.121430683315052, "nuclear": 0.0, "gas": 2.82940866719082}, "nameplateCapacity": 9442.3}, "Alaska": {"netGeneration": 6335033.511, "mix": {"oil": 13.1177817525334, "solar": 0.0, "coal": 9.37508349654355, "wind": 2.67144757377534, "biomass": 0.678771307669188, "hydro": 26.1802209374103, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 0.0, "gas": 47.9766949320682}, "nameplateCapacity": 3439.3}, "Maryland": {"netGeneration": 37166746.524, "mix": {"oil": 0.432115094511355, "solar": 0.561387648808749, "coal": 37.1991610016348, "wind": 1.4181900876279, "biomass": 2.34091930077492, "hydro": 3.74565237031159, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 39.7119725771528, "gas": 14.5906019191779}, "nameplateCapacity": 18265.2}, "New Mexico": {"netGeneration": 32922552.001, "mix": {"oil": 0.156982687189679, "solar": 2.31556475971366, "coal": 55.7832509209687, "wind": 10.9512198728546, "biomass": 0.0541069607331151, "hydro": 0.449454836765536, "geothermal": 0.0431862032623226, "unknown": 0.000847443431578843, "otherFossil": 0.0, "nuclear": 0.0, "gas": 30.2453863150808}, "nameplateCapacity": 13285.9}, "Arizona": {"netGeneration": 108734630.779, "mix": {"oil": 0.0474497764901804, "solar": 3.43739326254438, "coal": 27.9609257579863, "wind": 0.498073838066132, "biomass": 0.197155599400995, "hydro": 6.64585842381067, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 29.7764221046636, "gas": 31.4367212370378}, "nameplateCapacity": 40134.7}, "Oregon": {"netGeneration": 60181811.826, "mix": {"oil": 0.00805865072291105, "solar": 0.0680200182258296, "coal": 3.15408787957563, "wind": 11.8924168703487, "biomass": 1.73047554638906, "hydro": 57.4078691171161, "geothermal": 0.305239333302836, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 0.0, "gas": 25.4338325843189}, "nameplateCapacity": 19278.2}, "Alabama": {"netGeneration": 142863240.209, "mix": {"oil": 0.0320812876526775, "solar": 0.0218817660739702, "coal": 23.9798603432318, "wind": 0.0, "biomass": 2.33457241144212, "hydro": 5.22383854364561, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0168364122124984, "nuclear": 27.9301232266998, "gas": 40.4608060090415}, "nameplateCapacity": 38353.5}, "Virginia": {"netGeneration": 92554816.451, "mix": {"oil": 0.578425695153699, "solar": 0.0225898561547833, "coal": 17.8266381936999, "wind": 0.0, "biomass": 4.91986446946641, "hydro": 0.333668209147557, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 32.1235522890339, "gas": 44.1952612873437}, "nameplateCapacity": 34581.2}, "Colorado": {"netGeneration": 54418479.931, "mix": {"oil": 0.0128164274462212, "solar": 0.988835153985018, "coal": 55.0340160825281, "wind": 17.3125085611163, "biomass": 0.298253461236163, "hydro": 2.95558604633453, "geothermal": 0.0, "unknown": 0.0981063786604004, "otherFossil": 0.0, "nuclear": 0.0, "gas": 23.2998778886932}, "nameplateCapacity": 19872.6}, "Louisiana": {"netGeneration": 106842115.053, "mix": {"oil": 4.51060385878939, "solar": 0.0, "coal": 11.2443007965254, "wind": 0.0, "biomass": 2.69207760273855, "hydro": 1.03238595110488, "geothermal": 0.0, "unknown": 0.649419204816255, "otherFossil": 1.995293152188, "nuclear": 16.0534315224573, "gas": 61.8224879113802}, "nameplateCapacity": 36571.7}, "Mississippi": {"netGeneration": 62881294.963, "mix": {"oil": 0.0282839006551713, "solar": 0.0, "coal": 8.49541348114511, "wind": 0.0, "biomass": 2.42393331232631, "hydro": 0.0, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.00838461422035819, "nuclear": 9.37842008949327, "gas": 79.6655646021598}, "nameplateCapacity": 19599.7}, "Missouri": {"netGeneration": 78611512.544, "mix": {"oil": 0.0938663714822434, "solar": 0.0415766076953379, "coal": 76.7341676411401, "wind": 1.42712303791056, "biomass": 0.176360042251555, "hydro": 1.84155470470997, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0114222354425749, "nuclear": 11.9959262262824, "gas": 7.67800313308529}, "nameplateCapacity": 24747.7}, "Iowa": {"netGeneration": 54396530.724, "mix": {"oil": 0.510644158571517, "solar": 0.000277591232971245, "coal": 46.3234452100955, "wind": 36.9068077995302, "biomass": 0.462740086914409, "hydro": 1.68538138334089, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.022283274071317, "nuclear": 8.64515612980608, "gas": 5.44326436643707}, "nameplateCapacity": 22303.9}, "Texas": {"netGeneration": 453941342.056, "mix": {"oil": 0.0432703346914266, "solar": 0.160992166240827, "coal": 26.7062991106578, "wind": 12.6736163184591, "biomass": 0.370685631863286, "hydro": 0.295634011652853, "geothermal": 0.0, "unknown": 0.144483337222404, "otherFossil": 0.554282657036034, "nuclear": 9.26979790200154, "gas": 49.7809385301747}, "nameplateCapacity": 182433.5}, "Oklahoma": {"netGeneration": 78655008.003, "mix": {"oil": 0.0219455716971364, "solar": 0.0069111938235462, "coal": 24.3570561777216, "wind": 25.5153355935538, "biomass": 0.467638568809724, "hydro": 3.16063158376871, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0283195295391412, "nuclear": 0.0, "gas": 46.4421617810863}, "nameplateCapacity": 33525.2}, "U.S.": {"netGeneration": 4075322641.089, "mix": {"oil": 0.593638604155216, "solar": 0.881937072788413, "coal": 30.4034440970752, "wind": 5.56780957737731, "biomass": 1.71112161020832, "hydro": 6.40692342781077, "geothermal": 0.388298076428613, "unknown": 0.140815095004277, "otherFossil": 0.340778750119991, "nuclear": 19.7683069304823, "gas": 33.7969267585496}, "nameplateCapacity": 1515006.8}, "Michigan": {"netGeneration": 112121789.925, "mix": {"oil": 0.730436865892991, "solar": 0.00823657913825913, "coal": 36.1454028370175, "wind": 4.18810918198071, "biomass": 2.35007655237637, "hydro": 0.724841261349094, "geothermal": 0.0, "unknown": 0.00186101826593887, "otherFossil": 1.58249105030814, "nuclear": 28.1405691783868, "gas": 26.1279754752842}, "nameplateCapacity": 36977.2}, "Pennsylvania": {"netGeneration": 215066508.488, "mix": {"oil": 0.168652292280365, "solar": 0.0347824309890067, "coal": 25.4209872038413, "wind": 1.61635859510349, "biomass": 1.46520187301296, "hydro": 0.842847642902135, "geothermal": 0.0, "unknown": 0.00293444108779934, "otherFossil": 0.249873539132601, "nuclear": 38.557379978375, "gas": 31.6409820032753}, "nameplateCapacity": 68558.5}, "North Carolina": {"netGeneration": 130768152.699, "mix": {"oil": 0.192090640609279, "solar": 2.60776261862837, "coal": 28.6275972168915, "wind": 0.00476645106405565, "biomass": 1.95453554524712, "hydro": 3.3778759682066, "geothermal": 0.0, "unknown": 0.222989309133253, "otherFossil": 0.277544220702755, "nuclear": 32.719042179998, "gas": 30.015795849519}, "nameplateCapacity": 48223.6}, "New Hampshire": {"netGeneration": 19282493.05, "mix": {"oil": 0.201210252226213, "solar": 0.0, "coal": 2.18860205904539, "wind": 2.24205447801986, "biomass": 9.01526911004134, "hydro": 5.94003080472722, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 55.8079442567418, "gas": 24.6048890391982}, "nameplateCapacity": 4650.3}, "Kentucky": {"netGeneration": 80273501.005, "mix": {"oil": 1.51782791134958, "solar": 0.0146150346986756, "coal": 83.2429848118192, "wind": 0.0, "biomass": 0.579138339799489, "hydro": 4.33260037756264, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0622262907237682, "nuclear": 0.0, "gas": 10.2506072340467}, "nameplateCapacity": 31178.5}, "Ohio": {"netGeneration": 118922077.758, "mix": {"oil": 0.993395739314884, "solar": 0.0550988014865089, "coal": 57.8029332194481, "wind": 1.04665881730201, "biomass": 0.606897806174076, "hydro": 0.420500105170361, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.615739256244761, "nuclear": 14.1343791607182, "gas": 24.324397094141}, "nameplateCapacity": 46930.8}, "Indiana": {"netGeneration": 101397209.392, "mix": {"oil": 0.599855432825697, "solar": 0.221936575000556, "coal": 71.2792363847568, "wind": 4.81477919961092, "biomass": 0.44439506324001, "hydro": 0.418896366328742, "geothermal": 0.0, "unknown": 0.337687871555988, "otherFossil": 2.2332087632537, "nuclear": 0.0, "gas": 19.6500043434276}, "nameplateCapacity": 40933.2}, "Vermont": {"netGeneration": 1911207.085, "mix": {"oil": 0.210167648111503, "solar": 3.08867627089291, "coal": 0.0, "wind": 15.2355022600183, "biomass": 24.9839446755423, "hydro": 56.3788719381972, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 0.0, "gas": 0.102837207237784}, "nameplateCapacity": 796.3}, "New Jersey": {"netGeneration": 77598196.669, "mix": {"oil": 0.187840466788286, "solar": 1.05623353593692, "coal": 1.68979931987715, "wind": 0.0267904202739907, "biomass": 1.95655985151755, "hydro": 0.0, "geothermal": 0.0, "unknown": 0.0870029857005057, "otherFossil": 0.266307331208533, "nuclear": 38.4164253009358, "gas": 56.3130407877612}, "nameplateCapacity": 28577.0}, "Nebraska": {"netGeneration": 37197843.2, "mix": {"oil": 0.0, "solar": 0.0106970743959478, "coal": 58.8398611578095, "wind": 10.2063874211507, "biomass": 0.262838185793249, "hydro": 4.10962735327667, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 25.1253372451846, "gas": 1.44525156238933}, "nameplateCapacity": 10004.2}, "Tennessee": {"netGeneration": 79340633.31, "mix": {"oil": 0.153239840698565, "solar": 0.099087941172931, "coal": 39.2833183196113, "wind": 0.047575874371378, "biomass": 1.17640505095384, "hydro": 7.65070147719864, "geothermal": 0.0, "unknown": 0.000843403906167379, "otherFossil": 0.0432340184282968, "nuclear": 37.2798713455855, "gas": 14.2657227280735}, "nameplateCapacity": 27972.7}, "District Of Columbia": {"netGeneration": 76473.999, "mix": {"oil": 1.30841462457829, "solar": 0.0, "coal": 0.0, "wind": 0.0, "biomass": 69.005645055836, "hydro": 0.0, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 0.0, "gas": 29.6859403195857}, "nameplateCapacity": 24.9}, "South Dakota": {"netGeneration": 10289415.719, "mix": {"oil": 0.0271428920094766, "solar": 0.00353761583311981, "coal": 20.2409986596975, "wind": 30.6384063266924, "biomass": 0.0, "hydro": 40.162669178107, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 0.0, "gas": 8.9272453276606}, "nameplateCapacity": 5438.0}, "Connecticut": {"netGeneration": 36496559.656, "mix": {"oil": 0.251351199081465, "solar": 0.0671790164581009, "coal": 0.485992324632169, "wind": 0.0349128795302527, "biomass": 3.92767852879067, "hydro": 0.629461791630518, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0, "nuclear": 45.4165872979648, "gas": 49.186836961912}, "nameplateCapacity": 11788.5}, "Minnesota": {"netGeneration": 60036475.896, "mix": {"oil": 0.0511445406080547, "solar": 0.0168347660494798, "coal": 38.6536500501645, "wind": 17.4747253478972, "biomass": 3.63516628663332, "hydro": 2.01294568547713, "geothermal": 0.0, "unknown": 0.19491987542677, "otherFossil": 0.0, "nuclear": 23.0873250830994, "gas": 14.8732883646442}, "nameplateCapacity": 21832.4}, "Maine": {"netGeneration": 11514427.426, "mix": {"oil": 0.953425587860634, "solar": 0.0, "coal": 0.606396623673887, "wind": 14.4783842876034, "biomass": 25.3457416660948, "hydro": 26.0515580257956, "geothermal": 0.0, "unknown": 0.89064787469436, "otherFossil": 1.29038174518737, "nuclear": 0.0, "gas": 30.38346418909}, "nameplateCapacity": 5717.6}, "Wisconsin": {"netGeneration": 64966610.542, "mix": {"oil": 0.226441317247121, "solar": 0.00411154276602436, "coal": 51.3538262497966, "wind": 2.33236884883508, "biomass": 2.28197931114237, "hydro": 4.302606618444, "geothermal": 0.0, "unknown": 0.0455988075835716, "otherFossil": 0.0110326487344699, "nuclear": 15.6255556883278, "gas": 23.8164789671229}, "nameplateCapacity": 23413.6}, "Montana": {"netGeneration": 27783529.992, "mix": {"oil": 1.65537902584312, "solar": 0.0, "coal": 51.3585643202464, "wind": 7.70309361324901, "biomass": 0.0725249844060513, "hydro": 36.2895909924844, "geothermal": 0.0, "unknown": 1.17648122098447, "otherFossil": 0.0309021940007306, "nuclear": 0.0, "gas": 1.71346364878582}, "nameplateCapacity": 7258.5}, "Hawaii": {"netGeneration": 9948844.667, "mix": {"oil": 66.7445925896695, "solar": 0.88966025257374, "coal": 15.0507873675246, "wind": 6.42413261828819, "biomass": 5.5918934228451, "hydro": 0.913161271920704, "geothermal": 2.61439391902078, "unknown": 1.13431920421758, "otherFossil": 0.637059353939782, "nuclear": 0.0, "gas": 0.0}, "nameplateCapacity": 3501.8}, "Kansas": {"netGeneration": 47599990.322, "mix": {"oil": 0.0595035411749648, "solar": 0.00441596725954311, "coal": 48.5211521866395, "wind": 29.6447138436294, "biomass": 0.123596663089172, "hydro": 0.0641554748677105, "geothermal": 0.0, "unknown": 2.10084075144772e-06, "otherFossil": 0.0, "nuclear": 17.3236210717495, "gas": 4.2588391507495}, "nameplateCapacity": 19888.2}, "South Carolina": {"netGeneration": 96985763.86, "mix": {"oil": 0.117400600775043, "solar": 0.00512549452752034, "coal": 21.6556663760401, "wind": 0.0, "biomass": 2.45020844561225, "hydro": 1.28830660818325, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0468312083825458, "nuclear": 57.5609388356085, "gas": 16.8755224308708}, "nameplateCapacity": 31484.7}, "West Virginia": {"netGeneration": 75942967.562, "mix": {"oil": 0.161501361424458, "solar": 0.0, "coal": 94.1514409510465, "wind": 1.88552341186101, "biomass": 0.0, "hydro": 2.1568581820887, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.0324548406679132, "nuclear": 0.0, "gas": 1.61222125291139}, "nameplateCapacity": 20625.5}, "Nevada": {"netGeneration": 39228694.003, "mix": {"oil": 0.0280029332624738, "solar": 6.54049048925975, "coal": 5.52358623029987, "wind": 0.876564996065205, "biomass": 0.14087647170415, "hydro": 4.56099558168115, "geothermal": 8.54833199435843, "unknown": 0.0536036198428428, "otherFossil": 0.00189263501873871, "nuclear": 0.0, "gas": 73.7256550485074}, "nameplateCapacity": 19953.8}, "Delaware": {"netGeneration": 8731261.003, "mix": {"oil": 0.716636049997522, "solar": 0.585087908890953, "coal": 5.49004150218474, "wind": 0.0609419447027341, "biomass": 0.778661904624091, "hydro": 0.0, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 3.17797535844454, "nuclear": 0.0, "gas": 89.1906553311554}, "nameplateCapacity": 4010.7}, "Idaho": {"netGeneration": 15660938.441, "mix": {"oil": 0.0011707152891251, "solar": 0.190288725251396, "coal": 0.1863762010766, "wind": 16.4639879037307, "biomass": 3.394262132981, "hydro": 57.680273573303, "geothermal": 0.459710639725991, "unknown": 0.415351867392129, "otherFossil": 0.0, "nuclear": 0.0, "gas": 21.20857824125}, "nameplateCapacity": 6212.4}, "California": {"netGeneration": 197323836.964, "mix": {"oil": 0.0885926066314154, "solar": 9.78143414455527, "coal": 0.161600251206906, "wind": 6.81259009984281, "biomass": 3.1025378432278, "hydro": 14.5358883353839, "geothermal": 5.80634312625006, "unknown": 0.244690631037569, "otherFossil": 0.723083279462725, "nuclear": 9.58200406171968, "gas": 49.1612356206819}, "nameplateCapacity": 106792.9}, "Arkansas": {"netGeneration": 60445059.072, "mix": {"oil": 0.0700855395293054, "solar": 0.0432491923393949, "coal": 39.3747160179087, "wind": 0.0, "biomass": 2.2662363220001, "hydro": 5.9703969782852, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.00932544868986719, "nuclear": 22.2036707929482, "gas": 30.0623197082992}, "nameplateCapacity": 19535.8}, "New York": {"netGeneration": 134090832.639, "mix": {"oil": 0.476908093068945, "solar": 0.104116737315042, "coal": 1.32017813965061, "wind": 2.938440997013, "biomass": 2.32282244229962, "hydro": 19.7010500097137, "geothermal": 0.0, "unknown": 0.0207366897864929, "otherFossil": 0.0, "nuclear": 31.0021119092066, "gas": 42.1136349819461}, "nameplateCapacity": 51335.7}, "_define": {"netGeneration": "Net Generation (MWh)", "mix": {"coal": "Coal", "_units": "percentage", "biomass": "Biomass", "geothermal": "Geo-thermal", "solar": "Solar", "oil": "Oil", "gas": "Gas", "hydro": "Hydro", "wind": "Wind", "unknown": "Other unknown/purchased fuel", "otherFossil": "Other Fossil", "nuclear": "Nuclear"}, "nameplateCapacity": "Nameplate Capacity (MW)"}, "Florida": {"netGeneration": 238226428.16, "mix": {"oil": 1.1838750530123, "solar": 0.0940210545503543, "coal": 16.5512567857852, "wind": 0.0, "biomass": 2.56014508230251, "hydro": 0.073271047770674, "geothermal": 0.0, "unknown": 0.703383691618647, "otherFossil": 0.00998623795896645, "nuclear": 12.3076277569261, "gas": 66.5164332900752}, "nameplateCapacity": 100751.4}, "Wyoming": {"netGeneration": 46656629.978, "mix": {"oil": 0.119244714935337, "solar": 0.0, "coal": 85.7903235585195, "wind": 9.40774752906873, "biomass": 0.0, "hydro": 2.08649484593123, "geothermal": 0.0, "unknown": 0.139344691950248, "otherFossil": 0.767604330633421, "nuclear": 0.0, "gas": 1.68924032896151}, "nameplateCapacity": 13744.3}, "Georgia": {"netGeneration": 132902274.317, "mix": {"oil": 0.159399416679368, "solar": 0.662835154951894, "coal": 28.5100273720157, "wind": 0.0, "biomass": 3.44118703930145, "hydro": 1.43075880448999, "geothermal": 0.0, "unknown": 0.00257976471936003, "otherFossil": 0.0733993681054065, "nuclear": 25.9443730491926, "gas": 39.7754400305443}, "nameplateCapacity": 51336.4}, "Illinois": {"netGeneration": 187437381.035, "mix": {"oil": 0.0370806331138922, "solar": 0.026040696597145, "coal": 31.6573998349036, "wind": 5.68906473013071, "biomass": 0.249156281206178, "hydro": 0.0708684673588436, "geothermal": 0.0, "unknown": 0.225905150350681, "otherFossil": 0.110479676254971, "nuclear": 52.6079893239325, "gas": 9.32601520615151}, "nameplateCapacity": 62747.6}, "Washington": {"netGeneration": 114086582.682, "mix": {"oil": 0.0192530893353324, "solar": 0.000637233831047834, "coal": 4.03352910743163, "wind": 7.04888166782742, "biomass": 1.81228615931981, "hydro": 68.6700452649127, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.352049603218519, "nuclear": 8.43710038965381, "gas": 9.62621748446973}, "nameplateCapacity": 34016.1}, "Massachusetts": {"netGeneration": 31951671.137, "mix": {"oil": 1.32162439213174, "solar": 1.89638759911684, "coal": 5.86802379880449, "wind": 0.676406392655579, "biomass": 6.45211987271173, "hydro": 0.663708684576483, "geothermal": 0.0, "unknown": 0.0, "otherFossil": 0.00165159746509087, "nuclear": 16.9453355971823, "gas": 66.1747420653558}, "nameplateCapacity": 19517.4}, "Utah": {"netGeneration": 38133928.003, "mix": {"oil": 0.0827400208531232, "solar": 2.7630539379768, "coal": 68.021954394508, "wind": 2.15630028844898, "biomass": 0.233006856628429, "hydro": 1.99177488220478, "geothermal": 1.27207981218714, "unknown": 0.545655931021808, "otherFossil": 0.141865959794474, "nuclear": 0.0, "gas": 22.7915679163765}, "nameplateCapacity": 11043.7}} -------------------------------------------------------------------------------- /energyusage/data/json/us-emissions_2016.json: -------------------------------------------------------------------------------- 1 | {"Rhode Island": 870.822, "North Dakota": 1663.754, "Alaska": 925.862, "Maryland": 1012.682, "New Mexico": 1572.786, "Arizona": 932.225, "Oregon": 305.891, "Alabama": 912.917, "Virginia": 813.802, "Colorado": 1468.373, "Louisiana": 878.85, "Mississippi": 940.716, "Missouri": 1687.742, "Iowa": 997.858, "Texas": 1049.527, "Oklahoma": 1043.716, "U.S.": 998.443, "Michigan": 1099.854, "Pennsylvania": 855.444, "North Carolina": 867.441, "South Carolina": 629.428, "Kentucky": 1954.301, "Ohio": 1465.96, "Indiana": 1812.703, "Vermont": 56.89, "New Jersey": 557.822, "Nebraska": 1281.153, "Tennessee": 992.271, "District Of Columbia": 481.786, "South Dakota": 513.316, "Connecticut": 498.467, "Minnesota": 1012.67, "Maine": 336.964, "Wisconsin": 1388.88, "Montana": 1251.022, "Hawaii": 1522.102, "Kansas": 1195.553, "New Hampshire": 310.564, "West Virginia": 1975.757, "Nevada": 769.912, "_unit": "lbs/MWh", "Delaware": 887.415, "Idaho": 188.695, "California": 452.541, "Arkansas": 1115.65, "New York": 464.02, "Florida": 1024.205, "Wyoming": 2026.26, "Georgia": 1001.754, "Illinois": 811.318, "Washington": 186.844, "Massachusetts": 821.327, "Utah": 1627.372} -------------------------------------------------------------------------------- /energyusage/data/raw/2016/egrid.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/responsibleproblemsolving/energy-usage/b6cd5d4ee07f7c4f0f1499405c385a05654a2b3a/energyusage/data/raw/2016/egrid.xlsx -------------------------------------------------------------------------------- /energyusage/evaluate.py: -------------------------------------------------------------------------------- 1 | import time 2 | import statistics 3 | from timeit import default_timer as timer 4 | from multiprocessing import Process, Queue 5 | import os 6 | import datetime 7 | import subprocess 8 | import queue 9 | import csv 10 | 11 | import utils as utils 12 | import convert as convert 13 | import locate as locate 14 | import report as report 15 | import graph 16 | 17 | DELAY = .1 # in seconds 18 | 19 | def func(user_func, q, *args): 20 | """ Runs the user's function and puts return value in queue """ 21 | 22 | value = user_func(*args) 23 | q.put(value) 24 | 25 | def energy(user_func, *args, powerLoss = 0.8, year, printToScreen, timeseries): 26 | """ Evaluates the kwh needed for your code to run 27 | 28 | Parameters: 29 | user_func (function): user's function 30 | 31 | Returns: 32 | (process_kwh, return_value, watt_averages) 33 | 34 | """ 35 | 36 | baseline_check_seconds = 5 37 | files, multiple_cpus = utils.get_files() 38 | is_nvidia_gpu = utils.valid_gpu() 39 | is_valid_cpu = utils.valid_cpu() 40 | 41 | # GPU handling if Nvidia 42 | gpu_baseline =[0] 43 | gpu_process = [0] 44 | bash_command = "nvidia-smi -i 0 --format=csv,noheader --query-gpu=power.draw" 45 | 46 | time_baseline = [] 47 | reading_baseline_wattage = [] 48 | 49 | time_process = [] 50 | reading_process_wattage = [] 51 | 52 | for i in range(int(baseline_check_seconds / DELAY)): 53 | if is_nvidia_gpu: 54 | output = subprocess.check_output(['bash','-c', bash_command]) 55 | output = float(output.decode("utf-8")[:-2]) 56 | gpu_baseline.append(output) 57 | if is_valid_cpu: 58 | files = utils.measure_files(files, DELAY) 59 | files = utils.update_files(files) 60 | else: 61 | time.sleep(DELAY) 62 | # Adds the most recent value of GPU; 0 if not Nvidia 63 | last_reading = utils.get_total(files, multiple_cpus) + gpu_baseline[-1] 64 | if last_reading >=0 and printToScreen: 65 | utils.log("Baseline wattage", last_reading) 66 | time = round(i* DELAY, 1) 67 | time_baseline.append(time) 68 | reading_baseline_wattage.append(last_reading) 69 | if timeseries: 70 | with open('baseline_wattage.csv', 'w') as baseline_wattage_file: 71 | baseline_wattage_writer = csv.writer(baseline_wattage_file) 72 | baseline_wattage_writer.writerow(["time", "baseline wattage reading"]) 73 | for i in range(len(time_baseline)): 74 | baseline_wattage_writer.writerow([time_baseline[i], reading_baseline_wattage[i]]) 75 | if printToScreen: 76 | utils.newline() 77 | 78 | # Running the process and measuring wattage 79 | q = Queue() 80 | p = Process(target = func, args = (user_func, q, *args,)) 81 | 82 | start = timer() 83 | small_delay_counter = 0 84 | return_value = None 85 | p.start() 86 | 87 | while(p.is_alive()): 88 | # Checking at a faster rate for quick processes 89 | if (small_delay_counter > DELAY): 90 | delay = DELAY / 10 91 | small_delay_counter+=1 92 | else: 93 | delay = DELAY 94 | 95 | if is_nvidia_gpu: 96 | output = subprocess.check_output(['bash','-c', bash_command]) 97 | output = float(output.decode("utf-8")[:-2]) 98 | gpu_process.append(output) 99 | if is_valid_cpu: 100 | files = utils.measure_files(files, delay) 101 | files = utils.update_files(files, True) 102 | else: 103 | time.sleep(delay) 104 | # Just output, not added 105 | last_reading = (utils.get_total(files, multiple_cpus) + gpu_process[-1]) / powerLoss 106 | if last_reading >=0 and printToScreen: 107 | utils.log("Process wattage", last_reading) 108 | time = round(timer()-start, 1) 109 | time_process.append(time) 110 | reading_process_wattage.append(last_reading) 111 | # Getting the return value of the user's function 112 | try: 113 | return_value = q.get_nowait() 114 | break 115 | except queue.Empty: 116 | pass 117 | if timeseries: 118 | with open('process_wattage.csv', 'w') as process_wattage_file: 119 | process_wattage_writer = csv.writer(process_wattage_file) 120 | process_wattage_writer.writerow(["time", "process wattage reading"]) 121 | for i in range(len(time_process)): 122 | process_wattage_writer.writerow([time_process[i], reading_process_wattage[i]]) 123 | p.join() 124 | end = timer() 125 | for file in files: 126 | file.process = file.process[1:-1] 127 | file.baseline = file.baseline[1:-1] 128 | if is_nvidia_gpu: 129 | gpu_baseline_average = statistics.mean(gpu_baseline[2:-1]) 130 | gpu_process_average = statistics.mean(gpu_process[2:-1]) 131 | else: 132 | gpu_baseline_average = 0 133 | gpu_process_average = 0 134 | 135 | total_time = end-start # seconds 136 | # Formatting the time nicely 137 | timedelta = str(datetime.timedelta(seconds=total_time)).split('.')[0] 138 | 139 | if files[0].process == []: 140 | raise Exception("Process executed too fast to gather energy consumption") 141 | files = utils.average_files(files) 142 | 143 | process_average = utils.get_process_average(files, multiple_cpus, gpu_process_average) 144 | baseline_average = utils.get_baseline_average(files, multiple_cpus, gpu_baseline_average) 145 | difference_average = process_average - baseline_average 146 | watt_averages = [baseline_average, process_average, difference_average, timedelta] 147 | 148 | # Subtracting baseline wattage to get more accurate result 149 | process_kwh = convert.to_kwh((process_average - baseline_average)*total_time) / powerLoss 150 | 151 | if is_nvidia_gpu: 152 | gpu_file = file("GPU", "") 153 | gpu_file.create_gpu(gpu_baseline_average, gpu_process_average) 154 | files.append(file("GPU", "")) 155 | 156 | # Logging 157 | if printToScreen: 158 | utils.log("Final Readings", baseline_average, process_average, difference_average, timedelta) 159 | return (process_kwh, return_value, watt_averages, files, total_time, time_baseline, reading_baseline_wattage, time_process, reading_process_wattage) 160 | 161 | 162 | def energy_mix(location, year = 2016): 163 | """ Gets the energy mix information for a specific location 164 | 165 | Parameters: 166 | location (str): user's location 167 | location_of_default (str): Specifies which average to use if 168 | location cannot be determined 169 | 170 | Returns: 171 | breakdown (list): percentages of each energy type 172 | """ 173 | if location == "Unknown": 174 | location = "United States" 175 | 176 | if locate.in_US(location): 177 | # Default to U.S. average for unknown location 178 | 179 | data = utils.get_data("data/json/energy-mix-us_" + year + ".json") 180 | s = data[location]['mix'] # get state 181 | coal, oil, gas = s['coal'], s['oil'], s['gas'] 182 | nuclear, hydro, biomass, wind, solar, geo, = \ 183 | s['nuclear'], s['hydro'], s['biomass'], s['wind'], \ 184 | s['solar'], s['geothermal'] 185 | 186 | low_carbon = sum([nuclear,hydro,biomass,wind,solar,geo]) 187 | breakdown = [coal, oil, gas, low_carbon] 188 | 189 | return breakdown # list of % of each 190 | 191 | else: 192 | data = utils.get_data("data/json/energy-mix-intl_" + year + ".json") 193 | c = data[location] # get country 194 | total, breakdown = c['total'], [c['coal'], c['petroleum'], \ 195 | c['naturalGas'], c['lowCarbon']] 196 | 197 | # Get percentages 198 | breakdown = list(map(lambda x: 100*x/total, breakdown)) 199 | 200 | return breakdown # list of % of each 201 | 202 | 203 | def emissions(process_kwh, breakdown, location, year, printToScreen): 204 | """ Calculates the CO2 emitted by the program based on the location 205 | 206 | Parameters: 207 | process_kwh (int): kWhs used by the process 208 | breakdown (list): energy mix corresponding to user's location 209 | location (str): location of user 210 | 211 | Returns: 212 | emission (float): kilograms of CO2 emitted 213 | state_emission (float): lbs CO2 per MWh; 0 if international location 214 | 215 | """ 216 | 217 | if process_kwh < 0: 218 | raise OSError("Process wattage lower than baseline wattage. Do not run other processes" 219 | " during the evaluation, or try evaluating a more resource-intensive process.") 220 | if printToScreen: 221 | utils.log("Energy Data", breakdown, location) 222 | state_emission = 0 223 | 224 | # Case 1: Unknown location, default to US data 225 | if location == "Unknown": 226 | location = "United States" 227 | # Case 2: United States location 228 | if locate.in_US(location): 229 | # US Emissions data is in lbs/Mwh 230 | data = utils.get_data("data/json/us-emissions_" + year + ".json") 231 | state_emission = data[location] 232 | emission = convert.lbs_to_kgs(state_emission*convert.to_MWh(process_kwh)) 233 | 234 | # Case 3: International location 235 | else: 236 | # Breaking down energy mix 237 | coal, petroleum, natural_gas, low_carbon = breakdown 238 | breakdown = [convert.coal_to_carbon(process_kwh * coal/100), 239 | convert.petroleum_to_carbon(process_kwh * petroleum/100), 240 | convert.natural_gas_to_carbon(process_kwh * natural_gas/100), 0] 241 | emission = sum(breakdown) 242 | if printToScreen: 243 | utils.log("Emissions", emission) 244 | return (emission, state_emission) 245 | 246 | 247 | #OLD VERSION: US, EU, Rest comparison 248 | def old_emissions_comparison(process_kwh, year, default_location, printToScreen): 249 | # Calculates emissions in different locations 250 | 251 | intl_data = utils.get_data("data/json/energy-mix-intl_" + year + ".json") 252 | global_emissions, europe_emissions, us_emissions = [], [], [] 253 | # Handling international 254 | for country in intl_data: 255 | c = intl_data[country] 256 | total, breakdown = c['total'], [c['coal'], c['petroleum'], \ 257 | c['naturalGas'], c['lowCarbon']] 258 | if isinstance(total, float) and float(total) > 0: 259 | breakdown = list(map(lambda x: 100*x/total, breakdown)) 260 | coal, petroleum, natural_gas, low_carbon = breakdown 261 | breakdown = [convert.coal_to_carbon(process_kwh * coal/100), 262 | convert.petroleum_to_carbon(process_kwh * petroleum/100), 263 | convert.natural_gas_to_carbon(process_kwh * natural_gas/100), 0] 264 | emission = sum(breakdown) 265 | if locate.in_Europe(country): 266 | europe_emissions.append((country,emission)) 267 | else: 268 | global_emissions.append((country,emission)) 269 | 270 | global_emissions.sort(key=lambda x: x[1]) 271 | europe_emissions.sort(key=lambda x: x[1]) 272 | 273 | # Handling US 274 | us_data = utils.get_data("data/json/us-emissions_" + year + ".json") 275 | for state in us_data: 276 | if ((state != "United States") and state != "_units"): 277 | if us_data[state] != "lbs/MWh": 278 | emission = convert.lbs_to_kgs(us_data[state]*convert.to_MWh(process_kwh)) 279 | us_emissions.append((state, emission)) 280 | us_emissions.sort(key=lambda x: x[1]) 281 | 282 | max_global, max_europe, max_us = global_emissions[len(global_emissions)-1], \ 283 | europe_emissions[len(europe_emissions)-1], us_emissions[len(us_emissions)-1] 284 | median_global, median_europe, median_us = global_emissions[len(global_emissions)//2], \ 285 | europe_emissions[len(europe_emissions)//2], us_emissions[len(us_emissions)//2] 286 | min_global, min_europe, min_us= global_emissions[0], europe_emissions[0], us_emissions[0] 287 | if default_location and printToScreen: 288 | utils.log('Emissions Comparison default', max_global, median_global, min_global, max_europe, \ 289 | median_europe, min_europe, max_us, median_us, min_us) 290 | default_emissions = [max_global, median_global, min_global, max_europe, \ 291 | median_europe, min_europe, max_us, median_us, min_us] 292 | return default_emissions 293 | 294 | 295 | def emissions_comparison(process_kwh, locations, year, default_location, printToScreen): 296 | # TODO: Disambiguation of states such as Georgia, US and Georgia 297 | intl_data = utils.get_data("data/json/energy-mix-intl_" + year + ".json") 298 | us_data = utils.get_data("data/json/us-emissions_" + year + ".json") 299 | emissions = [] # list of tuples w/ format (location, emission) 300 | 301 | for location in locations: 302 | if locate.in_US(location): 303 | emission = convert.lbs_to_kgs(us_data[location]*convert.to_MWh(process_kwh)) 304 | emissions.append((location, emission)) 305 | else: 306 | c = intl_data[location] 307 | total, breakdown = c['total'], [c['coal'], c['petroleum'], \ 308 | c['naturalGas'], c['lowCarbon']] 309 | if isinstance(total, float) and float(total) > 0: 310 | breakdown = list(map(lambda x: 100*x/total, breakdown)) 311 | coal, petroleum, natural_gas, low_carbon = breakdown 312 | breakdown = [convert.coal_to_carbon(process_kwh * coal/100), 313 | convert.petroleum_to_carbon(process_kwh * petroleum/100), 314 | convert.natural_gas_to_carbon(process_kwh * natural_gas/100), 0] 315 | emission = sum(breakdown) 316 | emissions.append((location,emission)) 317 | 318 | if emissions != [] and not default_location and printToScreen: 319 | utils.log('Emissions Comparison', emissions) 320 | return emissions 321 | 322 | 323 | def get_comparison_data(result, locations, year, printToScreen): 324 | geo = locate.get_location_information() 325 | location = locate.get(printToScreen, geo) 326 | default_location = False 327 | if locations == ["Mongolia", "Iceland", "Switzerland"]: 328 | default_location = True 329 | comparison_values = emissions_comparison(result, locations, year, default_location, printToScreen) 330 | default_emissions = old_emissions_comparison(result, year, default_location, printToScreen) 331 | return (location, default_location, comparison_values, default_emissions) 332 | 333 | def png_bar_chart(location, emission, default_emissions): 334 | default_emissions_list = [] 335 | for i in range(0, 9): 336 | rounded_default_emission = float(format((default_emissions[i])[1], '.3g')) 337 | default_emissions_list.append(rounded_default_emission) 338 | global_dict = {"Mongolia" : default_emissions_list[0], "South Korea": default_emissions_list[1], "Bhutan" : default_emissions_list[2]} 339 | eu_dict = {"Kosovo" : default_emissions_list[3], "Ukraine" : default_emissions_list[4], "Iceland" : default_emissions_list[5]} 340 | us_dict = {"Wyoming" : default_emissions_list[6], "Mississippi" : default_emissions_list[7], "Vermont" : default_emissions_list[8]} 341 | graph.make_comparison_bar_charts(location, emission, us_dict, eu_dict, global_dict) 342 | 343 | def evaluate(user_func, *args, pdf=False, png = False, timeseries=False, powerLoss=0.8, energyOutput=False, \ 344 | locations=["Mongolia", "Iceland", "Switzerland"], year="2016", printToScreen = True): 345 | """ Calculates effective emissions of the function 346 | 347 | Parameters: 348 | user_func: user's function + associated args 349 | pdf (bool): whether a PDF report should be generated 350 | powerLoss (float): PSU efficiency rating 351 | energyOutput (bool): return value also includes information about energy usage, not just function's return 352 | locations (list of strings): list of locations to be compared 353 | year (str): year of dataset to be used 354 | printToScreen (bool): get information in the command line 355 | 356 | """ 357 | try: 358 | utils.setGlobal(printToScreen) 359 | if (utils.valid_cpu() or utils.valid_gpu()): 360 | result, return_value, watt_averages, files, total_time, time_baseline, reading_baseline_wattage, time_process, reading_process_wattage = energy(user_func, *args, powerLoss = powerLoss, year = year, \ 361 | printToScreen = printToScreen, timeseries = timeseries) 362 | location, default_location, comparison_values, default_emissions = get_comparison_data(result, locations, year, printToScreen) 363 | breakdown = energy_mix(location, year = year) 364 | emission, state_emission = emissions(result, breakdown, location, year, printToScreen) 365 | if printToScreen: 366 | utils.log("Assumed Carbon Equivalencies") 367 | if printToScreen: 368 | utils.log("Process Energy", result) 369 | func_info = [user_func.__name__, *args] 370 | kwh_and_emissions = [result, emission, state_emission] 371 | if pdf: 372 | #pass 373 | report.generate(location, watt_averages, breakdown, kwh_and_emissions, \ 374 | func_info, comparison_values, default_emissions, default_location) 375 | if png: 376 | # generate energy mix pie chart 377 | energy_dict = {"Coal" : breakdown[0], "Petroleum" : breakdown[1], "Natural Gas" : breakdown[2], "Low Carbon" : breakdown[3]} 378 | figtitle = "Location: " + location 379 | location_split = location.split() 380 | filename = location_split[0] 381 | for i in range(1, len(location_split)): 382 | filename += "_" + location_split[i] 383 | filename += ".png" 384 | if locate.in_US(location): 385 | energy_dict["Oil"] = energy_dict.pop("Petroleum") 386 | figtitle = figtitle + ", USA" 387 | graph.pie_chart(energy_dict, figtitle, filename) 388 | # generate emissions comparison bar charts 389 | png_bar_chart(location, emission, default_emissions) 390 | if timeseries: 391 | graph.timeseries(time_baseline, reading_baseline_wattage, "Baseline Wattage Timeseries") 392 | graph.timeseries(time_process, reading_process_wattage, "Process Wattage Timeseries") 393 | if energyOutput: 394 | return (total_time, result, return_value) 395 | else: 396 | return return_value 397 | 398 | else: 399 | utils.log("The energy-usage package only works on Linux kernels " 400 | "with Intel processors that support the RAPL interface and/or machines with" 401 | " an Nvidia GPU. Please try again on a different machine.") 402 | except Exception as e: 403 | print("\n" + str(e)) 404 | -------------------------------------------------------------------------------- /energyusage/graph.py: -------------------------------------------------------------------------------- 1 | import matplotlib 2 | matplotlib.use('Agg') 3 | import matplotlib.pyplot as plt 4 | import numpy as np 5 | 6 | FONTSIZE = 20 7 | TITLESIZE = 30 8 | plt.rcdefaults() 9 | 10 | """ 11 | Creates a pie chart based on the energy composition. Takes a dictionary mapping energy to percent 12 | based on energy types: 13 | - Coal 14 | - Oil/Petroleum 15 | - Natural Gas 16 | - Low Carbon 17 | """ 18 | def pie_chart(energy_dict, figtitle, filename): 19 | # Pie chart 20 | labels = ["Coal", "Oil", "Natural Gas", "Low Carbon"] 21 | if "Petroleum" in energy_dict: 22 | labels[1] = "Petroleum" 23 | sizes = [energy_dict[key] for key in labels] 24 | #colors 25 | colors = ['#b2182b','#ef8a62','#fddbc7','#2166ac'] 26 | fig1, ax1 = plt.subplots() 27 | patches, texts, autotexts = ax1.pie(sizes, colors = colors, labels=labels, autopct='%1.1f%%', 28 | startangle=90, labeldistance = 0.8, pctdistance = 0.4) 29 | for text in texts: 30 | text.set_color('black') 31 | text.set_fontsize(FONTSIZE) 32 | text.set_bbox(dict(facecolor='white', alpha=0.5, linewidth=0.0)) 33 | for autotext in autotexts: 34 | autotext.set_color('black') 35 | autotext.set_fontsize(FONTSIZE) 36 | autotext.set_bbox(dict(facecolor='white', alpha=0.5, linewidth=0.0)) 37 | 38 | # Equal aspect ratio ensures that pie is drawn as a circle 39 | ax1.axis('equal') 40 | ax1.set_title(figtitle, fontsize = TITLESIZE) 41 | plt.tight_layout() 42 | 43 | bb = (texts, autotexts) 44 | plt.savefig(filename, bbox_extra_artists = bb) #, bbox_inches = 'tight') 45 | print("plot saved to: " + filename) 46 | plt.clf() 47 | plt.close() 48 | 49 | """ 50 | Takes a dictionary mapping "Min", "Median", "Max", and whatever the current location name is 51 | to the kg CO2 values for those locations. Min/Med/Max will be graphed in grey and current 52 | location in black on the same chart. 53 | """ 54 | def bar_chart(bar_dict, location_key, title, filename, y_step, figsize = None): 55 | 56 | plt.figure(figsize=figsize) 57 | 58 | objects = sorted(bar_dict.keys(), key = bar_dict.get) 59 | y_pos = np.arange(len(objects)) 60 | co2 = [ bar_dict[key] for key in objects ] 61 | color_dict = {} 62 | for key in objects: 63 | if key == location_key: 64 | color_dict[key] = 'black' 65 | else: 66 | color_dict[key] = 'gray' 67 | colors = [ color_dict[key] for key in objects ] 68 | 69 | plt.bar(y_pos, co2, align='center', color = colors) 70 | plt.xticks(y_pos, objects, fontsize = FONTSIZE) 71 | yticks = [] 72 | plt.yticks([x*y_step for x in range(0, 11)]) 73 | label = plt.ylabel('kg CO2', fontsize = FONTSIZE) 74 | title = plt.title(title, fontsize = TITLESIZE) 75 | 76 | plt.savefig(filename, bbox_inches = 'tight') 77 | print("plot saved to: " + filename) 78 | plt.clf() 79 | plt.close() 80 | 81 | def make_comparison_bar_charts(currlocation_key, currlocation_co2, us_dict, eu_dict, global_dict): 82 | us_max = modify_dict(us_dict, currlocation_key, currlocation_co2) 83 | us_y_step = float(format(us_max, '.1g')) / 10 84 | bar_chart(us_dict, currlocation_key, "US Comparison CO2 Emissions", "us.png", us_y_step, figsize = (10,4)) 85 | eu_max = modify_dict(eu_dict, currlocation_key, currlocation_co2) 86 | eu_y_step = float(format(eu_max, '.1g')) / 10 87 | bar_chart(eu_dict, currlocation_key, "Europe Comparison CO2 Emissions", "europe.png", 88 | eu_y_step, figsize = (10,4)) 89 | global_max = modify_dict(global_dict, currlocation_key, currlocation_co2) 90 | global_y_step = float(format(global_max, '.1g')) / 10 91 | bar_chart(global_dict, currlocation_key, 92 | "Global (Excluding Europe and US)\nComparison CO2 Emissions", "global.png", 93 | global_y_step, figsize = (10,4)) 94 | 95 | def modify_dict(comparison_dict, location_key, location_value): 96 | sorted_keys = sorted(comparison_dict.keys(), key = comparison_dict.get) 97 | new_key = "Minimum:\n" + sorted_keys[0] 98 | comparison_dict[new_key] = comparison_dict.pop(sorted_keys[0]) 99 | new_key = "Median:\n" + sorted_keys[1] 100 | comparison_dict[new_key] = comparison_dict.pop(sorted_keys[1]) 101 | new_key = "Maximum:\n" + sorted_keys[2] 102 | comparison_dict[new_key] = comparison_dict.pop(sorted_keys[2]) 103 | comparison_dict[location_key] = location_value 104 | return comparison_dict[new_key] 105 | 106 | def timeseries(time, reading, title): 107 | fig, ax = plt.subplots() 108 | ax.plot(time, reading) 109 | 110 | if "Baseline" in title: 111 | ylabel = "baseline wattage (watts)" 112 | filename = "baseline_wattage.png" 113 | else: 114 | ylabel = "process wattage (watts)" 115 | filename = "process_wattage.png" 116 | 117 | ax.set(xlabel='time (s)', ylabel=ylabel, title=title) 118 | ax.grid() 119 | 120 | fig.savefig(filename) 121 | print("plot saved to: " + filename) 122 | plt.clf() 123 | plt.close() 124 | 125 | -------------------------------------------------------------------------------- /energyusage/locate.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | # TODO: Make these sets 4 | STATES = ['Alabama','Alaska','Arizona','Arkansas','California','Colorado', \ 5 | 'Connecticut','Delaware', 'Florida','Georgia','Hawaii','Idaho', \ 6 | 'Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana', \ 7 | 'Maine','Maryland','Massachusetts','Michigan','Minnesota', \ 8 | 'Mississippi','Missouri','Montana','Nebraska','Nevada', \ 9 | 'New Hampshire','New Jersey','New Mexico','New York', \ 10 | 'North Carolina','North Dakota','Ohio','Oklahoma','Oregon', \ 11 | 'Pennsylvania', 'Rhode Island','South Carolina','South Dakota', \ 12 | 'Tennessee','Texas','Utah','Vermont','Virginia','Washington', \ 13 | 'West Virginia','Wisconsin','Wyoming'] 14 | 15 | EUROPE = ['Albania','Andorra','Armenia','Austria','Azerbaijan', \ 16 | 'Belarus','Belgium','Bosnia and Herzegovina','Bulgaria', \ 17 | 'Croatia','Cyprus','Czech Republic','Denmark','Estonia','Finland', \ 18 | 'France','Georgia','Germany','Greece','Hungary','Iceland', \ 19 | 'Ireland','Italy','Kazakhstan','Kosovo','Latvia','Liechtenstein', \ 20 | 'Lithuania','Luxembourg','Malta','Moldova','Monaco','Montenegro', \ 21 | 'Netherlands','Macedonia','Norway','Poland','Portugal','Romania', \ 22 | 'Russia','San Marino','Serbia','Slovakia','Slovenia','Spain', \ 23 | 'Sweden','Switzerland','Turkey','Ukraine','United Kingdom','Vatican City'] 24 | 25 | 26 | """ LOCATION UTILS """ 27 | 28 | def get_location_information(): 29 | geo = requests.get("https://get.geojs.io/v1/ip/geo.json").json() 30 | return geo 31 | 32 | def get(printToScreen, geo): 33 | """ Gets user's location via GeoJS API 34 | 35 | Returns: 36 | location (str): location of user's IP address 37 | """ 38 | 39 | location = "Unknown" 40 | try: 41 | if geo["country"] == "United States": 42 | try: 43 | location = geo["region"] 44 | except: 45 | location = "United States" 46 | else: 47 | location = geo['country'] 48 | except: 49 | pass 50 | if printToScreen: 51 | print("Location: {:>70}".format(location)) 52 | return location 53 | 54 | def in_US(location): 55 | return (location in STATES)# or location == "United States") 56 | 57 | def in_Europe(location): 58 | return (location in EUROPE) 59 | -------------------------------------------------------------------------------- /energyusage/raw_to_json.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import json 3 | import pandas as pd 4 | import optparse 5 | 6 | states = { "AL": "Alabama", "AK": "Alaska", "AS": "American Samoa", "AZ": "Arizona", \ 7 | "AR": "Arkansas", "CA": "California", "CO": "Colorado", "CT": "Connecticut", \ 8 | "DE": "Delaware", "DC": "District Of Columbia", "FL": "Florida", "GA": "Georgia", \ 9 | "HI": "Hawaii", "ID": "Idaho", "IL": "Illinois", "IN": "Indiana", "IA": "Iowa", \ 10 | "KS": "Kansas", "KY": "Kentucky", "LA": "Louisiana", "ME": "Maine", "MD": "Maryland", \ 11 | "MA": "Massachusetts", "MI": "Michigan", "MN": "Minnesota", "MS": "Mississippi", \ 12 | "MO": "Missouri", "MT": "Montana", "NE": "Nebraska", "NV": "Nevada", "NH": "New Hampshire", \ 13 | "NJ": "New Jersey", "NM": "New Mexico", "NY": "New York", "NC": "North Carolina", \ 14 | "ND": "North Dakota", "OH": "Ohio", "OK": "Oklahoma", "OR": "Oregon", "PA": "Pennsylvania", \ 15 | "RI": "Rhode Island", "SC": "South Carolina", "SD": "South Dakota", "TN": "Tennessee", \ 16 | "TX": "Texas", "UT": "Utah", "VT": "Vermont", "VA": "Virginia", "WA": "Washington", \ 17 | "WV": "West Virginia", "WI": "Wisconsin", "WY": "Wyoming", \ 18 | "U.S.": "U.S.", "_unit":"_unit", "_define": "_define" 19 | } 20 | 21 | def parse_args(): 22 | """Parse command line arguments for year.""" 23 | parser = optparse.OptionParser(description='find year') 24 | 25 | 26 | parser.add_option('-y', '--year', type='string', help='year for the data') 27 | 28 | (opts, args) = parser.parse_args() 29 | mandatories = ['year',] 30 | for m in mandatories: 31 | if not opts.__dict__[m]: 32 | print('mandatory option ' + m + ' is missing\n') 33 | parser.print_help() 34 | sys.exit() 35 | return opts 36 | 37 | 38 | # take the arg from the script 39 | opts = parse_args() 40 | year = opts.year 41 | 42 | """ Converts the US EIA csv file to json """ 43 | # Definiting structure of JSON 44 | countries = {"_define": { 45 | "total":"TOTAL EMISSIONS", 46 | "coal":"COAL", 47 | "naturalGas":"NATURAL GAS", 48 | "petroleum":"PETROLEUM + OTHER LIQUIDS", 49 | "lowCarbon":"NUCLEAR, RENEWABLES + OTHERS", 50 | "units":"Quad Btu" 51 | }} 52 | categories = ["total", "coal", "naturalGas", "petroleum", "lowCarbon"] 53 | category_index = -1 54 | with open("./data/raw/" + year + "/international_data.csv") as csvfile: 55 | reader = csv.reader(csvfile, delimiter=',') 56 | # Skipping unnecessary headers 57 | [next(reader) for i in range(7)] 58 | for row in reader: 59 | # Category line - increment to move on to next category 60 | if len(row) == 3: 61 | category_index += 1 62 | # Country line 63 | elif len(row) == 5: 64 | if row[1] in countries: 65 | if row[-1] == "--" or row[-1] == "(s)": 66 | row[-1] = 0 67 | countries[row[1]][categories[category_index]] = float(row[-1]) 68 | else: 69 | if row[-1] == "--" or row[-1] == "(s)": 70 | row[-1] = 0 71 | country_dict = {} 72 | country_dict[categories[category_index]] = float(row[-1]) 73 | countries[row[1]] = country_dict 74 | json_file = json.dumps(countries) 75 | with open("./data/json/energy-mix-intl_" + year + ".json", 'w') as jsonwriter: 76 | jsonwriter.write(json_file) 77 | 78 | 79 | """ Converts eGRID xlsx file to json """ 80 | # Table 3: CO2 Emissions 81 | 82 | egrid = pd.ExcelFile("./data/raw/" + year + "/egrid.xlsx") 83 | emissions = egrid.parse('Table 3') 84 | emissions.to_csv("./data/csv/egrid_emissions_" + year + ".csv", sep=',') 85 | 86 | state_carbon = {"_unit": "lbs/MWh"} 87 | with open("./data/csv/egrid_emissions_" + year + ".csv") as csvfile: 88 | reader = csv.reader(csvfile, delimiter=',') 89 | [next(reader) for i in range(4)] 90 | for row in reader: 91 | if row[2] != "": 92 | state_carbon[row[2]] = float(row[3]) 93 | 94 | # Handling the renaming of the states 95 | state_carbon = { states[key]:value for key, value in state_carbon.items()} 96 | json_file = json.dumps(state_carbon) 97 | with open("./data/json/us-emissions_" + year + ".json", 'w') as jsonwriter: 98 | jsonwriter.write(json_file) 99 | 100 | # Table 4: State Resource Mix 101 | resource_mix = egrid.parse('Table 4') 102 | resource_mix.to_csv("./data/csv/egrid_resource_mix_" + year + ".csv", sep=',') 103 | state_resource_mix = {"_define":{ 104 | "nameplateCapacity":"Nameplate Capacity (MW)", 105 | "netGeneration":"Net Generation (MWh)", 106 | "mix":{ 107 | "coal":"Coal", 108 | "oil":"Oil", 109 | "gas":"Gas", 110 | "otherFossil":"Other Fossil", 111 | "nuclear":"Nuclear", 112 | "hydro":"Hydro", 113 | "biomass":"Biomass", 114 | "wind":"Wind", 115 | "solar":"Solar", 116 | "geothermal":"Geo-thermal", 117 | "unknown":"Other unknown/purchased fuel", 118 | "_units":"percentage" 119 | }}} 120 | 121 | with open("./data/csv/egrid_resource_mix_" + year + ".csv") as csvfile: 122 | reader = csv.reader(csvfile, delimiter=',') 123 | [next(reader) for i in range(3)] 124 | for row in reader: 125 | if row[2] != "": 126 | state_resource_mix[row[2]] = { 127 | "nameplateCapacity": float(row[3]), 128 | "netGeneration": float(row[4]), 129 | "mix": { 130 | "coal": float(row[5]), 131 | "oil": float(row[6]), 132 | "gas": float(row[7]), 133 | "otherFossil": float(row[8]), 134 | "nuclear": float(row[9]), 135 | "hydro": float(row[10]), 136 | "biomass": float(row[11]), 137 | "wind": float(row[12]), 138 | "solar": float(row[13]), 139 | "geothermal": float(row[14]), 140 | "unknown": float(row[15]) 141 | }} 142 | state_resource_mix = { states[key]:value for key, value in state_resource_mix.items()} 143 | json_file = json.dumps(state_resource_mix) 144 | with open("./data/json/energy-mix-us_" + year + ".json", 'w') as jsonwriter: 145 | jsonwriter.write(json_file) 146 | -------------------------------------------------------------------------------- /energyusage/report.py: -------------------------------------------------------------------------------- 1 | from reportlab.lib.pagesizes import letter, landscape 2 | from reportlab.lib.units import inch 3 | from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle 4 | from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle 5 | from reportlab.lib.enums import TA_CENTER 6 | from reportlab.lib import colors 7 | from reportlab.graphics.charts.piecharts import Pie 8 | from reportlab.graphics.shapes import * # not used? 9 | from reportlab.graphics.charts.barcharts import VerticalBarChart 10 | from reportlab.graphics.charts.textlabels import Label 11 | 12 | import energyusage.convert as convert 13 | import evaluate as evaluate 14 | import locate 15 | 16 | import math 17 | 18 | year = "2016" 19 | 20 | styles = getSampleStyleSheet() 21 | TitleStyle = ParagraphStyle(name='Normal', fontSize=16, alignment= TA_CENTER, fontName="Times-Bold") 22 | SubtitleStyle = ParagraphStyle(name='Normal',fontSize=12, alignment= TA_CENTER, fontName="Times-Roman") 23 | # MonospacedSubtitleStyle = ParagraphStyle(name='Normal',fontSize=12, alignment= TA_CENTER, fontName="Courier") 24 | HeaderStyle = ParagraphStyle(name='Normal',fontSize=16) 25 | SubheaderStyle = ParagraphStyle(name='Normal', fontName="Times-Roman") 26 | DescriptorStyle = ParagraphStyle(name='Normal',fontSize=14, alignment= TA_CENTER) 27 | BodyTextStyle = styles["BodyText"] 28 | 29 | 30 | def bold(text): 31 | return ""+text+"" 32 | 33 | def title(text, Elements, style=TitleStyle, klass=Paragraph, sep=0.3): 34 | """ Creates title of report """ 35 | t = klass(bold(text), style) 36 | Elements.append(t) 37 | 38 | def subtitle(text, Elements, style=SubtitleStyle, klass=Paragraph, sep=0.1, spaceBefore=True, spaceAfter = True): 39 | """ Creates descriptor text for a (sub)section; sp adds space before text """ 40 | s = Spacer(0, 1.5*sep*inch) 41 | if spaceBefore: 42 | Elements.append(s) 43 | d = klass(text, style) 44 | Elements.append(d) 45 | if spaceAfter: 46 | Elements.append(s) 47 | 48 | 49 | 50 | def readings_and_mix_table(reading_data, mix_data, breakdown, state_emission, location, Elements): 51 | ''' 52 | Creates 2 tables that are then embedded as the columns of 1 bigger table 53 | ''' 54 | no_rows = 1 # not used 55 | no_cols = 1 56 | col_size = 4.5 57 | 58 | readings_table = Table(reading_data, no_cols*[col_size/2*inch], 5*[0.25*inch] + [0.3*inch], hAlign="LEFT") 59 | readings_table.setStyle(TableStyle([('FONT', (0,0), (-1,-1), "Times-Roman"), 60 | ('FONT', (0,0), (-1,0), "Times-Bold"), 61 | ('FONTSIZE', (0,0), (-1,-1), 12), 62 | ('FONTSIZE', (0,0), (-1,0), 13), 63 | ('ALIGN', (0,0), (0,-1), "RIGHT"), 64 | ('VALIGN', (-1,-1), (-1,-1), "TOP")])) 65 | 66 | 67 | d = Drawing(100, 100) 68 | pc = Pie() 69 | 70 | data = [] 71 | if state_emission: 72 | data = ["Coal", "Oil", "Natural Gas", "Low Carbon"] 73 | else: 74 | data = ["Coal", "Petroleum", "Natural Gas", "Low Carbon"] 75 | 76 | for i in range(4): 77 | data[i] += ": " + str(round(breakdown[i], 1)) + "%" 78 | 79 | pc.x = 45 80 | pc.y = 0 81 | pc.width = 55 82 | pc.height = 55 83 | pc.data = breakdown[:4] 84 | pc.slices[0].fillColor = colors.Color(202.0/255, 0.0/255, 32.0/255) 85 | pc.slices[1].fillColor = colors.Color(244.0/255, 165.0/255, 130.0/255) 86 | pc.slices[2].fillColor = colors.Color(5.0/255, 113.0/255, 176.0/255) 87 | pc.slices[3].fillColor = colors.Color(146.0/255, 197.0/255, 222.0/255) 88 | pc.labels = data 89 | pc.slices.strokeWidth=0.5 90 | pc.sideLabels = True 91 | d.add(pc) 92 | 93 | mix_data = [['Energy Mix Data'], [d], ['Location: ' + location]] 94 | mix_table = Table(mix_data, no_cols*[col_size/2*inch], [.25*inch, 1*inch, .3*inch], hAlign="RIGHT") 95 | mix_table.setStyle(TableStyle([('FONT', (0,0), (-1,-1), "Times-Roman"), 96 | ('FONT', (0,0), (0,0), "Times-Bold"), 97 | ('FONTSIZE', (0,0), (0,0), 13), 98 | ('FONTSIZE', (-1,-1), (-1,-1), 12), 99 | ('ALIGN', (0,0), (0,0), "LEFT")])) 100 | 101 | 102 | table_data = [(readings_table, mix_table)] 103 | t = Table(table_data, [4.25*inch, 3*inch], hAlign='CENTER') 104 | t.setStyle(TableStyle([('VALIGN', (-1,-1), (-1,-1), "TOP")])) 105 | Elements.append(t) 106 | 107 | 108 | def kwh_and_emissions_table(data, Elements): 109 | 110 | s = Spacer(9*inch, .2*inch) 111 | Elements.append(s) 112 | 113 | no_rows = 1 114 | no_cols = 2 115 | col_size = 2 116 | 117 | t = Table(data, [2.75*inch, 2.15*inch],[.25*inch, .29*inch], hAlign="CENTER") 118 | t.setStyle([('FONT',(0,0),(-1,-1),"Times-Roman"), 119 | ('FONT',(0,0),(0,-1),"Times-Bold"), 120 | ('FONTSIZE', (0,0), (-1,-1), 12), 121 | ('ALIGN', (0,0), (0,-1), "RIGHT"), 122 | ('ALIGN',(1,1),(1,-1), "LEFT"), 123 | ('BOX', (0,0), (-1,-1), 1, colors.black), 124 | ('VALIGN', (0,0), (-1,-1), "TOP")]) 125 | Elements.append(t) 126 | 127 | 128 | def equivs_and_emission_equivs(equivs_data, emissions_data, Elements): 129 | ''' 130 | Creates a table with 2 columns, each with their own embedded table 131 | The embedded tables contain 2 vertically-stacked tables, one for the header 132 | and the other one for the actual data in order to have better alignment 133 | 134 | The first row of the 2nd vertically-stacked table is smaller than the rest in 135 | order to remove the extra space and make these tables look cohesive with the 136 | energy usage readings and energy mix tables 137 | 138 | Setup: 139 | * Table(data[array of arrays, one for each row], [column widths], [row heights]) 140 | * Spacer(width, height) 141 | 142 | 143 | ''' 144 | s = Spacer(9*inch, .2*inch) 145 | Elements.append(s) 146 | 147 | no_rows = 1 148 | no_cols = 1 149 | col_size = 4.5 150 | 151 | equivs_header_data = [["Assumed Carbon Equivalencies"]] 152 | 153 | # Table(data) 154 | equivs_header_table = Table(equivs_header_data, [3*inch], [.25*inch]) 155 | equivs_header_table.setStyle(TableStyle([('FONT',(0,0),(0,-1),"Times-Bold"), 156 | ('FONTSIZE', (0,0), (-1,-1), 13)])) 157 | 158 | 159 | equivs_data_table = Table(equivs_data, [1*inch, 2*inch], [0.17*inch, 0.25*inch, 0.25*inch, 0.25*inch],hAlign="LEFT") 160 | equivs_data_table.setStyle(TableStyle([('FONT', (0,0), (-1,-1), "Times-Roman"), 161 | ('FONTSIZE', (0,0), (-1,-1), 12), 162 | ('ALIGN', (0,0), (0,-1), "RIGHT"), 163 | ('VALIGN', (-1,-1), (-1,-1), "TOP")])) 164 | 165 | t1_data = [[equivs_header_table],[equivs_data_table]] 166 | 167 | t1 = Table(t1_data, [3*inch]) 168 | 169 | emission_equiv_para = Paragraph('CO2' + 170 | ' Emissions Equivalents', style = styles["Normal"]) 171 | emissions_header_data = [[emission_equiv_para]] 172 | emissions_header_table = Table(emissions_header_data, [3*inch], [.25*inch]) 173 | emissions_header_table.setStyle(TableStyle([('FONT',(0,0),(0,-1),"Times-Bold"), 174 | ('FONTSIZE', (0,0), (-1,-1), 13)])) 175 | 176 | 177 | emissions_data_table = Table(emissions_data, [2.1*inch, 1.5*inch], [0.17*inch, 0.25*inch, 0.25*inch],hAlign="LEFT") 178 | emissions_data_table.setStyle(TableStyle([('FONT', (0,0), (-1,-1), "Times-Roman"), 179 | ('FONTSIZE', (0,0), (-1,-1), 12), 180 | ('ALIGN', (0,0), (0,-1), "RIGHT"), 181 | ('VALIGN', (-1,-1), (-1,-1), "TOP")])) 182 | 183 | t2_data = [[emissions_header_table],[emissions_data_table]] 184 | 185 | t2 = Table(t2_data, [3*inch]) 186 | 187 | 188 | table_data = [(t1, t2)] 189 | t = Table(table_data, [4.25*inch, 3*inch], hAlign='CENTER') 190 | t.setStyle(TableStyle([('VALIGN', (-1,-1), (-1,-1), "TOP")])) 191 | Elements.append(t) 192 | 193 | 194 | def gen_bar_graphs(comparison_values, location, emission): 195 | bc = VerticalBarChart() 196 | labels = [] 197 | data = [] 198 | comparison_values.append([location, emission]) 199 | comparison_values.sort(key = lambda x: x[1]) 200 | for pair in comparison_values: 201 | labels.append(pair[0]) 202 | data.append(pair[1]) 203 | data = [data] 204 | location_index = labels.index(location) 205 | bc.x = -150 206 | bc.y = -110 207 | bc.height = 100 208 | bc.width = 150 209 | bc.data = data 210 | bc.strokeColor = colors.black 211 | bc.valueAxis.valueMin = 0 212 | bc.valueAxis.valueMax = data[0][-1] + data[0][-1] * .1 213 | distance = abs(int(math.log10(abs(data[0][-1])))) + 1 # distance of 1 significant figure to decimal point 214 | bc.valueAxis.valueStep = float(format(data[0][-1], '.1g')) / 3 215 | bc.valueAxis.labelTextFormat = '%0.' + str(distance) + 'g' 216 | bc.categoryAxis.labels.boxAnchor = 'ne' 217 | bc.categoryAxis.labels.dx = 8 218 | bc.categoryAxis.labels.dy = -2 219 | bc.categoryAxis.labels.angle = 30 220 | bc.categoryAxis.categoryNames = labels 221 | for i in range(len(labels)): 222 | bc.bars[(0, i)].fillColor = colors.Color(166.0/255, 189.0/255, 219.0/255) 223 | bc.bars[(0, location_index)].fillColor = colors.Color(28.0/255, 144.0/255, 153.0/255) 224 | return bc 225 | 226 | 227 | def comparison_graphs(comparison_values, location, emission, default_emissions, default_location, Elements): 228 | s = Spacer(9*inch, .2*inch) 229 | Elements.append(s) 230 | drawing = Drawing(0, 0) 231 | 232 | if not default_location: 233 | bc = gen_bar_graphs(comparison_values, location, emission) 234 | bc.y = -120 235 | bc.height = 125 236 | bc.width = 300 237 | drawing.add(bc) 238 | else: 239 | bc1 = gen_bar_graphs(default_emissions[:3], location, emission) 240 | bc2 = gen_bar_graphs(default_emissions[3:6], location, emission) 241 | bc3 = gen_bar_graphs(default_emissions[6:], location, emission) 242 | 243 | offset = -257 244 | bc1.x = -10 + offset 245 | bc2.x = 190 + offset 246 | bc3.x = 390 + offset 247 | drawing.add(bc1) 248 | drawing.add(bc2) 249 | drawing.add(bc3) 250 | 251 | label_offset = offset + 80 252 | label1, label2, label3 = Label(), Label(), Label() 253 | label1.setText("Global (excluding Europe and US)") 254 | label1.x, label1.y = -17 + label_offset, -160 255 | label1.fontName = "Times-Bold" 256 | 257 | label2.setText("Europe") 258 | label2.x, label2.y = 185 + label_offset, -160 259 | label2.fontName = "Times-Bold" 260 | 261 | label3.setText("United States") 262 | label3.x, label3.y = 385 + label_offset, -160 263 | label3.fontName = "Times-Bold" 264 | 265 | drawing.add(label1) 266 | drawing.add(label2) 267 | drawing.add(label3) 268 | 269 | if_elsewhere_para = Paragraph('Kilograms of CO2 emissions for the function if the computation had been performed elsewhere', style = styles["Normal"]) 271 | graph_data = [['Emission Comparison'], [if_elsewhere_para], [drawing]] 272 | graph_table = Table(graph_data, [6.5*inch], [.25*inch, .25*inch, .25*inch], hAlign="CENTER") 273 | graph_table.setStyle(TableStyle([('FONT', (0,0), (0,0), "Times-Bold"), 274 | ('FONT', (0,1),(0,1),"Times-Roman"), 275 | ('FONTSIZE', (0,0), (0,0), 13), 276 | ('FONTSIZE', (0,1), (0,1), 12), 277 | ('ALIGN', (0,0), (-1,-1), "CENTER")])) 278 | 279 | Elements.append(graph_table) 280 | 281 | def report_header(kwh, emission, Elements): 282 | effective_emission = Paragraph('{:.2e} kg CO2 '.format(emission), style = styles["Normal"]) 283 | # Total kWhs used and effective emissions 284 | kwh_and_emissions_data = [["Total kilowatt hours used:", "{:.2e} kWh".format(kwh)], 285 | ["Effective emissions:", effective_emission]] 286 | 287 | kwh_and_emissions_table(kwh_and_emissions_data, Elements) 288 | 289 | def report_equivalents(emission, state_emission, Elements): 290 | # Equivalencies and CO2 emission equivalents 291 | per_house = Paragraph('% of CO2 per US house/day:'.format(emission), style = styles["Normal"]) 292 | emissions_data = [ 293 | ['Miles driven:', "{:.2e} miles".format(convert.carbon_to_miles(emission))], 294 | ['Min. of 32-in. LCD TV:', "{:.2e} minutes".format(convert.carbon_to_tv(emission))], 295 | [per_house, \ 296 | "{:.2e}%".format(convert.carbon_to_home(emission))]] 297 | 298 | coal_para = Paragraph('996 kg CO2 /MWh', style = styles["Normal"]) 299 | oil_para = Paragraph('817 kg CO2 /MWh', style = styles["Normal"]) 300 | gas_para = Paragraph('744 kg CO2 /MWh', style = styles["Normal"]) 301 | low_para = Paragraph('0 kg CO2 /MWh', style = styles["Normal"]) 302 | 303 | if state_emission: 304 | equivs_data = [['Coal:', coal_para], 305 | ['Oil:', oil_para], 306 | ['Natural gas:', gas_para], 307 | ['Low carbon:', low_para]] 308 | else: 309 | equivs_data = [['Coal:', coal_para], 310 | ['Petroleum:', oil_para], 311 | ['Natural gas:', gas_para], 312 | ['Low carbon:', low_para]] 313 | 314 | equivs_and_emission_equivs(equivs_data, emissions_data, Elements) 315 | # utils.log("Assumed Carbon Equivalencies") 316 | # utils.log("Emissions", emission) 317 | 318 | 319 | def generate(location, watt_averages, breakdown, kwh_and_emissions, func_info, \ 320 | comparison_values, default_emissions, default_location): 321 | # TODO: remove state_emission and just use location 322 | """ Generates the entire pdf report 323 | 324 | Parameters: 325 | location (str): user's location, locations=["Romania", "Brazil"] 326 | watt_averages (list): list of baseline, total, process wattage, process duration 327 | breakdown (list): [% coal, % oil/petroleum, % natural gas, % low carbon] 328 | kwh_and_emissions (list): [kwh used, emission in kg CO2, state emission > 0 for US states] 329 | func_info (list): [user func name, user func args (0 or more)] 330 | 331 | """ 332 | 333 | Elements = [] 334 | kwh, emission, state_emission = kwh_and_emissions 335 | baseline_average, process_average, difference_average, process_duration = watt_averages 336 | 337 | # Initializing document 338 | doc = SimpleDocTemplate("energy-usage-report.pdf",pagesize=landscape(letter), topMargin=.3*inch) 339 | 340 | title("Energy Usage Report", Elements) 341 | 342 | # Handling header with function name and arguments 343 | func_name, *func_args = func_info 344 | info_text = " for the function " + func_name 345 | if len(func_args) > 0: 346 | if len(func_args) == 1: 347 | info_text += " with the input " + str(func_args[0]) + "." 348 | else: 349 | info_text += " with the inputs " 350 | for arg in func_args: 351 | info_text += arg + "," 352 | info_text = info_text[len(info_text)-1] + "." 353 | else: 354 | info_text += "." 355 | 356 | subtitle("Energy usage and carbon emissions" + info_text, Elements, spaceBefore=True) 357 | 358 | # Energy Usage Readings and Energy Mix Data 359 | readings_data = [['Energy Usage Readings', ''], 360 | ['Average baseline wattage:', "{:.2f} watts".format(baseline_average)], 361 | ['Average total wattage:', "{:.2f} watts".format(process_average)], 362 | ['Average process wattage:', "{:.2f} watts".format(difference_average)], 363 | ['Process duration:', process_duration], 364 | ['','']] #hack for the alignment 365 | 366 | if state_emission: 367 | coal, oil, natural_gas, low_carbon = breakdown 368 | mix_data = [['Energy Mix Data', ''], 369 | ['Coal', "{:.2f}%".format(coal)], 370 | ['Oil', "{:.2f}%".format(oil)], 371 | ['Natural gas', "{:.2f}%".format(natural_gas)], 372 | ['Low carbon', "{:.2f}%".format(low_carbon)]] 373 | else: 374 | coal, petroleum, natural_gas, low_carbon = breakdown 375 | mix_data = [['Energy Mix Data', ''], 376 | ['Coal', "{:.2f}%".format(coal)], 377 | ['Petroleum', "{:.2f}%".format(petroleum)], 378 | ['Natural gas', "{:.2f}%".format(natural_gas)], 379 | ['Low carbon', "{:.2f}%".format(low_carbon)]] 380 | 381 | readings_and_mix_table(readings_data, mix_data, breakdown, state_emission, location, Elements) 382 | report_header(kwh, emission, Elements) 383 | report_equivalents(emission, state_emission, Elements) 384 | comparison_graphs(comparison_values, location, emission, default_emissions, default_location, Elements) 385 | 386 | doc.build(Elements) 387 | -------------------------------------------------------------------------------- /energyusage/test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import requests 3 | import evaluate as evaluate 4 | import locate as locate 5 | 6 | YEAR = "2016" 7 | PROCESS_KWH = 0.1 8 | printToScreen = False 9 | 10 | class Test(unittest.TestCase): 11 | def test_kwh_to_co2(self): 12 | # US locations 13 | breakdown = [5.868023799, 1.321624392, 66.17474207, 26.63395815] 14 | location = "Massachusetts" 15 | emission, state_emission = evaluate.emissions(PROCESS_KWH, breakdown, \ 16 | location, YEAR, printToScreen) 17 | self.assertAlmostEqual(emission, 0.037254766047499006) 18 | self.assertEqual(state_emission, 821.327) 19 | 20 | # Unknown and international location 21 | breakdown = [5.572323934, 36.95920652, 20.30010129, 37.16836826] 22 | location = "New Zealand" 23 | emission, state_emission = evaluate.emissions(PROCESS_KWH, breakdown, \ 24 | location, YEAR, printToScreen) 25 | self.assertAlmostEqual(emission, 0.05083272721075440) 26 | self.assertEqual(state_emission, 0) 27 | 28 | 29 | def test_ip_to_location(self): 30 | geo = requests.get("https://get.geojs.io/v1/ip/geo/165.82.47.11.json").json() 31 | self.assertEqual(locate.get(printToScreen, geo), "Pennsylvania") 32 | 33 | 34 | def test_get_local_energy_mix(self): 35 | output_pennsylvania_mix = [] 36 | output_unknown_mix = [] 37 | 38 | pennsylvania_mix = [25.4209872, 0.1686522923, 31.640982, 42.51657052] 39 | unknown_mix = [14.34624948, 39.45439942, 28.64046947, 17.55888163] 40 | # breadown from function 41 | pennsylvania_breakdown = evaluate.energy_mix("Pennsylvania", YEAR) 42 | unknown_breadown = evaluate.energy_mix("Unknown", YEAR) 43 | 44 | for i in range(0, 4): 45 | # US locations 46 | pennsylvania_mix[i] = round(pennsylvania_mix[i], 5) 47 | output_pennsylvania_mix.append(round(pennsylvania_breakdown[i], 5)) 48 | 49 | # Unknown (default to US) or international locations 50 | unknown_mix[i] = round(unknown_mix[i], 5) 51 | output_unknown_mix.append(round(unknown_breadown[i], 5)) 52 | 53 | self.assertListEqual(output_pennsylvania_mix, pennsylvania_mix) 54 | self.assertListEqual(output_unknown_mix, unknown_mix) 55 | 56 | 57 | def test_emissions_comparison(self): 58 | locations = ["New Zealand"] 59 | default_location = False 60 | 61 | comparison_values = evaluate.emissions_comparison(PROCESS_KWH, locations, \ 62 | YEAR, default_location, printToScreen) 63 | comparison_values_list = list(comparison_values[0]) 64 | comparison_value = comparison_values_list[1] 65 | self.assertAlmostEqual(comparison_value, 0.05083272721075440) 66 | 67 | 68 | def test_old_emissions_comparison(self): 69 | default_location = True 70 | rounded_default_emissions_list = [] 71 | 72 | default_emissions = evaluate.old_emissions_comparison(PROCESS_KWH, YEAR,\ 73 | default_location, printToScreen) 74 | for value in default_emissions: 75 | default_emissions_list = list(value) 76 | rounded_default_emissions = round(default_emissions_list[1], 11) 77 | rounded_default_emissions_list.append(rounded_default_emissions) 78 | 79 | self.assertListEqual(rounded_default_emissions_list, [0.09233947591, \ 80 | 0.07541226821, 0.01049881617, 0.09433027569, 0.06590723112, 0.01697252192, \ 81 | 0.09190960756, 0.04500865546, 0.00258048699]) 82 | 83 | 84 | def test_small_energy_consumption_exception(self): 85 | def small_function(n): 86 | n+1 87 | 88 | with self.assertRaises(Exception) as e: 89 | evaluate.evaluate(small_function(), 10) 90 | self.assertTrue("Process executed too fast to gather energy consumption" in e.exception) 91 | 92 | 93 | if __name__ == '__main__': 94 | unittest.main() 95 | -------------------------------------------------------------------------------- /energyusage/utils.py: -------------------------------------------------------------------------------- 1 | import json 2 | import math 3 | import os 4 | import re 5 | import statistics 6 | import subprocess 7 | import sys 8 | import time 9 | 10 | import energyusage.convert as convert 11 | import energyusage.locate as locate 12 | from energyusage.RAPLFile import RAPLFile 13 | 14 | printToScreenGlobal = True 15 | BASE = "/sys/class/powercap/" 16 | DELAY = .1 # in seconds 17 | DIR_PATH = os.path.dirname(os.path.realpath(__file__)) 18 | 19 | """ MEASUREMENT UTILS """ 20 | 21 | def read(file): 22 | """ Opens file and reads energy measurement """ 23 | if file == "": 24 | return 0 25 | with open(file, 'r') as f: 26 | return convert.to_joules(int(f.read())) 27 | 28 | def average_files(raplfiles): 29 | for file in raplfiles: 30 | file.process_average = statistics.mean(file.process) 31 | file.baseline_average = statistics.mean(file.baseline) 32 | return raplfiles 33 | 34 | def measure(file, delay=1): 35 | """ Measures the energy output of FILE """ 36 | start_measure, end_measure = 0, 0 # start and end are functions 37 | start_measure = read(file) 38 | time.sleep(delay) 39 | end_measure = read(file) 40 | return end_measure - start_measure 41 | 42 | def get_process_average(raplfiles, multiple_cpus, gpu): 43 | total = 0 44 | if multiple_cpus: 45 | 46 | for file in raplfiles: 47 | if "CPU" in file.name: 48 | total+= file.process_average 49 | else: 50 | for file in raplfiles: 51 | if file.name == "Package": 52 | total+=file.process_average 53 | return total + gpu 54 | 55 | def get_baseline_average(raplfiles, multiple_cpus, gpu): 56 | total = 0 57 | if multiple_cpus: 58 | for file in raplfiles: 59 | if "CPU" in file.name: 60 | total += file.baseline_average 61 | else: 62 | for file in raplfiles: 63 | if file.name == "Package": 64 | total += file.baseline_average 65 | return total + gpu 66 | 67 | def get_total(raplfiles, multiple_cpus): 68 | total = 0 69 | if multiple_cpus: 70 | for file in raplfiles: 71 | if "CPU" in file.name: 72 | total += file.recent 73 | else: 74 | for file in raplfiles: 75 | if file.name == "Package": 76 | total = file.recent 77 | if (total): 78 | return total 79 | return 0 80 | 81 | def update_files(raplfiles, process = False): 82 | if process: 83 | for file in raplfiles: 84 | if file.recent >= 0: 85 | file.process.append(file.recent) 86 | else: 87 | for file in raplfiles: 88 | if file.recent >= 0: 89 | file.baseline.append(file.recent) 90 | return raplfiles 91 | 92 | def start(raplfile): 93 | measurement = read(raplfile.path) 94 | raplfile.recent = measurement 95 | return raplfile 96 | 97 | def end(raplfile, delay): 98 | measurement = read(raplfile.path) 99 | raplfile.recent = (measurement - raplfile.recent) / delay 100 | return raplfile 101 | 102 | def measure_files(files, delay = 1): 103 | """ Measures the energy output of all packages which should give total power usage 104 | 105 | Parameters: 106 | files (list): list of RAPLFiles 107 | delay (int): RAPL file reading rate in ms 108 | 109 | Returns: 110 | files (list): list of RAPLfiles with updated measurements 111 | """ 112 | 113 | files = list(map(start, files)) 114 | time.sleep(delay) 115 | files = list(map(lambda x: end(x, delay), files)) # need lambda to pass in delay 116 | return files 117 | 118 | def reformat(name, multiple_cpus): 119 | """ Renames the RAPL files for better readability/understanding """ 120 | if 'package' in name: 121 | if multiple_cpus: 122 | name = "CPU" + name[-1] # renaming it to CPU-x 123 | else: 124 | name = "Package" 125 | if name == 'core': 126 | name = "CPU" 127 | elif name == 'uncore': 128 | name = "GPU" 129 | elif name == 'dram': 130 | name = name.upper() 131 | return name 132 | 133 | def get_files(): 134 | """ Gets all the RAPL files with their names on the machine 135 | 136 | Returns: 137 | filenames (list): list of RAPLFiles 138 | """ 139 | # Removing the intel-rapl folder that has no info 140 | files = list(filter(lambda x: ':' in x, os.listdir(BASE))) 141 | names = {} 142 | cpu_count = 0 143 | multiple_cpus = False 144 | for file in files: 145 | if (re.fullmatch("intel-rapl:.", file)): 146 | cpu_count += 1 147 | 148 | if cpu_count > 1: 149 | multiple_cpus = True 150 | 151 | for file in files: 152 | path = BASE + '/' + file + '/name' 153 | with open(path) as f: 154 | name = f.read()[:-1] 155 | renamed = reformat(name, multiple_cpus) 156 | names[renamed] = BASE + file + '/energy_uj' 157 | 158 | filenames = [] 159 | for name, path in names.items(): 160 | name = RAPLFile(name, path) 161 | filenames.append(name) 162 | 163 | return filenames, multiple_cpus 164 | 165 | 166 | # from realpython.com/python-rounding 167 | def round_up(n, decimals=4): 168 | """ Rounds up if digit is >= 5 """ 169 | 170 | multiplier = 10 ** decimals 171 | return math.floor(n*multiplier + 0.5) / multiplier 172 | 173 | 174 | """ LOGGING UTILS """ 175 | 176 | def log_header(text): 177 | if len(text) > 16: 178 | sys.stdout.write("-"*80 + "\n" + "-"*25 + " {:^28} ".format(text) + 179 | "-"*25 + "\n" + "-"*80+ "\n") 180 | else: 181 | sys.stdout.write("-"*80 + "\n" + "-"*31 + " {:^16} ".format(text) + 182 | "-"*31 + "\n" + "-"*80+ "\n") 183 | 184 | # from https://stackoverflow.com/a/52590238 185 | def delete_last_lines(): 186 | # Moves cursor up one line 187 | sys.stdout.write('\x1b[1A') 188 | sys.stdout.write('\x1b[1A') 189 | 190 | def newline(): 191 | sys.stdout.write('\n') 192 | 193 | def setGlobal(printToScreen): 194 | global printToScreenGlobal 195 | printToScreenGlobal = printToScreen 196 | 197 | def log(*args): 198 | if (re.search("Package|CPU.*|GPU|DRAM", args[0])): 199 | measurement = args[1] 200 | sys.stdout.write("\r{:<24} {:>49.2f} {:5<}".format(args[0]+":", measurement, "watts")) 201 | 202 | if args[0] == "Baseline wattage": 203 | measurement = args[1] 204 | sys.stdout.write("\r{:<24} {:>49.2f} {:5<}".format(args[0]+":", measurement, "watts")) 205 | 206 | elif args[0] == "Process wattage": 207 | measurement = args[1] 208 | sys.stdout.write("\r{:<17} {:>56.2f} {:5<}".format(args[0]+":", measurement, "watts")) 209 | 210 | elif args[0] == "Final Readings": 211 | newline() 212 | baseline_average, process_average, difference_average, timedelta = args[1], args[2], args[3], args[4] 213 | delete_last_lines() 214 | log_header(args[0]) 215 | sys.stdout.write("{:<25} {:>48.2f} {:5<}\n".format("Average baseline wattage:", baseline_average, "watts")) 216 | sys.stdout.write("{:<25} {:>48.2f} {:5<}\n".format("Average total wattage:", process_average, "watts")) 217 | sys.stdout.write("{:<25} {:>48.2f} {:5<}\n".format("Average process wattage:", difference_average, "watts")) 218 | sys.stdout.write("{:<17} {:>62}\n".format("Process duration:", timedelta)) 219 | 220 | elif args[0] == "Energy Data": 221 | location = args[2] 222 | log_header('Energy Data') 223 | if location == "Unknown" or locate.in_US(location): 224 | coal, oil, gas, low_carbon = args[1] 225 | if location == "Unknown": 226 | location = "United States" 227 | sys.stdout.write("{:^80}\n{:<13}{:>66.2f}%\n{:<13}{:>66.2f}%\n{:<13}{:>66.2f}%\n" 228 | "{:<13}{:>66.2f}%\n".format("Location unknown, default energy mix in "+location+":", "Coal:", coal, "Oil:", oil, 229 | "Natural Gas:", gas, "Low Carbon:", low_carbon)) 230 | elif locate.in_US(location): 231 | sys.stdout.write("{:^80}\n{:<13}{:>66.2f}%\n{:<13}{:>66.2f}%\n{:<13}{:>66.2f}%\n" 232 | "{:<13}{:>66.2f}%\n".format("Energy mix in "+location, "Coal:", coal, "Oil:", oil, 233 | "Natural Gas:", gas, "Low Carbon:", low_carbon)) 234 | else: 235 | coal, natural_gas, petroleum, low_carbon = args[1] 236 | sys.stdout.write("{:^80}\n{:<13}{:>66.2f}%\n{:<13}{:>66.2f}%\n{:<13}{:>66.2f}%\n" 237 | "{:<13}{:>66.2f}%\n".format("Energy mix in "+location, "Coal:", coal, "Petroleum:", petroleum, 238 | "Natural Gas:", natural_gas, "Low Carbon:", low_carbon)) 239 | 240 | elif args[0] == "Emissions": 241 | emission = args[1] 242 | log_header('Emissions') 243 | sys.stdout.write("{:<19}{:>54.2e} kg CO2\n".format("Effective emission:", \ 244 | emission)) 245 | sys.stdout.write("{:<24}{:>50.2e} miles\n".format("Equivalent miles driven:", \ 246 | convert.carbon_to_miles(emission))) 247 | sys.stdout.write("{:<45}{:>27.2e} minutes\n".format("Equivalent minutes of 32-inch LCD TV watched:", \ 248 | convert.carbon_to_tv(emission))) 249 | sys.stdout.write("{:<45}{:>34.2e}%\n".format("Percentage of CO2 used in a US" 250 | " household/day:",convert.carbon_to_home(emission))) 251 | 252 | elif args[0] == "Assumed Carbon Equivalencies": 253 | log_header('Assumed Carbon Equivalencies') 254 | sys.stdout.write("{:<14} {:>65}\n".format("Coal:", "995.725971 kg CO2/MWh")) 255 | sys.stdout.write("{:<14} {:>65}\n".format("Petroleum:", "816.6885263 kg CO2/MWh")) 256 | sys.stdout.write("{:<14} {:>65}\n".format("Natural gas:", "743.8415916 kg CO2/MWh")) 257 | sys.stdout.write("{:<14} {:>65}\n".format("Low carbon:", "0 kg CO2/MWh")) 258 | elif args[0] == "Emissions Comparison": 259 | log_header('Emissions Comparison') 260 | emissions = args[1] 261 | for location, emission in emissions: 262 | sys.stdout.write("{:<19}{:>54.2e} kg CO2\n".format(location+":", emission)) 263 | 264 | #OLD VERSION: US, EU, Rest comparison 265 | elif args[0] == "Emissions Comparison default": 266 | log_header('Emissions Comparison') 267 | (max_global, median_global, min_global, max_europe, median_europe, min_europe, 268 | max_us, median_us, min_us) = args[1:] 269 | sys.stdout.write("{:^80}\n".format("Quantities below expressed in kg CO2")) 270 | sys.stdout.write("{:8}{:<23} {:<23} {:<22}\n".format("", "US", "Europe", \ 271 | "Global minus US/Europe")) 272 | sys.stdout.write("{:<7} {:<13}{:>10.2e} {:<13}{:>10.2e} {:<14}{:>10.2e}\n".format("Max:", max_us[0], max_us[1], \ 273 | max_europe[0], max_europe[1], max_global[0], max_global[1])) 274 | sys.stdout.write("{:<7} {:<13}{:>10.2e} {:<13}{:>10.2e} {:<14}{:>10.2e}\n".format("Median:", median_us[0], median_us[1], \ 275 | median_europe[0], median_europe[1], median_global[0], median_global[1])) 276 | sys.stdout.write("{:<7} {:<13}{:>10.2e} {:<13}{:>10.2e} {:<14}{:>10.2e}\n".format("Min:", min_us[0], min_us[1], \ 277 | min_europe[0], min_europe[1], min_global[0], min_global[1])) 278 | elif args[0] == "Process Energy": 279 | energy = args[1] 280 | sys.stdout.write("-"*80+ "\n" + "-"*80 + "\n") 281 | sys.stdout.write("{:<13} {:51} {:>10.2e} {:>3}\n".format("Process used:", "", energy, "kWh")) 282 | 283 | else: 284 | sys.stdout.write(args[0]) 285 | 286 | 287 | """ MISC UTILS """ 288 | 289 | def get_data(file): 290 | file = os.path.join(DIR_PATH, file) 291 | with open(file) as f: 292 | data = json.load(f) 293 | return data 294 | 295 | def valid_cpu(): 296 | return os.path.exists(BASE) and bool(os.listdir(BASE)) 297 | 298 | def valid_gpu(): 299 | """ Checks that there is a valid Nvidia GPU """ 300 | try: 301 | bash_command = "nvidia-smi > /dev/null 2>&1" #we must pipe to ignore error message 302 | output = subprocess.check_call(['bash', '-c', bash_command]) 303 | return isinstance(output, float) # directly return a boolean 304 | except: 305 | return False 306 | -------------------------------------------------------------------------------- /get-country-averages.py: -------------------------------------------------------------------------------- 1 | import statistics 2 | import json 3 | import energyusage 4 | import energyusage.locate as locate 5 | with open("./energyusage/data/json/energy-mix-intl.json") as file: 6 | data = json.load(file) 7 | 8 | max = "" 9 | median = "" 10 | min = "" 11 | countries = [] 12 | 13 | 14 | for country in data: 15 | c = data[country] 16 | total, breakdown = c['total'], [c['coal'], c['petroleum'], \ 17 | c['naturalGas'], c['lowCarbon']] 18 | if isinstance(c['total'], float) and locate.in_Europe(country): 19 | #breakdown = list(map(lambda x: 100*x/total, breakdown)) 20 | countries.append((country,breakdown)) 21 | 22 | coal = 0 23 | petroleum = 0 24 | naturalGas = 0 25 | lowCarbon = 0 26 | length = len(countries) 27 | 28 | for country in countries: 29 | coal+=country[1][0] 30 | naturalGas+=country[1][1] 31 | petroleum+=country[1][2] 32 | lowCarbon+=country[1][3] 33 | 34 | coal /= length 35 | petroleum /= length 36 | naturalGas /= length 37 | lowCarbon /= length 38 | total = coal+petroleum+naturalGas+lowCarbon 39 | print("Total: " + str(total) + "\nCoal: " + str(coal) + "\nPetroleum: " + str(petroleum) + "\nNatural Gas: " + str(naturalGas) + "\nLow Carbon: " + str(lowCarbon)) 40 | 41 | 42 | 43 | ''' 44 | sorted_countries = sorted(countries, key= lambda x: x[1][0], reverse=True) 45 | max = sorted_countries[0] 46 | min = sorted_countries[len(sorted_countries)-1] 47 | median = sorted_countries[len(sorted_countries)//2 + 1] 48 | 49 | print("Max is " + max[0]) 50 | print("Min is " + min[0]) 51 | print("Median is " + median[0]) 52 | ''' -------------------------------------------------------------------------------- /get_top_countries.py: -------------------------------------------------------------------------------- 1 | import statistics 2 | import json 3 | with open("./energyusage/data/json/energy-mix-intl_2016.json") as file: 4 | data = json.load(file) 5 | 6 | max = "" 7 | median = "" 8 | min = "" 9 | countries = [] 10 | 11 | 12 | for country in data: 13 | c = data[country] 14 | total, breakdown = c['total'], [c['coal'], c['petroleum'], \ 15 | c['naturalGas'], c['lowCarbon']] 16 | if isinstance(c['total'], float) and c['total'] != 0: 17 | breakdown = list(map(lambda x: 100*x/total, breakdown)) 18 | countries.append((country,breakdown)) 19 | 20 | sorted_countries = sorted(countries, key= lambda x: x[1][0], reverse=True) 21 | max = sorted_countries[0] 22 | min = sorted_countries[len(sorted_countries)-1] 23 | median = sorted_countries[len(sorted_countries)//2 + 1] 24 | 25 | print("Max is " + max[0]) 26 | print("Min is " + min[0]) 27 | print("Median is " + median[0]) 28 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | 3 | -------------------------------------------------------------------------------- /sample.py: -------------------------------------------------------------------------------- 1 | import energyusage 2 | 3 | # user function to be evaluated 4 | def recursive_fib(n): 5 | if (n<=2): return 1 6 | else: return recursive_fib(n-1) + recursive_fib(n-2) 7 | 8 | def main(): 9 | energyusage.evaluate(recursive_fib, 40, pdf=True, energyOutput=True) 10 | # returns 102,334,155 11 | 12 | if __name__ == '__main__': main() 13 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | with open("README.md", "r") as fh: 4 | long_description = fh.read() 5 | 6 | NAME = "energyusage" 7 | VERSION = "0.0.13" 8 | 9 | DESCRIPTION = "Measuring the environmental impact of computation" 10 | LONG_DESCRIPTION = long_description 11 | LONG_DESCRIPTION_CONTENT_TYPE = 'text/markdown' 12 | 13 | URL = "https://github.com/responsibleproblemsolving/energy-usage" 14 | 15 | AUTHOR = "Sorelle Friedler, Kadan Lottick, Silvia Susai" 16 | AUTHOR_EMAIL = "sorelle@cs.haverford.edu" 17 | 18 | LICENSE = "Apache 2.0" 19 | 20 | CLASSIFIERS = [ 21 | "Programming Language :: Python :: 3", 22 | "License :: OSI Approved :: Apache Software License", 23 | "Operating System :: OS Independent", 24 | ] 25 | 26 | PACKAGES = ['energyusage'] 27 | 28 | PACKAGE_DATA = { 29 | 'energyusage.data.csv' : ['*.csv'], 30 | 'energyusage.data.json' : ['*.json'] 31 | } 32 | INCLUDE_PACKAGE_DATA = True 33 | 34 | PACKAGE_DIR = { 35 | 'energyusage.data' : 'data' 36 | } 37 | 38 | INSTALL_REQUIRES = [ 39 | 'requests', 40 | 'reportlab' 41 | ] 42 | 43 | setup( 44 | name= NAME, 45 | version=VERSION, 46 | description=DESCRIPTION, 47 | long_description=LONG_DESCRIPTION, 48 | long_description_content_type = LONG_DESCRIPTION_CONTENT_TYPE, 49 | url=URL, 50 | author=AUTHOR, 51 | author_email = AUTHOR_EMAIL, 52 | license = LICENSE, 53 | classifiers=CLASSIFIERS, 54 | packages = PACKAGES, 55 | package_data = PACKAGE_DATA, 56 | include_package_data = INCLUDE_PACKAGE_DATA, 57 | package_dir = PACKAGE_DIR, 58 | install_requires=INSTALL_REQUIRES 59 | ) 60 | --------------------------------------------------------------------------------