本文整理匯總了Python中linetools.lists.linelist.LineList.all_transitions方法的典型用法代碼示例。如果您正苦於以下問題:Python LineList.all_transitions方法的具體用法?Python LineList.all_transitions怎麽用?Python LineList.all_transitions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類linetools.lists.linelist.LineList
的用法示例。
在下文中一共展示了LineList.all_transitions方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_all_transitions
# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import all_transitions [as 別名]
def test_all_transitions():
error_msg = 'Something is wrong in all_transitions()'
ism = LineList('ISM')
#check simple case
line = 'OVI'
ovi_transitions = ism.all_transitions(line)
assert len(ovi_transitions) == 2, error_msg
#print(ovi_transitions['name'])
#check unknown
line = 'unknown'
out = ism.all_transitions(line)
assert type(out) == dict, error_msg
#check case of single transition ion
line = 'CIII'
out = ism.all_transitions(line)
assert type(out) == dict, error_msg
# wrest
out = ism.all_transitions(1215.6700*u.AA)
assert len(out) == 30 # 30 Lyman series transitions
示例2: test_all_transitions
# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import all_transitions [as 別名]
def test_all_transitions():
error_msg = 'Something is wrong in all_transitions()'
ism = LineList('ISM')
#check simple case
line = 'OVI'
ovi_transitions = ism.all_transitions(line)
assert len(ovi_transitions) == 2, error_msg
#print(ovi_transitions['name'])
#check unknown
line = 'unknown'
out = ism.all_transitions(line)
assert type(out) == dict, error_msg
#check case of single transition ion
line = 'CIII'
out = ism.all_transitions(line)
assert type(out) == dict, error_msg
#check case of transitions from excited levels
line='FeII*'
out = ism.all_transitions(line)
assert len(out) == 27, "wrong line counts"
print(out)
# wrest
out = ism.all_transitions(1215.6700*u.AA)
assert len(out) == 30,"wrong line counts" # 30 Lyman series transitions
#print('test_all_transitions() passed')
h2 = LineList('H2')
line = 'B19-0P(1)'
out = h2.all_transitions(line)
assert len(out) == 7
示例3: Component
# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import all_transitions [as 別名]
class Component(object):
def __init__(self, z, wrest, vlim=[-300.,300]*u.km/u.s,
linelist=None):
# Init
self.init_wrest = wrest
self.zcomp = z
self.vlim = vlim
self.attrib = {'N': 0., 'Nsig': 0., 'flagN': 0, # Column
'b': 0.*u.km/u.s, 'bsig': 0.*u.km/u.s, # Doppler
'z': self.zcomp, 'zsig': 0.,
'Quality': 'None'}
self.comment = 'None'
#
self.linelist = linelist
self.lines = []
self.init_lines()
#
self.name = 'z{:.5f}_{:s}'.format(
self.zcomp,self.lines[0].data['name'].split(' ')[0])
#
def init_lines(self):
'''Fill up the component lines
'''
if self.linelist is None:
self.linelist = LineList('Strong')
# Get the lines
all_trans = self.linelist.all_transitions(self.init_wrest)
#QtCore.pyqtRemoveInputHook()
#xdb.set_trace()
#QtCore.pyqtRestoreInputHook()
if isinstance(all_trans,dict):
all_trans = [all_trans]
for trans in all_trans:
self.lines.append(AbsLine(trans['wrest'],
linelist=self.linelist))
# Sync
self.sync_lines()
def sync_lines(self):
'''Synchronize attributes of the lines
'''
for line in self.lines:
line.attrib['N'] = self.attrib['N']
line.attrib['b'] = self.attrib['b']
line.attrib['z'] = self.attrib['z']
示例4: add_abslines_from_linelist
# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import all_transitions [as 別名]
def add_abslines_from_linelist(self, llist='ISM', wvlim=None, min_Wr=None, **kwargs):
"""
It adds associated AbsLines satisfying some conditions (see parameters below).
Parameters
----------
llist : str
Name of the linetools.lists.linelist.LineList
object where to look for the transition names.
Default is 'ISM', which means the function looks
within `list = LineList('ISM')`.
wvlims : Quantity array, optional
Observed wavelength limits for AbsLines to be added.
e.g. [1200, 2000]*u.AA.
min_Wr : Quantity, optional
Minimum rest-frame equivalent with for AbsLines to be added.
This is calculated in the very low optical depth regime tau0<<1,
where Wr is independent of Doppler parameter or gamma (see eq. 9.15 of
Draine 2011). Still, a column density attribute for the AbsComponent
is needed.
Returns
-------
Adds AbsLine objects to the AbsComponent._abslines list.
Notes
-----
**kwargs are passed to AbsLine.add_absline() method.
"""
# get the transitions from LineList
llist = LineList(llist)
name = ions.ion_name(self.Zion, nspace=0)
transitions = llist.all_transitions(name)
# unify output to be always QTable
if isinstance(transitions, dict):
transitions = llist.from_dict_to_qtable(transitions)
# check wvlims
if wvlim is not None:
cond = (transitions['wrest']*(1+self.zcomp) >= wvlim[0]) & \
(transitions['wrest']*(1+self.zcomp) <= wvlim[1])
transitions = transitions[cond]
# check outputs
if len(transitions) == 0:
warnings.warn("No transitions satisfying the criteria found. Doing nothing.")
return
# loop over the transitions when more than one found
for transition in transitions:
iline = AbsLine(transition['name'], z=self.zcomp)
iline.limits.set(self.vlim)
iline.attrib['coord'] = self.coord
iline.attrib['logN'] = self.logN
iline.attrib['sig_logN'] = self.sig_logN
iline.attrib['flag_N'] = self.flag_N
iline.attrib['N'] = 10**iline.attrib['logN'] / (u.cm * u.cm)
iline.attrib['sig_N'] = 10**iline.attrib['sig_logN'] / (u.cm * u.cm)
for key in self.attrib.keys():
iline.attrib[key] = self.attrib[key]
if min_Wr is not None:
# check logN is defined
logN = self.logN
if logN == 0:
warnings.warn("AbsComponent does not have logN defined. Appending AbsLines "
"regardless of min_Wr.")
else:
N = 10**logN / (u.cm*u.cm)
Wr_iline = iline.get_Wr_from_N(N=N) # valid for the tau0<<1 regime.
if Wr_iline < min_Wr: # do not append
continue
# add the absline
self.add_absline(iline)
示例5: add_abslines_from_linelist
# 需要導入模塊: from linetools.lists.linelist import LineList [as 別名]
# 或者: from linetools.lists.linelist.LineList import all_transitions [as 別名]
def add_abslines_from_linelist(self, llist='ISM', init_name=None, wvlim=None, min_Wr=None, **kwargs):
"""
It adds associated AbsLines satisfying some conditions (see parameters below).
Parameters
----------
llist : str, optional
Name of the linetools.lists.linelist.LineList
object where to look for the transition names.
Default is 'ISM', which means the function looks
within `list = LineList('ISM')`.
init_name : str, optional
Name of the initial transition used to define the AbsComponent
wvlim : Quantity array, optional
Observed wavelength limits for AbsLines to be added.
e.g. [1200, 2000]*u.AA.
min_Wr : Quantity, optional
Minimum rest-frame equivalent with for AbsLines to be added.
This is calculated in the very low optical depth regime tau0<<1,
where Wr is independent of Doppler parameter or gamma (see eq. 9.15 of
Draine 2011). Still, a column density attribute for the AbsComponent
is needed.
Returns
-------
Adds AbsLine objects to the AbsComponent._abslines list.
Notes
-----
**kwargs are passed to AbsLine.add_absline() method.
"""
from linetools.lists import utils as ltlu
# get the transitions from LineList
llist = LineList(llist)
if init_name is None: # we have to guess it
if (self.Zion) == (-1, -1): # molecules
# init_name must be in self.attrib (this is a patch)
init_name = self.attrib['init_name']
else: # atoms
init_name = ions.ion_to_name(self.Zion, nspace=0)
transitions = llist.all_transitions(init_name)
# unify output to be a Table
if isinstance(transitions, dict):
transitions = ltlu.from_dict_to_table(transitions)
# check wvlims
if wvlim is not None:
# Deal with units
wrest = transitions['wrest'].data * transitions['wrest'].unit
# Logic
cond = (wrest*(1+self.zcomp) >= wvlim[0]) & \
(wrest*(1+self.zcomp) <= wvlim[1])
transitions = transitions[cond]
# check outputs
if len(transitions) == 0:
warnings.warn("No transitions satisfying the criteria found. Doing nothing.")
return
# loop over the transitions when more than one found
for transition in transitions:
iline = AbsLine(transition['name'], z=self.zcomp, linelist=llist)
iline.limits.set(self.vlim)
iline.attrib['coord'] = self.coord
iline.attrib['logN'] = self.logN
iline.attrib['sig_logN'] = self.sig_logN
iline.attrib['flag_N'] = self.flag_N
iline.attrib['N'] = 10**iline.attrib['logN'] / (u.cm * u.cm)
iline.attrib['sig_N'] = 10**iline.attrib['sig_logN'] / (u.cm * u.cm)
for key in self.attrib.keys():
iline.attrib[key] = self.attrib[key]
if min_Wr is not None:
# check logN is defined
if self.logN == 0:
pass
else:
N = 10.**self.logN / u.cm**2
Wr_iline = iline.get_Wr_from_N(N=N) # valid for the tau0<<1 regime.
if Wr_iline < min_Wr: # do not append
continue
# add the absline
self.add_absline(iline)