synthpop.population =================== .. py:module:: synthpop.population .. autoapi-nested-parse:: This file contains the Population Class. Its task is to handle the generation process for each population according to the dedicated modules for: 1) population density, 2) initial mass function, 3) age distribution, 4) metallicity distribution, 5+6) isochrone systems and interpolator, 7+8) extinction map and law, and 9) kinematics. Classes ------- .. autoapisummary:: synthpop.population.Population Module Contents --------------- .. py:class:: Population(pop_params: str, population_index: int, glbl_params: synthpop_utils.Parameters, **positional_kwargs) Population subclass for model class. Requires a population parameter file to be initialized. Attributes ---------- name : string l_deg : float b_deg : float solid_angle : float popid : int params : dict age : age.Age class imf : initial_mass_function.InitialMassFunction subclass kinematics : kinematics.Kinematics subclass metallicity : metallicity.Metallicity subclass population_density : population_density.PopulationDensity subclass position : position.Position class Methods ------- __init__(self,population_file,population_index,isochrones,bands,**kwargs) : None initialize the Population class assign_subclasses(self, subclasses) : None convenience function to assign subsections to Population upon initialization update(self,**kwargs) : None update population with new kwargs (e.g., new l_deg and b_deg) mc_totmass(self,r_inner,r_outer,N) : float [M_sun] monte carlo to calculate the total mass in between radius_1 and radius_2 within self.solid_angle_sr using N draws central_totmass(self,r_inner,r_outer) : float [M_sun] use the central density of a slice to estimate the total mass within the slice estimate_field(self,) : float [M_sun], float [number of stars] estimate the total mass and stars in a field generate_field(self) : pandas.DataFrame generate stars in slices of self.step_size out to self.max_distance generate_stars_in_slice(self,r_inner,r_outer,N) :np.array generate the initial parameter for N = stars in a slices slice r_inner and r_outer check_field(self, TBD...) : estimates the number of missing stars in the generated field evolve_field(self,data) : float x 4 estimates the evolved parameter for each star in the field .. py:attribute:: glbl_params .. py:attribute:: sun .. py:attribute:: scale_factor .. py:attribute:: pop_params .. py:attribute:: name .. py:attribute:: popid .. py:attribute:: l_deg :value: 180 .. py:attribute:: b_deg :value: 0 .. py:attribute:: solid_angle_sr :value: 1e-12 .. py:attribute:: position .. py:attribute:: min_mass .. py:attribute:: max_mass .. py:attribute:: skip_lowmass_stars .. py:attribute:: max_distance .. py:attribute:: step_size .. py:attribute:: N_mc_totmass .. py:attribute:: lost_mass_option .. py:attribute:: N_av_mass .. py:attribute:: av_mass_corr :value: None .. py:attribute:: generator .. py:method:: assign_subclasses() initialization of all the subclass Returns ------- population_density, imf, age, metallicity, kinematics, evolution, extinction .. py:method:: get_evolution_class() .. py:method:: get_evolution_class_config() .. py:method:: get_extinction_class() .. py:method:: get_population_density_class() .. py:method:: get_imf_class() .. py:method:: get_age_class() .. py:method:: get_metallicity_class() .. py:method:: get_kinematics_class(population_density) .. py:method:: set_position(l_deg: float, b_deg: float, solid_angle: float, solid_angle_unit: str, **position_kwargs) set a new location and broadcast the new location position and extinction Parameters ---------- l_deg : float [degree] galactic longitude b_deg : float [degree] galactic latitude solid_angle : float [solid_angle_unit] setting size of the cone solid_angle_unit : str unit for solid_ange position_kwargs: dict keywords forwarded to the position class Returns ------- .. py:method:: mc_totmass(r_inner: float, r_outer: float, n_picks: int = 1000) -> float Monte Carlo integration of the total mass in a slice, given near and far bounding radii r_inner and r_outer. Want to add some catch for large error in the mass, then increase value of N. Recall that for a Monte Carlo integration: Q_N = Volume * (1/N) * sum_N f(x) = V*, the expected error in Q_N decreases as 1/sqrt(N). Parameters ---------- r_inner : float [kpc] inner radius of the slice r_outer : float [kpc] outer radius of the slice n_picks : int number of picks for the integration Returns ------- total_mass : float total mass in the slice .. py:method:: central_totmass(r_inner: float, r_outer: float) -> float Returns the mass using the denisty in the center of a slice Parameters ---------- r_inner : float [kpc] inner radius of the slice r_outer : float [kpc] outer radius of the slice Returns ------- totmass: float [Msun] mass of a slice using the central density .. py:method:: estimate_field(**kwargs) -> Tuple[float, float] estimate the field in the current pointing .. py:method:: estimate_average_mass_correction(n_stars: int = 10000, use_save_value: bool = False, **kwargs) -> float Estimates the ratio between the average evolved mass and initialmass Generates and evolve N stars in the cone, Evolve them and estimates the average mass Parameters ---------- n_stars : int numbers of test stars use_save_value: bool used the stored value if it is already estimated for a previous location Returns ------- av_mass_corr : float sum(mass_evolved)/sum(mass_initial) .. py:method:: get_mass_loss_for_option(lost_mass_option) .. py:method:: get_n_star_expected(radii, average_imass_per_star, av_mass_corr) estimates the number of stars in each slice .. py:method:: convert_to_dataframe(popid, initial_parameters, m_evolved, final_phase_flag, galactic_coordinates, proper_motions, cartesian_coordinates, velocities, vr_lsr, extinction_in_map, props, user_props, mags, headers) :staticmethod: convert data to a pandas data_frame .. py:method:: generate_field() -> Tuple[pandas.DataFrame, Dict] Generate the stars in the field estimates the number of stars from a density distribution and generates stars based on the individual distributions estimates evolved properties by interpolating the isochrones Returns ------- population_df : DataFrame collected stars for this population distribution : dict collected distributions, by now only the distance distribution .. py:method:: remove_stars(df: pandas.DataFrame, radii_star: numpy.ndarray, missing_stars: numpy.ndarray, radii: numpy.ndarray) -> pandas.DataFrame :staticmethod: Removes stars form data frame in the corresponding slice if missing_stars is < 0 .. py:method:: check_field(radii: numpy.ndarray, average_imass_per_star: float, m_initial: numpy.ndarray, m_evolved: numpy.ndarray, radii_star: numpy.ndarray, mass_per_slice: numpy.ndarray, fract_mass_limit: Union[Tuple[float, float], Tuple[numpy.ndarray, numpy.ndarray]]) -> numpy.ndarray Check if stars are missing in a given slice Estimates the number of stars that are missing Only used for lost_mass_option 3 Parameters ---------- radii : ndarray m_initial : ndarray m_evolved : ndarray radii_star : ndarray mass_per_slice : ndarray fract_mass_limit : ndarray or float Returns ------- missing_stars : ndarray number of missing stars in each slice .. py:method:: do_kinematics(dist: numpy.ndarray, star_l_deg: numpy.ndarray, star_b_deg: numpy.ndarray, x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, **kwargs) -> Tuple[numpy.ndarray, Ellipsis] calls the generation of velocities Parameters ---------- dist, star_l_deg, star_b_deg: ndarray Spherical Coordinates, used to transform from cartesian velocities to galactic velocities x, y, z: ndarray Cartesian coordinates, used to generate random Veloities kwargs : dict Keyword arguments passed to draw_random_velocity. Returns ------- u, v, w : ndarray cartesian velocities vr: ndarray radial velocity respect to the center of the galaxie mu_l, mu_b : ndarray galactic proper motion rv : ndarray radial velocity respect to the earth .. py:method:: extract_magnitudes(radii_inner, galactic_coordinates, ref_mag, props, inside_grid=None, not_evolved=None) .. py:method:: extract_properties(m_initial, props, req_keys, user_keys, inside_grid=None, not_evolved=None) :staticmethod: