def get_snr_of_dip(times,<EOL>mags,<EOL>modeltimes,<EOL>modelmags,<EOL>atol_normalization=<NUM_LIT>,<EOL>indsforrms=None,<EOL>magsarefluxes=False,<EOL>verbose=True,<EOL>transitdepth=None,<EOL>npoints_in_transit=None):
if magsarefluxes:<EOL><INDENT>if not np.isclose(np.nanmedian(modelmags), <NUM_LIT:1>, atol=atol_normalization):<EOL><INDENT>raise AssertionError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>if not transitdepth:<EOL><INDENT>transitdepth = np.abs(np.max(modelmags) - np.min(modelmags))<EOL><DEDENT>if not len(mags) == len(modelmags):<EOL><INDENT>from scipy.interpolate import interp1d<EOL>fn = interp1d(modeltimes, modelmags, kind='<STR_LIT>', bounds_error=True,<EOL>fill_value=np.nan)<EOL>modelmags = fn(times)<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>')<EOL><DEDENT><DEDENT>subtractedmags = mags - modelmags<EOL>if isinstance(indsforrms, np.ndarray):<EOL><INDENT>subtractedrms = np.std(subtractedmags[indsforrms])<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>subtractedrms = np.std(subtractedmags)<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>')<EOL><DEDENT><DEDENT>def _get_npoints_in_transit(modelmags):<EOL><INDENT>if np.nanmedian(modelmags) == <NUM_LIT:1>:<EOL><INDENT>return len(modelmags[(modelmags != <NUM_LIT:1>)])<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT><DEDENT>if not npoints_in_transit:<EOL><INDENT>npoints_in_transit = _get_npoints_in_transit(modelmags)<EOL><DEDENT>snr = np.sqrt(npoints_in_transit) * transitdepth/subtractedrms<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>'.format(npoints_in_transit) +<EOL>'<STR_LIT>'.format(transitdepth) +<EOL>'<STR_LIT>'.format(subtractedrms) +<EOL>'<STR_LIT>'.format(snr))<EOL><DEDENT>return snr, transitdepth, subtractedrms<EOL>
Calculate the total SNR of a transit assuming gaussian uncertainties.

    `modelmags` gets interpolated onto the cadence of `mags`. The noise is
    calculated as the 1-sigma std deviation of the residual (see below).

    Following Carter et al. 2009::

        Q = sqrt( Γ T ) * δ / σ

    for Q the total SNR of the transit in the r->0 limit, where::

        r = Rp/Rstar,
        T = transit duration,
        δ = transit depth,
        σ = RMS of the lightcurve in transit.
        Γ = sampling rate

    Thus Γ * T is roughly the number of points obtained during transit.
    (This doesn't correctly account for the SNR during ingress/egress, but this
    is a second-order correction).

    Note this is the same total SNR as described by e.g., Kovacs et al. 2002,
    their Equation 11.

    NOTE: this only works with fluxes at the moment.

    Parameters
    ----------

    times,mags : np.array
        The input flux time-series to process.

    modeltimes,modelmags : np.array
        A transiting planet model, either from BLS, a trapezoid model, or a
        Mandel-Agol model.

    atol_normalization : float
        The absolute tolerance to which the median of the passed model fluxes
        must be equal to 1.

    indsforrms : np.array
        A array of bools of `len(mags)` used to select points for the RMS
        measurement. If not passed, the RMS of the entire passed timeseries is
        used as an approximation. Genearlly, it's best to use out of transit
        points, so the RMS measurement is not model-dependent.

    magsarefluxes : bool
        Currently forced to be True because this function only works with
        fluxes.

    verbose : bool
        If True, indicates progress and warns about problems.

    transitdepth : float or None
        If the transit depth is known, pass it in here. Otherwise, it is
        calculated assuming OOT flux is 1.

    npoints_in_transits : int or None
        If the number of points in transit is known, pass it in here. Otherwise,
        the function will guess at this value.

    Returns
    -------

    (snr, transit_depth, noise) : tuple
        The returned tuple contains the calculated SNR, transit depth, and noise
        of the residual lightcurve calculated using the relation described
        above.