def periodNormalLPPTransitMetric(rawTLpp, newPerMes, mapInfo):
    '\n    Normalize the rawTransitMetric value by those with the closest period.\n    This part removes the period dependence of the metric at short periods.\n    Plus it makes a value near one be the threshold between good and bad.\n    \n    newPerMes is the np.array([period, mes]) of the new sample\n    '
    knownTrPeriods = mapInfo.mappedPeriods[mapInfo.knnGood]
    knownTrMes = mapInfo.mappedMes[mapInfo.knnGood]
    knownTrrawLpp = mapInfo.dymeans[mapInfo.knnGood]
    nPercentil = mapInfo.nPercentil
    nPsample = mapInfo.nPsample
    logPeriods = np.log10(knownTrPeriods)
    logMes = np.log10(knownTrMes)
    knownPerMes = np.stack((logPeriods, logMes), axis=(- 1))
    np.shape(knownPerMes)
    logNew = np.log10(newPerMes).reshape(1, (- 1))
    (dist, ind) = knnDistance_fromKnown(knownPerMes, logNew, nPsample)
    nearPeriodLpp = knownTrrawLpp[ind]
    LppNPercentile = np.percentile(nearPeriodLpp, nPercentil)
    NormLppTransitMetric = (rawTLpp / LppNPercentile)
    return NormLppTransitMetric
Normalize the rawTransitMetric value by those with the closest period.
This part removes the period dependence of the metric at short periods.
Plus it makes a value near one be the threshold between good and bad.

newPerMes is the np.array([period, mes]) of the new sample
def periodNormalLPPTransitMetric(rawTLpp, newPerMes, mapInfo):
    '\n    Normalize the rawTransitMetric value by those with the closest period.\n    This part removes the period dependence of the metric at short periods.\n    Plus it makes a value near one be the threshold between good and bad.\n    \n    newPerMes is the np.array([period, mes]) of the new sample\n    '
    knownTrPeriods = mapInfo.mappedPeriods[mapInfo.knnGood]
    knownTrMes = mapInfo.mappedMes[mapInfo.knnGood]
    knownTrrawLpp = mapInfo.dymeans[mapInfo.knnGood]
    nPercentil = mapInfo.nPercentil
    nPsample = mapInfo.nPsample
    logPeriods = np.log10(knownTrPeriods)
    logMes = np.log10(knownTrMes)
    knownPerMes = np.stack((logPeriods, logMes), axis=(- 1))
    np.shape(knownPerMes)
    logNew = np.log10(newPerMes).reshape(1, (- 1))
    (dist, ind) = knnDistance_fromKnown(knownPerMes, logNew, nPsample)
    nearPeriodLpp = knownTrrawLpp[ind]
    LppNPercentile = np.percentile(nearPeriodLpp, nPercentil)
    NormLppTransitMetric = (rawTLpp / LppNPercentile)
    return NormLppTransitMetric