Package: astroARIADNE
ARIADNE (spectrAl eneRgy dIstribution bAyesian moDel averagiNg fittEr)Characterize stellar atmospheres easily!ARIADNEIs a code written in python 3.7+ designed to fit broadband
photometry to different stellar atmosphere models automatically using Nested
Sampling algorithms.InstallationYou can installARIADNEwithpip install astroARIADNEOtherwise you can clone this repository withgit clone https://github.com/jvines/astroARIADNE.git
cd astroARIADNEAnd then runpython setupy.py installBut for the code to work, first you must install the necessary dependencies.Dependencies:Numpy (https://numpy.org/)Scipy (https://www.scipy.org/)Pandas (https://pandas.pydata.org/)numba (http://numba.pydata.org/)astropy (https://astropy.readthedocs.io/en/stable/)astroquery (https://astroquery.readthedocs.io/en/latest/)regions (https://astropy-regions.readthedocs.io/en/latest/index.html)PyAstronomy (https://pyastronomy.readthedocs.io/en/latest/)corner (https://corner.readthedocs.io/en/latest/)tqdm (https://tqdm.github.io/)matplotlib (https://matplotlib.org/)termcolor (https://pypi.org/project/termcolor/)extinction (https://extinction.readthedocs.io/en/latest/)pyphot (http://mfouesneau.github.io/docs/pyphot/)dustmaps (https://dustmaps.readthedocs.io/en/latest/)PyMultinest (https://johannesbuchner.github.io/PyMultiNest/) [OPTIONAL]dynesty (https://dynesty.readthedocs.io/en/latest/)isochrones (https://isochrones.readthedocs.io/en/latest/)PyMultinest is an optional package and can be hard to install! If you're
planning on doing BMA only then you can skip installing it!!Most can be easily installed with pip or conda but some might have special
instructions (like PyMultinest!!)ARIADNEhas been tested on OS X up to Catalina and Linux. It doesNOTrun on Windows because healpy, a dependency of dustmaps isn't available for
Windows (seehttps://github.com/healpy/healpy/issues/25#issue-2987102)In order to plot the models, you have to download them first:But note that plotting the SED model is optional. You can run the code without
them!ModelLinkPhoenix v2ftp://phoenix.astro.physik.uni-goettingen.de/HiResFITS/PHOENIX-ACES-AGSS-COND-2011/Phoenix v2   wavelength fileftp://phoenix.astro.physik.uni-goettingen.de/HiResFITS/WAVE_PHOENIX-ACES-AGSS-COND-2011.fitsBT-Modelshttp://osubdd.ens-lyon.fr/phoenix/Castelli & Kuruczhttp://ssb.stsci.edu/cdbs/tarfiles/synphot3.tar.gzKurucz 1993http://ssb.stsci.edu/cdbs/tarfiles/synphot4.tar.gzThe wavelength file for the Phoenix model has to be placed in the root folder
of the PHOENIXv2 models.For the code to find these models, you have to place them somewhere in your
computer as follows:Models_Dir  
│
└───BTCond
│   │
│   └───CIFIST2011
│   
└───BTNextGen
│	 │
│	 └───AGSS2009
│
└───BTSettl
│	 │
│	 └───AGSS2009
│
└───Castelli_Kurucz
│	 │
│	 └───ckm05
│	 │
│	 └───ckm10
│	 │
│	 └───ckm15
│	 │
│	 └───ckm20
│	 │
│	 └───ckm25
│	 │
│	 └───ckp00
│	 │
│	 └───ckp02
│	 │
│	 └───ckp05
│
└───Kurucz
│	 │
│	 └───km01
│	 │
│	 └───km02
│	 │
│	 └───km03
│	 │
│	 └───km05
│	 │
│	 └───km10
│	 │
│	 └───km15
│	 │
│	 └───km20
│	 │
│	 └───km25
│	 │
│	 └───kp00
│	 │
│	 └───kp01
│	 │
│	 └───kp02
│	 │
│	 └───kp03
│	 │
│	 └───kp05
│	 │
│	 └───kp10
│
└───PHOENIXv2
	 │
     └─── WAVE_PHOENIX-ACES-AGSS-COND-2011.fits
	 └───Z-0.0
	 │
	 └───Z-0.5
	 │
	 └───Z-1.0
	 │
	 └───Z-1.5
	 │
	 └───Z-2.0
	 │
	 └───Z+0.5
	 │
	 └───Z+1.0Notes:The Phoenix v2 models with alpha enhancements are unusedBT-models are BT-Settl, BT-Cond, and BT-NextGenHow to use?Stellar information setupTo useARIADNEstart by setting up the stellar information, this is done by
importing the Star module.fromastroARIADNE.starimportStarAfter importing, a star has to be defined.Stars are defined inARIADNEby their RA and DEC in degrees, a name, and
optionally the Gaia DR3 source id, for example:ra=75.795dec=-30.399starname='NGTS-6'gaia_id=4875693023844840448s=Star(starname,ra,dec,g_id=gaia_id)The starname is used purely for user identification later on, and thegaia_idis provided to make sure the automatic photometry retrieval collects
the correct magnitudes, otherwiseARIADNEwill try and get thegaia_idby
itself using a cone search centered around the RA and DEC.Executing the previous block will start the photometry and stellar parameter
retrieval routine.ARIADNEwill query Gaia DR2 for an estimate on the
temperature, radius, parallax and luminosity for display as preliminar
information, as it's not used during the fit, and prints them along with its
TIC, KIC IDs if any of those exist, its Gaia DR3 ID, and maximum line-of-sight
extinction Av:Gaia DR2 ID : 4875693023844840448
			TIC : 1528696
			Effective temperature : 4975.000 +/- 104.390
			Stellar radius : 0.656 +/- 0.141
			Stellar Luminosity : 0.238 +/- 0.003
			Parallax : 3.297 +/- 0.036
			Maximum Av : 0.030If you already know any of those values, you can override the search for them by
providing them in the Star constructor with their respective uncerainties.
Likewise if you already have the magnitudes and wish to override the on-line
search, you can provide a dictionary where the keys are the filters and values
are the mag, mag_err tuples.If you want to check the retrieved magnitudes you can call theprint_magsmethod from Star:s.print_mags()This will print the filters used, magnitudes and uncertainties. For NGTS-6 this
would look like this:Filter     	Magnitude	Uncertainty
		----------------	---------	-----------
		    2MASS_H     	 11.7670 	  0.0380
		    2MASS_J     	 12.2220 	  0.0330
		    2MASS_Ks    	 11.6500 	  0.0320
		GROUND_JOHNSON_V	 14.0870 	  0.0210
		GROUND_JOHNSON_B	 15.1710 	  0.0140
		  GaiaDR2v2_G   	 13.8175 	  0.0006
		  GaiaDR2v2_RP  	 13.1127 	  0.0015
		  GaiaDR2v2_BP  	 14.4012 	  0.0027
		     SDSS_g     	 14.6390 	  0.0580
		     SDSS_i     	 13.3780 	  0.0570
		     SDSS_r     	 13.7030 	  0.0320
		  WISE_RSR_W1   	 11.5550 	  0.0270
		  WISE_RSR_W2   	 11.6360 	  0.0270
		   GALEX_NUV    	 21.9520 	  0.4090
		      TESS      	 13.1686 	  0.0062Note:ARIADNEautomatically prints and saves the used magnitudes and
filters to a file.The way the photometry retrieval works is that Gaia DR2 crossmatch catalogs are
queried for the Gaia ID, these crossmatch catalogs exist for ALL-WISE, APASS,
Pan-STARRS1, SDSS, 2MASS and Tycho-2, so finding photometry relies on these
crossmatches. In the case of NGTS-6, there are also Pan-STARRS1 photometry whichARIADNEcouldn't find due to the Pan-STARRS1 source not being identified in
the Gaia DR2 crossmatch, in this case if you wanted to add that photometry
manually, you can do so by using theadd_magmethod from Star, for example, if
you wanted to add the PS1_r mag to ourStarobject you would do:s.add_mag(13.751,0.032,'PS1_r')If for whatever reasonARIADNEfound a bad photometry point and you needed
to remove it, you can invoke theremove_magmethod. For example you wanted
to remove the TESS magnitude due to it being from a blended source, you can just
runs.remove_mag('NGTS')A list of allowed filters can be foundhereInterstellar extinctionARIADNEhas an incorporated prior for the interstellar extinction in the
Visual band, $A_{\rm V}$ which consists of a uniform prior between 0 and the
maximum line-of-sight value provided by theSFD dust maps.
This, however, can be changed either by a custom prior (see Fitter setup) or by
changing the dustmap used. We provide following dustmaps:SFD (2011)Planck Collaboration (2013)Planck Collaboration (2016; GNILC)Lenz, Hensley & Doré (2017)Bayestar (2019)These maps are all implemented through thedustmapspackage and
need to be downloaded. Instructions to download the dustmaps can be found in
its documentation.To change the dustmap you need to provide thedustmapparameter to theStarconstructor, for example:ra=75.795dec=-30.399starname='NGTS-6'gaia_id=4875693023844840448s=Star(starname,ra,dec,g_id=gaia_id,dustmap='Bayestar')This concludes the stellar setup and now we're ready to set up the parameters
for the fitting routine.Fitter setupIn this section we'll detail how to set up the fitter for the Bayesian Model
Averaging (BMA) mode ofARIADNE. For single models the procedure is very
similar.First, import the fitter fromARIADNEfromastroARIADNE.fitterimportFitterThere are several configuration parameters we have to setup, the first one is
the output folder where we wantARIADNEto output the fitting files and
results, next we have to select the fitting engine (for BMA only dynesty is
supported), number of live points to use, evidence tolerance threshold, and the
following only apply for dynesty: bounding method, sampling method, threads,
dynamic nested sampler. After selecting all of those, we need to select the
models we want to use and finally, we feed them all to the fitter:out_folder='your folder here'engine='dynesty'nlive=500dlogz=0.5bound='multi'sample='rwalk'threads=4dynamic=Falsesetup=[engine,nlive,dlogz,bound,sample,threads,dynamic]# Feel free to uncomment any unneeded/unwanted modelsmodels=['phoenix','btsettl','btnextgen','btcond','kurucz','ck04']f=Fitter()f.star=sf.setup=setupf.av_law='fitzpatrick'f.out_folder=out_folderf.bma=Truef.models=modelsf.n_samples=100000Note:While you can always select all 6 models,ARIADNEhas an internal
filter put in place in order to avoid having the user unintentionally bias the
results. For stars with Teff > 4000 K BT-Settl, BT-NextGen and BT-Cond are
identical and thus only BT-Settl is used, even if the three are selected. On the
other hand, Kurucz and Castelli & Kurucz are known to work poorly on stars with
Teff < 4000 K, thus they aren't used in that regime.We allow the use of four different extinction laws:fitzpatrickcardelliodonnellcalzettiThe next step is setting up the priors to use:f.prior_setup={'teff':('default'),'logg':('default'),'z':('default'),'dist':('default'),'rad':('default'),'Av':('default')}A quick explanation on the priors:The default prior for Teff is an empirical prior drawn from the RAVE survey
temperatures distribution, the distance prior is drawn from theBailer-Jonesdistance estimate from Gaia EDR3, and the radius has a flat prior ranging from
0.5 to 20 R$_\odot$. The default prior for the metallicityzand log g are
also their respective distributions from the RAVE survey, the default prior for
Av is a flat prior that ranges from 0 to the maximum of line-of-sight as per the
SFD map, finally the excess noise parameters all have gaussian priors centered
around their respective uncertainties.We offer customization on the priors as well, those are listed in the following
table.PriorHyperparametersFixedvalueNormalmean, stdTruncNormmean, std, lower_lim, uppern_limUniformini, endRAVE (log g only)---Default---So if you knew (from a spectroscopic analysis, for example) that the effective
temperature is 5600 +/- 100 and the metallicity is [Fe/H] = 0.09 +/- 0.05 and
you wanted to use them as priors, and the star is nearby (< 70 pc), so you
wanted to fix Av to 0, your prior dictionary should look like this:f.prior_setup={'teff':('normal',5600,100),'logg':('default'),'z':('normal',0.09,0.05),'dist':('default'),'rad':('default'),'Av':('fixed',0)}After having set up everything we can finally initialize the fitter and start
fittingf.initialize()f.fit_bma()Now we wait for our results!VisualizationAfter the fitting has finished, we need to visualize our results.ARIADNEincludes a plotter object to do just that! We first star by importing the
plotter:fromastroARIADNE.plotterimportSEDPlotterThe setup for the plotter is already made for you, but if you really want to
change them, instructions on how to change it can be foundhereBefore we plot the SEDs we need to tellARIADNEwhere to find our models.
This step isn't necessary if you don't want or need SED plots and are happy with
the HR diagram, histograms, cornerplot and RAW SED. This is done with an
environmental variable called ARIADNE_MODELS, to set it up you just need to runexport ARIADNE_MODELS='/path/to/Models_Dir/'in your terminal. You can also
add that instruction to your.bash_profileor.bashrcand the runsource ~/.bash_profileso you don't have to export everytime.Now thatARIADNEknows where to find the models we only need to specify
the results file location and the output folder for the plots!in_file=out_folder+'BMA_out.pkl'plots_out_folder='your plots folder here'Now we instantiate the plotter and call the desired plotting methods!
We offer 5 different plots:A RAW SED plotA SED plot with the model and synthetic photometryA corner plotAn HR diagram taken from MIST isochronesHistograms showing the parameter distributions for each model.artist=SEDPlotter(in_file,plots_out_folder)artist.plot_SED_no_model()artist.plot_SED()artist.plot_bma_hist()artist.plot_bma_HR(10)artist.plot_corner()The number given toplot_bma_HRis the number of extra tracks you want to
plot, drawn randomly from the posterior distribution.If you're iterating through lots of stars you can call the SEDPlottercleanmethod to clear opened figures withartist.clean()If you don't have the models in your computer, then theplot_SEDmethod will
fail, as it needs the complete model grid.An example usage file is provided in the repository calledtest_bma.pyfor the
BMA approach and test.py for single model fitting.OUTPUT FILESAfterARIADNEhas finished running, it will output a series of files and
plots showing the results of the fit and other information.The most important file is thebest_fit.datwhich contains the best fiting
parameters with the 1 sigma error bars and the 3 sigma confidence interval.
Then there are pickle files for each of the used models plus a last one for the
BMA, these contain raw information about the results. There is aprior.datfile that shows the priors used and amags.datfile with the used magnitudes
and filters.Another important output are the plots. Inside the plots folder you can findCORNER.png/pdfwith the cornerplot (the plot showing the distribution of the
parameters agains eachother),HR_diagram.png/pdfonly for the BMA, with the HR
diagram showing the position of the star,SED_no_model.png/pdfwith the RAW
SED showing each photometry point color coded to their respective filter, andSED.png/pdfwith the SED with the catalog photometry plus synthetic
photometry. If BMA was done, there's also ahistogramsfolder inside the plot
folder with various histograms of the fitted parameters and their distribution
per model, highlighting the benefits of BMA.Examples of those figures:Infrared ExcessAs of version 1.0,ARIADNEnow allows for Infrared Excess visualization!To visualize infrared excess you just need to add the relevant photometric
observations to theStarobject with theadd_mag()method. After the fitting
is done, you then need to initiate thePlotterobject with their_excessparameter set toTrue:artist=SEDPlotter(in_file,plots_out_folder,pdf=True,ir_excess=True)Finally after plotting, you should get an SED figure with your manually added
photometry!Allowed filters for infrared excess plots areWISE W3, WISE W4, HERSCHEL PACS
BLUE, GREEN and RED, names for these filters can be found in thefilters page.Citing ARIADNEFor a more in depth look on the inner workings ofARIADNEconsiderreading the paper!Additionally, you can find how to citeARIADNEand its dependencieshere