Comments (6)
stewi.getInventory('eGRID', year, stewiformat='flowbyfacility')
will return a dataframe that includes emissions and Electricity output as a flow.
Note also that stewi.getInventoryFacilities('eGRID', year)
includes the fuel type by facility.
My guess is some combination of these generated the files originally but I do not know.
from electricitylci.
from electricitylci.
Note that it does not appear that StEWI has the facility generation data from eGRID. Tried the various formats with "getInventory," but failed to find 'Electricity' data.
- https://github.com/USEPA/standardizedinventories/blob/master/stewi/__init__.py#L63
- https://github.com/USEPA/standardizedinventories/blob/master/stewi/formats.py#L10
Found it here:
from electricitylci.
Example code:
import os
import pandas as pd
from stewi import getInventoryFacilities
from stewi import getInventory
def make_egrid_subregion_ref(year):
"""Generate the 'egrid_subregion_generation_inventory_reference' CSV data
file for a given year (if it does not already exist).
Parameters
----------
year : ing
Data year.
"""
# Define the output file, which should be in data directory of package.
ref_name = "egrid_subregion_generation_by_fuelcategory_reference_%s.csv" % year
ref_path = os.path.join(data_dir, ref_name)
if os.path.exists(ref_path):
logging.info(
"eGRID subregion generation inventory %s reference exists" % year)
else:
logging.info(
"Creating eGRID subregion generation inventory "
"%s reference CSV" % year)
# Pull the inventory data from stewi.
a = stewi.getInventory("eGRID", year)
# Pull facility meta data from stewi.
meta_cols = [
'FacilityID',
'eGRID subregion acronym',
'Plant primary coal/oil/gas/ other fossil fuel category'
]
b = stewi.getInventoryFacilities("eGRID", 2018)[meta_cols]
# Merge two data frames together to get inventory + facility metadata.
c = pd.merge(
left=a.query("FlowName == 'Electricity'"),
right=b,
on="FacilityID",
)
# Group by and sum by FacilityID and FuelCategory to get total
# electricity generation. Update column names to match existing
# CSV files in the repo.
c = c.groupby(
by=[
'eGRID subregion acronym',
'Plant primary coal/oil/gas/ other fossil fuel category']
)['FlowAmount'].agg('sum').reset_index()
c = c.rename(columns={
'eGRID subregion acronym': 'Subregion',
'Plant primary coal/oil/gas/ other fossil fuel category': 'FuelCategory',
'FlowAmount': 'Electricity'
})
# Convert Electricity from MJ to MWh; and order
c['Electricity'] /= 3600.0
c = c.sort_values(by=['FuelCategory', 'Subregion'])
c.to_csv(ref_path, index=False)
from electricitylci.
^^^ The method above will be added to egrid_facilities.py
to create the reference CSV when called in the global space of egrid_energy.py
right before the file is accessed to avoid FileNotFound Error.
from electricitylci.
NOTE: I found no reference to either "egrid_subregion_totals_reference_2016.csv" or "egrid_subregion_totals_reference_2014.csv" so I omitted their creation.
from electricitylci.
Related Issues (20)
- What impact assessment method? HOT 4
- Globals, references to globals, and editing references of globals
- Forced BA aggregation for FERC and US, but what about eGRID? HOT 3
- Should PC link to petcoke UP? HOT 2
- KeyError in fill_default_provider_uuids
- Missing data file reference in Wiki
- No fuel category in Stewi's getInventoryFacilities for eGRID 2020 HOT 1
- _exchange_table_creation_ref missing renewables HOT 1
- EIA coalpublic2021.xls Excel file format cannot be determined HOT 1
- Missing International Mix data for 2021 onward HOT 3
- Addressing the Industrial Cogeneration Problem and Implementing the filter in model_config HOT 1
- Fix output exchange flows mislabeled as resources HOT 5
- Mexican balancing authority labeled as Canada in BA_Codes_930.xlsx HOT 7
- No 2022 EIA transmission and distribution loss data HOT 3
- Missing Canadian Exports for 2021 and beyond HOT 1
- Fix region mis-match between consumption and distribution mixes
- Incorrect output flow for "at grid; consumption mix" HOT 2
- Issues with the electricity column in generate_plant_water_use() HOT 1
- Update coal model inventories
- Set temporal representativeness attribute for processes to inventory vintage, not target year
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electricitylci.