Handling isochrones : the Isochrones module¶
The Isochrones
module provide tools to handle isochrones libraries and turn them
into stellar fluxes or stellar magnitudes in different filters.
Currently Isochrones
uses isochrones from the
MIST
from the
CMD
projects and BastI
isochrones.
MIST isochrones¶
MIST
isochrones come as a set of files in a directory.
To download the MIST
databases for a given filter set,
move to workspace/Isochrones/MIST
in the pNbody
distribution. Informations are provided in a README
file.
Isochrones can be displayed with the isochrones_plot
command (see Isochrones Scripts for mode
details), for example:
isochrones_plot -d MIST_v1.2_vvcrit0.0_UBVRIplus --Age 13000 --x log_Teff --y 'log_L' --invertx
where MIST_v1.2_vvcrit0.0_UBVRIplus
is a MIST
directory.
The list of keys stored in the database can be obtained from the --info
option:
isochrones_plot -d MIST_v1.2_vvcrit0.0_UBVRIplus --info
BastI isochrones¶
BastI
isochrones come as a set of files in a directory. To download the BastI
databases for a given filter set,
move to workspace/Isochrones/BastI
in the pNbody
distribution. Informations are provided in a README
file.
Once the database (directory) is downloaded, isochrones can be displayed with the
isochrones_plot
command (see Isochrones Scripts for mode
details), for example:
isochrones_plot -d P04O1D1E1Y247 --Age 13000 --x G_BP-G_RP --y G --inverty --xmin -1 --xmax 3 --ymin -5 --ymax 13 --MH -2
where P04O1D1E1Y247
is a BastI
directory.
The list of available BastI
isochrones:
name |
description |
release |
---|---|---|
P00O1D1E1Y247 |
Scaled solar models & transformations |
GAIA-DR3 |
P04O1D1E1Y247 |
Alpha-enhanced=+0.4 models & transformations |
GAIA-DR3 |
P04O1D1E1Y275 |
Alpha-enhanced=+0.4 models & transformations |
GAIA-DR3 |
P04O1D1E1Y300 |
Alpha-enhanced=+0.4 models & transformations |
GAIA-DR3 |
P04O1D1E1Y320 |
Alpha-enhanced=+0.4 models & transformations |
GAIA-DR3 |
CMD isochrones¶
CMD
isochrones are stored in one single file.
To download the CMD
file, move to workspace/Isochrones/CMD
in the pNbody
distribution.
Informations are provided in a README
file.
Isochrones can be displayed with the isochrones_plot
command (see Isochrones Scripts for mode
details), by directly pointing towards the CMD file, for example:
isochrones_plot -f CMD_Euclid.dat --Age 13000 --x Bluemag-Redmag --y VISmag --inverty
Retrieving info from the Isochrones database¶
Computing magnitudes¶
The following lines provides an example how to get
from pNbody import Isochrones
# load the database
DB = Isochrones.Isochrones(dirname="P04O1D1E1Y247")
# get the keys
keys = DB.getKeys().keys()
# check that one specific key exists
DB.checkKeyExists("G")
# define an age (in Myr)
age = 13000
# define a metallicity (log10(M/H))
mh = -2
# define a star mass (in solar mass)
mass = 0.65
# get the maximal stellar mass (in solar mass) for a given age and metallicity
DB.getMaxStellarMass(age,mh)
# get the corresponding magnitude in a given filter
DB.get(age,mh,1,key="G")
Generate a SSP magnitude grid¶
As it allows to retrieve a magnitude for a given stellar mass, a given age and a given
metalliity, the Isochrones
module can be use to create magnitudes lookup tables for a
given single stellar population, i.e., a given age an metallicity, assuming some IMF.
Such table is created with the isochrones_generate_magnitudes_grid
command, for example (see Isochrones Scripts for mode
details):
isochrones_generate_magnitudes_grid --rebinAges --M0 1e6 --filter_key VIS -d P04O1D1E1Y247_euclid -o Euclid_VIS_BastI_1e6.hdf5
or:
isochrones_generate_magnitudes_grid --rebinAges --M0 1e6 --filter_key VISmag -o EuclidVISmag_CMD_1e6.pkl CMD_Euclid.dat
By default the script uses a Kroupa IMF which is hardcoded in the script. It is possible to change the IMF by providing a file
(using the --imf
parameter) containing for example:
params = {}
params["Mmax"] = 50.
params["Mmin"] = 0.05
params["as"] = [0.7,-0.8,-1.7,-1.3]
params["ms"] = [0.08,0.5,1.0]
where as
is the slope of the IMF in the mass intervals ms
given is solar masses:
The output of isochrones_generate_magnitudes_grid
is either a python pickle file or an hdf5 file which contains a 2D magnitude table and two vectors providing the binning in age and metallicity. Ages are provided in Myrs.
The pickle file can be read as:
import pickle
f = open(filename,"rb")
Mags = pickle.load(f)
binsAge = pickle.load(f)
binsMH = pickle.load(f)
f.close()
The script isochrones_plot_magnitudes_grid
(see Isochrones Scripts for mode details)
allows to plot the previously generated magnitudes grid:
isochrones_plot_magnitudes_grid EuclidVISmag_CMD_1e6.pkl
The info on the content of the hdf5 files can be obtained with:
isochrones_ssp_grid_info Euclid_VIS_BastI_1e6.hdf5
Check the content of isochrones_ssp_grid_info
to see how to read this file format.
Generate a SSP luminosity grid¶
If the isocrhones tables provide a luminosity field (log of the luminosity)
it is possible to generate a luminosity instead of a magnitude grid (note the --luminosity_key
):
isochrones_generate_magnitudes_grid --rebinAges --M0 1e6 --luminosity_key 'log(L/Lo)' -d P04O1D1E1Y247_euclid -o BolLum_BastI_1e6.hdf5
If the output is stored as a pkl file, the table may be displayed with:
isochrones_plot_magnitudes_grid --luminosity Euclid_logL_CMD_1e6.pkl
SSP Grids¶
Single stellar population grids (SSP) are stored in the ``pNbody` directory
config/opt/filters/
or on the user directory
~/.pNbody/opt/filters/
Those tables can be re-created using the script:
tools/Isochrones/generateSSPGrids.sh
Isochrones Scripts¶
isochrones_plot
¶
usage: isochrones_plot [-h] [-o FILENAME] [-d DIRECTORY] [-f FILENAME]
[--Age FLOAT] [--MH ...] [--addMasses] [--x STRING]
[--y STRING] [--xmin FLOAT] [--xmax FLOAT]
[--ymin FLOAT] [--ymax FLOAT] [--invertx] [--inverty]
[--info]
Display isochrones or colour magnitude diagrams
options:
-h, --help show this help message and exit
-o FILENAME Name of the output file
-d DIRECTORY a directory (default=None)
-f FILENAME the name of isochrones database file
--Age FLOAT Isochrone Age
--MH ... [MH/H]
--addMasses Add masses
--x STRING x value
--y STRING y value
--xmin FLOAT xmin
--xmax FLOAT xmax
--ymin FLOAT ymin
--ymax FLOAT ymax
--invertx force invert x axis
--inverty force invert y axis
--info get info (list of keys) and exit.
Examples:
--------
isochrones_plot -d P04O1D1E1Y247 --info
isochrones_plot -d P04O1D1E1Y247 --Age 13000 --x logTe --y 'log(L/Lo)'--invertx
isochrones_plot -d P04O1D1E1Y247 --Age 13000 --x G_BP-G_RP --y G --inverty
isochrones_plot -d P04O1D1E1Y247 --Age 13000 --MH -2
isochrones_plot -d P04O1D1E1Y247 --Age 13000 --MH -2 -1
isochrones_plot -d P04O1D1E1Y247 --Age 13000 --addMasses --MH -2 -1
isochrones_plot -d P04O1D1E1Y247 --Age 13000 --x G_BP-G_RP --y G --inverty --xmin -1 --xmax 3 --ymin -5 --ymax 13 --MH -2
isochrones_plot -d MIST_v1.2_vvcrit0.0_UBVRIplus --info
isochrones_plot -d MIST_v1.2_vvcrit0.0_UBVRIplus --Age 13000 --x log_Teff --y 'log_L' --invertx
isochrones_plot -d MIST_v1.2_vvcrit0.0_UBVRIplus --Age 13000 --x Gaia_BP_EDR3-Gaia_RP_EDR3 --y Gaia_G_EDR3 --inverty
isochrones_plot -f CMD_Euclid.dat --info
isochrones_plot -f CMD_Euclid.dat --Age 13000 --x logTe --y logL --invertx
isochrones_plot -f CMD_Euclid.dat --Age 13000 --x Bluemag-Redmag --y VISmag --inverty
isochrones_py
¶
usage: isochrones_py [-h] [-d DIRECTORY] [-f FILENAME]
Launch python with the MIST database loaded.
The database will then be accessible throught the DB variable.
options:
-h, --help show this help message and exit
-d DIRECTORY a directory (default=None)
-f FILENAME the name of isochrones database file
Examples:
--------
isochrones_py -d P04O1D1E1Y247
isochrones_py -d MIST_v1.2_vvcrit0.0_UBVRIplus
isochrones_py -f CMD_Euclid.dat
isochrones_generate_magnitudes_grid
¶
usage: isochrones_generate_magnitudes_grid [-h] [-d DIRECTORY] [-f FILENAME]
[-o OUTPUTFILENAME]
[--filter_key STRING]
[--luminosity_key STRING]
[--interpolation_mode STRING]
[--M0 FLOAT] [--rebinAges]
[--seed INT] [--imf STRING]
[--info]
Generate a grid of magnitude. The grid is a 2d matrix discretized in [M/H] and ages.
It is actually stored as a pickle file.
The script takes as input either a MIST database or an ascii file from the CMD tool (http://stev.oapd.inaf.it/cmd/).
By default, the IMF is the Kroupa 2001 one. It can be changed to anything providing a parameter file containing
the IMF parametrisation:
params = {}
params["Mmax"] = 50.
params["Mmin"] = 0.05
params["as"] = [0.7,-0.8,-1.7,-1.3]
params["ms"] = [0.08,0.5,1.0]
where ``as`` is the slope of the IMF in the mass intervals ``ms`` given is solar masses.
options:
-h, --help show this help message and exit
-d DIRECTORY a directory (default=None)
-f FILENAME the name of isochrones database file
-o OUTPUTFILENAME Name of the output file
--filter_key STRING the filter key as stored in the database
--luminosity_key STRING
the luminosity key as stored in the database
(log(L/Lo))
--interpolation_mode STRING
the interpolation mode (nearest or lininterp)
--M0 FLOAT the mass of the stellar population assumed to compute
the magnitudes. Values lower than 1e6 may lead to
stochastic fluctuations
--rebinAges use an hard-coded binning
[10**(np.linspace(0.6,4.1,71))] for the ages and not
the binning provided by the database
--seed INT random seed
--imf STRING a file containing the IMF parameters
--info get info (list of keys) and exit.
Examples:
--------
For an ascii CMD file e.g. CMD_Euclid.dat:
isochrones_generate_magnitudes_grid --rebinAges --M0 1e6 --filter_key VISmag -f CMD_Euclid.dat -o EuclidVISmag_CMD_1e6.hdf5
isochrones_generate_magnitudes_grid --rebinAges --M0 1e6 --filter_key VISmag -f CMD_Euclid.dat -o EuclidVISmag_CMD_1e6.hdf5 --imf imf.py
isochrones_generate_magnitudes_grid --rebinAges --M0 1e6 --filter_key G -d P04O1D1E1Y247 -o GAIA_G_BastI_1e6.hdf5
isochrones_generate_magnitudes_grid --rebinAges --M0 1e6 --filter_key G --luminosity_key 'log(L/Lo)' -d P04O1D1E1Y247 -o GAIA_G_BastI_1e6.hdf5
isochrones_plot_magnitudes_grid
¶
usage: isochrones_plot_magnitudes_grid [-h] [--luminosity] [-o OUTPUTFILENAME]
FILENAME
From a given magnitude grid, plot the magnitude as a function of stellar masses, for each metallicity bin.
Magnitudes are normalized to 1e11 Msol.
positional arguments:
FILENAME file
options:
-h, --help show this help message and exit
--luminosity assume luminosities
-o OUTPUTFILENAME Name of the output file
Examples:
--------
isochrones_plot_magnitudes_grid HSTF475Xmag_CMD_1e6.pkl
isochrones_plot_magnitudes_grid HSTF475Xmag_CMD_1e6.hdf5
isochrones_ssp_grid_info
¶
usage: isochrones_ssp_grid_info [-h] FILE
Provide information on an SSP grid (works only with the hdf5 format)
positional arguments:
FILE one hdf5 file
options:
-h, --help show this help message and exit
Examples:
--------
isochrones_ssp_grid_info GAIA_G_BastI_1e6.hdf5
The IsochronesBlock class¶
The IsochronesGrid class¶
- class pNbody.Isochrones.main.IsochronesGrid(dirname=None, default_keys=None, filename=None)¶
self.M is a numpy 2D matrix containing isochrones data (self.M[i,j]) for a given metallicity and age.
The Metallicity and Ages considered for the matrix is:
self.binsMH : in log10[M/H] self.binsAge : in Myr
- FillDBGaps()¶
Fill missing isochrones with the nearest one
- checkKeyExists(key)¶
check if the key key is the key list
- get(Age, MH, Mass, key=None, mode='masslininterp')¶
For a given Age, MH, Mass, return the value given by the key key.
mode provides different ways of interpolating tables. masslininterp interpolates over masses and
- getAgeIndex(Age)¶
determine the index for a given Age
- getAgeIndexes(Age)¶
determine the indexes bracketing a given Age
- getKeys()¶
return the list of the keys
- getMHIndex(MH)¶
determine the index for a given MH
- getMHIndexes(MH)¶
determine the indexes bracketing a given MH
- getMassIndexes(Mass, i, j)¶
From i (Age) and j (MH), and Mass the mass, return the two indexes bracketing the mass.
- getMaxStellarMass(Age, MH)¶
for a given Age and MH, get the maximal stellar mass
- interpolateMassAndValue(Mass, i, j, key)¶
From i (Age) and j (MH), return the interpolated key for a given mass Mass
- organizeDB()¶
Create the self.M matrix from the isochrones blocks