synthpop.modules.evolution.lagrange_interpolator
An interpolator for the isochrone grid
Uses a 2nd order Lagrange polynomial over mass (linear at grid edges) and linear over age and metallicity
Classes
Performs an interpolation using lagrangian polynomials |
Module Contents
- class synthpop.modules.evolution.lagrange_interpolator.LagrangeInterpolator(isochrones=None, **kwargs)
Bases:
synthpop.modules.evolution._evolution.EvolutionInterpolatorPerforms an interpolation using lagrangian polynomials 2 order for the mass (linear if it is at the edge of the isochrone grid) and a linear interpolation for age and metallicity
Methods
- lagrange_poly(x, grid, fgrid)ndarray
performs interpolation using lagrange polynomials
- grid_n4(grid, value)ndarray, ndarray
get the closest points from the isochrones mass grid
- combined_grid(met_key, mass, iso_ages, props)ndarray, ndarray
get the grid points for different metallicities and ages
- interp_props(self,track,mass,age,props)dict
interp the properties using the isochrones.
get_evolved_props () : dict, ndarray
- interpolator_name = 'Lagrange_Polynomials'
- accept_np_arrays = True
- log_ages
- lin_ages
- iso_met
- lagrange_poly(x, grid, fgrid)
cubic interpolation function using the lagrange polynomial Poly = sum_{i} f_{i} * Pi_{j, j!=i} (x-xj)/(xi-xj) Interpolation function Uses a lower order if the grid has fewer than 4 unique grid points (combined grid is defined in a way that it produces 4,2 or 1 unique grid points)
Parameters
- x: ndarray
values at which the grid should be interpolated
- grid: ndarray
grid points. must have shape […, 1, j]
- fgrid: ndarray
function values for each grid point must have shape […, i, j] where
Returns
- f: ndarray
interpolated value for f(x)
- static grid_n4(grid, value)
Gets the nearest four points in grid to value. If the value is inside the grid it will return the two values on either side (y) and their indices (x) If the value is outside the grid it returns 4 times the closest value ant its indices If the value is below/above the second lowest/or highest value it returns 2 times the next-lowest/second-highest value and two time the second-lowest/next-highest value and their indices This triggers the interpolation to switch to a linear interpolation between both values
Parameters
grid: pandas.DataFrame value: ndarray
Returns
- indicesndarray
indices for the 4 closest neighbours (two upper + two lower)
- valuesndarray
grid values for the 4 closest neighbours (two upper + two lower)
- combined_grid(met_key, mass, iso_ages, props)
Creates a combined grid for the different stars, Uses the isochrone based on each individual metallicity and age uses the grid_n4 to find adjacent entries for the masses
creates a numpy data array which contains the properties for the selected grid cells
Parameters
met_key :ndarray mass : ndarray iso_ages : ndarray props : list
Returns
grid : ndarray data : ndarray
- interp_props(met_key, log_iso_ages, mass, props, met_key_higher=None, met=None, log_iso_ages_higher=None, log_ages=None, age_interpolation='linear', **kwargs)
Interpolates the isochrones and returns the value at the given mass metallicity and age. Determines the closets 2 upper and lower neighbours grid and performs a cubic interpolation using the lagrange polynomials. At the edge of isochrone grid it only performs a linear interpolation and outside it uses the closest grid point. If met_key_higher and/or log_iso_ages_higher it also performs a linear interpolation in metallicity and or age
Parameters:
- met_sting: ndarray
numpy array of metallicity dictionary key for each star. If met_key_higher is given it is the lower metallicity for the interpolation, otherwise the closets metallicity and no interpolation is performed
- log_iso_ages: ndarray
numpy array of iso_ages as defined in the isochrones, If log_iso_ages_higher is given it is the lower log_iso_ages for the interpolation, otherwise the closets log_iso_ages and no interpolation is performed
- massndarray
initial mass for each star
- propsSet
list of properties which should be derived from the interpolation
- met_key_higherndarray, None, optional
numpy array of metallicity dictionary keys for each star. used us higher value for the interpolation. If None, an interpolation is not performed
- metndarray, None, optional
initial metallicity for each star. used when interpolating the stars
- log_iso_ages_higherndarray, None, optional
numpy array of metallicity dictionary key for each star. used us higher value for the interpolation. If None, an interpolation is not performed
- log_agesndarray, None, optional
log10(age) for each star. used when interpolating the stars
- age_interpolationstring, optional
type of age interpolation. if ‘linear’, it performs interpolation in age, if ‘log’, it performs an interpolation in log(age) space
Returns
- inter_props
returns a dictionary with interpolated values for each property that looks like this: {‘star_mass’: ndarray, ‘log_Teff’: ndarray, ‘log_g’: ndarray, ‘log_L’: ndarray, ‘initial_mass’: ndarray, ‘2MASS_Ks’: ndarray, ‘2MASS_J’: ndarray, ‘2MASS_H’: ndarray, ‘Bessell_V’: ndarray, ‘Bessell_I’: ndarray}
- get_weights_from_charon(phase1, phase2, x1, x2, x, trans=5.5)
charon transfers the “living” stars at the red giant clump to the “death” white Dwarfs
- get_evolved_props(m_init, met, age, props, age_interpolation='linear', met_interpolation=True, *kwargs)
Parameters
m_init : ndarray [Msun] met : ndarray [dex] age : ndarray [Gyr] props : Set age_interpolation : string, optional met_interpolation : bool, optional kwargs : dict, optional
Returns
s_track : dict in_grid : ndarray