Estimate mass in cgs from absolute J magnitude, using the relationship of
    Delfosse+ (2000A&A...364..217D).

    j_abs - The absolute J magnitude.

    Returns: the estimated mass in grams.

    If j_abs > 11, a fixed result of 0.1 Msun is returned. Values of j_abs <
    5.5 are illegal and get NaN. There is a discontinuity in the relation at
    j_abs = 11, which yields 0.0824 Msun.

def mass_from_j (j_abs):
    """Estimate mass in cgs from absolute J magnitude, using the relationship of
    Delfosse+ (2000A&A...364..217D).

    j_abs - The absolute J magnitude.

    Returns: the estimated mass in grams.

    If j_abs > 11, a fixed result of 0.1 Msun is returned. Values of j_abs <
    5.5 are illegal and get NaN. There is a discontinuity in the relation at
    j_abs = 11, which yields 0.0824 Msun.

    """
    j_abs = np.asfarray (j_abs)
    return np.piecewise (j_abs,
                         [j_abs > 11,
                          j_abs <= 11,
                          j_abs < 5.5],
                         [0.1 * cgs.msun,
                          _delfosse_mass_from_j_helper,
                          np.nan])