Package gmisclib :: Module mcmc_newlogger
[frames] | no frames]

Module mcmc_newlogger

source code

Classes
  WildNumber
  logger_base
  DBGlogger
  logger
  NoDataError
There is not a complete set of data in the log file: data from the outer optimizer and at least one full set of inner optimizer results.
  logline
This holds the information from one line of a log file.
Functions
 
ok(x) source code
 
readiter(logfd, trigger=None)
Reads in one line at a time from a log file.
source code
 
read_raw(logfd)
Read log information in raw line-by-line form.
source code
 
read_log(fname, which)
Read in a log file, returning information that you can use to restart the optimizer.
source code
 
read_multilog(fname, Nsamp=10, tail=0.5)
Read in a log file, producing a sample of stepperstate information.
source code
 
read_multi_uid(fname, uid, Nsamp=10, tail=0.0, trigger=None)
Read in a log file, selecting information only for a particular UID.
source code
(dict{str:str}, list(logline))
read_tail_uid(fname, uid, Nsamp=10, tail=0.0, trigger=None)
Read in a log file, selecting information only for a particular UID.
source code
 
read_human_fmt(fname)
This reads a more human-readable format, as produced by print_log.
source code
 
load_module(phdr) source code
 
print_log(fname, which) source code
Variables
  HUGE = 1e+30
  __package__ = 'gmisclib'

Imports: os, re, cPickle, numpy, die, avio, GM, dictops, load_mod, IC, BadFormatError


Function Details

readiter(logfd, trigger=None)

source code 

Reads in one line at a time from a log file. This is an iterator. At every non-comment line, it yields an output.

Parameters:
  • logfd - a file descriptor for a log file produced by this module.
  • trigger - this is None or a regular expression that specifies when to start paying attention to the data. If trigger is not None, body lines before trigger matches are ignored. Note that trigger is matched to a line with trailing whitespace stripped away.
Returns:
(Yields) (hdr, x) where hdr is a dictionary of the header information current at that point in the file and x is a logline class containing the current line's data.
Raises:

read_log(fname, which)

source code 

Read in a log file, returning information that you can use to restart the optimizer. The log file must be produced by logger.add().

Parameters:
  • fname (str) - the filename to read.
  • which (str) - a string that tells which log entry to grab.
    • "last": the final logged entry;
    • "index%d" (i.e. "index" followed directly by an integer): the %dth log entry (negative numbers count backwards from the end), so "index-1" is the final logged entry and "index0" is the first;
    • "frac%g" (i.e. "frac" followed by a float): picks a log entry as a fraction of the length of the log. "frac0" is the first, and "frac1" is the final entry.
    • "best": picks the iteration with the most positive logP value.
Returns:
(hdr, stepperstate, vlists, logps), where
  • hdr is all the header information from the log file (e.g. metadata).
  • stepperstate is a dictionary of IC.index instances, one per UID and newstem2.position.OuterUID. It will evoke a True when passed to newstem2.position.is_statedict(). Basically, this is a single moment of the stepper's state.
  • vlists is a dictionary (again, one per UID plus...) whose values are lists of position vectors that were recently encountered. This is helpful for the optimizer to figure out plausible step sizes. Basically, this is many moments of state information near idx.
  • logps is a dictionary (again...) whose values are recently obtained values for logP for that UID. This is mostly useful for display and debugging purposes.
Raises:

read_multilog(fname, Nsamp=10, tail=0.5)

source code 

Read in a log file, producing a sample of stepperstate information.

Parameters:
  • tail - Where to start in the file? tail=0 means that you start at the trigger or beginning. tail=1-epsilon means you take just the last tiny bit of the file.

read_multi_uid(fname, uid, Nsamp=10, tail=0.0, trigger=None)

source code 

Read in a log file, selecting information only for a particular UID. This *doesn't* read in multiple UIDs, no matter what the name says: the "multi" refers to the fact that it gives you multiple samples from the log. In other words, it provides a time-series of the changes to the parameters.

OBSOLETE.

Parameters:
  • Nsamp (int or None.) - the maximum number of samples to extract (or None, or -1). None means "as many as are available"; -1 means "as many samples as there are parameters."
  • tail - Where to start in the file? tail=0 means that you start at the trigger or beginning. tail=1-epsilon means you take just the last tiny bit of the file.
Raises:
  • NoDataError - When the log file is empty or a trigger is set but not triggered.

read_tail_uid(fname, uid, Nsamp=10, tail=0.0, trigger=None)

source code 

Read in a log file, selecting information only for a particular UID. It gives you multiple samples from the log. In other words, it provides a time-series of the changes to the parameters.

Parameters:
  • Nsamp (int or None.) - the maximum number of samples to extract (or None, or -1). None means "as many as are available"; -1 means "as many samples as there are parameters."
  • tail - Where to start in the file? tail=0 means that you start at the trigger or beginning. tail=1-epsilon means you take just the last tiny bit of the file.
Returns: (dict{str:str}, list(logline))
The data file's header, and the selected list of logline instances.
Raises:
  • NoDataError - When the log file is empty or a trigger is set but not triggered.

read_human_fmt(fname)

source code 

This reads a more human-readable format, as produced by print_log. It can easily be modified with a text editor to change parameters.