當前位置: 首頁>>代碼示例>>Python>>正文


Python LineList.closest方法代碼示例

本文整理匯總了Python中linetools.lists.linelist.LineList.closest方法的典型用法代碼示例。如果您正苦於以下問題:Python LineList.closest方法的具體用法?Python LineList.closest怎麽用?Python LineList.closest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在linetools.lists.linelist.LineList的用法示例。


在下文中一共展示了LineList.closest方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: fill_data

# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import closest [as 別名]
    def fill_data(self, trans, linelist=None, closest=False, verbose=True):
        """ Fill atomic data and setup analy.

        Parameters
        ----------
        trans : Quantity or str
          Either a rest wavelength (e.g. 1215.6700*u.AA) or the name
          of a transition (e.g. 'CIV 1548'). For an unknown transition
          use string 'unknown'.
        linelist : LineList, optional
          Class of linelist or str setting LineList
        closest : bool, optional
          Take the closest line to input wavelength? [False]
        """

        # Deal with LineList
        if linelist is None:
            llist = LineList('ISM')
        elif isinstance(linelist,basestring):
            llist = LineList(linelist)
        elif isinstance(linelist,LineList):
            llist = linelist
        else:
            raise ValueError('Bad input for linelist')

        # Closest?
        llist.closest = closest

        # Data
        newline = llist[trans]
        try:
            self.data.update(newline)  # Expected to be a LineList dict object
        except TypeError:
            pdb.set_trace()


        # Update
        self.wrest = self.data['wrest']
        self.name = self.data['name']

        #
        self.analy.update( {
            'flg_eye': 0,
            'flg_limit': 0, # No limit
            'datafile': '', 
            'name': self.data['name']
            })

        # Additional fundamental attributes for Absorption Line
        self.attrib.update(abs_attrib.copy())
開發者ID:banados,項目名稱:linetools,代碼行數:52,代碼來源:spectralline.py

示例2: fill_data

# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import closest [as 別名]
    def fill_data(self, trans, linelist=None, closest=False, verbose=True):
        """ Fill atomic data and setup analy.

        Parameters
        ----------
        trans : Quantity or str
          Either a rest wavelength (e.g. 1215.6700*u.AA) or the name
          of a transition (e.g. 'CIV 1548'). For an unknown transition
          use string 'unknown'.
        linelist : LineList, optional
          Class of linelist or str setting LineList
        closest : bool, optional
          Take the closest line to input wavelength? [False]
        """

        # Deal with LineList
        if linelist is None:
            if self.ltype == 'Abs':
                llist = LineList('ISM')
            elif self.ltype == 'Em':
                llist = LineList('Galaxy')
            else:
                raise ValueError("Not ready for ltype = {:s}".format(self.ltype))
        elif isinstance(linelist,basestring):
            llist = LineList(linelist)
        elif isinstance(linelist,LineList):
            llist = linelist
        else:
            raise ValueError('Bad input for linelist')

        # Closest?
        llist.closest = closest

        # Data
        newline = llist[trans]
        if newline is None:
            raise ValueError("Transition {} not found in LineList {:s}".format(trans, llist.list))
        try:
            self.data.update(newline)  # Expected to be a LineList dict object
        except TypeError:
            raise TypeError("Probably should not be here")


        # Update
        self.wrest = self.data['wrest']
        self.name = self.data['name']

        #
        self.update()  # is this used ?
開發者ID:lwymarie,項目名稱:linetools,代碼行數:51,代碼來源:spectralline.py

示例3: fill_data

# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import closest [as 別名]
    def fill_data(self, trans, linelist=None, closest=False):
        """ Fill atomic data and setup analy.

        Parameters
        ----------
        trans : Quantity or str
          Either a rest wavelength (e.g. 1215.6700*u.AA) or the name
          of a transition (e.g. 'CIV 1548'). For an unknown transition
          use string 'unknown'.
        linelist : LineList, optional
          Class of linelist or str setting LineList
        closest : bool, optional
          Take the closest line to input wavelength? [False]
        """

        # Deal with LineList
        if linelist is None:
            llist = LineList('ISM')
        elif isinstance(linelist,basestring):
            llist = LineList(linelist)
        elif isinstance(linelist,LineList):
            llist = linelist
        else:
            raise ValueError('Bad input for linelist')

        # Closest?
        llist.closest = closest

        # Data
        newline = llist[trans]
        self.data.update(newline)

        # Update
        self.wrest = self.data['wrest']
        self.trans = self.data['name']

        #
        self.analy.update( {
            'flg_eye': 0,
            'flg_limit': 0, # No limit
            'datafile': '', 
            'name': self.data['name']
            })

        # Additional attributes for Absorption Line
        self.attrib.update({'N': 0., 'Nsig': 0., 'flagN': 0, # Column
                       'b': 0.*u.km/u.s, 'bsig': 0.*u.km/u.s  # Doppler
                       } )
開發者ID:nhmc,項目名稱:linetools,代碼行數:50,代碼來源:spectralline.py

示例4: fill_data

# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import closest [as 別名]
    def fill_data(self, trans, linelist=None, closest=False, verbose=True,
                  use_CACHE=False, **kwargs):
        """ Fill atomic data and setup analy.

        Parameters
        ----------
        trans : Quantity or str
          Either a rest wavelength (e.g. 1215.6700*u.AA) or the name
          of a transition (e.g. 'CIV 1548'). For an unknown transition
          use string 'unknown'.
        linelist : str or LineList or list of LineList objects, optional
          Class of linelist or str setting LineList
          or list of LineList objects
        closest : bool, optional
          Take the closest line to input wavelength? [False]
        """
        global CACHE_LLIST   # Only cached if LineList is *not* input
        # Deal with LineList
        flg_list = False
        if linelist is None:
            if use_CACHE and (CACHE_LLIST is not None):
                llist = CACHE_LLIST
            else:
                if self.ltype == 'Abs':
                    llist = LineList('ISM')
                elif self.ltype == 'Em':
                    llist = LineList('Galaxy')
                else:
                    raise ValueError("Not ready for ltype = {:s}".format(self.ltype))
        elif isinstance(linelist,basestring):
            llist = LineList(linelist)
        elif isinstance(linelist,LineList):
            llist = linelist
        elif isinstance(linelist,list):
            llist = linelist[0]
            flg_list = True
        else:
            raise ValueError('Bad input for linelist')

        # Cache
        CACHE_LLIST = llist
        # Closest?
        llist.closest = closest

        # Data
        if flg_list:  # Allow for a list of LineList
            for llist in linelist:
                llist.closest = closest
                newline = llist[trans]
                if newline is not None:
                    break
        else:
            newline = llist[trans]

        # Success?
        if newline is None:
            print("Transition {} not found in LineList {:s}".format(trans, llist.list))
            raise ValueError("You may need to set clear_CACHE_LLIST=True")
        try:
            self.data.update(newline)  # Expected to be a LineList dict object
        except TypeError:
            raise TypeError("Probably should not be here")


        # Update
        if isinstance(self.data, dict):
            self.wrest = self.data['wrest']
        else:
            self.wrest = self.data['wrest']*self.data['wrest'].unit
        self.name = self.data['name']

        #
        self.update()  # is this used ?
開發者ID:linetools,項目名稱:linetools,代碼行數:75,代碼來源:spectralline.py

示例5: test_closest

# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import closest [as 別名]
def test_closest():
    ism = LineList('ISM')
    ism.closest=True
    # 
    line = ism[1250.584*u.AA]
    np.testing.assert_allclose(line['wrest'], 1250.578*u.AA, rtol=1e-7)
開發者ID:jnburchett,項目名稱:linetools,代碼行數:8,代碼來源:test_use_linelist.py


注:本文中的linetools.lists.linelist.LineList.closest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。