From e1bf2787388d230cc530bcd2d9b2c694e35d0fbb Mon Sep 17 00:00:00 2001 From: "J. Xavier Prochaska" Date: Thu, 27 Oct 2016 19:18:01 -0700 Subject: [PATCH] emiss -> em --- docs/examples/EmissLine_examples.ipynb | 72 ++++++++------------------ linetools/analysis/linelimits.py | 8 +-- linetools/line_utils.py | 4 +- linetools/spectralline.py | 16 +++--- linetools/tests/test_init_emissline.py | 12 ++--- 5 files changed, 43 insertions(+), 69 deletions(-) diff --git a/docs/examples/EmissLine_examples.ipynb b/docs/examples/EmissLine_examples.ipynb index f78acce9..6597ec48 100644 --- a/docs/examples/EmissLine_examples.ipynb +++ b/docs/examples/EmissLine_examples.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Examples for EmissLine class [v1.0]" + "# Examples for EmissLine class [v1.1]" ] }, { @@ -55,7 +55,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 2, @@ -65,7 +65,7 @@ ], "source": [ "reload(lsp)\n", - "emisslin = lsp.EmissLine('Halpha')\n", + "emisslin = lsp.EmLine('Halpha')\n", "emisslin" ] }, @@ -171,7 +171,7 @@ " 'limits': {u'vlim': {'unit': u'km / s', 'value': [0.0, 0.0]},\n", " u'wvlim': {'unit': u'Angstrom', 'value': [6564.613, 6564.613]},\n", " u'zlim': [0.0, 0.0]},\n", - " 'ltype': u'Emiss',\n", + " 'ltype': u'Em',\n", " 'name': u'Halpha',\n", " 'wrest': {'unit': u'Angstrom', 'value': 6564.613}}" ] @@ -203,7 +203,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 5, @@ -228,9 +228,21 @@ "cell_type": "code", "execution_count": 6, "metadata": { - "collapsed": true + "collapsed": false }, - "outputs": [], + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'module' object has no attribute 'EmissLine'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0memisslines\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0memisslin\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlsp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mEmissLine\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Hbeta'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m: 'module' object has no attribute 'EmissLine'" + ] + } + ], "source": [ "emisslines = [emisslin, lsp.EmissLine('Hbeta')]" ] @@ -244,22 +256,11 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { "collapsed": false }, - "outputs": [ - { - "data": { - "text/plain": [ - "[, ]" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "wrest_values = ltlu.parse_speclines(emisslines, 'wrest')\n", "wrest_values" @@ -274,38 +275,11 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": { "collapsed": false }, - "outputs": [ - { - "data": { - "text/html": [ - "<Table length=2>\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
wrestnameZionEjzEWsig_EWflag_fluxfluxsig_flux
Angstrom1 / cmAngstromAngstromerg / serg / s
float64unicode6int64int64float64float64float64float64int64float64float64
4862.683Hbeta110.00.00.00.000.00.0
6564.613Halpha110.00.00.00.000.00.0
" - ], - "text/plain": [ - "\n", - " wrest name Z ion Ej ... sig_EW flag_flux flux sig_flux\n", - "Angstrom 1 / cm ... Angstrom erg / s erg / s \n", - "float64 unicode6 int64 int64 float64 ... float64 int64 float64 float64 \n", - "-------- -------- ----- ----- ------- ... -------- --------- ------- --------\n", - "4862.683 Hbeta 1 1 0.0 ... 0.0 0 0.0 0.0\n", - "6564.613 Halpha 1 1 0.0 ... 0.0 0 0.0 0.0" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "reload(ltlu)\n", "tbl = ltlu.transtable_from_speclines(emisslines)\n", diff --git a/linetools/analysis/linelimits.py b/linetools/analysis/linelimits.py index 4c9e2c30..524c57d4 100644 --- a/linetools/analysis/linelimits.py +++ b/linetools/analysis/linelimits.py @@ -27,15 +27,15 @@ class LineLimits(object): """ @classmethod def from_specline(cls, aline, zlim): - """ From AbsLine or Emissline + """ From AbsLine or Emline Parameters ---------- aline : AbsLine """ - from ..spectralline import AbsLine, EmissLine - if not isinstance(aline, (AbsLine, EmissLine)): - raise IOError("Input aline must be AbsLine or EmissLine") + from ..spectralline import AbsLine, EmLine + if not isinstance(aline, (AbsLine, EmLine)): + raise IOError("Input aline must be AbsLine or EmLine") # slf = cls(aline.wrest, aline.attrib['z'], zlim) return slf diff --git a/linetools/line_utils.py b/linetools/line_utils.py index 93e35e01..c7047eb4 100644 --- a/linetools/line_utils.py +++ b/linetools/line_utils.py @@ -8,7 +8,7 @@ from astropy.table import Table from astropy.units import Quantity -from linetools.spectralline import AbsLine, EmissLine +from linetools.spectralline import AbsLine, EmLine def parse_speclines(speclines, key, mk_array=False): """ Generate a list or array of items from a list of SpectralLines @@ -70,7 +70,7 @@ def transtable_from_speclines(speclines, add_keys=None): keys = ['wrest','name','Z', 'ion', 'Ej', 'z', 'EW', 'sig_EW'] if speclines[0].ltype == 'Abs': keys += ['flag_N', 'logN', 'sig_logN'] - if speclines[0].ltype == 'Emiss': + if speclines[0].ltype == 'Em': keys += ['flag_flux', 'flux', 'sig_flux'] if add_keys is not None: keys += add_keys diff --git a/linetools/spectralline.py b/linetools/spectralline.py index 7ddc064a..3bf1be36 100644 --- a/linetools/spectralline.py +++ b/linetools/spectralline.py @@ -69,7 +69,7 @@ class SpectralLine(object): Attributes ---------- ltype : str - Type of line, either 'Abs' or 'Emiss' (not currently implemented though) + Type of line, either 'Abs' or 'Em' (not currently implemented though) wrest : Quantity Rest wavelength z : float @@ -111,8 +111,8 @@ def from_dict(cls, idict, coord=None, warn_only=False, chk_data=True, **kwargs): sline = AbsLine(idict['name'], **kwargs) except KeyError: # This is to be compatible JSON files already written with old notation (e.g. DLA H100) sline = AbsLine(idict['trans'], **kwargs) - elif idict['ltype'] == 'Emiss': - sline = EmissLine(idict['name'], **kwargs) + elif idict['ltype'] == 'Em': + sline = EmLine(idict['name'], **kwargs) else: raise ValueError("Not prepared for type {:s}.".format(idict['ltype'])) # Check data @@ -182,7 +182,7 @@ def __init__(self, ltype, trans, linelist=None, closest=False, z=0., # Required self.ltype = ltype - if ltype not in ['Abs', 'Emiss']: + if ltype not in ['Abs', 'Em']: raise ValueError('spec/lines: Not ready for type {:s}'.format(ltype)) # Init @@ -202,7 +202,7 @@ def __init__(self, ltype, trans, linelist=None, closest=False, z=0., zlim = kwargs['zlim'] except KeyError: zlim = [z,z] - if ltype in ['Abs', 'Emiss']: + if ltype in ['Abs', 'Em']: self.limits = LineLimits.from_specline(self, zlim) else: raise ValueError('Not ready to set limits for this type') @@ -226,7 +226,7 @@ def fill_data(self, trans, linelist=None, closest=False, verbose=True): if linelist is None: if self.ltype == 'Abs': llist = LineList('ISM') - elif self.ltype == 'Emiss': + elif self.ltype == 'Em': llist = LineList('Galaxy') else: raise ValueError("Not ready for ltype = {:s}".format(self.ltype)) @@ -678,7 +678,7 @@ def __repr__(self): txt = txt + '>' return (txt) -class EmissLine(SpectralLine): +class EmLine(SpectralLine): """Class representing a spectral emission line. Parameters @@ -690,7 +690,7 @@ class EmissLine(SpectralLine): """ def __init__(self, trans, **kwargs): # Generate with type - super(EmissLine, self).__init__('Emiss', trans, **kwargs) + super(EmLine, self).__init__('Em', trans, **kwargs) def update(self): """ Fill in a few additional dicts diff --git a/linetools/tests/test_init_emissline.py b/linetools/tests/test_init_emissline.py index 211c606a..3b4b5125 100644 --- a/linetools/tests/test_init_emissline.py +++ b/linetools/tests/test_init_emissline.py @@ -1,4 +1,4 @@ -# Module to run tests on initializing EmissLine +# Module to run tests on initializing EmLine # TEST_UNICODE_LITERALS from __future__ import print_function, absolute_import, division, unicode_literals @@ -7,7 +7,7 @@ import pytest from astropy import units as u -from linetools.spectralline import EmissLine, SpectralLine +from linetools.spectralline import EmLine, SpectralLine from linetools import utils as ltu ''' @@ -18,17 +18,17 @@ def data_path(filename): def test_mk_emissline(): # Init Halpha - emisslin = EmissLine(6564.613*u.AA) + emisslin = EmLine(6564.613*u.AA) assert emisslin.name == 'Halpha' # Init Halpha by name - emisslin2 = EmissLine('Halpha') + emisslin2 = EmLine('Halpha') np.testing.assert_allclose(emisslin2.data['wrest'], 6564.613*u.AA) def test_dicts(): # Init Halpha - emisslin = EmissLine(6564.613*u.AA) + emisslin = EmLine(6564.613*u.AA) emisslin.analy['spec'] = 'tmp.fits' edict = emisslin.to_dict() assert isinstance(edict, dict) @@ -38,4 +38,4 @@ def test_dicts(): newdict = ltu.loadjson('tmp.json') newlin = SpectralLine.from_dict(newdict) assert newlin.name == 'Halpha' - assert newlin.ltype == 'Emiss' + assert newlin.ltype == 'Em'