< All Topics

Parsing multi-stream deposition results

If you need to access the result values from a deposition run, an easy way to do this is to access the results.py file.  results.py is created at the end of a deposition run and contains all the output values, stored as Python dictionaries.

An example is shown below (and is attached to this article).

formatted_results = {   'all_streams': {   'error': 0.0,
                       'tonnage above water': '316,941 t',
                       'tonnage below water': '6,838,874 t',
                       'total tonnage': '7,155,815 t',
                       'total volume': '7,155,815 m3',
                       'volume above water': '316,941 m3',
                       'volume below water': '6,838,874 m3'},
    'pipelines': [   {   'average thickness': '7.59 m',
                         'discharge elevation': '114.000 m',
                         'discharge name': u'disch_1',
                         'discontinuty fixed': 'No',
                         'error': 0.0,
                         'maximum runout distance': '753.2 m',
                         'maximum thickness': '15.3 m',
                         'minimum tailings elevation': '97.930 m',
                         'pipeline_name': u'0-disch_1',
                         'surface area': '690,500 m2',
                         'tailings name': u'Sand',
                         'thickness 10 percentile': '1.38 m',
                         'thickness 25 percentile': '3.84 m',
                         'thickness 50 percentile': '7.95 m',
                         'thickness 75 percentile': '11.4 m',
                         'thickness 90 percentile': '13.0 m',
                         'tonnage above water': '203,942 t',
                         'tonnage below water': '5,162,491 t',
                         'total tonnage': '5,366,433 t',
                         'total volume': '5,366,433 m3',
                         'volume above water': '203,942 m3',
                         'volume below water': '5,162,491 m3'},
                     {   'average thickness': '8.15 m',
                         'discharge elevation': '114.000 m',
                         'discharge name': u'disch_2',
                         'discontinuty fixed': 'No',
                         'error': 0.0,
                         'maximum runout distance': '626.1 m',
                         'maximum thickness': '15.6 m',
                         'minimum tailings elevation': '97.930 m',
                         'pipeline_name': u'1-disch_2',
                         'surface area': '395,300 m2',
                         'tailings name': u'Sand',
                         'thickness 10 percentile': '1.57 m',
                         'thickness 25 percentile': '4.39 m',
                         'thickness 50 percentile': '8.96 m',
                         'thickness 75 percentile': '12.0 m',
                         'thickness 90 percentile': '13.3 m',
                         'tonnage above water': '112,999 t',
                         'tonnage below water': '1,676,383 t',
                         'total tonnage': '1,789,382 t',
                         'total volume': '1,789,382 m3',
                         'volume above water': '112,999 m3',
                         'volume below water': '1,676,383 m3'}],
    'pond_summary': {   'fluid volume': '3,452,534 m3',
                        'pond area': '1,118,407 m2',
                        'pond elevation': '112.000 m'}}

results = {   'all_streams': {   'error': 0.0,
                       'tonnage above water': 316941.05241813918,
                       'tonnage below water': 6838874.3552245758,
                       'total tonnage': 7155815.4076427156,
                       'total volume': 7155815.4076427156,
                       'volume above water': 316941.05241813918,
                       'volume below water': 6838874.3552245758},
    'pipelines': [   {   'average thickness': 7.5936511764264409,
                         'discharge elevation': 114.0,
                         'discharge name': u'disch_1',
                         'discontinuty fixed': 'No',
                         'error': 0.0,
                         'maximum runout distance': 753.15368899381826,
                         'maximum thickness': 15.332381134448184,
                         'minimum tailings elevation': 97.930148605768196,
                         'pipeline_name': u'0-disch_1',
                         'surface area': 690499.9102783203,
                         'tailings name': u'Sand',
                         'thickness 10 percentile': 1.379912635061308,
                         'thickness 25 percentile': 3.8404962157599201,
                         'thickness 50 percentile': 7.95355647763283,
                         'thickness 75 percentile': 11.384940776266205,
                         'thickness 90 percentile': 12.95215346864007,
                         'tonnage above water': 203942.15200736272,
                         'tonnage below water': 5162491.134373202,
                         'total tonnage': 5366433.2863805657,
                         'total volume': 5366433.2863805657,
                         'volume above water': 203942.15200736272,
                         'volume below water': 5162491.134373202},
                     {   'average thickness': 8.1519883887476841,
                         'discharge elevation': 114.0,
                         'discharge name': u'disch_2',
                         'discontinuty fixed': 'No',
                         'error': 0.0,
                         'maximum runout distance': 626.09632437629693,
                         'maximum thickness': 15.649875961396901,
                         'minimum tailings elevation': 97.930148605768196,
                         'pipeline_name': u'1-disch_2',
                         'surface area': 395299.9267578125,
                         'tailings name': u'Sand',
                         'thickness 10 percentile': 1.571016005108774,
                         'thickness 25 percentile': 4.3873515131187659,
                         'thickness 50 percentile': 8.9591415795681755,
                         'thickness 75 percentile': 12.02327028138723,
                         'thickness 90 percentile': 13.264997431434894,
                         'tonnage above water': 112998.90041077648,
                         'tonnage below water': 1676383.2208513734,
                         'total tonnage': 1789382.1212621497,
                         'total volume': 1789382.1212621497,
                         'volume above water': 112998.90041077648,
                         'volume below water': 1676383.2208513734}],
    'pond_summary': {   'fluid volume': 3452533.8435728326,
                        'pond area': 1118407.4542764872,
                        'pond elevation': 112.0}}

There are 2 dictionaries defined.  One is the numerical results. The other is the numerical values formatted as text, with appropriate units.

To load the dictionaries, run the following code.

vars = {}
script_text = open('results.py','rt').read() 
exec script_text in None, vars
print vars.keys()

In Line 3 we use the Python command exec which will take the text in script_text and treat it as Python code. This will generate 2 dictionaries.  To make sure that we can get these dictionaries, we need to define our own dictionary (Line 1) and then pass it to the exec command.

In Line 2, the text in results.py is loaded, and then passed to the exec command in Line 3. In Line 4 the keys in the vars dictionary are printed.

Running this code will print the following to the output window.

['formatted_results', 'results']

We will work with the results dictionary (this is the numerical values, not the formatted text). 

We access the results dictionary by using theĀ [ ] operator (lLine 4 below).

vars = {}
script_text = open('results.py','rt').read() 
exec script_text in None, vars
result_dict = vars['results']

print result_dict.keys()

We should see the keys of the results dictionary printed.

['pipelines', 'pond_summary', 'all_streams']

These represent 3 more data structures.  Pipelines is a list that contains the deposition results for each deposition line (in single stream deposition this will have a single entry, in multi-stream deposition this will have an entry for each line).

pond_summary represents the pond results.  all_streams are the total volumes/tonnages for all the pipelines.

Getting pipeline results

To iterate through the pipelines and get the volume deposited from each one, we can use the following code.

vars = {}
script_text = open('results.py','rt').read() 
exec script_text in None, vars
result_dict = vars['results']

pipelines = result_dict['pipelines']
for i, p in enumerate(pipelines):
    print 'Pipeline {}:'.format(i), p['total volume']

In Line 7, as we loop through each entry in the pipelines list, the enumerate function is used to create a variable (i) that increments by 1 each time the loop is run. The first pipeline is referred to as index 0.

Pipeline 0: 5366433.28638
Pipeline 1: 1789382.12126

Accessing pond results 

To get details of the pond, we access the pond_summary dictionary.

vars = {}
script_text = open('results.py','rt').read() 
exec script_text in None, vars
result_dict = vars['results']

pond_summary = result_dict['pond_summary']
print 'Pond volume:', pond_summary['fluid volume']
print 'Pond elevation:', pond_summary['pond elevation']

This will print the results as shown below.

Pond volume: 3452533.84357
Pond elevation: 112.0

Table of Contents