Skip to content

Commit

Permalink
tutorial for binaries SF
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred Castro Ginard authored and Alfred Castro Ginard committed Apr 22, 2024
1 parent 68d7138 commit 32b115b
Showing 1 changed file with 325 additions and 0 deletions.
325 changes: 325 additions & 0 deletions docs/notebooks/dr3-unresolved-binaries.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "1a68188d",
"metadata": {},
"source": [
"# Gaia DR3 detectability of unresolved binary systems\n",
"\n",
"updated 27 Mar. 2024"
]
},
{
"cell_type": "markdown",
"id": "52760350",
"metadata": {},
"source": [
"In this notebook, we discuss how to estimate the detectability of unresolved binary systems based on RUWE. \n",
"\n",
"We also present a forward model to simulate a RUWE value for well-behaved single sources or binary systems, based on the astrimetric goodness-of-fit. We present a sky-varying map of maximum RUWE values compatible with single sources, where sources with larger RUWE can be considered potential binary systems.\n",
"\n",
"This work is currently based on precomputed maps at a resolution of HEALPix level 5. However, the procedure described here, further developed in [Castro-Ginard et al. (2024)](https://ui.adsabs.harvard.edu/abs/2023A%26A...677A..37C/abstract), is applicable to any resolution (Gaia scanning law details from GOST are required)."
]
},
{
"cell_type": "markdown",
"id": "0af89492",
"metadata": {},
"source": [
"### Sky-varying RUWE threshold"
]
},
{
"cell_type": "markdown",
"id": "da665ba9",
"metadata": {},
"source": [
"One of the main results in [Castro-Ginard et al. (2024)](https://ui.adsabs.harvard.edu/abs/2023A%26A...677A..37C/abstract) is Fig. 3, which shows a sky-varying RUWE thresdhold above which soucers show potential signs of binarity. \n",
"\n",
"To reproduce the plot, and access these RUWE values, we need to import the relevant module from the GaiaUnlimited package and create the selection function object. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ab15766",
"metadata": {},
"outputs": [],
"source": [
"from gaiaunlimited.selectionfunctions import binaries\n",
"\n",
"binariesSF = binaries.BinarySystemsSelectionFunction()"
]
},
{
"cell_type": "markdown",
"id": "39c43f5e",
"metadata": {},
"source": [
"This object provides a pre-computed table at HEALPix level 5, which includes for each pixel the RUWE thresholds together with the Gaia scanning law details needed to compute them and the probability to select sources with a RUWE higher than the threshold (estimated as in [Castro-Ginard et al., 2023](https://ui.adsabs.harvard.edu/abs/2023A%26A...677A..37C/abstract)).\n",
"\n",
"These values are accessible through their sky coordinates, using an astropy SkyCoord object. We generate the coordinates of the centres of each HEALPix at level 5 to generate an all-sky map."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "639b7f60",
"metadata": {},
"outputs": [],
"source": [
"from gaiaunlimited import fetch_utils,utils\n",
"\n",
"coords_of_centres = utils.get_healpix_centres(5)\n",
"coords_of_centres"
]
},
{
"cell_type": "markdown",
"id": "615a1a9e",
"metadata": {},
"source": [
"Then, we query the values for the RUWE threshold with:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "04c9937f",
"metadata": {},
"outputs": [],
"source": [
"ruwe_threshold = binariesSF.query_RUWE(coords_of_centres,crowding = True)\n",
"\n",
"print(\"RUWE threshold per pixel:\")\n",
"print(ruwe_threshold)"
]
},
{
"cell_type": "markdown",
"id": "58fb840a",
"metadata": {},
"source": [
"The argument \"crowding = True\" gives us the contribution to a increased RUWE from sources other than binarity, gauged directly from Gaia data. Setting \"crowding = False\" will provide a RUWE threshold where values above are only increased by binarity. The default and recommended setting for \"crowding\" is True.\n",
"\n",
"To show a sky map of these values we use the healpy python package."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e714cc7b",
"metadata": {},
"outputs": [],
"source": [
"import healpy as hp\n",
"\n",
"plt.figure()\n",
"hp.mollview(ruwe_threshold)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "50e8752b",
"metadata": {},
"source": [
"The Gaia scanning law details to estimate the above values are also accessible through the selection function object we created. This will provide the observation times, scanning angles or the along-scan parallax factors for each CCD observation of a certain pixel (usually 9 CCD observations per source transit). The number of observations can be derived from the previous. These data are collected through the Gaia Observation Forecast Tool ([GOST](https://gaia.esac.esa.int/gost/))."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "add7cf25",
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "unexpected EOF while parsing (915200205.py, line 2)",
"output_type": "error",
"traceback": [
"\u001b[0;36m Input \u001b[0;32mIn [1]\u001b[0;36m\u001b[0m\n\u001b[0;31m print(\"Number of CCD observations: {}\".format(len(observation_times))\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unexpected EOF while parsing\n"
]
}
],
"source": [
"observation_times, scanning_angles, AL_parallax_factors = binariesSF.query_ScanningLaw(coords_of_centres)\n",
"\n",
"print(\"Number of CCD observations per pixel:\")\n",
"n_observations = np.hstack([len(observation_times[i]) for i in range(hp.order2npix(5))])\n",
"print(n_observations)\n",
"\n",
"plt.figure()\n",
"hp.mollview(n_observations)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "0e67c96a",
"metadata": {},
"source": [
"### Selection function of potential binary systems based on RUWE"
]
},
{
"cell_type": "markdown",
"id": "807fba5e",
"metadata": {},
"source": [
"Based on this sky-varyin RUWE threshold we can estimate the probability to select sources with RUWE higher than the threshold, which can be seen as potential binary systems (note that there are other contributions that will lead to an increased RUWE which are not taken into account).\n",
"\n",
"These probabilities are computed using the subsample selection function (link to notebook), and are dependend only on the sky coordinates. These probabilities are a multiplicative factor to the Gaia catalogue selection function(link to notebook), described in [Cantat-Gaudin et al. (2023)](https://ui.adsabs.harvard.edu/abs/2023A%26A...669A..55C/abstract), and which depends on the sky coordinates and magnitude."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bba23b17",
"metadata": {},
"outputs": [],
"source": [
"probability,variance = binariesSF.query(coords_of_centres,return_variance = True)\n",
"\n",
"plt.figure()\n",
"hp.mollview(probability)\n",
"plt.show()\n",
"\n",
"plt.figure()\n",
"hp.mollview(variance)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "9797e696",
"metadata": {},
"source": [
"### Forward model to estimate the RUWE for a simulated source"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0bb41e2b",
"metadata": {},
"outputs": [],
"source": [
"from gaiaunlimited.utils import SimulateGaiaSource"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db85e3ca",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ra = \n",
"dec = \n",
"\n",
"source = SimulateGaiaSource(ra, dec, period = 0, eccentricity = 0, initial_phase = 0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d891b2e1",
"metadata": {},
"outputs": [],
"source": [
"Gmag = \n",
"parallax = \n",
"semimajor_axis = \n",
"mass_ratio = \n",
"luminosity_ratio = \n",
"phi = \n",
"theta = \n",
"omega = \n",
"\n",
"al_position, al_error = source.observe(Gmag, parallax,\\\n",
" semimajor_axis,\\\n",
" mass_ratio, luminosity_ratio,\\\n",
" phi, theta, omega,)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fc3dee20",
"metadata": {},
"outputs": [],
"source": [
"ruwe = source.unit_weight_error(al_position, al_error)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dcde5550",
"metadata": {},
"outputs": [],
"source": [
"Gmag = \n",
"parallax = \n",
"semimajor_axis = \n",
"mass_ratio = \n",
"luminosity_ratio = \n",
"phi = \n",
"theta = \n",
"omega = \n",
"\n",
"al_positions, al_errors = source.observe(Gmag, parallax,\\\n",
" semimajor_axis,\\\n",
" mass_ratio, luminosity_ratio,\\\n",
" phi, theta, omega,)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a395efde",
"metadata": {},
"outputs": [],
"source": [
"ruwes = source.unit_weight_error(al_positions, al_errors)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "50497f16",
"metadata": {},
"outputs": [],
"source": [
"plt.figure()\n",
"plt.hist(ruwes,bins = np.logspace(np.log10(0.5),np.log10(100),100))\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 32b115b

Please sign in to comment.