Return delta's for equation 4
        delta_C = 1 for site class C, 0 otherwise
        delta_D = 1 for site class D, 0 otherwise
480668
def _get_deltas(self, sites):
        
        siteclass = sites.siteclass
        delta_C = np.zeros_like(siteclass, dtype=np.float)
        delta_C[siteclass == b'C'] = 1

        delta_D = np.zeros_like(siteclass, dtype=np.float)
        delta_D[siteclass == b'D'] = 1

        return delta_C, delta_D
1355950
def _get_stddevs(self, C, stddev_types, num_sites):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
            for stddev_type in stddev_types)
        stddevs = [np.zeros(num_sites) + C['SigmaTot'] for _ in stddev_types]
        return stddevs
534290
def lm_deltaf(damping_times, modes):
    

    df = {}
    for lmn in modes:
        l, m, nmodes = int(lmn[0]), int(lmn[1]), int(lmn[2])
        for n in range(nmodes):
            df['%d%d%d' %(l,m,n)] = \
                1. / qnm_time_decay(damping_times['%d%d%d' %(l,m,n)], 1./1000)

    return min(df.values())
1011939
def _calcOffAxisFactor(self, aLocation, deltaLocation, limits):
        
        relative = []
        for dim in limits.keys():
            f = aLocation[dim]
            v = deltaLocation[dim]
            mB, M, mA = limits[dim]
            r = 0
            if mA is not None and v > mA:
                relative.append(0)
                continue
            elif mB is not None and v < mB:
                relative.append(0)
                continue
            if f < v-_EPSILON:
                if mB is None:
                    if M is not None and mA is not None:
                        if v == M:
                            r = (float(max(f,mA)-min(f, mA))/float(max(M,mA)-min(M, mA)))
                        else:
                            r = -(float(max(f,mA)-min(f, mA))/float(max(M,mA)-min(M, mA)) -1)
                    else: r = 0
                elif mA is None: r = 0
                else: r = float(f-mB)/(mA-mB)
            elif f > v+_EPSILON:
                if mB is None: r = 0
                elif mA is None:
                    if M is not None and mB is not None:
                        if v == M:
                            r = (float(max(f,mB)-min(f, mB))/(max(mB, M)-min(mB, M)))
                        else:
                            r = -(float(max(f,mB)-min(f, mB))/(max(mB, M)-min(mB, M)) - 1)
                    else: r = 0
                else: r = float(mA-f)/(mA-mB)
            else: r = 1
            relative.append(r)
        f = 1
        for i in relative:
            f *= i
        return f
770100
def get_RaDecOffsets(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
    """"""
    delta_ra_deg = ra1_deg - ra2_deg
    adj = math.cos(math.radians(dec2_deg))
    if delta_ra_deg > 180.0:
        delta_ra_deg = (delta_ra_deg - 360.0) * adj
    elif delta_ra_deg < -180.0:
        delta_ra_deg = (delta_ra_deg + 360.0) * adj
    else:
        delta_ra_deg *= adj

    delta_dec_deg = dec1_deg - dec2_deg
    return (delta_ra_deg, delta_dec_deg)
370120
def _get_delta(self, stds, dists):
        
        delta = np.maximum((0.1-0.001*dists.repi), np.zeros_like(dists.repi))
        return delta
369270
def _get_basic_term(self, C, rup, dists):
        
        # Fictitious depth calculation
        if rup.mag > 5.:
            c4m = C['c4']
        elif rup.mag > 4.:
            c4m = C['c4'] - (C['c4']-1.) * (5. - rup.mag)
        else:
            c4m = 1.
        R = np.sqrt(dists.rrup**2. + c4m**2.)
        # basic form
        base_term = C['a1'] * np.ones_like(dists.rrup) + C['a17'] * dists.rrup
        # equation 2 at page 1030
        if rup.mag >= C['m1']:
            base_term += (C['a5'] * (rup.mag - C['m1']) +
                          C['a8'] * (8.5 - rup.mag)**2. +
                          (C['a2'] + C['a3'] * (rup.mag - C['m1'])) *
                          np.log(R))
        elif rup.mag >= self.CONSTS['m2']:
            base_term += (C['a4'] * (rup.mag - C['m1']) +
                          C['a8'] * (8.5 - rup.mag)**2. +
                          (C['a2'] + C['a3'] * (rup.mag - C['m1'])) *
                          np.log(R))
        else:
            base_term += (C['a4'] * (self.CONSTS['m2'] - C['m1']) +
                          C['a8'] * (8.5 - self.CONSTS['m2'])**2. +
                          C['a6'] * (rup.mag - self.CONSTS['m2']) +
                          C['a7'] * (rup.mag - self.CONSTS['m2'])**2. +
                          (C['a2'] + C['a3'] * (self.CONSTS['m2'] - C['m1'])) *
                          np.log(R))
        return base_term
16466
def _get_stddevs(self, C, stddev_types, mag, num_sites):
        
        stddevs = []
        for _ in stddev_types:
            if mag < 7.16:
                sigma = C['c11'] + C['c12'] * mag
            elif mag >= 7.16:
                sigma = C['c13']
            stddevs.append(np.zeros(num_sites) + sigma)

        return stddevs
149199
def _compute_non_linear_term(self, C, pga_only, sites):
        
        Vref = self.CONSTS['Vref']
        Vcon = self.CONSTS['Vcon']
        c = self.CONSTS['c']
        n = self.CONSTS['n']
        lnS = np.zeros_like(sites.vs30)

        # equation (6a)
        idx = sites.vs30 < Vref
        lnS[idx] = (
            C['sb1'] * np.log(sites.vs30[idx] / Vref) +
            C['sb2'] * np.log(
                (pga_only[idx] + c * (sites.vs30[idx] / Vref) ** n) /
                ((pga_only[idx] + c) * (sites.vs30[idx] / Vref) ** n)
            )
        )

        # equation (6b)
        idx = sites.vs30 >= Vref
        new_sites = sites.vs30[idx]
        new_sites[new_sites > Vcon] = Vcon
        lnS[idx] = C['sb1'] * np.log(new_sites / Vref)

        return lnS
349567
def delta(self):
        
        number      = self._numberSpinner.value()
        unit        = self._unitCombo.currentText()
        direction   = self._directionCombo.currentText()
        
        # use past tense
        if direction == 'ago':
            number = -number
        
        if unit == 'year(s)':
            return datetime.timedelta(number * 365)
        elif unit == 'month(s)':
            return datetime.timedelta(number * 30)
        elif unit == 'week(s)':
            return datetime.timedelta(number * 7)
        elif unit == 'day(s)':
            return datetime.timedelta(number)
        elif unit == 'hour(s)':
            return datetime.timedelta(0, number * 3600)
        elif unit == 'minute(s)':
            return datetime.timedelta(0, number * 60)
        else:
            return datetime.timedelta(0, number)
625975
def _get_deltas(event):
        """"""
        delta_x = round(event.deltaX())
        delta_y = round(event.deltaY())
        delta_z = round(event.deltaZ())
        return delta_x, delta_y, delta_z
741976
def _get_basin_depth_term(self, C, sites, period):
        
        return np.zeros(len(sites.vs30), dtype=float)
793190
def _get_deltas(self, rake):
        
        # delta_R = 1 for reverse focal mechanism (45<rake<135)
        # and for interface events, 0 for all other events
        # delta_S = 1 for Strike-slip focal mechanisms (0<=rake<=45) or
        # (135<=rake<=180) or (-45<=rake<=0), 0 for all other events
        # delta_V = 1 for TVZ events, 0 for all other events
        # delta_I = 1 for interface events, 0 for all other events

        # All deltas = 0 for Model 3: Deep Region, pag 198

        delta_R, delta_S = 0, 0
        delta_V, delta_I = 0, 0

        if rake > 45.0 and rake < 135.0:
            delta_R = 1

        if (rake >= 0.0 and rake <= 45.0) or \
           (rake >= 135 and rake <= 180.0) or \
           (rake >= -180.0 and rake <= -135.0) or \
           (rake >= -45.0 and rake < 0.0):
            delta_S = 1

        return delta_R, delta_S, delta_V, delta_I
615567
function getVelocity(delta_time, delta_x, delta_y) {
    return {
      x: Math.abs(delta_x / delta_time) || 0,
      y: Math.abs(delta_y / delta_time) || 0
    };
  }
927852
def _compute_mean(self, C, mag, rrup, hypo_depth, delta_R, delta_S,
                      delta_V, delta_I, vs30):

        
        # mean is calculated for all the 4 classes using the same equation.
        # For DowrickRhoades2005SSlab, the coefficients which don't appear in
        # Model 3 equationare assigned to zero

        mean = (C['A1'] + (C['A2'] + C['A2R'] * delta_R + C['A2V'] * delta_V) *
                mag + (C['A3'] + C['A3S'] * delta_S + C['A3V'] * delta_V) *
                np.log10(np.power((rrup**3 + C['d']**3), 1.0 / 3.0)) +
                C['A4'] * hypo_depth + C['A5'] * delta_I)

        # Get S site class term
        S = self._get_site_class(vs30, mean)

        # Add S amplification term to mean value
        mean = mean + S

        return mean
1066873
def delta(f, s, d=None):
    
    if d is None:
        d = tempfile.SpooledTemporaryFile(max_size=MAX_SPOOL, mode='wb+')
    sig = ctypes.c_void_p()
    try:
        job = _librsync.rs_loadsig_begin(ctypes.byref(sig))
        try:
            _execute(job, s)
        finally:
            _librsync.rs_job_free(job)
        r = _librsync.rs_build_hash_table(sig)
        if r != RS_DONE:
            raise LibrsyncError(r)
        job = _librsync.rs_delta_begin(sig)
        try:
            _execute(job, f, d)
        finally:
            _librsync.rs_job_free(job)
    finally:
        _librsync.rs_free_sumset(sig)
    return d
569242
def zoom_delta(self, d, p=(0., 0.), c=1.):
        """"""
        dx, dy = d
        x0, y0 = p

        pan_x, pan_y = self._pan
        zoom_x, zoom_y = self._zoom
        zoom_x_new, zoom_y_new = (zoom_x * math.exp(c * self._zoom_coeff * dx),
                                  zoom_y * math.exp(c * self._zoom_coeff * dy))

        zoom_x_new = max(min(zoom_x_new, self._zmax), self._zmin)
        zoom_y_new = max(min(zoom_y_new, self._zmax), self._zmin)

        self.zoom = zoom_x_new, zoom_y_new

        if self._zoom_to_pointer:
            zoom_x, zoom_y = self._zoom_aspect((zoom_x,
                                                zoom_y))
            zoom_x_new, zoom_y_new = self._zoom_aspect((zoom_x_new,
                                                        zoom_y_new))

            self.pan = (pan_x - x0 * (1. / zoom_x - 1. / zoom_x_new),
                        pan_y - y0 * (1. / zoom_y - 1. / zoom_y_new))

        self.update()