Numbers(inThing, col=0, skip=0)¶
Simple 1-dimensional data handling. Emphasis on ‘simple’.
Feed this a list of floats, or the name of a file containing floats. If it is a file, lines are read in only if the first character is a digit. So lines starting with words, ‘#’, or blank lines, are ignored (and those ignored lines do not contribute to the ‘skip’, below). So this should be able to read in MrBayes
*.pfiles, sensibly skipping the first lines.
If inThing is a file, it can have multiple columns. This says which one to use. Zero-based!
If inThing is a file, you can skip lines at the beginning. This says how many. It skips ‘skip’ data lines in addition to ignored lines, ‘cuz ignored lines are skipped anyway.
histo()method does a simple 1-D histogram, putting the data into bins. It would be usual to not supply a
binSize, in which case a suitable binSize is chosen for you. But if you don’t like the result, you can optionally specify a binSize, (eg myNumbers.binSize=10.0)
If your numbers are in more than one list or file, you can read in more stuff with the
(property) Return the bin size
Uses gsl. Returns a tuple of the mean and the variance.
Returns log of the harmonic mean of logs.
Self is in log form. The harmonic mean is calculated after exponentiating, and the result is returned as a log.
The method was stolen uncritically from MrBayes. This gives the same result as MrBayes.
histo(verbose=True, binSize=None, padMin=None, padMax=None)¶
Put the data nicely into bins.
After you do this, the bins are available in self.bins, a list of pairs.
Args padMin and padMax extend the range up or down, where the extended bins would have zero content, so they would be placeholders. It would be good for making two different histos have exactly the same range, eg so you can plot them in the same plot.
A horrible hack to plot stuff with GnuPlot.
A file, gnuplot_instructs, is written. Then gnuplot is called. The default terminal type is ‘qt’, so that is needed.
Couldn’t this be done in a clever way with (existing) proper python hooks into GnuPlot? -yes, but it would require installing another module.
To make a png, you could call it with:
To plot to the terminal, say term=’dumb’.
read(inThing, col=0, skip=0)¶
Slurp in some more numbers.
You can use this repeatedly, eg if your numbers are in more than one list or file.