Returns the opitmal SNR squared in the given detector.

        Parameters
        ----------
        det : str
            The name of the detector.

        Returns
        -------
        float :
            The opimtal SNR squared.
1778
def det_optimal_snrsq(self, det):
        
        # try to get it from current stats
        try:
            return getattr(self._current_stats, '{}_optimal_snrsq'.format(det))
        except AttributeError:
            # hasn't been calculated yet; call loglr to do so
            self._loglr()
            # now try returning again
            return getattr(self._current_stats, '{}_optimal_snrsq'.format(det))
1118051
def dInd_calc(TNR, TPR):
    
    try:
        result = math.sqrt(((1 - TNR)**2) + ((1 - TPR)**2))
        return result
    except Exception:
        return "None"
910897
def obfn_reg(self):
        

        rl1 = np.linalg.norm((self.Wl1 * self.obfn_g1var()).ravel(), 1)
        rtv = np.sum(np.sqrt(np.sum(self.obfn_g0var()**2, axis=-1)))
        return (self.lmbda*rl1 + self.mu*rtv, rl1, rtv)
887326
def get_rmetric( self, mode_inv = 'svd', return_svd = False ):
        
        if self.H is None:
            self.H, self.G, self.Hvv, self.Hsval = riemann_metric(self.Y, self.L, self.mdimG, invert_h = True, mode_inv = mode_inv)
        if self.G is None:
            self.G, self.Hvv, self.Hsvals,  self.Gsvals = compute_G_from_H( self.H, mode_inv = self.mode_inv )
        if mode_inv is 'svd' and return_svd:
            return self.G, self.Hvv, self.Hsvals, self.Gsvals
        else:
            return self.G
975779
def _der(self,*args):
        '''
        
        '''
        if len(args) > 0:
            if _isscalar(args[0]):
                return 0.0
            else:
                shape = args[0].shape
                return np.zeros(shape)
        else:
            return 0.0
867241
def _dEndfr(self):
        
        Mc = self._chirp_mass()
        return (np.pi**(2./3.)*Mc**(5./3.)/(3.*(1.+self.z)**(1./3.)
                * (self.freqs_orb/(1.+self.z))**(1./3.))*(2./self.n)**(2./3.)
                * self._g_func()/self._f_func())
106380
def inv(self):
        
        if self.det == 0:
            raise ValueError("SquareTensor is non-invertible")
        return SquareTensor(np.linalg.inv(self))
1063813
def value(self):
        """"""
        return self._sign[1] * self.S0 * norm.cdf(
            self._sign[1] * self.d1, 0.0, 1.0
        ) - self._sign[1] * self.K * np.exp(-self.r * self.T) * norm.cdf(
            self._sign[1] * self.d2, 0.0, 1.0
        )
1021871
def dim_dsigmai(self, pars):
        
        """
        self._set_parameters(pars)
        result = np.sum(- self.m * self.otc * np.sin(self.ang) / self.denom,
                        axis=1)

        return result
441526
def erank(self):
        
        r = self.r
        n = self.n
        d = self.d
        if d <= 1:
            er = 0e0
        else:
            sz = _np.dot(n * r[0:d], r[1:])
            if sz == 0:
                er = 0e0
            else:
                b = r[0] * n[0] + n[d - 1] * r[d]
                if d is 2:
                    er = sz * 1.0 / b
                else:
                    a = _np.sum(n[1:d - 1])
                    er = (_np.sqrt(b * b + 4 * a * sz) - b) / (2 * a)
        return er
445772
def get_rms(self):
        
        return np.sqrt(np.mean(np.square(self._entry_scores)))
699394
private static double snorm(double[] x, int itol) {
        int n = x.length;

        if (itol <= 3) {
            double ans = 0.0;
            for (int i = 0; i < n; i++) {
                ans += x[i] * x[i];
            }
            return Math.sqrt(ans);
        } else {
            int isamax = 0;
            for (int i = 0; i < n; i++) {
                if (Math.abs(x[i]) > Math.abs(x[isamax])) {
                    isamax = i;
                }
            }

            return Math.abs(x[isamax]);
        }
    }
907591
def icnr(x, scale=2, init=nn.init.kaiming_normal_):
    ""
    ni,nf,h,w = x.shape
    ni2 = int(ni/(scale**2))
    k = init(torch.zeros([ni2,nf,h,w])).transpose(0, 1)
    k = k.contiguous().view(ni2, nf, -1)
    k = k.repeat(1, 1, scale**2)
    k = k.contiguous().view([nf,ni,h,w]).transpose(0, 1)
    x.data.copy_(k)
840647
def get_observed_mmax_sigma(self, default=None):
        
        if not isinstance(self.data['sigmaMagnitude'], np.ndarray):
            obsmaxsig = default
        else:
            obsmaxsig = self.data['sigmaMagnitude'][
                np.argmax(self.data['magnitude'])]
        return obsmaxsig
163420
def get_op(self):
        """"""
        if self.centrosymmetric:
            rot = np.tile(np.vstack((self.rotations, -self.rotations)), 
                          (self.nsubtrans, 1, 1))
            trans = np.repeat(self.subtrans, 2*len(self.rotations), axis=0)
        else:
            rot = np.tile(self.rotations, (self.nsubtrans, 1, 1))
            trans = np.repeat(self.subtrans, len(self.rotations), axis=0)
        return rot, trans
353788
def calcfluxscale(d, imstd_med, flagfrac_med):
    

    # useful functions and VLA parameters
    sensitivity = lambda sefd, dt, bw, eta, nbl, npol: sefd/(eta*np.sqrt(nbl*2 * dt * bw * npol))
    nbl = lambda nant: nant*(nant-1)/2
    eta = {'L': 0.92, 'S': 0.92, 'C': 0.8, 'X': 0.8}   # correlator efficiency
    sefd = {'L': 420, 'S': 370, 'C': 310, 'X': 250}    # fixed to match exposure calculator int time to 100 microJy.

    bw = sum([d['spw_nchan_select'][i]*d['spw_chansize'][i] for i in range(len(d['spw_chansize']))])
    dt = d['inttime']
    npol = d['npol']
    nant = d['nants']
    freq = d['freq'][0]
    if (freq >= 1 and freq < 2):
        band = 'L'
    elif (freq >= 2 and freq < 4):
        band = 'S'
    elif (freq >= 4 and freq < 8):
        band = 'C'
    elif (freq >= 8 and freq < 12):
        band = 'X'
    else:
        logger.warn('first channel freq ({0}) not in bands L, S, C, or X. Assuming L band.'.format(freq))
        band = 'L'

    goodfrac = 1 - flagfrac_med # correct for flagged data
    slim_theory = sensitivity(sefd[band], dt, bw, eta[band], goodfrac*nbl(nant), npol)
    fluxscale = slim_theory/imstd_med

    return fluxscale
1219720
def contrast_rms(data, *kwargs):
    
    av = np.average(data, *kwargs)
    mal = 1 / (data.shape[0] * data.shape[1])
    return np.sqrt(mal * np.sum(np.square(data - av)))