synthpop.modules.evolution.charon_interpolator ============================================== .. py:module:: synthpop.modules.evolution.charon_interpolator .. autoapi-nested-parse:: An interpolator for the isochrone grid Within each isochrone, it uses a cubic interpolation between adjacent grid-points. It aligns the phases between adjacent ages and performs a linear interpolation in metallicity and age. See Klüter & Huston et al (SynthPop Paper I, in prep). Classes ------- .. autoapisummary:: synthpop.modules.evolution.charon_interpolator.CharonInterpolator Module Contents --------------- .. py:class:: CharonInterpolator(isochrones=None, props_no_charon=None, coins=2, **kwargs) Bases: :py:obj:`synthpop.modules.evolution._evolution.EvolutionInterpolator` Performs 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 .. py:attribute:: interpolator_name :value: 'Charon_Polynomials' .. py:attribute:: accept_np_arrays :value: True .. py:attribute:: log_ages .. py:attribute:: lin_ages .. py:attribute:: iso_met .. py:attribute:: props_no_charon .. py:method:: get_tip_func() .. py:method:: grid_n4(grid, value) :staticmethod: 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 ------- indices : ndarray indices for the 4 closest neighbours (two upper + two lower) values : ndarray grid values for the 4 closest neighbours (two upper + two lower) .. py:method:: lagrange_poly(x, grid, fgrid) :staticmethod: 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) .. py:method:: combined_grid(mass, iso_met, 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 ---------- mass : ndarray iso_met :ndarray iso_ages : ndarray props : list Returns ------- grid : ndarray data : ndarray .. py:method:: interp_props(mass, met_grid, log_age_grid, props) 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. Parameters: ----------- mass : ndarray initial mass for each star met_grid: ndarray numpy array of metallicity dictionary key for each star. log_age_grid: ndarray numpy array of iso_ages as defined in the isochrones, props : Set list of properties which should be derived from the interpolation Returns ------- inter_props returns a dictionary with interpolated values for each property .. py:method:: get_modified_mass(mass, met, log_age, grid_met, grid_log_age) This function estimates the modified mass. by shifting the mass such that the phase transition points. Parameters ---------- mass met log_age grid_met grid_log_age Returns ------- .. py:method:: get_adjacent_gridpoints(met, log_ages) Estimates the adjacent metallicity and age grid-points Parameters ---------- met : np.ndarray metallicity for each star log_ages: np.ndarray log10(age) for each star Returns ------- iso_met_lower iso_met_higher log_iso_ages_lower log_iso_ages_higher iso_ages_lower iso_ages_higher .. py:method:: get_weights(met, age, iso_met_lower, iso_met_higher, iso_ages_lower, iso_ages_higher) :staticmethod: Estimates the weights for each grid-point Parameters ---------- met age iso_met_lower iso_met_higher iso_ages_lower iso_ages_higher Returns ------- .. py:method:: get_evolved_props(m_init: numpy.ndarray, met: numpy.ndarray, age: numpy.ndarray, props: Set, inter_age: str = 'linear') Parameters ---------- m_init : ndarray [Msun] inital masses for the stars met : ndarray [dex] initial metallicities for the stars age : ndarray [Gyr] ages for the stars props : Set list of stellar properties that should be returnd inter_age: str ["linear" or "log"] performe the age interpolation in age or in log10(age). Returns ------- s_track : dict in_grid : ndarray