Models ====== The ``GCfit`` Models can be accessed through the core module at .. code-block:: python >>> import gcfit All models are based off of the single base class :class:`gcfit.core.Model`. To begin, we can start by exploring a model with some arbitrary default parameters. The :class:`gcfit.core.Model` class gives default values for many arguments, which you may want to adjust yourself. See the documentation of said class for more explanation of the meaning of all available parameters. .. code-block:: python >>> model = gcfit.Model(W0=6.3, M=5e5, rh=6.7, age=12, FeH=-0.7) >>> model >> # Mean masses per bin >>> model.mj >>> # Total mass per bin >>> model.Mj >>> # Stellar object types (MS, NS, WD, BH) >>> model.star_types array(['MS', 'MS', 'MS', 'MS', 'MS', 'MS', 'MS', 'MS', 'MS', 'WD', 'WD', 'WD', 'WD', 'WD', 'WD', 'NS', 'BH', 'BH', 'BH', 'BH'], dtype='>> # Total mass and number of black holes, in their repective bins >>> model.BH.Mj >>> model.BH.Nj Notice that the majority of interesting quantities in :class:`gcfit.core.Model` are stored as :class:`astropy.Quantity` objects, with their respective units. The radial profiles of a number of system properties, such as velocity dispersion, density and energy, are available for each mass bin, as well as a number of useful radii. .. code-block:: python >>> # Radial profile domain >>> model.r >>> # Density profile of the most massive main-sequence stars >>> model.rhoj[model.nms - 1] >>> # Half-mass radius of each mass bin >>> model.rhj See :class:`gcfit.core.Model` for further description of all available properties. Models matching a number of historical DF formulations can also be created easily using the relevant generator functions. These functions mostly consist of setting a specific default value for the truncation parameter ``g``. .. code-block:: python >>> # Generate a King (1966) model >>> king = gcfit.Model.king(6.3, 5e5, 6.7, age=12, FeH=-0.7) >>> model.g, king.g (1.5, 1) Sampled Models ^^^^^^^^^^^^^^ These (multimass) models can also be sampled, in order to return a random distribution of stars matching the phase-space distribution of the models. .. code-block:: python >>> sampled = model.sample() >>> sampled >>> # Total number of stars in the system >>> sampled.Nstars >>> # Cartesian coordinates of all stars, centred on the cluster centre >>> sampled.pos.x >>> sampled.pos.z >>> sampled.pos._fields ('x', 'y', 'z', 'r', 'theta', 'phi') >>> # Radial and tangential velocities of each star >>> sampled.vel.r >>> sampled.vel.t >>> sampled.vel._fields ('x', 'y', 'z', 'r', 't', 'theta', 'phi') If a centre coordinate on the sky is given (as an :class:`astropy.SkyCoord` with both position and velocity), the projected positions and velocities on the sky can also be computed. .. code-block:: python >>> import astropy.units as u >>> from astropy.coordinates import SkyCoord >>> deg, masyr, kms = u.deg, u.Unit('mas/yr'), u.Unit('km/s') >>> cen = SkyCoord(l=45. * deg, b=55. * deg, >>> pm_l_cosb=5 * masyr, pm_b=3 * masyr, radial_velocity=2 * kms, >>> frame='galactic') >>> p_sampled = model.sample(centre=cen) >>> p_sampled.galactic.lon >>> p_sampled.galactic.pm_b >>> p_sampled.galactic._fields ('lat', 'lon', 'distance', 'pm_l_cosb', 'pm_b', 'v_los') Observations ^^^^^^^^^^^^ Another useful class within ``GCfit`` is the :class:`gcfit.core.Observations` class, which acts as a container for a number of observational datasets. These observations are key for all fitting (see below), but are also useful when working with individual models, as they contain a number of useful metadata fields about the cluster: .. code-block:: python >>> obs = gcfit.Observations('NGC104') Observations(cluster="NGC0104") >>> model = gcfit.Model(W0=6.3, M=5e5, rh=6.7, observations=obs) >>> model.age, model.FeH (, -0.72) More information on the datafiles underlying this class, and how to create your own datafiles can be found at (TODO).