return fan power in bhp given the fan IDF object
761790
def fanpower_bhp(ddtt):
    """"""
    from eppy.bunch_subclass import BadEPFieldError # here to prevent circular dependency
    try:
        fan_tot_eff = ddtt.Fan_Total_Efficiency # from V+ V8.7.0 onwards
    except BadEPFieldError as e:
        fan_tot_eff = ddtt.Fan_Efficiency 
    pascal = float(ddtt.Pressure_Rise)
    if str(ddtt.Maximum_Flow_Rate).lower() == 'autosize': 
    # str can fail with unicode chars :-(
        return 'autosize'
    else:
        m3s = float(ddtt.Maximum_Flow_Rate)
    return fan_bhp(fan_tot_eff, pascal, m3s)
455548
def _gh(self, x):
        
        Pgen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u.
        Qgen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u.

        for i, gen in enumerate(self._gn):
            gen.p = Pgen[i] * self._base_mva # active generation in MW
            gen.q = Qgen[i] * self._base_mva # reactive generation in MVAr

        # Rebuild the net complex bus power injection vector in p.u.
        Sbus = self.om.case.getSbus(self._bs)

        Vang = x[self._Va.i1:self._Va.iN + 1]
        Vmag = x[self._Vm.i1:self._Vm.iN + 1]
        V = Vmag * exp(1j * Vang)

        # Evaluate the power flow equations.
        mis = V * conj(self._Ybus * V) - Sbus

        # Equality constraints (power flow).
        g = r_[mis.real,  # active power mismatch for all buses
               mis.imag]  # reactive power mismatch for all buses

        # Inequality constraints (branch flow limits).
        # (line constraint is actually on square of limit)
        flow_max = array([(l.rate_a / self._base_mva)**2 for l in self._ln])
        # FIXME: There must be a more elegant method for this.
        for i, v in enumerate(flow_max):
            if v == 0.0:
                flow_max[i] = Inf

        if self.flow_lim == IFLOW:
            If = self._Yf * V
            It = self._Yt * V
            # Branch current limits.
            h = r_[(If * conj(If)) - flow_max,
                   (It * conj(It)) - flow_max]
        else:
            i_fbus = [e.from_bus._i for e in self._ln]
            i_tbus = [e.to_bus._i for e in self._ln]
            # Complex power injected at "from" bus (p.u.).
            Sf = V[i_fbus] * conj(self._Yf * V)
            # Complex power injected at "to" bus (p.u.).
            St = V[i_tbus] * conj(self._Yt * V)
            if self.flow_lim == PFLOW: # active power limit, P (Pan Wei)
                # Branch real power limits.
                h = r_[Sf.real()**2 - flow_max,
                       St.real()**2 - flow_max]
            elif self.flow_lim == SFLOW: # apparent power limit, |S|
                # Branch apparent power limits.
                h = r_[(Sf * conj(Sf)) - flow_max,
                       (St * conj(St)) - flow_max].real
            else:
                raise ValueError

        return h, g
974207
def AC(self):
        '''
        

        '''
        try:
            return self._AC
        except AttributeError:
            pass
        self._AC = [self.A, self.C]
        return self._AC
664256
def getbfs(coords, gbasis):
    """"""

    sym2powerlist = {
        'S' : [(0,0,0)],
        'P' : [(1,0,0),(0,1,0),(0,0,1)],
        'D' : [(2,0,0),(0,2,0),(0,0,2),(1,1,0),(0,1,1),(1,0,1)],
        'F' : [(3,0,0),(2,1,0),(2,0,1),(1,2,0),(1,1,1),(1,0,2),
               (0,3,0),(0,2,1),(0,1,2), (0,0,3)]
        }

    bfs = []
    for i, at_coords in enumerate(coords):
        bs = gbasis[i]
        for sym,prims in bs:
            for power in sym2powerlist[sym]:
                bf = cgbf(at_coords,power)
                for expnt,coef in prims:
                    bf.add_pgbf(expnt,coef)
                bf.normalize()
                bfs.append(bf)

    return bfs
9367
def RMS_energy(frames):
    """"""
    f = frames.flatten()
    return N.sqrt(N.mean(f * f))
619947
private static int getPowerSum(char[] iArr) {
		int iSum = 0;
		if (power.length == iArr.length) {
			for (int i = 0; i < iArr.length; i++) {
				iSum += Integer.valueOf(String.valueOf(iArr[i])) * power[i];
			}
		}
		return iSum;
	}
328398
def speed_i(self):
        
        self._speed_i, value = self.get_attr_int(self._speed_i, 'speed_pid/Ki')
        return value
983148
function powColVector(x, power) {
                var result = x.clone();
                for (var i = 0; i < x.rows; ++i) {
                    result[i][0] = Math.pow(result[i][0], power);
                }
                return result;
            }
437881
def get_pid_gain(self, ids, **kwargs):
        
        return tuple([tuple(reversed(t)) for t in self._get_pid_gain(ids, **kwargs)])
495679
def _compute_f0_factor(self, rrup):
        
        # f0 = max(log10(R0/rrup),0)
        f0 = np.log10(self.COEFFS_IMT_INDEPENDENT['R0'] / rrup)
        f0[f0 < 0] = 0.0

        return f0
605061
def watts2pascal(watts, cfm, fan_tot_eff):
    """"""
    bhp = watts2bhp(watts)
    return bhp2pascal(bhp, cfm, fan_tot_eff)
1163746
def rms(signal, fs):
    
    # if a signal contains a some silence, taking the RMS of the whole
    # signal will be calculated as less loud as a signal without a silent
    # period. I don't like this, so I am going to chunk the signals, and
    # take the value of the most intense chunk
    chunk_time = 0.001  # 1 ms chunk
    chunk_samps = int(chunk_time * fs)
    amps = []
    if chunk_samps > 10:
        for i in range(0, len(signal) - chunk_samps, chunk_samps):
            amps.append(np.sqrt(np.mean(pow(signal[i:i + chunk_samps], 2))))
        amps.append(np.sqrt(np.mean(pow(signal[len(signal) - chunk_samps:], 2))))
        return np.amax(amps)
    else:
        # samplerate low, just rms the whole thing
        return np.sqrt(np.mean(pow(signal, 2)))
177462
async def get_power_parameters(self):
        """"""
        data = await self._handler.power_parameters(system_id=self.system_id)
        return data
612711
def obfn_f(self):
        
        """

        obf = 0.0
        for i in range(self.Nb):
            obf += self.obfn_fi(self.obfn_fvar(i), i)
        return obf
260147
def sinLdot_fc(tfdata, pfdata):
    """"""
    
    dphi_fc(tfdata)
    
    sin_fc(pfdata)
    dtheta_fc(pfdata)
    
    return 1j * (tfdata - pfdata)
1155076
def hyperprior(self):
        
        hp = self.k.hyperprior * self.noise_k.hyperprior
        if self.mu is not None:
            hp *= self.mu.hyperprior
        return hp
845083
def _run_power_flow(self, Ybus, Sbus, V, pv, pq, pvpq, **kw_args):
        
        Va = angle(V)
        Vm = abs(V)

        # Initial evaluation of F(x0)...
        F = self._evaluate_function(Ybus, V, Sbus, pv, pq)
        # ...and convergency check.
        converged = self._check_convergence(F)

        # Perform Newton iterations.
        i = 0
        while (not converged) and (i < self.iter_max):
            V, Vm, Va = self._one_iteration(F, Ybus, V, Vm, Va, pv, pq, pvpq)
            F = self._evaluate_function(Ybus, V, Sbus, pv, pq)
            converged = self._check_convergence(F)
            i += 1

        if converged:
            if self.verbose:
                logger.info("Newton's method power flow converged in %d "
                            "iterations." % i)
        else:
            logger.error("Newton's method power flow did not converge in %d "
                         "iterations." % i)

        return V, converged, i