synthpop.position ================= .. py:module:: synthpop.position .. autoapi-nested-parse:: This file includes the Position class. It handles the generation of star positions within a given cone. Classes ------- .. autoapisummary:: synthpop.position.Position Module Contents --------------- .. py:class:: Position(coord_trans, **kwargs) Position class for a Population class. This contains methods to randomly generate positions within a field/slice, Attributes ---------- l_deg : float [degree] Galactic longitude of the current field in degrees. l_rad : float [radian] Galactic longitude of the current field in radians. b_deg : float [degree] Galactic latitude of the current field in degrees. b_rad : float [radian] Galactic latitude of the current field in radians. cone_angle : float [radian] opening angle of the cone Methods ------- __init__(l_deg: float, b_deg: float, solid_angle_sr: float) : None Initialize the Class update(*args, **kwargs) : None Update the class with new coordinates, passes arguments to __init__() draw_random_point_in_slice(dist_inner: float, dist_outer: float, N: int = 1): tuple generate N points within the slice rotate_00_to_lb(delta_l: ndarray, delta_b: ndarray) : Tuple[ndarray, ndarray] rotates a cone from pointing toward 0,0 to (l,b) .. py:attribute:: coord_trans .. py:attribute:: l_deg :value: None .. py:attribute:: l_rad :value: None .. py:attribute:: b_deg :value: None .. py:attribute:: b_rad :value: None .. py:attribute:: cone_angle :value: None .. py:method:: update_location(l_deg: float, b_deg: float, solid_angle: float) Set the location and solid_angle Parameters ---------- l_deg, b_deg : float [deg] galactic longitude and latitude in degrees solid_angle : float [sr] size of the cone .. py:method:: draw_random_point_in_slice(dist_inner: float, dist_outer: float, n_stars: int = 1) -> Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] Draw one or more random point in a slice given coordinates (self.l, self.b) [degrees], solid angle[steradians], and distance range[kpc] To get distance d, we draw from a cumulative quadratic distribution. To do so, we found the integrated r**2 such that our CDF is Prob(x) = (x**3 - dist_inner**3)/(dist_outer**3 - dist_inner**3) Then, we invert for x(Prob) so that we can draw Prob from Uniform(0,1) x = ((r_max**3 - r_min**3)*Prob + r_min**3)**(1/3) Parameters ---------- dist_inner : float [kpc] lower distance dist_outer : float [kpc] upper distance n_stars : int, None, optional number of stars drawn if None return one position as float Returns ------- x : float, ndarray [kpc] Cartesian X coordinate (centered at the galactic center) of the drawn positions y : float, ndarray [kpc] Cartesian Y coordinate (centered at the galactic center) of the drawn positions z : float, ndarray [kpc] Cartesian Z coordinate (centered at the galactic center) of the drawn positions d_kpc : float, ndarray [kpc] distances of the drawn positions star_l_deg : float, ndarray [deg] galactic longitude of the drawn positions star_b_deg : float, ndarray [deg] galactic latitude of the drawn positions .. py:method:: rotate_00_to_lb(delta_l: numpy.ndarray, delta_b: numpy.ndarray) -> Tuple[numpy.ndarray, numpy.ndarray] Rotates coordinate system such that 0, 0 lands on self.l ,self.b Parameters ---------- delta_l : float, ndarray [radians] difference in galactic longitude delta_b : float, ndarray [radians] difference in galactic longitude Returns ------- star_l_rad : float, ndarray [radians] galactic longitude star_b_rad : float, ndarray [radians] galactic latitude