Parameters
    ----------
    dipole_mode: Which dipoles should be extracted
        "all"
        "before"
        "between"
        "after"
979350
def _parse_radic_header(header_group, dipole_mode="all"):
    
    header = ''.join(header_group[1])

    nr_of_electrodes = _get_nr_of_electrodes(header.split('\n'))
    groups = itertools.groupby(
        header.split('\n'),
        lambda line: (
            line.startswith('[End Readings]') or
            line.startswith('[Begin Readings]')
        )
    )

    for key, group in groups:
        # there is only one group we are interested in: the first one
        if key:
            tmp = np.array(
                [
                    np.fromstring(
                        x, sep=' ', dtype=int
                    )
                    for x in next(groups)[1]
                ],
            )

            # curpots = tmp.T.copy()
            # curpots.resize(nr_of_electrodes + 2, tmp.shape[0])
            break

    # now we have the raw readings, pad them with zeros
    readings = []
    for raw_reading in tmp:
        voltage_rus = raw_reading[3:]
        # note that we now have the last electrode in here, too (so one more
        # than we have RUs. This electrode is always 0
        normed_reading = np.zeros(nr_of_electrodes)
        for i in voltage_rus[np.where(voltage_rus > 0)]:
            normed_reading[i - 1] = i
        readings.append(np.hstack((raw_reading[0:3], normed_reading)))

    # now generate the available configurations
    # add calibration
    reading_configs = {}
    for nr, reading in enumerate(readings):
        # nr = reading[0]
        A = reading[1]
        B = reading[2]

        voltages = []

        # loop over the RU-settings
        # we always measure to the next zero electrode
        for i in range(3, nr_of_electrodes + 3):
            for j in range(i + 1, nr_of_electrodes + 3):
                if reading[j] == 0:
                    M = i - 2
                    N = j - 2
                    all_active = ((reading[i] == 0) and (reading[j] == 0))
                    # print('a', 'b', 'm, n', A, B, M, N, all_active)
                    voltages.append((A, B, M, N, all_active))
                    break

        reading_configs[nr + 1] = np.array(voltages)
    return reading_configs
567939
def mag_field(RAW_IMU, SENSOR_OFFSETS=None, ofs=None):
    ''''''
    mag_x = RAW_IMU.xmag
    mag_y = RAW_IMU.ymag
    mag_z = RAW_IMU.zmag
    if SENSOR_OFFSETS is not None and ofs is not None:
        mag_x += ofs[0] - SENSOR_OFFSETS.mag_ofs_x
        mag_y += ofs[1] - SENSOR_OFFSETS.mag_ofs_y
        mag_z += ofs[2] - SENSOR_OFFSETS.mag_ofs_z
    return sqrt(mag_x**2 + mag_y**2 + mag_z**2)
826978
def _parse_refraction(line, lines):
    """"""
    split_line = line.split()

    energy = float(split_line[0])
    ref_ind_xx = float(split_line[1])
    ref_ind_zz = float(split_line[2])
    extinct_xx = float(split_line[3])
    extinct_zz = float(split_line[4])

    return {"energy": energy, "ref_ind_xx": ref_ind_xx, "ref_ind_zz": ref_ind_zz, "extinct_xx": extinct_xx,
            "extinct_zz": extinct_zz}
281035
def mag_pmf(matrix):
    
    nmags, ndists, nlons, nlats, neps = matrix.shape
    mag_pmf = numpy.zeros(nmags)
    for i in range(nmags):
        mag_pmf[i] = numpy.prod(
            [1. - matrix[i, j, k, l, m]
             for j in range(ndists)
             for k in range(nlons)
             for l in range(nlats)
             for m in range(neps)])
    return 1. - mag_pmf
292482
def get_edot(F, mc, e):
    

    # chirp mass
    mc *= SOLAR2S

    dedt = -304/(15*mc) * (2*np.pi*mc*F)**(8/3) * e * \
        (1 + 121/304*e**2) / ((1-e**2)**(5/2))

    return dedt
34756
def separate_directions(di_block):
    
    ppars = doprinc(di_block)
    di_df = pd.DataFrame(di_block)  # turn into a data frame for easy filtering
    di_df.columns = ['dec', 'inc']
    di_df['pdec'] = ppars['dec']
    di_df['pinc'] = ppars['inc']
    di_df['angle'] = angle(di_df[['dec', 'inc']].values,
                           di_df[['pdec', 'pinc']].values)
    mode1_df = di_df[di_df['angle'] <= 90]
    mode2_df = di_df[di_df['angle'] > 90]
    mode1 = mode1_df[['dec', 'inc']].values.tolist()
    mode2 = mode2_df[['dec', 'inc']].values.tolist()
    return mode1, mode2
1014623
def _parse_fc(self, f, natom, dim):
        

        ndim = np.prod(dim)
        fc = np.zeros((natom, natom * ndim, 3, 3), dtype='double', order='C')
        for k, l, i, j in np.ndindex((3, 3, natom, natom)):
            line = f.readline()
            for i_dim in range(ndim):
                line = f.readline()
                # fc[i, j * ndim + i_dim, k, l] = float(line.split()[3])
                fc[j, i * ndim + i_dim, l, k] = float(line.split()[3])
        return fc
867241
def _dEndfr(self):
        
        Mc = self._chirp_mass()
        return (np.pi**(2./3.)*Mc**(5./3.)/(3.*(1.+self.z)**(1./3.)
                * (self.freqs_orb/(1.+self.z))**(1./3.))*(2./self.n)**(2./3.)
                * self._g_func()/self._f_func())
1279458
def mode_name(self):
        

        for name, id in self.MODES.iteritems():
            if id == self.mode:
                return name
40329
def read_piezo_tensor(self):
        
        header_pattern = r"PIEZOELECTRIC TENSOR  for field in x, y, " \
                         r"z\s+\(C/m\^2\)\s+([X-Z][X-Z]\s+)+\-+"
        row_pattern = r"[x-z]\s+" + r"\s+".join([r"(\-*[\.\d]+)"] * 6)
        footer_pattern = r"BORN EFFECTIVE"
        pt_table = self.read_table_pattern(header_pattern, row_pattern,
                                           footer_pattern, postprocess=float)
        self.data["piezo_tensor"] = pt_table
1153629
def get_mode(device):
    '''
    
    '''
    ret = {}
    cmd = 'quotaon -p {0}'.format(device)
    out = __salt__['cmd.run'](cmd, python_shell=False)
    for line in out.splitlines():
        comps = line.strip().split()
        if comps[3] not in ret:
            if comps[0].startswith('quotaon'):
                if comps[1].startswith('Mountpoint'):
                    ret[comps[4]] = 'disabled'
                    continue
                elif comps[1].startswith('Cannot'):
                    ret[device] = 'Not found'
                    return ret
                continue
            ret[comps[3]] = {
                'device': comps[4].replace('(', '').replace(')', ''),
            }
        ret[comps[3]][comps[0]] = comps[6]
    return ret
699069
def dre_dc(self, pars):
        
        """
        self._set_parameters(pars)
        # term 1
        num1a = np.log(self.w * self.tau) * self.otc * np.sin(self.ang)
        num1b = self.otc * np.cos(self.ang) * np.pi / 2.0
        term1 = (num1a + num1b) / self.denom

        # term 2
        num2 = self.otc * np.sin(self.c / np.pi) * 2
        denom2 = self.denom ** 2
        term2 = num2 / denom2

        # term 3
        num3a = 2 * np.log(self.w * self.tau) * self.otc * np.cos(self.ang)
        num3b = 2 * ((self.w * self.tau) ** 2) * np.pi / 2.0 * np.sin(self.ang)
        num3c = 2 * np.log(self.w * self.tau) * self.otc2
        term3 = num3a - num3b + num3c

        result = self.sigmai * self.m * (term1 + term2 * term3)

        return result
122036
private void calcBoundaries() {
		minBoundary.x = Double.MAX_VALUE;
		maxBoundary.x = Double.MIN_VALUE;
		minBoundary.y = Double.MAX_VALUE;
		maxBoundary.x = Double.MIN_VALUE;
		minBoundary.z = Double.MAX_VALUE;
		maxBoundary.z = Double.MIN_VALUE;
		xzRadiusMax = Double.MIN_VALUE;

		Point3d probe = new Point3d();

		for (Point3d[] list: subunits.getTraces()) {
			for (Point3d p: list) {
				probe.set(p);
				transformationMatrix.transform(probe);

				minBoundary.x = Math.min(minBoundary.x, probe.x);
				maxBoundary.x = Math.max(maxBoundary.x, probe.x);
				minBoundary.y = Math.min(minBoundary.y, probe.y);
				maxBoundary.y = Math.max(maxBoundary.y, probe.y);
				minBoundary.z = Math.min(minBoundary.z, probe.z);
				maxBoundary.z = Math.max(maxBoundary.z, probe.z);
				xzRadiusMax = Math.max(xzRadiusMax, Math.sqrt(probe.x*probe.x + probe.z * probe.z));
			}
		}
//		System.out.println("MinBoundary: " + minBoundary);
//		System.out.println("MaxBoundary: " + maxBoundary);
//		System.out.println("zxRadius: " + xzRadiusMax);
	}
1124319
def radar_xsect(scatterer, h_pol=True):
    
    Z = scatterer.get_Z()
    if h_pol:
        return 2 * np.pi * \
            (Z[0,0] - Z[0,1] - Z[1,0] + Z[1,1])
    else:
        return 2 * np.pi * \
            (Z[0,0] + Z[0,1] + Z[1,0] + Z[1,1])
489809
def dynacRepresentation(self):
        
        if self.plane.val == 'H':
            p = 0
        elif self.plane.val == 'V':
            p = 1
        return ['STEER', [[self.field_strength.val], [p]]]
360346
public static void lsp_prev_extract(
	  float lsp[],                /* (i) Q13 : unquantized LSP parameters  */
	  float lsp_ele[],            /* (o) Q13 : target vector               */
	  float fg[][],          /* (i) Q15 : MA prediction coef.         */
	  float freq_prev[][],   /* (i) Q13 : previous LSP vector         */
	  float fg_sum_inv[]          /* (i) Q12 : inverse previous LSP vector */
	)
	{
	  int j, k;

	  /*----- compute target vectors for each MA coef.-----*/
	  for( j = 0 ; j < LD8KConstants.M ; j++ ) {
	      lsp_ele[j]=lsp[j];
	      for ( k = 0 ; k < LD8KConstants.MA_NP ; k++ )
	         lsp_ele[j] -= freq_prev[k][j] * fg[k][j];
	      lsp_ele[j] *= fg_sum_inv[j];
	   }

	   return;
	}
963895
def get_SZ_orient(self):
        

        tm_outdated = self._tm_signature != (self.radius, self.radius_type, 
            self.wavelength, self.m, self.axis_ratio, self.shape, self.ddelt, 
            self.ndgs)
        scatter_outdated = self._scatter_signature != (self.thet0, self.thet, 
            self.phi0, self.phi, self.alpha, self.beta, self.orient)

        orient_outdated = self._orient_signature != \
            (self.orient, self.or_pdf, self.n_alpha, self.n_beta)
        if orient_outdated:
            self._init_orient()
        
        outdated = tm_outdated or scatter_outdated or orient_outdated

        if outdated:
            (self._S_orient, self._Z_orient) = self.orient(self)
            self._set_scatter_signature()

        return (self._S_orient, self._Z_orient)