<jupyter_start><jupyter_text>Examples for AbsLine class (v1.6)<jupyter_code># suppress warnings for these examples
import warnings
warnings.filterwarnings('ignore')

# import
import astropy.units as u
from linetools.spectralline import AbsLine, SpectralLine
from linetools import spectralline as ltsp
from linetools import line_utils as ltlu
from linetools.spectra import io as lsio
from linetools.spectra.xspectrum1d import XSpectrum1D<jupyter_output><empty_output><jupyter_text>Generate a line<jupyter_code>abslin = AbsLine(1548.195*u.AA)
abslin<jupyter_output>Loading abundances from Asplund2009
Abundances are relative by number on a logarithmic scale with H=12<jupyter_text>Data<jupyter_code>abslin.data<jupyter_output><empty_output><jupyter_text>As dict<jupyter_code>abslin = AbsLine(1548.195*u.AA)
tmp = abslin.to_dict()
tmp<jupyter_output><empty_output><jupyter_text>From dict<jupyter_code>tmp2 = SpectralLine.from_dict(tmp)
tmp2<jupyter_output><empty_output><jupyter_text>From old dict (using analy['vlim']) -- Backwards compatability<jupyter_code>tmp.pop('limits')
tmp['analy']['vlim'] = [-150,150]*u.km/u.s
tmp['attrib']['z'] = 0.5
tmp3 = SpectralLine.from_dict(tmp)<jupyter_output><empty_output><jupyter_text>List of AbsLines<jupyter_code>abslines = [abslin, AbsLine('HI 1215')]<jupyter_output><empty_output><jupyter_text>Parse<jupyter_code>wrest_values = ltlu.parse_speclines(abslines, 'wrest')
wrest_values<jupyter_output><empty_output><jupyter_text>Transition Table<jupyter_code>tbl = ltlu.transtable_from_speclines(abslines)
tbl<jupyter_output><empty_output><jupyter_text>Measure an EW<jupyter_code># Set spectrum
abslin.analy['spec'] = XSpectrum1D.from_file('../../linetools/spectra/tests/files/UM184_nF.fits')
# Set analysis range
abslin.limits.set([6080.78, 6087.82]*u.AA)  # wvlim
# Measure
abslin.measure_ew() # Observer frame
print('EW = {:g} with error {:g}'.format(abslin.attrib['EW'],abslin.attrib['sig_EW']))<jupyter_output>EW = 0.993502 Angstrom with error 0.0527114 Angstrom<jupyter_text>Measure AODM<jupyter_code>#
abslin.analy['spec'] = lsio.readspec('../../linetools/spectra/tests/files/UM184_nF.fits')
abslin.setz(2.92929)
abslin.limits.set((-150., 150.)*u.km/u.s)  # vlim
abslin.measure_aodm()
N, sigN, flgN = [abslin.attrib[key] for key in ['N','sig_N','flag_N']] 
print('logN = {:g}, siglogN = {:g}'.format(abslin.attrib['logN'], abslin.attrib['sig_logN']))<jupyter_output>logN = 13.9051, siglogN = 0.0207026<jupyter_text>Another Table<jupyter_code>tbl = ltlu.transtable_from_speclines(abslines)
tbl<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14079563182527302, 'fraction_numerical': 0.038611544461778474, 'mean_word_length': 8.903474903474903, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '414309', 'license': 'Apache-2.0', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1034, 'n_words': 148, 'path': 'data/notebooks/nb_200532.ipynb', 'repo_name': 'DavidRV00/notebook-analysis', 'size': '2564'}