def parse_log(logfile, body, param):
    """"
    Parse log file for one of a body's initial conditions and return it.  This
    is useful for when a parameter is not outputted but one needs it later on
    for bigplanet analysis.

    Parameters
    ----------
    logfile : str
        path to the logfile
    body : str
        name of body whose variable you're looking for
    param : str
        body's parameter

    Returns
    -------
    param : float
        initial condition of interest
    """

    # Open log file and get lines
    with open(logfile) as handle:
        lines = handle.readlines()

    # Loop over all lines in the input file looking for body string of the form
    # ----- BODY: planet ----
    to_find_body = "BODY: %s" % body
    for ii in range(0,len(lines)):

        line = lines[ii].strip(' \t\n\r') # Remove whitespace

        # Found it? If so, now loop over lines below it looking for param
        # of the form (param)
        if line.find(to_find_body) != -1:
            to_find_param = "(%s)" % param
            found_it = False
            while not found_it:

                # At the end of the file?
                if ii == len(lines) - 1:
                    raise RuntimeError("Couldn't find %s in %s." % (param, logfile))

                line = lines[ii].strip(' \t\n\r') # Remove whitespace

                # Found it? Done!
                if line.startswith(to_find_param):
                    words = line.split()
                    return float(words[-1])

                # On to the next line
                ii = ii + 1

    # Didn't find it
    raise RuntimeError("Couldn't find %s in %s." % (param, logfile))