def test_available_transitions(): error_msg = 'Something is wrong in available_transitions()' ism = LineList('ISM') wvlims = (900,1800)*u.AA z = 0.1 transitions = ism.available_transitions(wvlims/(1+z),n_max_tuple=5) assert transitions[2]['name'] == 'HI 972' , error_msg assert isinstance(transitions,Table), error_msg transitions = ism.available_transitions(wvlims/(1+z),n_max_tuple=2) assert transitions[2]['name'] == 'CIII 977' , error_msg wvlims = (1200,1800)*u.AA z = 0.5 transitions = ism.available_transitions(wvlims/(1+z), n_max_tuple=2) assert transitions[0]['name'] == 'HI 1025', error_msg assert 'OVI 1031' in transitions['name'], error_msg assert 'CIII 977' in transitions['name'], error_msg wvlims = (1000,3000)*u.AA z = 1.5 transitions = ism.available_transitions(wvlims/(1+z),n_max_tuple=2) assert 'NeVIII 770' in transitions['name'], error_msg assert 'MgX 609' in transitions['name'], error_msg assert 'HI 1215' not in transitions['name'], error_msg wvlims = (1215.6,1217)*u.AA z = 0 transitions = ism.available_transitions(wvlims/(1+z),n_max_tuple=2) assert isinstance(transitions,dict), error_msg
def test_available_transitions(): error_msg = 'Something is wrong in available_transitions()' ism = LineList('ISM') wvlims = (900,1800)*u.AA z = 0.1 transitions = ism.available_transitions(wvlims/(1+z),n_max_tuple=5) assert transitions[2]['name'] == 'HI 972' , error_msg assert isinstance(transitions,QTable), error_msg transitions = ism.available_transitions(wvlims/(1+z),n_max_tuple=2) assert transitions[2]['name'] == 'CIII 977' , error_msg wvlims = (1200,1800)*u.AA z = 0.5 transitions = ism.available_transitions(wvlims/(1+z), n_max_tuple=2) assert transitions[0]['name'] == 'HI 1025', error_msg assert 'OVI 1031' in transitions['name'], error_msg assert 'CIII 977' in transitions['name'], error_msg wvlims = (1000,3000)*u.AA z = 1.5 transitions = ism.available_transitions(wvlims/(1+z),n_max_tuple=2) assert 'NeVIII 770' in transitions['name'], error_msg assert 'MgX 609' in transitions['name'], error_msg assert 'HI 1215' not in transitions['name'], error_msg wvlims = (1215.6,1217)*u.AA z = 0 transitions = ism.available_transitions(wvlims/(1+z),n_max_tuple=2) assert isinstance(transitions,dict), error_msg
def measure_sodium_EW(filename): from linetools.lists.linelist import LineList from astropy import units as u from linetools.spectralline import AbsLine from linetools.spectra.xspectrum1d import XSpectrum1D import matplotlib.pyplot as plt sp = XSpectrum1D.from_file('RF_' + filename) sp.normalize(co=sp.co) wvlim = [5880, 6030] * u.AA strong = LineList('Strong') transitions = strong.available_transitions(wvlim, n_max_tuple=None, min_strength=0.0) line1 = transitions['wrest'][0] line2 = transitions['wrest'][1] avg_line = (line1 + line2) / 2.0 # Plot the spectrum to get limits for EW fig = plt.figure() plt.axvline(x=line1, color='k', linestyle='--') plt.axhline(y=1.0, color='r', linestyle='--') plt.axvline(x=line2, color='k', linestyle='--') sp.plot(xlim=(avg_line - 30, avg_line + 30)) S1 = AbsLine(transitions['wrest'][0] * u.AA, z=0.0) S1.analy['spec'] = sp S2 = AbsLine(transitions['wrest'][1] * u.AA, z=0.0) S2.analy['spec'] = sp #x = float(input("Enter a lower lim: ")) #y = float(input("Enter a higher lim: ")) x = 5888 y = 5896 S1.limits.set([x, y] * u.AA) S1.measure_ew(flg=1) # Measure the EW of the first line EW1 = S1.attrib['EW'], S1.attrib['sig_EW'] #x = float(input("Enter a lower lim: ")) #y = float(input("Enter a higher lim: ")) x = 5895 y = 5905 S2.limits.set([x, y] * u.AA) S2.measure_ew() # Measure the EW of the second line EW2 = S2.attrib['EW'], S2.attrib['sig_EW'] return EW1, EW2
targ_coord[1] == prop['DEC']) data = prop[w] radec = SkyCoord(targ_coord[0] + ':00', targ_coord[1] + ':00', unit=(u.hourangle, u.deg)) # Get the expected sodium transition wavelengths from the target properties line = data['Sod_line'] #Define the wavelength range to search for redshifted Sodium lines wvlim = [line - 30.0, line + 30.0] * u.AA strong = LineList('Strong') #Search for lines transitions = strong.available_transitions(wvlim / (1 + data['z']), n_max_tuple=None, min_strength=0.0) # Transform lines to the redshifted wavelength line1 = transitions['wrest'][0] * (1 + data['z']) line2 = transitions['wrest'][1] * (1 + data['z']) # plot the figure fig = plt.figure() fig.suptitle(name[42:-5] + ' z=' + str(data['z'])) plt.axvline(x=line1, color='k', linestyle='--') plt.axvline(x=line2, color='k', linestyle='--') sp.plot(xlim=(line - 30, line + 30)) fig.savefig(name + '.pdf') # Save a copy of the figure sp.fit_continuum(kind='QSO', redshift=data['zq'])