Return the state of modeling and inversion for a given SIP dir. The
    result does not take into account sensitivities or potentials, as
    optionally generated by CRMod.

    Parameters
    ----------
    sipdir: string
        Directory to check

    Returns
    -------
    crmod_is_finished: bool
        True if all tomodirs of this SIP directory contain finished modeling
        results.
    crtomo_is_finished: bool
        True if all tomodirs of this SIP directory contain finished inversion
        results.

def sipdir_is_finished(sipdir):
    """Return the state of modeling and inversion for a given SIP dir. The
    result does not take into account sensitivities or potentials, as
    optionally generated by CRMod.

    Parameters
    ----------
    sipdir: string
        Directory to check

    Returns
    -------
    crmod_is_finished: bool
        True if all tomodirs of this SIP directory contain finished modeling
        results.
    crtomo_is_finished: bool
        True if all tomodirs of this SIP directory contain finished inversion
        results.

    """
    if not is_sipdir(sipdir):
        raise Exception('Directory is not a valid SIP directory!')

    subdirs_raw = sorted(glob.glob(sipdir + os.sep + 'invmod' + os.sep + '*'))
    subdirs = [x for x in subdirs_raw if os.path.isdir(x)]

    crmod_finished = True
    crtomo_finished = True
    for subdir in subdirs:
        subcrmod, subcrtomo = td_is_finished(subdir)
        if not subcrmod:
            crmod_finished = False
        if not subcrtomo:
            crtomo_finished = False

    return crmod_finished, crtomo_finished