当前位置: 首页>>代码示例>>Python>>正文


Python math.log10函数代码示例

本文整理汇总了Python中math.log10函数的典型用法代码示例。如果您正苦于以下问题:Python log10函数的具体用法?Python log10怎么用?Python log10使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log10函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: badness

 def badness(self):
     """
     How bad is the error?
     
     Returns the max of the absolute logarithmic errors of kf and Kc
     """
     return max(abs(math.log10(self.k_ratio)), abs(math.log10(self.Keq_ratio)))
开发者ID:comocheng,项目名称:RMG-Py,代码行数:7,代码来源:network.py

示例2: metal_con

def metal_con(filename, distances, real_dist, bins=35, limits=(-3.1, 0.2),
              avgs=1, detection=1, tag="out"):
    """ main bit """
    if filename[-4:] == '.csv':  delim = ','
    else:  delim = None
    data = shift_data(fi.read_data(filename, delim), real_dist, distances[0])
    mod_actual = 5.*(ma.log10(real_dist*1000) - 1.)
    mod_new = 5.*(ma.log10(distances[0]*1000) - 1.)
    mod = mod_actual - mod_new
    print "Effective Magnitude Shift = {0}, average g={1}".format(mod, sc.mean(data[:,2]))
    new_data = cut_data(data, 4,2,3,5, deff=0, modulus=mod, full=1)
    FeH = get_photo_metal(new_data[:,4],new_data[:,2],new_data[:,3])
    ref_hist = np.histogram(FeH, bins, limits)
    hist = []
    #Also iterate over several runs and average
    for i in range(len(distances)):
        print "#- Convolving to distance {0} kpc".format(distances[i])
        if i==0:  deff=0
        else: deff=detection
        temp_hist = []
        for j in range(avgs):
            #holds dist constant, applies appropriate errors for new distance
            new_data = con.convolve(data, real_dist, distances[i])
            #shift data so detection efficiency works correctly;  has no noticable effect if deff=0
            new_data = shift_data(new_data, distances[0], distances[i])
            # apply color cuts and detection efficiency to shifted and convolved data
            new_data = cut_data(new_data, 4,2,3,5, deff=deff, modulus=None, full=0)
            print "Average g = {0}, total stars = {1}".format(sc.mean(new_data[:,2]), len(new_data[:,0]))
            FeH = get_photo_metal(new_data[:,4],new_data[:,2],new_data[:,3])
            temp_hist.append(np.histogram(FeH, bins, limits))
        new_hist = avg_hists(temp_hist)
        hist.append(new_hist)
    plot_hists(hist, ref_hist, distances, tag)
    return hist
开发者ID:MNewby,项目名称:Newby-tools,代码行数:34,代码来源:metal_CA.py

示例3: auto_precision

 def auto_precision(self):
     """Automatically find the precision based on the format of the tick
     label.
     """
     
     if self.ticklabel.format.lower()=="general":
         self.ticklabel.prec = 0 # doesn't matter
     elif self.ticklabel.format.lower()=="decimal":
         x = self.tick.major
         p = int(math.floor(math.log10(x)))
         if p>=0:
             self.ticklabel.prec = 0
         else:
             z = math.floor(x/(10**p))
             y = x-z*10**p
             if y==0.0:
                 self.ticklabel.prec = -p
             else:
                 prec = -int(math.floor(math.log10(y)+0.0000001))
                 self.ticklabel.prec = prec
     elif self.ticklabel.format.lower()=="power":
         self.ticklabel.prec = 0
     elif self.ticklabel.format.lower() in ["exponential","scientific"]:
         x = self.tick.major
         p = int(math.floor(math.log10(x)))
         z = math.floor(x/(10**p))
         y = x-z*10**p
         if y==0.0:
             self.ticklabel.prec = 0
         else:
             prec = -int(math.floor(math.log10(y/10**p)+0.0000001))
             self.ticklabel.prec = prec
     else:
         self.ticklabel.prec = 1
开发者ID:mmckerns,项目名称:pygrace,代码行数:34,代码来源:axis.py

示例4: lporder

def lporder (freq1, freq2, delta_p, delta_s):
    '''
    FIR lowpass filter length estimator.  freq1 and freq2 are
    normalized to the sampling frequency.  delta_p is the passband
    deviation (ripple), delta_s is the stopband deviation (ripple).

    Note, this works for high pass filters too (freq1 > freq2), but
    doesnt work well if the transition is near f == 0 or f == fs/2

    From Herrmann et al (1973), Practical design rules for optimum
    finite impulse response filters.  Bell System Technical J., 52, 769-99
    '''
    df = abs (freq2 - freq1)
    ddp = math.log10 (delta_p)
    dds = math.log10 (delta_s)

    a1 = 5.309e-3
    a2 = 7.114e-2
    a3 = -4.761e-1
    a4 = -2.66e-3
    a5 = -5.941e-1
    a6 = -4.278e-1

    b1 = 11.01217
    b2 = 0.5124401

    t1 = a1 * ddp * ddp
    t2 = a2 * ddp
    t3 = a4 * ddp * ddp
    t4 = a5 * ddp

    dinf=((t1 + t2 + a3) * dds) + (t3 + t4 + a6)
    ff = b1 + b2 * (ddp - dds)
    n = dinf / df - ff * df + 1
    return n
开发者ID:djacobow,项目名称:sdr-rnav,代码行数:35,代码来源:firdes.py

示例5: add_stat_text

def add_stat_text(axhi, weights, bins) :
    #mean, rms, err_mean, err_rms, neff = proc_stat(weights,bins)
    mean, rms, err_mean, err_rms, neff, skew, kurt, err_err = proc_stat(weights,bins)
    pm = r'$\pm$' 
    txt  = 'Mean=%.2f%s%.2f\nRMS=%.2f%s%.2f\n' % (mean, pm, err_mean, rms, pm, err_rms)
    txt += r'$\gamma1$=%.3f  $\gamma2$=%.3f' % (skew, kurt)
    #txt += '\nErr of err=%8.2f' % (err_err)
    xb,xe = axhi.get_xlim()     
    yb,ye = axhi.get_ylim()     
    #x = xb + (xe-xb)*0.84
    #y = yb + (ye-yb)*0.66
    #axhi.text(x, y, txt, fontsize=10, color='k', ha='center', rotation=0)
    x = xb + (xe-xb)*0.98
    y = yb + (ye-yb)*0.95

    if axhi.get_yscale() is 'log' :
        #print 'axhi.get_yscale():', axhi.get_yscale()
        log_yb, log_ye = log10(yb), log10(ye)
        log_y = log_yb + (log_ye-log_yb)*0.95
        y = 10**log_y

    axhi.text(x, y, txt, fontsize=10, color='k',
              horizontalalignment='right',
              verticalalignment='top',
              rotation=0)
开发者ID:FilipeMaia,项目名称:psdmrepo,代码行数:25,代码来源:PlotImgSpeWidget.py

示例6: __init__

    def __init__(self, image, normalize=True, title=None, parent=None):
        qt.QFrame.__init__(self, parent)
        self.viewer = ImageViewer(image, normalize, title, parent=self)
        self.setWindowTitle(self.viewer.windowTitle())

        self._captionCoords = 0, 0
        self._xplaces = int(math.log10(self.viewer.image.width) + 1.0)
        self._yplaces = int(math.log10(self.viewer.image.height) + 1.0)
        self._valueplaces = self.viewer.image.channels * 5

        self.label = qt.QLabel(self)
        font = qt.QFont()
        font.setPointSize(10)
        font.setStyleHint(qt.QFont.TypeWriter)
        self.label.setFont(font)

        self._layout = qt.QVBoxLayout(self)
        self._layout.setSpacing(5)
        self._layout.addWidget(self.viewer, 1)
        self._layout.addWidget(self.label)

        self.connect(self.viewer, SIGNAL('mouseOver(int, int)'), self.updateCaption)
        self.connect(self.viewer.cursorAction, SIGNAL('triggered()'), self._toggleCaptionSignals)

        self.updateCaption()
开发者ID:DaveRichmond-,项目名称:vigra,代码行数:25,代码来源:imagewindow.py

示例7: get_median_mag

    def get_median_mag(self, area, rake):
        """
        Return magnitude (Mw) given the area and rake.

        Setting the rake to ``None`` causes their "All" rupture-types
        to be applied.

        :param area:
            Area in square km.
        :param rake:
            Rake angle (the rupture propagation direction) in degrees,
            from -180 to 180.
        """
        assert rake is None or -180 <= rake <= 180
        if rake is None:
            # their "All" case
            return 4.07 + 0.98 * log10(area)
        elif (-45 <= rake <= 45) or (rake > 135) or (rake < -135):
            # strike slip
            return 3.98 + 1.02 * log10(area)
        elif rake > 0:
            # thrust/reverse
            return 4.33 + 0.90 * log10(area)
        else:
            # normal
            return 3.93 + 1.02 * log10(area)
开发者ID:glenn-rix,项目名称:oq-hazardlib,代码行数:26,代码来源:wc1994.py

示例8: score_response

 def score_response(self, comment, response):
     """
     This function can be modified to give a good internal scoring for a
     response. If negative, we won't post. This is useful when there is more
     than one possible response in our database.
     """
     # Discard the obviously bad responses
     if response.body.strip() == "[deleted]":
         return -1
     simple_body = rewriter.simplify_body(comment.body)
     if response.score < config.good_comment_threshold:
         return -1
     # Derive our base score. We use a logarithm, because reddit scores are
     # roughly logrithmic <http://amix.dk/blog/post/19588>
     base_score = math.log10(response.score)
     # A raw pentalty to subtract for the comment being in a different
     # context from it's parent
     response_parent = self.__get_parent(response)
     if response_parent is not None:
         similarity = self._get_parent_similarity_ratio(comment, response_parent)
         difference_penalty = math.log10(10000) * (1 - similarity) ** 10
     else:
         difference_penalty = math.log10(10000)
     # give it some points for length
     length_reward = math.log10(len(simple_body))
     # throw in some randomness for good luck
     fuzz_multiplier = random.gauss(mu=1, sigma=0.05)
     # put it all together
     final_score = (base_score - difference_penalty + length_reward) * fuzz_multiplier
     return final_score
开发者ID:bgw,项目名称:NotVeryCleverBot,代码行数:30,代码来源:scoring.py

示例9: _rescale

def _rescale(lo,hi,step,pt=None,bal=None,scale='linear'):
    """
    Rescale (lo,hi) by step, returning the new (lo,hi)
    The scaling is centered on pt, with positive values of step
    driving lo/hi away from pt and negative values pulling them in.
    If bal is given instead of point, it is already in [0,1] coordinates.

    This is a helper function for step-based zooming.
    """
    # Convert values into the correct scale for a linear transformation
    # TODO: use proper scale transformers
    if scale=='log':
        lo,hi = log10(lo),log10(hi)
        if pt is not None: pt = log10(pt)

    # Compute delta from axis range * %, or 1-% if persent is negative
    if step > 0:
        delta = float(hi-lo)*step/100
    else:
        delta = float(hi-lo)*step/(100-step)

    # Add scale factor proportionally to the lo and hi values, preserving the
    # point under the mouse
    if bal is None:
        bal = float(pt-lo)/(hi-lo)
    lo = lo - bal*delta
    hi = hi + (1-bal)*delta

    # Convert transformed values back to the original scale
    if scale=='log':
        lo,hi = pow(10.,lo),pow(10.,hi)

    return (lo,hi)
开发者ID:reflectometry,项目名称:osrefl,代码行数:33,代码来源:polplot.py

示例10: p_powerset

 def p_powerset(self, p):
     '''powerset : POWER EQ default
                 | POWER EQ value
                 | POWER EQ value dbm
                 | POWER EQ value w
                 | POWER EQ value mw
                 | POWER EQ value uw
                 | POWER EQ value nw'''
     from math import log10
     if len(p) == 4: # Default or unitless value
         p[0] = {'power' : p[3]} # Return power, even if just 'default', since user explicitly set it
     else:   # Units specified
         if p[4] == 'dbm':
             p[0] = {'power' : p[3]}
         elif p[4] == 'w':
             # Convert value in W to dBm
             p[0] = {'power' : 10*log10(p[3]*1e+3)}
         elif p[4] == 'mw':
             # Convert value in mW to dBm
             p[0] = {'power' : 10*log10(p[3])}
         elif p[4] == 'uw':
             # Convert value in uW to dBm
             p[0] = {'power' : 10*log10(p[3]*1e-3)}
         elif p[4] == 'nw':
             # Convert value in nW to dBm
             p[0] = {'power' : 10*log10(p[3]*1e-6)}
         else: # How'd we get here?! Assume units of dBm
             print("ERROR: Undefined case in grammar of powerset. Assuming units of dBm.")   # TODO: throw exception here
             p[0] = {'power' : p[3]}
开发者ID:johnoutwater,项目名称:range-tools,代码行数:29,代码来源:cmdfileparser.py

示例11: interact

    def interact(self):
        # counterclockwise
        if self.left_pressed:
            self.angle = (self.angle + 10) % 360

        if self.right_pressed:
            self.angle = self.angle - 10
            if self.angle < 0:
                self.angle += 360

        if self.up_pressed:
            self.speed = math.log10(self.speed + 2) * 5
        elif self.speed > 1:
            self.speed = math.log10(self.speed) * 5
        else:
            self.speed = 0
        
        if self.space_pressed:
            self.bomb(0, 2)
            self.bomb(30, 5)
            self.bomb(-30 , 5)
            self.bomb(15, 15)
            self.bomb(-15 , 15)
            self.bomb(50, 30)
            self.bomb(-50 , 30)

        self.bombs += 0.2

        self.rotate()
        return True
开发者ID:j0hn,项目名称:buto,代码行数:30,代码来源:buto.dx.py

示例12: main

def main():
    ht = 50
    hr = 2
    f = 900 * 10**6
    c = 3 * 10**8
    gr = [1, 0.316, 0.1, 0.01]
    gl = 1
    r = -1

    distance = np.arange(1, 100001, 1, dtype=float)
    lambd = c / float(f)
    dc = 4 * ht * hr / lambd
    reflect = (distance**2 + (ht + hr)**2)**0.5
    los = (distance**2 + (ht - hr)**2)**0.5
    phi = 2 * pi * (reflect - los) / lambd
    flat = distance[:ht]
    decline = distance[ht:(dc + 1)]
    steep = distance[dc:]

    for i in range(len(gr)):
        temp = gl**0.5 / los + r * (gr[i]**0.5) * np.exp(phi * -1J) / reflect
        pr = (lambd / 4 / pi)**2 * (abs(temp)**2)
        plt.subplot(220 + i + 1)
        plt.plot(10*log(distance),10*log(pr)-10*log10(pr[0]),'b', \
                10*log(flat), np.zeros(len(flat)), 'y', \
                10*log(decline),-20*log(decline),'g', 10*log(steep),-40*log(steep),'r')
        plt.axvline(x=10 * log10(ht), linestyle='-.')
        plt.axvline(x=10 * log10(dc), linestyle='-.')
        plt.title("Gr = %s" % gr[i])

    plt.show()
开发者ID:creasyw,项目名称:Courses,代码行数:31,代码来源:2-8.py

示例13: Apparent_Magnitude_Absolute_Magnitude_Distance_Relation

 def Apparent_Magnitude_Absolute_Magnitude_Distance_Relation(self, var, val1, val2):
     if var == 'm': #val1 = M, val2 = d
         return(val1 + 5 * math.log10(val2 - 5))
     if var == 'M': #val1 = m, val2 = d
         return(val1 - 5 * math.log10(val2 - 5))
     if var == 'd': #val1 = m, val2 = M
         return(math.pow(10, (val1 - val2) / 5) + 5)
开发者ID:jcarter2010,项目名称:JPackage,代码行数:7,代码来源:JPAstro.py

示例14: fm_heat

def fm_heat(gene2heat, fm_threshold, cis_threshold=0.01, CIS=False):
    print "* Creating oncodrive heat map..."
    if CIS:
        print "\tIncluding CIS scores at threshold", cis_threshold, "..."
    heat = dict()
    src_fm, src_cis_amp, src_cis_del = 0, 0, 0
    for g, scores in gene2heat.items():
        if CIS:
            del_score = scores["del"] if scores["del"] < cis_threshold else NULL
            amp_score = scores["amp"] if scores["amp"] < cis_threshold else NULL
            fm_score = scores["fm"] if scores["fm"] < fm_threshold else NULL
            if fm_score == NULL and amp_score == NULL and del_score == NULL:
                continue
            min_val = min(del_score, amp_score, fm_score)
            heat[g] = -log10(min_val)
            if min_val == scores["fm"]:
                src_fm += 1
            elif min_val == scores["amp"]:
                src_cis_amp += 1
            elif min_val == scores["del"]:
                src_cis_del += 1
        else:
            if scores["fm"] >= fm_threshold:
                continue
            heat[g] = -log10(scores["fm"])
            src_fm += 1
    print "\t- Genes using FM score:", src_fm
    print "\t- Genes using CIS AMP score:", src_cis_amp
    print "\t- Genes using CIS DEL score:", src_cis_del

    return heat
开发者ID:simnim,项目名称:hotnet2,代码行数:31,代码来源:heat.py

示例15: psnr

def psnr(sp_img_1, sp_img_2):
    """
    Peak Signal To Noise Ratio - measure of image quality

    Parameters
    ----------
    :param *SpatialImage* sp_img_1: *SpatialImage* image

    :param *SpatialImage* sp_img_2: *SpatialImage* image

    Returns
    ----------
    :return: float psnr -- psnr value (dB)
    """
    if isinstance(sp_img_1, SpatialImage) and isinstance(sp_img_2, SpatialImage):
        if sp_img_1.itemsize==sp_img_2.itemsize:
            maxi =  2**(sp_img_1.itemsize*8) - 1
            mse = mean_squared_error(sp_img_1, sp_img_2)
            if mse!=0:
                psnr = 20.0*log10(maxi) - 10*log10(mse)
            elif mse==0:
                psnr = np.inf
            return psnr
        else:
            print('sp_img_1 and sp_img_2 does not have the same type')
            return
    else:
        print('sp_img_1 and sp_img_2 must be SpatialImage instances')
        return
开发者ID:VirtualPlants,项目名称:timagetk,代码行数:29,代码来源:img_metrics.py


注:本文中的math.log10函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。