Codes to calculate Temperature [K] and Density [particle/cm^3] from the lines ratio of certain ions in the narrow line region of a given AGN.
The python script takes the values for Einstein Coefficients, collision strength, and statistical weights from Osterbrock, 2006. The script is based on the one written by de Robertis, Dufour, & Hunt (fivel.f). The paper explaining the fivel program can be found at Journal of the Royal Astronomical Society of Canada. The script can also be taken from this repository.
- lmfit, Non-Linear Least-Squares Minimization and Curve-Fitting for Python
- astropy, To read FITS files
- scipy and numpy, Scientific computing packages
- matplotlib, The Python plotting library
- agn, For graphics and show graphics (must be ran within the same path - in Development)
If the program is called as a python module, the calling proccedure is like:
import agn
name = 'data/spec-1070-52591-0072.fits' #Example of .fits data
z = 0.00420765 #Redshift related to name fits
T, Ne = agn.calculation(name,z=z)
#or
T, Ne = calculation(name,z=z,ion1='OIII',ion2='SII')
#or if the user do not want the iteration proccess
T, Ne = calculation(name,z=z,ion1='OIII',ion2='SII',iteration=False)
print(" Temperature {}\n Density {}".format(T,Ne))
Here the user will be ased for the ions to make the calculations if they are not specified. Svailable ions are (O[III] or N[II]) and (S[II] or O[II]) (see Ions example below). It returns T and Ne, the temperature and particle density in [K] and [particle/cm^3] respectively, of the narrow line region from an AGN.
Note: As the lines_ratio
uses gaussian.py
and fivel.py
programs (both on this tree), for the moment the three programs must to be on the same folder.
-
name:
Name of the .fits file. The file should be obtained from the Sloan Digital Sky Survey (SDSS) Catalogue. In the catalogue, the user will provide either the Plate, MJD and FiberID, or the coordinates of the AGN. -
z Redshift. Necessary to center each emission line on the plots
-
ion1 ion2 (default=
None
)
Ions in which the calculations will be performed. If not set, then the user will be asked for the available ions to begin with. Svailable ions are: O[III] or N[II] for -like ions and S[II] or O[II] for -like ions. More ions will be added. -
statistics (default=
False
)
If set toTrue
, then it will display on the screen some information of the region of calculation, like the maximum and minimum values of wavelenght and fluxes, the Equivalent Width (as of URL) and area under the flux given by the Trapezoid and Simpson methods. -
header (default=
False
)
IfTrue
, the program will look for a Header-like structure to find per se the wavelenghts (in Development). -
plot (defalut=
True
)
Shows the gaussian fit and gaussian function in which the integral will be made, as well as the area result. -
savefig (default=
False
)
IfTrue
, it will save all the gaussian fits done on the program. -
show_model (default=
False
)
IsTrue
, it will display the residuals, gaussian fit, area and best fit. In this scope, every time the user selects the two points of interest (of integration), a new window will appear on the screen. In order to close it and pass the next figure, the user will have to first clic on the graph (so the window will disappear) and then close the graph. (in Development) -
iteration (dafalut=
True
)
Shows the iterations done by theagn.fivel
class. -
plot_spectrum (default=
False
)
Plots the initial spectrum
There are two equations used to make the calculations, from -like ions and -like ions
-
The equation for the ion O[III] is:
While the equation for the ion N[II] is:
-
The equation for the ion S[II] is:
And for the O[II] ion is: