Пример #1
0
def count_facility_matches():
    inventory_no_overlap = stewicombo.combineInventoriesforFacilitiesinOneInventory("eGRID", inventories_of_interest, filter_for_LCI=True,
                                                             remove_overlap=False)
    #drop duplicate Facility_IDs
    inventory_no_overlap_unique_ids = inventory_no_overlap.drop_duplicates(subset=['FacilityID','Source'])
    facility_counts_by_inventory = inventory_no_overlap_unique_ids.groupby('Source')['FacilityID'].count().reset_index()
    return facility_counts_by_inventory
stewicombooutputfile = ''
for k, v in inventories_of_interest.items():
    stewicombooutputfile = stewicombooutputfile + "{}_{}_".format(k, v)
stewicombooutputfile = stewicombooutputfile + 'fromstewicombo.csv'

if os.path.exists(data_dir + "/" + stewicombooutputfile):
    emissions_and_wastes_by_facility = pd.read_csv(data_dir + "/" +
                                                   stewicombooutputfile,
                                                   header=0,
                                                   dtype={
                                                       "FacilityID": "str",
                                                       "Year": "int",
                                                       "eGRID_ID": "str"
                                                   })
else:
    emissions_and_wastes_by_facility = stewicombo.combineInventoriesforFacilitiesinOneInventory(
        "eGRID", inventories_of_interest, filter_for_LCI=True)
    #drop SRS fields
    emissions_and_wastes_by_facility = emissions_and_wastes_by_facility.drop(
        columns=['SRS_ID', 'SRS_CAS'])
    #drop 'Electricity' flow
    emissions_and_wastes_by_facility = emissions_and_wastes_by_facility[
        emissions_and_wastes_by_facility['FlowName'] != 'Electricity']
    #Save it to a csv for the next call
    emissions_and_wastes_by_facility.to_csv(data_dir + stewicombooutputfile,
                                            index=False)

len(emissions_and_wastes_by_facility)
#with egrid 2016, tri 2016, nei 2016, rcrainfo 2015: 106284

#Get a list of unique years in the emissions data
years_in_emissions_and_wastes_by_facility = list(
Пример #3
0
#Get one of these inventory
tri2016 = stewi.getInventory(inventory,year)
#See first 50
tri2016.head(50)

#Look at all the unique flows in this inventory
tri2016flows = stewi.getInventoryFlows(inventory,year)
#See first 50
tri2016flows.head(50)

#Look at all the unique facilities in this inventory
tri2016facilities = stewi.getInventoryFacilities(inventory,year)
#See first 50
tri2016facilities.head(50)

#Now combine with some inventories in another inventory based on facilities
#Enter inventories that you would like to combine in the "Inventory_acryonym":"year" format enclosed in "{}"
inventories_to_get = {"TRI":"2016","NEI":"2016","RCRAInfo":"2015","eGRID":"2016"}

base_inventory = inventory
combinedinventories = stewicombo.combineInventoriesforFacilitiesinOneInventory(base_inventory, inventories_to_get)
#See first 50
combinedinventories.head(50)

#See a summary of the combined inventories by facility and flow
pivotofinventories =  stewicombo.pivotCombinedInventories(combinedinventories)
pivotofinventories.head(200)