*Given the observe frame lightcurve, determine if the SNe are discoverable by the survey or not.*

    **Key Arguments:**
        - ``log`` -- logger
        - ``redshiftArray`` -- the array of random redshifts
        - ``observedFrameLightCurveInfo`` -- the observed franme lightcurve info (dictionary)
        - ``discoverableList`` -- a list of dictionaries describing if the object is discoverable in each filter and finally if it is discoverable in any filter.
        - ``plot`` -- generate plots?

    **Return:**
        - ``ripeDayList`` -- a list of dictionaries describing the time relative to peak that the SN reaches the limiting mag of the survey

def determine_when_sne_are_ripe_for_discovery(
        log,
        redshiftArray,
        limitingMags,
        observedFrameLightCurveInfo,
        discoverableList,
        plot=True):
    """
    *Given the observe frame lightcurve, determine if the SNe are discoverable by the survey or not.*

    **Key Arguments:**
        - ``log`` -- logger
        - ``redshiftArray`` -- the array of random redshifts
        - ``observedFrameLightCurveInfo`` -- the observed franme lightcurve info (dictionary)
        - ``discoverableList`` -- a list of dictionaries describing if the object is discoverable in each filter and finally if it is discoverable in any filter.
        - ``plot`` -- generate plots?

    **Return:**
        - ``ripeDayList`` -- a list of dictionaries describing the time relative to peak that the SN reaches the limiting mag of the survey
    """
    ################ > IMPORTS ################
    ## STANDARD LIB ##
    import math
    ## THIRD PARTY ##
    ## LOCAL APPLICATION ##

    ################ >ACTION(S) ################
    filters = ['g', 'r', 'i', 'z']
    models = ['he80', 'he100', 'he130']

    ripeDayList = []
    for item in range(len(redshiftArray)):
        #log.info("I AM HERE %s" % (item,))
        ripeDayDict = {}
        if not discoverableList[item]["any"]:
            ripeDayDict["any"] = False
            for ffilter in filters:
                ripeDayDict[ffilter] = False
        else:
            for ffilter in filters:
                if not discoverableList[item][ffilter]:
                    ripeDayDict[ffilter] = False
                elif observedFrameLightCurveInfo[item]['lightCurves'][ffilter] is None:
                    ripeDayDict[ffilter] = False
                else:
                    explosionDay = observedFrameLightCurveInfo[
                        item]['explosionDay']
                    lowerLimit = explosionDay
                    upperLimit = 0.
                    ripeDay = lowerLimit
                    magGuess = observedFrameLightCurveInfo[
                        item]['lightCurves'][ffilter](ripeDay)
                    magDiff = limitingMags[ffilter] - magGuess

                    if magGuess > limitingMags[ffilter]:
                        while math.fabs(magDiff) > 0.01:
                            if magGuess > limitingMags[ffilter]:
                                #log.info('item %s ripeDay %s magGuess %s - going higher' % (item, ripeDay, magGuess))
                                lowerLimit = ripeDay
                                ripeDay = lowerLimit + \
                                    (upperLimit - lowerLimit) / 2.
                                magGuess = observedFrameLightCurveInfo[
                                    item]['lightCurves'][ffilter](ripeDay)
                            elif magGuess < limitingMags[ffilter]:
                                #log.info('item %s ripeDay %s' % (item, ripeDay))
                                upperLimit = ripeDay
                                ripeDay = lowerLimit + \
                                    (upperLimit - lowerLimit) / 2.
                                magGuess = observedFrameLightCurveInfo[
                                    item]['lightCurves'][ffilter](ripeDay)
                            magDiff = limitingMags[ffilter] - magGuess

                    ripeDay = float("%5.3f" % (ripeDay,))
                    # log.info('SN#%s, filter %s, ripeDay %s' % (item, ffilter,
                    # ripeDay,))
                    ripeDayDict[ffilter] = ripeDay
            ripeDayDict["any"] = False
            for ffilter in filters:
                if ripeDayDict[ffilter]:
                    ripeDayDict["any"] = True
        ripeDayList.append(ripeDayDict)

    # log.info('ripeDayList %s' % (ripeDayList,))

    return ripeDayList