gcfit.core.SampledModel#
- class gcfit.core.SampledModel(model, centre=None, *, distribute_masses=True, use_model_distance=True, seed=None, pool=None)#
Representation of a cluster based on sampling a Model.
Based on a solved Model, this class gives access to the phase-space coordinates of N stars and remnants, as sampled from the smooth model distributions.
The number of stars, within each mass bin, is determined by the Model.Nj.
The sampling algorithms are based heavily on those from limepy.sample, and are described in Gieles & Zocchi (2015). First, the masses are optionally sampled uniformally between the edges of their respective mass bins. Then the radial distances from the centre of the cluster are sampled based on the system’s enclosed mass profiles. The (total) velocities of the stars are then sampled based on an analytical form of the (velocity analogue) PDF, using the ziggurat algorithm. Finally, a number of angles are randomly sampled in order to assign velocity directions and 3D positions.
Optionally, if provided with a phase-space centre for the cluster, projected quantities on the sky (i.e. galactic coordinates and proper motions) can be computed.
- Parameters:
- modelModel
The base Model instance used to sample all stars from.
- centreastropy.SkyCoord, optional
An optional centre to the cluster, which will be used to compute projected quantities (in the galactic frame) for all star positions and velocities. Must include full 3D position and velocity components.
- distribute_massesbool, optional
Whether to sample the masses uniformally with each mass bin. If False, will simply assign each star the mean mass (Model.mj) for each bin. Defaults to True.
- use_model_distancebool, optional
If a centre SkyCoord is given, whether or not to force the distance coordinate to the match the model distance. Defaults to True.
- seedint, optional
A random seed to define the random generator used in all sampling. Passed to numpy.random.default_rng. Defaults to None.
- poolmultiprocessing.Pool, optional
A pooling object with a map method, used to generate some samples in parallel.
- Attributes:
- Nj(nmbin, ) astropy.Quantity
The number of stars sampled in each mass bin.
- Nint
The total number of stars sampled.
- Nstars, Nremint
The total number of stars and remnants sampled. N = Nstars + Nrem.
- star_types(N,) numpy.ndarray of ‘<U2’
The type of each object sampled (MS = main sequence star, WD = white dwarf, NS = neutron star, BH = black hole).
- m(N,) astropy.Quantity
The mass of each star.
- mbins(N,) numpy.ndarray
The mass bin index of each star.
- Mastropy.Quantity
The total mass of the sampled system. Will not match the base model exactly, due to the discretization of the number of stars.
- poscollections.namedtuple of (N,) astropy.Quantity
A named tuple containing all position coordinates for each star, in both cartesian and spherical coordinate systems (x, y, z, r, theta, phi).
- velcollections.namedtuple of (N,) astropy.Quantity
A named tuple containing all velocity vectors for each star, in both cartesian and spherical coordinate systems and in the tangential direction (x, y, z, r, t, theta, phi).
- galacticcollections.namedtuple of (N,) astropy.Quantity
A named tuple containing the projected positions and velocities (in the galactic frame) of each star (lon, lat, distance, pm_l_cosb, pm_b, v_los), based on the given cluster centre.
Methods
__init__(model[, centre, distribute_masses, ...])to_artpop(phot_system, pixel_scale, *[, ...])Construct an artpop.Source for use in simulated photometry.
Attributes
centregalactic- to_artpop(phot_system, pixel_scale, *, a_lam=0.0, projected=False, cutoff_radius=None, return_rem=False, iso_class=None, thin=False, **kwargs)#
Construct an artpop.Source for use in simulated photometry.
Computes, based on the masses and MIST Isochrones for the given phot_system, positions and magnitudes for all stars which are used to create an artificial Source object from artpop, to be used within artpop to simulate artificial imagery of this (sampled) cluster.
- Parameters:
- phot_systemstr
Name of the photometric system to simulate stellar magnitudes within. Must be supported by the given iso_class (therefore, likely part of the MIST isochrone catalogue).
- pixel_scalefloat or astropy.Quantity
The pixel scale of the mock image. If a float is given, the units will be assumed to be arcsec / pixels.
- a_lamfloat or dict, optional
Magnitude of extinction. If float, the same extinction will be applied to all bands. If dict, keys must match filters for this phot_system and will be applied individually, defaulting to 0 for missing filters.
- projectedbool, optional
If False (default) will use unprojected x-y star positions, otherwise will use the galactic longitude/latitude. A centre must have been provided at initilization.
- cutoff_radiusastropy.Quantity, optional
A maximum radius to apply to the sampled stars. Only stars sampled within this radius will be used.
- return_rembool, optional
If True, will also return the x and y positions (and types) of all remnants alongside the Source, which can be used to show the presence of dark remnants alongside simulated imagery. By default, only the Source is returned.
- iso_classartpop.Isochrone, optional
Optionally use a custom subclass of the typical artpop isochrone objects. This may be required for use with custom isochrones from sources other than the MIST catalogue. By default, the artpop.MISTIsochrone class is used.
- thinint, optional
If given, will “thin” out the stars used in the final tables by this factor. Not typically recommended unless absolutely necessary.
- Returns:
- artpop.Source
artpop artificial source object corresponding to this sampled cluster.