Returns the magnitude scaling term.
354935
def _get_magnitude_term(self, C, mag):
        
        lny = C['C1'] + (C['C3'] * ((8.5 - mag) ** 2.))
        if mag > 6.3:
            return lny + (-C['H'] * C['C5']) * (mag - 6.3)
        else:
            return lny + C['C2'] * (mag - 6.3)
827602
def _get_magnitude_term(self, C, mag):
        
        if mag >= self.CONSTS["Mh"]:
            return C["e1"] + C["b3"] * (mag - self.CONSTS["Mh"])
        else:
            return C["e1"] + (C["b1"] * (mag - self.CONSTS["Mh"])) +\
                (C["b2"] * (mag - self.CONSTS["Mh"]) ** 2.)
553547
def _get_magnitude_scaling_term(self, C, mag):
        
        dmag = mag - self.CONSTS["Mh"]
        if mag < self.CONSTS["Mh"]:
            return C["e1"] + (C["b1"] * dmag) + (C["b2"] * (dmag ** 2.0))
        else:
            return C["e1"] + (C["b3"] * dmag)
1156726
def _getScalesRand(self):
        
        if self.P>1:
            scales = []
            for term_i in range(self.n_randEffs):
                _scales = sp.randn(self.diag[term_i].shape[0])
                if self.jitter[term_i]>0:
                    _scales = sp.concatenate((_scales,sp.array([sp.sqrt(self.jitter[term_i])])))
                scales.append(_scales)
            scales = sp.concatenate(scales)
        else:
            scales=sp.randn(self.vd.getNumberScales())
        return scales
936458
def _get_magnitude_scaling_term(self, C, mag):
        
        if mag < 6.75:
            return C["a1_lo"] + C["a2_lo"] * mag + C["a3"] *\
                ((8.5 - mag) ** 2.0)
        else:
            return C["a1_hi"] + C["a2_hi"] * mag + C["a3"] *\
                ((8.5 - mag) ** 2.0)
747151
def transform(self, X):
        """"""
        if not self.is_fit:
            raise ValueError("The scaler has not been fit yet.")
        return (X-self.mean) / (self.std + 10e-7)
452228
def _compute_magnitude_squared_term(self, P, M, Q, W, mag):
        
        return P * (mag - M) + Q * (mag - M) ** 2 + W
1045506
def _compute_mean(self, C, mag, dists, rake):
        
        mean = (
            self._compute_magnitude_scaling_term(C, mag) +
            self._compute_geometric_decay_term(C, mag, dists) +
            self._compute_faulting_style_term(C, rake) +
            self._compute_anelestic_attenuation_term(C, dists)
        )

        return mean
540760
public void computeHessianScaling(DMatrixRMaj scaling ) {

		double max = 0;
		for (int i = 0; i < scaling.numRows; i++) {
			// mathematically it should never be negative but...
			double v = scaling.data[i] = sqrt(abs(scaling.data[i]));
			if( v > max )
				max = v;
		}

		// Add this number to avoid divide by zero.
		// Ceres solver just uses 1 no matter what. That's probably not the best approach because if you're doing
		// with very small numbers scaling will be washed out
		max *= 1e-12;
		for (int i = 0; i < scaling.numRows; i++) {
			scaling.data[i] += max;
		}
	}
159423
def get_magnitude_term(self, C, rup):
        
        b0, stress_drop = self._get_sof_terms(C, rup.rake)
        if rup.mag <= C["m1"]:
            return b0
        else:
            # Calculate moment (equation 5)
            m_0 = 10.0 ** (1.5 * rup.mag + 16.05)
            # Get stress-drop scaling (equation 6)
            if rup.mag > C["m2"]:
                stress_drop += (C["b2"] * (C["m2"] - self.CONSTANTS["mstar"]) +
                                (C["b3"] * (rup.mag - C["m2"])))
            else:
                stress_drop += (C["b2"] * (rup.mag - self.CONSTANTS["mstar"]))
            stress_drop = np.exp(stress_drop)
            # Get corner frequency (equation 4)
            f0 = 4.9 * 1.0E6 * 3.2 * ((stress_drop / m_0) ** (1. / 3.))
            return 1. / f0
243795
def get_distance_term(self, C, dists, rup):
        
        x_ij = dists.rrup
        # Get anelastic scaling term in quation 5
        if rup.ztor >= 50.:
            qslh = C["eSLH"] * (0.02 * rup.ztor - 1.0)
        else:
            qslh = 0.0
        # r_volc = np.copy(dists.rvolc)
        # r_volc[np.logical_and(r_volc > 0.0, r_volc <= 12.0)] = 12.0
        # r_volc[r_volc >= 80.0] = 80.0
        # Get r_ij - distance for geometric spreading (equations 3 and 4)
        c_m = min(rup.mag, self.CONSTANTS["m_c"])
        r_ij = x_ij + np.exp(C["alpha"] + C["beta"] * c_m)
        return C["gSL"] * np.log(r_ij) + \
            C["gLL"] * np.log(x_ij + 200.) +\
            C["eSL"] * x_ij + qslh * x_ij +\
            C["eSLV"] * dists.rvolc + C["gamma"]
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
511003
def magnitude(self):
        """"""
        return math.sqrt(
            reduce(lambda x, y: x + y, [x ** 2 for x in self.to_list()])
        )
1150972
def mag_scale_rel_to_hazardlib(mag_scale_rel, use_default=False):
    
    if isinstance(mag_scale_rel, BaseMSR):
        return mag_scale_rel
    elif isinstance(mag_scale_rel, str):
        if not mag_scale_rel in SCALE_RELS.keys():
            raise ValueError('Magnitude scaling relation %s not supported!'
                             % mag_scale_rel)
        else:
            return SCALE_RELS[mag_scale_rel]()
    else:
        if use_default:
            # Returns the Wells and Coppersmith string
            return WC1994()
        else:
            raise ValueError('Magnitude Scaling Relation Not Defined!')
1256689
def get_magnitude(self):
        """"""
        return math.sqrt(self.x*self.x + self.y*self.y)
944975
def magnitude(a):
    ""
    from math import sqrt
    sum = 0
    for coord in a:
        sum += coord ** 2
    return sqrt(sum)
277715
def get_magnitude_squared(self):
        """"""
        return self.x*self.x + self.y*self.y