aggrdef test definitions:
>>> from lxml import etree
>>> import datetime
>>> from pprint import pprint
>>> from simo.builder.output.aggrdef import AggregationOutputDef
>>> tdf = open('../../simulator/xml/schemas/Typedefs_SIMO.xsd')
>>> typedef = tdf.read()
>>> tdf.close()
>>> sf = open('../../simulator/xml/schemas/report_definition.xsd')
>>> schema = sf.read()
>>> sf.close()
>>> xml = '''<?xml version="1.0" encoding="UTF-8"?>
... <report_definition
... xmlns="http://www.simo-project.org/simo"
... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
... xsi:schemaLocation="http://www.simo-project.org/simo
... ../schemas/report_definition.xsd">
... <initial_date>2009-01-01</initial_date>
... <discount_rate>3.0</discount_rate>
... <reporting_periods>
... <period>
... <length>5</length>
... <unit>year</unit>
... </period>
... </reporting_periods>
... <reports>
... <report>
... <expression>sum[0:99](stratum:SP*stratum:HgM)</expression>
... <proportion>true</proportion>
... <group_by>
... <grouping>
... <level>stratum</level>
... <variable>HgM</variable>
... </grouping>
... <grouping>
... <level>stratum</level>
... <variable>DgM</variable>
... </grouping>
... </group_by>
... </report>
... <report>
... <expression>sum[0:99](operation:Volume)</expression>
... <proportion>false</proportion>
... </report>
... </reports>
... </report_definition>'''
Aggregation output definitions.
>>> aodef = AggregationOutputDef(typedef)
>>> aodef.schema = schema
>>> aodef.xml = ('test data', xml, None)
Aggregationoutput info.
>>> ao = aodef.obj['test data']
>>> pprint(ao.data)
{'discount_rate': 3.0,
'initial_date': datetime.date(2009, 1, 1),
'reporting_periods': [{'length': '5', 'unit': 'year'}],
'reporting_variables': [{'expression': 'sum[0:99](stratum:SP*stratum:HgM)',
'grouping': {'stratum': ['HgM', 'DgM']},
'proportion': True},
{'expression': 'sum[0:99](operation:Volume)',
'grouping': {},
'proportion': False}]}
Parses the agregation output instructions into self.data