本文整理汇总了Python中linetools.spectralline.AbsLine.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python AbsLine.to_dict方法的具体用法?Python AbsLine.to_dict怎么用?Python AbsLine.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linetools.spectralline.AbsLine
的用法示例。
在下文中一共展示了AbsLine.to_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dicts
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import to_dict [as 别名]
def test_dicts():
# Init HI Lya
abslin = AbsLine(1215.6700*u.AA)
adict = abslin.to_dict()
assert isinstance(adict, dict)
# Write
#pdb.set_trace()
ltu.savejson('tmp.json', adict, overwrite=True)
# Read
newdict = ltu.loadjson('tmp.json')
newlin = SpectralLine.from_dict(newdict)
assert newlin.name == 'HI 1215'
示例2: test_dicts
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import to_dict [as 别名]
def test_dicts():
# Init HI Lya
abslin = AbsLine(1215.6700*u.AA)
abslin.analy['spec'] = 'tmp.fits'
adict = abslin.to_dict()
assert isinstance(adict, dict)
# Write
#pdb.set_trace()
ltu.savejson('tmp.json', adict, overwrite=True)
# Read
newdict = ltu.loadjson('tmp.json')
newlin = SpectralLine.from_dict(newdict)
assert newlin.name == 'HI 1215'
# Old dict for compatability
newdict.pop('limits')
newdict['analy']['vlim'] = [-150,150]*u.km/u.s
newdict['attrib']['z'] = 0.5
tmp3 = SpectralLine.from_dict(newdict)
assert newlin.name == 'HI 1215'