Returns the hanging wall scaling term defined in equations 7 to 16
485811
def _get_hanging_wall_term(self, C, rup, dists):
        
        return (C["c10"] *
                self._get_hanging_wall_coeffs_rx(C, rup, dists.rx) *
                self._get_hanging_wall_coeffs_rrup(dists) *
                self._get_hanging_wall_coeffs_mag(C, rup.mag) *
                self._get_hanging_wall_coeffs_ztor(rup.ztor) *
                self._get_hanging_wall_coeffs_dip(rup.dip))
411797
def _get_site_scaling(self, C, pga_rock, sites, period, rjb):
        
        flin = self._get_linear_site_term(C, sites.vs30)
        fnl = self._get_nonlinear_site_term(C, sites.vs30, pga_rock)
        fbd = self._get_basin_depth_term(C, sites, period)
        return flin + fnl + fbd
164616
def getGradient(self,j):
        
        i = int(self.indicator['term'][j])
        r = int(self.indicator['row'][j])
        c = int(self.indicator['col'][j])
        rv = -np.kron(self.Fstar()[i][:,[r]],self.Astar()[i][[c],:])
        return rv
505482
def _compute_hanging_wall_effect(self, C, rjb, rrup, dip, mag):
        
        # eq. 8 (to be noticed that the USGS-NSHMP implementation defines
        # the hanging-wall term for all rjb distances, while in the original
        # manuscript, hw is computed only for rjb < 5). Again the 'firm rock'
        # is considered
        hw = np.zeros_like(rjb)
        if dip <= 70.:
            hw = (5. - rjb) / 5.

        # eq. 9
        f_m = 1 if mag > 6.5 else mag - 5.5

#        # eq. 10
        f_rrup = C['c15'] + np.zeros_like(rrup)
        idx = rrup < 8
        f_rrup[idx] *= rrup[idx] / 8

        # eq. 7 (to be noticed that the f3 factor is not included
        # while this is defined in the original manuscript)
        f_hw = hw * f_m * f_rrup

        return f_hw
1135463
def _get_xy_scaling_parameters(self):
        """"""
        gd = self.area_definition
        bx = self.x.min()
        mx = gd.pixel_size_x
        by = self.y.min()
        my = -abs(gd.pixel_size_y)
        return mx, bx, my, by
939576
def _get_magnitude_scaling(self, C, mag):
        
        if mag < self.CONSTANTS["mh"]:
            return C["e1"] + C["b1"] * (mag - self.CONSTANTS["mref"]) +\
                C["b2"] * ((mag - self.CONSTANTS["mref"]) ** 2.)
        else:
            d_m = self.CONSTANTS["mh"] - self.CONSTANTS["mref"]
            return C["e1"] + C["b3"] * (mag - self.CONSTANTS["mh"]) +\
                (C["b1"] * d_m) + C["b2"] * (d_m ** 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"]))
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)
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;
		}
	}
1346151
def equation(self):
        
        mat = np.empty((self.nunknowns, self.model.neq))
        rhs = np.zeros(self.nunknowns)  # Needs to be initialized to zero
        for icp in range(self.ncp):
            istart = icp * self.nlayers
            ieq = 0
            for e in self.model.elementlist:
                if e.nunknowns > 0:
                    mat[istart:istart + self.nlayers, ieq:ieq + e.nunknowns] = \
                        e.potinflayers(self.xcin[icp], self.ycin[icp], self.layers, aq=self.aqin) / self.aqin.Tcol - \
                        e.potinflayers(self.xcout[icp], self.ycout[icp], self.layers, aq=self.aqout) / self.aqout.Tcol
                    ieq += e.nunknowns
                else:
                    rhs[istart:istart + self.nlayers] -= \
                        e.potentiallayers(self.xcin[icp], self.ycin[icp], self.layers, aq=self.aqin) / self.aqin.T - \
                        e.potentiallayers(self.xcout[icp], self.ycout[icp], self.layers, aq=self.aqout) / self.aqout.T
        return mat, rhs
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"]
1362847
def _get_distance_scaling_term(self, C, mag, rrup):
        
        if mag < 6.75:
            mag_factor = -(C["b1_lo"] + C["b2_lo"] * mag)
        else:
            mag_factor = -(C["b1_hi"] + C["b2_hi"] * mag)
        return mag_factor * np.log(rrup + 10.0) + (C["gamma"] * rrup)
389753
function getBarBounds(vm) {
	var x1, x2, y1, y2, half;

	if (isVertical(vm)) {
		half = vm.width / 2;
		x1 = vm.x - half;
		x2 = vm.x + half;
		y1 = Math.min(vm.y, vm.base);
		y2 = Math.max(vm.y, vm.base);
	} else {
		half = vm.height / 2;
		x1 = Math.min(vm.x, vm.base);
		x2 = Math.max(vm.x, vm.base);
		y1 = vm.y - half;
		y2 = vm.y + half;
	}

	return {
		left: x1,
		top: y1,
		right: x2,
		bottom: y2
	};
}
927740
def _get_xy_scaling_parameters(self):
        """"""
        return self.mx, self.bx, self.my, self.by
234428
def scale(self):
        
        # use vertices peak-peak rather than exact extents
        scale = float((self.vertices.ptp(axis=0) ** 2).sum() ** .5)
        return scale
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
323864
def _compute_magnitude_terms(self, rup, coeffs):
        

        adj_mag = rup.mag - self.CONSTS['ref_mag']
        return coeffs['c1'] + coeffs['c2']*adj_mag + coeffs['c3']*adj_mag**2