synthpop.population
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
Population subclass for model class. |
Module Contents
- class synthpop.population.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
- glbl_params
- sun
- scale_factor
- pop_params
- name
- popid
- l_deg = 180
- b_deg = 0
- solid_angle_sr = 1e-12
- position
- min_mass
- max_mass
- skip_lowmass_stars
- max_distance
- step_size
- N_mc_totmass
- lost_mass_option
- N_av_mass
- av_mass_corr = None
- generator
- assign_subclasses()
initialization of all the subclass Returns ——- population_density, imf, age, metallicity, kinematics, evolution, extinction
- get_evolution_class()
- get_evolution_class_config()
- get_extinction_class()
- get_population_density_class()
- get_imf_class()
- get_age_class()
- get_metallicity_class()
- get_kinematics_class(population_density)
- 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_degfloat [degree]
galactic latitude
- solid_anglefloat [solid_angle_unit]
setting size of the cone
- solid_angle_unitstr
unit for solid_ange
- position_kwargs: dict
keywords forwarded to the position class
Returns
- 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*<f>, the expected error in Q_N decreases as 1/sqrt(N).
Parameters
- r_innerfloat [kpc]
inner radius of the slice
- r_outerfloat [kpc]
outer radius of the slice
- n_picksint
number of picks for the integration
Returns
- total_massfloat
total mass in the slice
- central_totmass(r_inner: float, r_outer: float) float
Returns the mass using the denisty in the center of a slice
Parameters
- r_innerfloat [kpc]
inner radius of the slice
- r_outerfloat [kpc]
outer radius of the slice
Returns
- totmass: float [Msun]
mass of a slice using the central density
- 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_starsint
numbers of test stars
- use_save_value: bool
used the stored value if it is already estimated for a previous location
Returns
- av_mass_corrfloat
sum(mass_evolved)/sum(mass_initial)
- get_mass_loss_for_option(lost_mass_option)
- get_n_star_expected(radii, average_imass_per_star, av_mass_corr)
estimates the number of stars in each slice
- static 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)
convert data to a pandas data_frame
- 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_dfDataFrame
collected stars for this population
- distributiondict
collected distributions, by now only the distance distribution
- static remove_stars(df: pandas.DataFrame, radii_star: numpy.ndarray, missing_stars: numpy.ndarray, radii: numpy.ndarray) pandas.DataFrame
Removes stars form data frame in the corresponding slice if missing_stars is < 0
- 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: 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
- 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
- kwargsdict
Keyword arguments passed to draw_random_velocity.
Returns
- u, v, wndarray
cartesian velocities
- vr: ndarray
radial velocity respect to the center of the galaxie
- mu_l, mu_bndarray
galactic proper motion
- rvndarray
radial velocity respect to the earth
- extract_magnitudes(radii_inner, galactic_coordinates, ref_mag, props, inside_grid=None, not_evolved=None)
- static extract_properties(m_initial, props, req_keys, user_keys, inside_grid=None, not_evolved=None)