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


Python RectBivariateSpline.x方法代码示例

本文整理汇总了Python中scipy.interpolate.RectBivariateSpline.x方法的典型用法代码示例。如果您正苦于以下问题:Python RectBivariateSpline.x方法的具体用法?Python RectBivariateSpline.x怎么用?Python RectBivariateSpline.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.interpolate.RectBivariateSpline的用法示例。


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

示例1: qlf

# 需要导入模块: from scipy.interpolate import RectBivariateSpline [as 别名]
# 或者: from scipy.interpolate.RectBivariateSpline import x [as 别名]
def qlf(cosmology, band, magnitude=False, returnraw=False):
  """ returns an scipy interpolated function for the hopkins 2007 QLF, 
      at a given band.
      band can be a frequency, or 'bol', 'blue', 'ir', 'soft', 'hard'.
      HOPKINS2007 cosmology is implied.
      result shall not depend on the input cosmology but the HOPKINS cosmology
      is implied in the fits.
      if return raw is true, return 
         zrange, Lbol, Lband, M_AB, S_nu, Phi
  """
  zbins = numpy.linspace(0, 6, 200)
  Lbolbins=numpy.linspace(8, 18, 300)

  U = cosmology.units
  banddict = {'bol':0, 'blue':-1, 'ir':-2, 'soft':-3, 'hard': -4}
  from scipy.interpolate import RectBivariateSpline
  if band in banddict: 
      band = banddict[band]

  else: band = _bandconv(U, band, hertz=True)
  key = band

  if key not in _qlf_interp:
    v = numpy.empty(numpy.broadcast(Lbolbins[None, :], zbins[:, None]).shape)
    Lband, M_AB, S_nu, Phi = _qlf.qlf(band, 1.0, Lbolbins)
    with sharedmem.TPool() as pool:
      def work(v, z):
        Lband_, M_AB_, S_nu, Phi = _qlf.qlf(band, z, Lbolbins)
        v[:] = Phi
      pool.starmap(work, zip(v, zbins))
    v /= (U.MPC ** 3)
    # Notice that hopkins used 3.9e33 ergs/s for Lsun, but we use a different number.
    # but the internal fits of his numbers
    # thus we skip the conversion, in order to match the fits with luminosity in terms of Lsun.
    # Lbol = Lbol - numpy.log10(U.SOLARLUMINOSITY/U.ERG*U.SECOND) + numpy.log10(3.9e33)
    data = numpy.empty(shape=len(Lbolbins),
        dtype=[
          ('Lbol', 'f4'),
          ('Lband', 'f4'),
          ('M_AB', 'f4'),
          ('S_nu', 'f4'),
          ('Phi', ('f4', v.shape[0]))])
    data['Lbol'] = Lbolbins
    data['Lband'] = Lband
    data['M_AB'] = M_AB
    data['S_nu'] = S_nu
    data['Phi'] = v.T
    _qlf_interp[key] = data
  data = _qlf_interp[key]
  if returnraw:
    return data.view(numpy.recarray)
  if magnitude:
    func = RectBivariateSpline(zbins, - data['M_AB'], data['Phi'].T)
    func.x = zbins
    func.y = -data['M_AB']
    func.z = data['Phi'].T
    return func
  else:
    func = RectBivariateSpline(zbins, data['Lband'], data['Phi'].T)
    func.x = zbins
    func.y = data['Lband']
    func.z = data['Phi'].T
    return func
开发者ID:rainwoodman,项目名称:gaepsi,代码行数:65,代码来源:agn.py


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