Permalink
Browse files

0.2. Water releases are good.

  • Loading branch information...
cmutel committed Sep 17, 2018
1 parent 0337f68 commit d753f2af2708c4c97d8e9345c965966502245971
Showing with 30 additions and 23 deletions.
  1. +1 −1 bw2_aware/__init__.py
  2. +28 −21 bw2_aware/aware.py
  3. +1 −1 setup.py
@@ -4,7 +4,7 @@
'AnnualNonagricultural'
)
__version__ = (0, 1)
__version__ = (0, 2)
from .aware import (
AnnualAgricultural,
@@ -3,22 +3,24 @@
from numbers import Number
SURFACE_WATER = [
('Fresh water (obsolete)', ('water', 'surface water')),
('Water', ('water',)),
('Water', ('water', 'surface water')),
('Water, cooling, unspecified natural origin', ('natural resource', 'in water')),
WATER_RESOURCE = [
('Water, lake', ('natural resource', 'in water')),
('Water, river', ('natural resource', 'in water')),
('Water, turbine use, unspecified natural origin', ('natural resource', 'in water')),
('Water, unspecified natural origin', ('natural resource', 'in water')),
('Water, cooling, unspecified natural origin', ('natural resource', 'in water')),
('Water, unspecified natural origin', ('natural resource', 'in ground')),
('Water, well, in ground', ('natural resource', 'in water')),
]
GROUND_WATER = [
# Ignored on the advice of Stephan Pfister (ETHZ)
# ('Water', ('water', 'ground-, long-term')),
WATER_RELEASE = [
('Fresh water (obsolete)', ('water', 'surface water')),
('Water', ('water',)),
('Water', ('water', 'surface water')),
('Water', ('water', 'ground-')),
('Water', ('water', 'ground-, long-term')),
('Water, unspecified natural origin', ('natural resource', 'in ground')),
('Water, well, in ground', ('natural resource', 'in water')),
]
@@ -32,17 +34,10 @@ class AWARE(LCIA):
url = "http://www.wulca-waterlca.org/aware.html"
id_column = 'id'
def _water_flows(self, kind='all'):
mapping = {
'all': SURFACE_WATER + GROUND_WATER,
'surface': SURFACE_WATER,
'ground': GROUND_WATER
}
flows = mapping[kind]
def _water_flows(self, water):
for act in self.db:
name, categories = act['name'], tuple(act['categories'])
for x, y in flows:
for x, y in water:
if name == x and categories == y:
yield act.key
@@ -54,19 +49,22 @@ def setup_geocollections(self):
}
def global_cfs(self):
for key in self._water_flows():
for key in self._water_flows(WATER_RESOURCE):
yield((key, self.global_cf, "GLO"))
for key in self._water_flows(WATER_RELEASE):
yield((key, self.global_cf * -1, "GLO"))
def regional_cfs(self):
water_flows = list(self._water_flows())
positive_water_flows = list(self._water_flows(WATER_RESOURCE))
negative_water_flows = list(self._water_flows(WATER_RELEASE))
for obj in self.global_cfs():
yield obj
with fiona.drivers():
with fiona.open(self.vector_ds) as src:
for feat in src:
for key in water_flows:
for key in positive_water_flows:
if not isinstance(feat['properties'][self.column], Number):
continue
yield (
@@ -75,6 +73,15 @@ def regional_cfs(self):
(self.geocollection, feat['properties'][self.id_column])
)
for key in negative_water_flows:
if not isinstance(feat['properties'][self.column], Number):
continue
yield (
key,
feat['properties'][self.column] * -1,
(self.geocollection, feat['properties'][self.id_column])
)
class AnnualAgricultural(AWARE):
column = "annual_agriculture"
@@ -16,7 +16,7 @@
setup(
name='bw2_aware',
version="0.1",
version="0.2",
packages=packages,
author="Chris Mutel",
author_email="cmutel@gmail.com",

0 comments on commit d753f2a

Please sign in to comment.