Returns the distance scaling term of the GMPE described in equation 2
17025
def _get_distance_scaling_term(self, C, rval, mag):
        
        r_adj = np.sqrt(rval ** 2.0 + C["h"] ** 2.0)
        return (
            (C["c1"] + C["c2"] * (mag - self.CONSTS["Mref"])) *
            np.log10(r_adj / self.CONSTS["Rref"]) -
            (C["c3"] * (r_adj - self.CONSTS["Rref"])))
602089
def get_scaling_function(y_m, y_M, x_m, x_M):
    
    if x_M <= x_m:
        return lambda _: y_m
    k = (y_M - y_m) / (x_M - x_m)
    b = y_m - k * x_m
    return lambda _: int(k * _ + b)
1200692
def _get_path_scaling(self, C, dists, mag):
        
        rval = np.sqrt((dists.rjb ** 2.0) + (C["h"] ** 2.0))
        scaling = (C["c1"] + C["c2"] * (mag - self.CONSTS["Mref"])) *\
            np.log(rval / self.CONSTS["Rref"])
        return scaling + ((C["c3"] + C["Dc3"]) * (rval - self.CONSTS["Rref"]))
1169481
def _sigma_ee_rel(self, gam, eps):
        
        A = 1 - 8 / 3 * (gam - 1) ** 0.2 / (gam + 1) * (eps / gam) ** (
            1.0 / 3.0
        )

        return (self._sigma_1(gam, eps) + self._sigma_2(gam, eps)) * A
602784
def scalar_projection(v1, v2):
    '''
    '''
    return np.dot(v1, v2) / np.linalg.norm(v2)
335082
def _compute_term2(self, C, mag, rrup):
        
        c78_factor = (C['c7'] * np.exp(C['c8'] * mag)) ** 2
        R = np.sqrt(rrup ** 2 + c78_factor)

        return C['c4'] * np.log(R) + (C['c5'] + C['c6'] * mag) * rrup
254907
def _scaled_bqm(bqm, scalar, bias_range, quadratic_range,
                ignored_variables, ignored_interactions,
                ignore_offset):
    """"""

    bqm_copy = bqm.copy()
    if scalar is None:
        scalar = _calc_norm_coeff(bqm_copy.linear, bqm_copy.quadratic,
                                  bias_range, quadratic_range,
                                  ignored_variables, ignored_interactions)

    bqm_copy.scale(scalar, ignored_variables=ignored_variables,
                   ignored_interactions=ignored_interactions,
                   ignore_offset=ignore_offset)
    bqm_copy.info.update({'scalar': scalar})
    return bqm_copy
1316092
def bound_perturbed_gmres(pseudo, p, epsilon, deltas):
    '''
    '''
    if not numpy.all(numpy.array(deltas) > epsilon):
        raise ArgumentError('all deltas have to be greater than epsilon')

    bound = []
    for delta in deltas:
        # get boundary paths
        paths = pseudo.contour_paths(delta)

        # get vertices on boundary
        vertices = paths.vertices()

        # evaluate polynomial
        supremum = numpy.max(numpy.abs(p(vertices)))

        # compute bound
        bound.append(epsilon/(delta-epsilon)
                     * paths.length()/(2*numpy.pi*delta)
                     * supremum)
    return bound
650242
def get_magnitude_scaling_term(self, C, mag):
        
        mval = mag - 3.0
        return C['b1'] + C['b2'] * mval + C['b3'] * (mval ** 2.0) +\
            C['b4'] * (mval ** 3.0)
1195009
def residue_distances(res_1_num, res_1_chain, res_2_num, res_2_chain, model):
    """"""

    res1 = model[res_1_chain][res_1_num].child_list[-1]
    res2 = model[res_2_chain][res_2_num].child_list[-1]
    distance = res1 - res2

    return distance
1003363
def exp_rmspe(pred:Tensor, targ:Tensor)->Rank0Tensor:
    ""
    pred,targ = flatten_check(pred,targ)
    pred, targ = torch.exp(pred), torch.exp(targ)
    pct_var = (targ - pred)/targ
    return torch.sqrt((pct_var**2).mean())
819407
def _compute_distance_term(self, C, rrup, mag):
        
        exponent_term = (1.0 + C["c3"] * np.exp(mag - 5.)) ** 2.
        return C["c2"] * np.log(np.sqrt(rrup ** 2. + exponent_term))
705686
def get_rmsd(self, mol1, mol2):
        
        label1, label2 = self._mapper.uniform_labels(mol1, mol2)
        if label1 is None or label2 is None:
            return float("Inf")
        return self._calc_rms(mol1, mol2, label1, label2)
479039
def get_rx_distance(self, mesh):
        
        # If the GC2 calculations have already been computed (by invoking Ry0
        # first) and the mesh is identical then class has GC2 attributes
        # already pre-calculated
        if not self.tmp_mesh or (self.tmp_mesh == mesh):
            self.gc2t, self.gc2u = self.get_generalised_coordinates(mesh.lons,
                                                                    mesh.lats)
            # Update mesh
            self.tmp_mesh = deepcopy(mesh)
        # Rx coordinate is taken directly from gc2t
        return self.gc2t
142996
def _compute_distance_term(self, C, rup, dists):
        
        return (C['c4'] + C['c5'] * rup.mag) * \
            np.log(np.sqrt(dists.rrup ** 2. + C['c6'] ** 2.))
1195398
def _compute_distance_terms(cls, dists, coeffs):
        
        return - np.log(dists.rhypo) - coeffs['c4']*dists.rhypo
1340618
def ccmodmd_ystep():
    

    mAXU = np.mean(mp_D_X + mp_D_U0, axis=0)
    mp_D_Y0[:] = mp_dprox(mAXU)
    AXU1 = mp_DX - mp_S + mp_D_U1
    mp_D_Y1[:] = mp_drho*AXU1 / (mp_W**2 + mp_drho)