Skip to content

Commit

Permalink
Try creating new dataset for recycled content in markets
Browse files Browse the repository at this point in the history
Doesn't work - gets errors due to linking.

Need to start over and have a clear strategy on naming and linking throughout entire calculation chain.
  • Loading branch information
cmutel committed Feb 1, 2019
1 parent b80cda7 commit 3554ca2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Empty file.
44 changes: 44 additions & 0 deletions ocelot/transformations/cutoff/wastes.py
Expand Up @@ -177,6 +177,49 @@ def create_recycled_content_datasets(data):
}


def create_recycled_content_datasets_for_markets(data):
"""Create new datasets for a few markets that consume post-consumer recyclable goods in the cutoff system model.
Create a new transforming activity that produces these recyclable inputs without any environmental burdens.
Used for markets like ``market for used vegetable cooking oil`` or ``market for waste newspaper``, where we don't have any activity producing the recyclable products."""
new_datasets = {}
all_names = {ds['name'] for ds in data}
for ds in data:
if ds['type'] != "market activity":
continue
products = [exc
for exc in ds['exchanges']
if exc['type'] in ('reference product', 'byproduct')
and exc['amount']]
if len(products) != 1:
continue
recyclabes = [exc
for exc in products
if exc.get('byproduct classification') == 'recyclable']
if len(recyclabes) != 1:
continue

exc = recyclabes[0]
exc['name'] += RC_STRING

if exc['name'] not in all_names:
rc = create_new_recycled_content_dataset(ds, exc)
new_datasets[rc['name']] = rc
for name in new_datasets:
logger.info({
'type': 'table element',
'data': (name,),
})
return data + list(new_datasets.values())

create_recycled_content_datasets_for_markets.__table__ = {
'title': 'Create new datasets to consume recyclable byproducts for markets',
'columns': ["Activity name"]
}



@single_input
def flip_non_allocatable_byproducts(dataset):
"""Change non-allocatable byproducts (i.e. classification ``recyclable`` or ``waste``) from outputs to technosphere to inputs from technosphere.
Expand Down Expand Up @@ -213,5 +256,6 @@ def flip_non_allocatable_byproducts(dataset):
"Handle waste outputs",
rename_recyclable_content_exchanges,
create_recycled_content_datasets,
create_recycled_content_datasets_for_markets,
flip_non_allocatable_byproducts,
)

0 comments on commit 3554ca2

Please sign in to comment.