Skip to content
Alex Deich edited this page Aug 20, 2015 · 23 revisions

As of this writing, ad_phat_tools.py (hereafter apt) has objects for:

  1. reddening and metallicity of raw data (apt.armpit)

  2. plotting tools (apt.armplot)

  3. a drawing tool used by apt.armplot (apt.region_draw)

  4. interpolation of a star's F336W, F475W, F814W magnitudes given mass, age, metallicity, and extinction (apt.ArtificialInterpolatedMagnitudes)

  5. simulation class (apt.StellarPopulationSimulator) which uses apt.ArtificialInterpolatedMagnitudes to simulate stellar populations

#armpit

Andromeda Reddening and Metallicity from Padova Isochrone Tracks (ARMPIT) takes as input a FITS table file (or simulation object, more on that below) and has methods for determining the reddening and metallicity of the stars in the input.

If you don't care about the machinery of the method, here's how to do a full analysis of some data set:

##Example:

given data set 'phat_data.fits'

import ad_phat_tools as apt
armpit01 = apt.armpit('phat_data.fits',4) # the two arguments are filename and
                                        # isochrone age to be fitted to
armpit01.write_data()

The last line will output a CSV file with columns for input colors, dereddened colors, metallicity (given as Z), A(F475W), as well as RA and DEC.

armplot and skyselect

The armplot object and skyselect method are for viewing and interacting with data produced by armpit. The primary feature allows the user to draw arbitrary regions on a spatial map of the data and to recover statistics about these regions.

##Example:

import ad_phat_tools as apt

apt_data = apt.armpit('phat_data.fits',4)

apt_data_plot = apt.armplot(apt_data)

apt_data_plot.skyselect()

This will bring up a plot of the PHAT data in RA,DEC: spatial phat map

You can then click with the right mouse button to select arbitrary regions of data. Then, by pressing any of the bound keys, you can create plots of the regions. The bound keys and their associated plots are

1: Color-magnitude diagram

2: Color-color diagram

3: Cumulative histogram of metallicity

4: Cumulative histogram of Av

Pressing ctrl in addition to any one of these keys saves the associated plot out to a nice PDF.

selected regions and their plots

There are other helpful keys:

w: save the current set of regions as a pickle object. The next time you want these exact regions, invoke the skyselect tool with the argument apt_data_plot.skyselect(point_list='<PICKLE_FILENAME>')

c: clear all plots. Clears the spatial plot of any lines drawn on it

a/ctrl+a: draw/save all plots.

This module is the one that undergoes the most change.

ArtificialInterpolatedMagnitudes

This object returns the magnitude of a simulated star that is created by interpolating between different isochrones. Inputs are mass, age, metallicity and extinction, and outputs are magnitudes in the HST wide-field filters F336W,F475W, and F814W.

It requires a directory of Padova isochrones in FITS format, whose downloading and conversion can be automated with the IsochroneDownloader.py script available in this repo. Note that IsochroneDownloader.py requires the stilts package for converting the .dat files into .fits.

ArtificialInterpolatedMagnitudes then grabs the two which closest approximate the requested age, interpolates them in mass-metallicity space to determine magnitude, and finally takes a weighted average of the two derived values. I have tried to make this as generic as possible, so there are no restrictions on what the isochrone files be named. Neither are there restrictions on the age gap of each isochrone. All that's required is that there is one directory of isochrones which need only have columns for F336W, F475W, and F814W filters, and a column for age, in units of log(age/yr)

Any attempt to do a 4D interpolation invariably crashed scipy's LinearNDInterpolator. So instead I interpolate on-the-fly, which adds about 10 seconds every time a new interpolation is needed. However, each new interpolation is stored in a dictionary, so you only need to do it once. I tried pickling the full dictionary, and that always resulted in a pickle object on the order of 15GB, so on-the-fly interpolation it is.

##Example: > import ad_phat_tools as apt

> artificial_star = apt.ArtificialInterpolatedMagnitudes()

> artificial_star(age=5.24,mass=2.15,z_value=0.005,av=0)

> Magnitude in F336W: 1.07562730094
  Magnitude in F475W: 1.56553468202
  Magnitude in F814W: 1.6903108969

StellarPopulationSimulator

This uses apt.ArtificialInterpolatedMagnitudes to simulate stellar populations to a given set of inputs, which can be any combination of mass, metallicity, age, and Av. The output is a FITS file.

##Usage: apt.StellarPopulationSimulator(numstars,ages='all',z_values='all',masses='all',av='none',rv=3.1,output_file='',fits_comments='')

Input parameters:

numstars: The number of stars to be simulated, int.

ages: The age range to be simulated. Either int, all or numpy array specifying the age for each specific star. In the latter case, the length of the array must be equal to numstars.

z_values: The metallicity range to be simulated. Either int, all or numpy array specifying the metallicity for each specific star. In the latter case, the length of the array must be equal to numstars.

masses: The mass range to be simulated. Either int, all or numpy array specifying the mass for each specific star. In the latter case, the length of the array must be equal to numstars.

av: The Av to be added to the simulated magnitudes. Either int, none or numpy array specifying the Av for each specific star. In the latter case, the length of the array must be equal to numstars.

output_file: The name of the FITS output file. If left blank, the name is given by the naming convention sim_out_*numstars*_*month*_*day*.fits. str

fits_comments: Comments to go in the primary header of the FITS file. str

rv: Rv value. Options are 3.1 and 5. float

Output:

A FITS table file. The header contains four extra rows:

'IS_SIM': Used to tell apt.armpit that the input file is a simulation

'FREEPRMS': Lists which of mass, age, and metallicity, if any, are free parameters.

'RV_VALUE': Which Rv value was used to extinct the data if Av is included in the simulation

'COMMENTS': The value of the fits_comments input parameter

Columns: In order to make this output work nicely with the rest of ad_phat_tools, some extraneous columns are added to the output which make it look like PHAT data. RA,DEC: Obviously not real; these are added for the reason stated above. RA and DEC are instead used as index columns. RA = DEC = index.

MASS: Input mass

Z: Input metallicity

AGE: Input age

<filter>_NAKED, <filter>_VEGA: Each filter interpolated, F336W, F475W, and F814W, has two columns, NAKED and VEGA. These are only different if Av is included in the simulation, in which case <filter>_NAKED is the isochrone interpolated magnitude and <filter>_VEGA is the extincted magnitude. In the case that no extinction is added, both columns are the same.

<filter>_ERR: Dummy column to make it look like PHAT data. Meaningless