Spectrum with line labels
Here we show how to use the line file “xout_lines1.fits” to add line labels to a spectral plot. For this example we resuse the output files calculated in example.
>>> import matplotlib.pyplot as plt
>>> from astropy.io import fits
>>> import numpy as np
>>>
>>> spec=fits.open('files/xout_spect1.fits')[2].data
>>> lines=fits.open('files/xout_lines1.fits')[2].data
>>>
>>> plt.plot(spec['energy'], spec['emit_outward'])
>>> plt.xscale("log")
>>> plt.yscale("log")
>>> plt.xlabel("Energy [eV]")
>>> plt.ylabel("Flux")
>>>
>>> emin=500. # in eV
>>> emax=800. # in eV
>>>
>>> plt.xlim(emin, emax)
>>> plt.ylim(1e9, 1e15)
>>> for ii in range(20):
>>>
>>> elin=12398./lines[ii][4] # A to eV
>>> if emin<elin<emax:
>>> plt.plot(elin, 2e13, '|', color='black')
>>> plt.text ( 12398./lines[ii][4], 5e13, lines[ii][1], rotation='vertical', horizontalalignment='center')
>>>
>>> plt.show()