Source

bubble-economy / conversion.py

#!/usr/bin/env python
# encoding: utf-8
"""
conversion.py

IO routes. only CSV IO ATM, for Terrys convenience.

Created by dan mackinlay on 2010-10-28.
Copyright (c) 2010 __MyCompanyName__. All rights reserved.
"""

import numpy as np

def terry_summary(ts):
    # _axes = {0:'x', 1:'y'}
    _stats = {'min': np.min, 'max': np.max, 'median': np.median}
    _members = {'vels': ts.raw_output_vels, 'locs': ts.raw_output_locs}
    for stat_name, stat_fn in _stats.iteritems():
        for dataset_name, dataset_val in _members.iteritems():
            fname = '-'.join([
              'vicsek', dataset_name, stat_name
            ]) + '.csv.gz'
            content = np.apply_along_axis(
              stat_fn, 1,
              dataset_val
            )
            np.savetxt(
              fname, content, fmt='%0.7f', delimiter=',')


if __name__ == '__main__':
  main()