|
| 1 | +#!/usr/bin/env python |
| 2 | +#========================================================================= |
| 3 | +# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public |
| 4 | +# License (GPL) version 3, as described at www.opensource.org. |
| 5 | +# Author: William H. Majoros (bmajoros@alumni.duke.edu) |
| 6 | +#========================================================================= |
| 7 | +from __future__ import (absolute_import, division, print_function, |
| 8 | + unicode_literals, generators, nested_scopes, with_statement) |
| 9 | +from builtins import (bytes, dict, int, list, object, range, str, ascii, |
| 10 | + chr, hex, input, next, oct, open, pow, round, super, filter, map, zip) |
| 11 | +# The above imports should allow this program to run in both Python 2 and |
| 12 | +# Python 3. You might need to update your version of module "future". |
| 13 | +import sys |
| 14 | +import ProgramName |
| 15 | +from StanParser import StanParser |
| 16 | + |
| 17 | +#========================================================================= |
| 18 | +# main() |
| 19 | +#========================================================================= |
| 20 | +if(len(sys.argv)<3): |
| 21 | + exit(ProgramName.get()+" <infile.txt> <var1> <var2> ...\n") |
| 22 | +infile=sys.argv[1] |
| 23 | +variables=sys.argv[2:] |
| 24 | + |
| 25 | +parser=StanParser(infile) |
| 26 | +#(median,mean,SD,min,max)=parser.getSummary(variable) |
| 27 | +#print("# posterior median=",median,sep="") |
| 28 | +samplesByVar=[] |
| 29 | +n=0 |
| 30 | +for var in variables: |
| 31 | + samples=parser.getVariable(var) |
| 32 | + samplesByVar.append(samples) |
| 33 | + n=len(samples) |
| 34 | +for i in range(n): |
| 35 | + line=[] |
| 36 | + for sample in samplesByVar: line.append(str(sample[i])) |
| 37 | + print("\t".join(line)) |
| 38 | + |
| 39 | + |
| 40 | + |
0 commit comments