def test_todict_withjson(): radec = SkyCoord(ra=123.1143 * u.deg, dec=-12.4321 * u.deg) # HI Lya, Lyb lya = AbsLine(1215.670 * u.AA) lya.limits.set([-300., 300.] * u.km / u.s) lya.attrib['z'] = 2.92939 lya.attrib['coord'] = radec lyb = AbsLine(1025.7222 * u.AA) lyb.limits.set([-300., 300.] * u.km / u.s) lyb.attrib['z'] = lya.attrib['z'] lyb.attrib['coord'] = radec abscomp = AbsComponent.from_abslines([lya, lyb]) # Instantiate HIsys = LymanAbsSystem.from_components([abscomp]) # Dict adict = HIsys.to_dict() assert isinstance(adict, dict) # Verify it is JSON compatible (failing in Python 3) import io, json with io.open('tmp.json', 'w', encoding='utf-8') as f: f.write( unicode( json.dumps(adict, sort_keys=True, indent=4, separators=(',', ': '))))
def test_one_component(): # Instantiate abscomp = lyman_comp(radec) HIsys = LymanAbsSystem.from_components([abscomp]) # Test assert HIsys.abs_type == 'HILyman' assert len(HIsys._components) == 1 assert HIsys._components[0].Zion[0] == 1 assert HIsys._components[0].Zion[1] == 1
def test_one_component(): radec = SkyCoord(ra=123.1143*u.deg, dec=-12.4321*u.deg) # HI Lya, Lyb lya = AbsLine(1215.670*u.AA) lya.analy['vlim'] = [-300.,300.]*u.km/u.s lya.attrib['z'] = 2.92939 lyb = AbsLine(1025.7222*u.AA) lyb.analy['vlim'] = [-300.,300.]*u.km/u.s lyb.attrib['z'] = lya.attrib['z'] abscomp = AbsComponent.from_abslines([lya,lyb]) abscomp.coord = radec # Instantiate HIsys = LymanAbsSystem.from_components([abscomp]) # Test assert HIsys.abs_type == 'HILyman' assert len(HIsys._components) == 1 assert HIsys._components[0].Zion[0] == 1 assert HIsys._components[0].Zion[1] == 1
def test_todict(): radec = SkyCoord(ra=123.1143*u.deg, dec=-12.4321*u.deg) # HI Lya, Lyb lya = AbsLine(1215.670*u.AA) lya.analy['vlim'] = [-300.,300.]*u.km/u.s lya.attrib['z'] = 2.92939 lyb = AbsLine(1025.7222*u.AA) lyb.analy['vlim'] = [-300.,300.]*u.km/u.s lyb.attrib['z'] = lya.attrib['z'] abscomp = AbsComponent.from_abslines([lya,lyb]) abscomp.coord = radec # Instantiate HIsys = LymanAbsSystem.from_components([abscomp]) # Dict adict = HIsys.to_dict() assert isinstance(adict, dict) # Instantiate newsys = AbsSystem.from_dict(adict) assert isinstance(newsys, AbsSystem)
def test_one_component(): radec = SkyCoord(ra=123.1143 * u.deg, dec=-12.4321 * u.deg) # HI Lya, Lyb lya = AbsLine(1215.670 * u.AA) lya.analy['vlim'] = [-300., 300.] * u.km / u.s lya.attrib['z'] = 2.92939 lya.attrib['N'] = 1e17 / u.cm**2 lyb = AbsLine(1025.7222 * u.AA) lyb.analy['vlim'] = [-300., 300.] * u.km / u.s lyb.attrib['z'] = lya.attrib['z'] abscomp = AbsComponent.from_abslines([lya, lyb]) abscomp.coord = radec # Instantiate HIsys = LymanAbsSystem.from_components([abscomp]) # Test assert HIsys.abs_type == 'HILyman' assert len(HIsys._components) == 1 assert HIsys._components[0].Zion[0] == 1 assert HIsys._components[0].Zion[1] == 1
def test_todict(): radec = SkyCoord(ra=123.1143 * u.deg, dec=-12.4321 * u.deg) # HI Lya, Lyb lya = AbsLine(1215.670 * u.AA) lya.analy['vlim'] = [-300., 300.] * u.km / u.s lya.attrib['z'] = 2.92939 lya.attrib['coord'] = radec lyb = AbsLine(1025.7222 * u.AA) lyb.analy['vlim'] = [-300., 300.] * u.km / u.s lyb.attrib['z'] = lya.attrib['z'] lyb.attrib['coord'] = radec abscomp = AbsComponent.from_abslines([lya, lyb]) # Instantiate HIsys = LymanAbsSystem.from_components([abscomp]) # Dict adict = HIsys.to_dict() assert isinstance(adict, dict) # Instantiate #pdb.set_trace() newsys = AbsSystem.from_dict(adict) assert isinstance(newsys, AbsSystem)
def test_todict_withjson(): radec = SkyCoord(ra=123.1143*u.deg, dec=-12.4321*u.deg) # HI Lya, Lyb lya = AbsLine(1215.670*u.AA) lya.analy['vlim'] = [-300.,300.]*u.km/u.s lya.attrib['z'] = 2.92939 lyb = AbsLine(1025.7222*u.AA) lyb.analy['vlim'] = [-300.,300.]*u.km/u.s lyb.attrib['z'] = lya.attrib['z'] abscomp = AbsComponent.from_abslines([lya,lyb]) abscomp.coord = radec # Instantiate HIsys = LymanAbsSystem.from_components([abscomp]) # Dict adict = HIsys.to_dict() assert isinstance(adict, dict) # Verify it is JSON compatible (failing in Python 3) import io,json with io.open('tmp.json', 'w', encoding='utf-8') as f: f.write(unicode(json.dumps(adict, sort_keys=True, indent=4, separators=(',', ': '))))