def regressionScale(comparisonFlux, targetFlux, time, ingress, egress,
                    returncoeffs=False):

    outOfTransit = (time < ingress) + (time > egress)
    regressMatrix = np.vstack([comparisonFlux[outOfTransit]]).T
    assert len(targetFlux[outOfTransit]) > 0, \
        'No fluxes marked as "out-of-transit" according to input ingress/egress'
    m = LA.lstsq(regressMatrix, targetFlux[outOfTransit])[0]
    scaledVector = m*comparisonFlux
    if returncoeffs:
        return scaledVector, m
    else:
        return scaledVector
Use a least-squares regression to stretch and offset a comparison
dataset/ETHPy150Open OSCAAR/OSCAAR/oscaar/mathMethods.py/regressionScale