Returns the magnitude scaling term in equations 1 and 2
517790
def get_magnitude_scaling_term(self, C, rup):
        
        if rup.mag <= self.CONSTANTS["m_c"]:
            return C["ccr"] * rup.mag
        else:
            return (C["ccr"] * self.CONSTANTS["m_c"]) +\
                (C["dcr"] * (rup.mag - self.CONSTANTS["m_c"]))
80333
def _get_distance_scaling_term(self, C, rjb, mag):
        
        # Depth adjusted distance, equation 11 (Page 63)
        rval = np.sqrt(rjb ** 2.0 + C["c11"] ** 2.0)
        f_0, f_1, f_2 = self._get_distance_segment_coefficients(rval)
        return ((C["c4"] + C["c5"] * mag) * f_0 +
                (C["c6"] + C["c7"] * mag) * f_1 +
                (C["c8"] + C["c9"] * mag) * f_2 +
                (C["c10"] * rval))
833436
def _compute_magnitude_scaling_term(self, C, mag):
        
        c1 = self.CONSTS['c1']
        if mag <= c1:
            return C['b1'] + C['b2'] * (mag - c1) + C['b3'] * (8.5 - mag) ** 2
        else:
            return C['b1'] + C['b7'] * (mag - c1) + C['b3'] * (8.5 - mag) ** 2
1092105
def vector_magnitude(vector_in):
    
    sq_sum = 0.0
    for vin in vector_in:
        sq_sum += vin**2
    return math.sqrt(sq_sum)
139935
def _compute_term_5(self, C, mag, R):
        
        return (
            (C['a20'] + C['a21'] * mag + C['a22'] * np.power(mag, 2) +
             C['a23'] * np.power(mag, 3)) * np.power(R, 4)
        )
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"])))
559871
def _compute_distance_scaling(self, C, rhypo):
        
        return C["c"] * np.log10(np.sqrt((rhypo ** 2.) + (C["h"] ** 2.))) +\
            (C["d"] * rhypo)
829054
def _get_scaling_term(self, C, rrup):
        
        a_f = 0.15 + 0.0007 * rrup
        a_f[a_f > 0.35] = 0.35
        return C["af"] + a_f
405057
def _get_magnitude_scaling_term(self, C, rup):
        
        dmag = rup.mag - C["Mh"]
        if rup.mag <= C["Mh"]:
            mag_term = (C["e4"] * dmag) + (C["e5"] * (dmag ** 2.0))
        else:
            mag_term = C["e6"] * dmag
        return self._get_style_of_faulting_term(C, rup) + mag_term
702893
def magnitude(self):
    

    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2 + self.w ** 2)
1191335
def _compute_nonlinear_magnitude_term(self, C, mag):
        
        return self._compute_linear_magnitude_term(C, mag) +\
            C["b3"] * ((mag - 7.0) ** 2.)
961447
def get_magnitude_scaling(self, C, mag):
        
        d_m = mag - self.CONSTANTS["Mh"]
        if mag < self.CONSTANTS["Mh"]:
            return C["e1"] + C["b1"] * d_m + C["b2"] * (d_m ** 2.0)
        else:
            return C["e1"] + C["b3"] * d_m
1363837
def scalar_term(self, st):
        """"""
        if isinstance(st, binary_type):
            return _ScalarTermS(st, self._jinja_sub)
        elif isinstance(st, text_type):
            return _ScalarTermU(st, self._jinja_sub)
        elif st is None:
            return _ScalarTermU(u(''), self._jinja_sub)
        else:
            return st
475784
def _compute_magnitude(self, rup, C):
        
        return C['b1'] + (C['b2'] * rup.mag) + (C['b3'] * (rup.mag ** 2))
1082079
def feature_scaling(x, xmin, xmax, a=0, b=1):
    ''''''
    return a + float(x - xmin) * (b - a) / (xmax - xmin)
930370
def get_normalized(self):
        """"""
        magnitude = self.get_magnitude()
        if magnitude > 0:
            magnitude = 1.0 / magnitude
            return Point(self.x * magnitude, self.y * magnitude)
        else:
            return self
143894
def mag_scale_rel(value):
    
    value = value.strip()
    if value not in SCALEREL:
        raise ValueError(
            "'%s' is not a recognized magnitude-scale relationship" % value)
    return value