A python code to determine the quenched star formation history parameters of a galaxy using the MCMC algorithm emcee (http://dan.iel.fm/emcee/current/). Please ensure this module is installed and can be imported into your Python installation.
The sample function implements the emcee EnsembleSampler function for the galaxy colours input. Burn-in is run and calculated for the length specified before the sampler is reset and then run for the length of steps specified.
u_r : Observed u-r colour of a galaxy; k-corrected. Single value.
err_u_r : Error on the observed u-r colour of a galaxy. Single value.
nuv_u : Observed nuv-u colour of a galaxy; k-corrected. Single value.
err_nuv_u : Error on the observed nuv-u colour of a galaxy. Single value.
z : Observed redshfit of a galaxy. Single value.
dr8 : Sloan ID DR8 number - can be any identification number for a galaxy.
ra : Right ascension of galaxy in degrees. Used for identification.
dec : Declination of galaxy in degrees. Used for identification.
s : Array of shape (nsteps * nwalkers, 2) containing the positions of the walkers at all steps for all 4 parameters.
fig : s plotted as contours and integrated over to a each one dimensional histogram with median values and 1sigma values either side. The triangle.py module is necessary to produce these plots and is provided in the starfpy repository. It can also be downloaded here: https://github.com/dfm/triangle.py or with pip install triangle_plot at the command line.
Running the code
Data inputs occur with the starfpy.py file, all necessary functions are in the posterior.py file. The code can be run as follows:
python starpy.py u_r, err_u_r, nuv_u, err_nuv_u, z, dr8, ra, dec
python starpy.py 2.2564125061 0.0635264205263 1.66131782532 0.12668874395 0.033525165 1237661968496984320 163.734802246 41.4984283447
Returns the 50th percentile of the walker positions from emcee for the quenched star formation history parameters [t, tau] as:
Best fit [t, tau] values found by starpy for input parameters are : [9.3231936694250255, 1.287285042079878]
if using the look up tables provided in the repository.
The posterior function gives you the option of using either the look up tables provided (
ur_look_up_ssfr.npy), a look up table which you have created for NUV-u and u-r or using the SPS model you specify to calculate the colour from an SED each time a new [tq, tau] value is generated by the MCMC chain.
The u-r and NUV-u look up tables provided were generated for 50 observed ages, 100 tau and 100 quenching time values for an exponential quenching SFH model using the expsfh function in posterior.py. Using these look up tables or ones generated by the user will ensure run time is ~3 minutes for one galaxy as opposed to ~3 hours.
You can generate your own look up table in two colours with lookup.py bu specifying an SPS model (again takes a LONG time).
If you wish to specify an SPS model it must be in a readable format for
starpy. You can therefore extract the either the BC03 or M05 SPS models into ASCII files with the
extract_m05.py files which use the raw files as downloaded from http://www2.iap.fr/users/charlot/bc2003/ or http://www-astro.physics.ox.ac.uk/~maraston/Claudia%27s_Stellar_Population_Models.html respectively.
If you use this code in your research please cite this paper: Smethurst et al. 2015, MNRAS, 450, 435 and acknowledge:
"This work has made use of the StarPy star formation history Python code described in Smethurst et al. (2015)."