def regressionScale(comparisonFlux, targetFlux, time, ingress, egress,
                    returncoeffs=False):
    """
    Use a least-squares regression to stretch and offset a comparison
    star fluxes to scale them to the relative intensity of the target
    star. Only do this regression considering the out-of-transit
    portions of the light curve.

    Parameters
    ----------
    comparisonFlux : numpy.ndarray
        Flux of a comparison star

    targetFlux : numpy.ndarray
        Flux of the target star

    time : numpy.ndarray
        List of times for each flux measurement in JD

    ingress : float
        Time of ingress (JD, assuming time list is in JD)

    egress : float
        Time of egress (JD, assuming time list is in JD)

    Returns
    -------
    scaledVector : numpy.ndarray
        Rescaled version of the comparisonFlux vector using the above
        described process
    """

    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
dataset/ETHPy150Open OSCAAR/OSCAAR/oscaar/mathMethods.py/regressionScale/original