diff options
author | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 01:50:45 +0100 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 01:50:45 +0100 |
commit | cbabefebf76a7c288648752812e87bd41999757f (patch) | |
tree | 0659aad01825ed157d3a402c524fc5452adea39f /plugins/grapher.py | |
parent | ec53566f5ccb4fb88f2f42c3099ab630c0f2375d (diff) |
Plugin updates. Scroll to top command is now 'Q'.
Diffstat (limited to 'plugins/grapher.py')
-rwxr-xr-x | plugins/grapher.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/grapher.py b/plugins/grapher.py new file mode 100755 index 0000000..bd93205 --- /dev/null +++ b/plugins/grapher.py @@ -0,0 +1,50 @@ +#!/usr/bin/python +''' +This script generates a data file that can be read by gnuplot or similar +software. Columns, representing different data fields, may be generated via +command line arguments. Current available columns include: + +- current cycle: always present +- number of organisms: activate with '-o' flag + +To run it, simply call it from within the ./bin/ directory inside the SALIS +main directory, such as: + +../plugins/grapher.py -o def.sim.*.auto + +Calling this will create a single DATA file including data from all files +matching the given pattern. This file may, in turn, be passed into gnuplot +for generating graphs. +''' +import os +import sys +from ctypes import * + +current_arg = 1 +data_flags = [] + +while sys.argv[current_arg][0] == '-': + if sys.argv[current_arg] == '-o': + data_flags.append('organism_count') + print('organism count will be graphed') + else: + print('{} is not a valid flag'.format(sys.argv[current_arg])) + + current_arg += 1 + +files = sys.argv[current_arg:] +oname = 'output.data' +salis = CDLL('libsalis.so') +salis.s_getCycle.restype = c_uint +salis.s_getEpoch.restype = c_uint +salis.sp_getCount.restype = c_uint + +with open(oname, 'w') as output: + for f in files: + salis.s_load(bytes(f, 'utf-8')) + cycle = salis.s_getCycle() + epoch = salis.s_getEpoch() + date = cycle + (epoch * (2 ** 32)) + output.write('{} {}\n'.format(date, salis.sp_getCount())) + print('info of date {} added to output.data'.format(date)) + salis.s_quit() |