<resource schema="gcns">
	<meta name="creationDate">2021-03-11T11:36:23Z</meta>
	<meta name="schema-rank">100</meta>

	<meta name="title">The Gaia eDR3 Catalogue of Nearby Stars GCNS</meta>
	<meta name="description" format="rst">
		This is a clean and well characterised catalogue of objects within 100pc of
		the Sun from the Gaia early third data release. We characterise the
		catalogue using the full data release, and comparisons to other catalogues
		in literature and simulations.  For all candidates (measured parallax &lt;
		8 mas), we calculate a distance probability function using Bayesian
		procedures and mock catalogues for the prediction of the priors. For each
		entry using a random forest classifier we attempt to remove sources with
		spurious astrometric solutions.
		
		This results in 331312 objects that should contain at least 92% of stars
		within 100 pc at spectral type M9.

		GCNS comes with several auxiliary tables, in particular lists of
		resolved stellar systems, of known neary stars not found in eDR3 and
		of candidates of Hyades and ComaBer cluster members.
	</meta>

	<meta name="subject">catalogs</meta>
	<meta name="subject">hertzsprung-russell-diagram</meta>
	<meta name="subject">luminosity-function</meta>
	<meta name="subject">stellar-mass-functions </meta>
	<meta name="subject">solar-neighborhood</meta>

	<meta name="creator">Smart, R.L.; Sarro, L.M.; Rybizki, J.;  Reylé, C.;
		Robin, A.C.; Hambly, N.C.; Abbas, U.; Barstow, M.A.; de Bruijne, J.H.J.;
		Bucciarelli, B.; Carrasco, J.M.; Cooper, W.J.; Hodgkin, S.T.; Masana, E.;
		Michalik, D.; Sahlmann, J.; Sozzetti, A.; Gaia Collaboration</meta>

	<meta name="instrument">Gaia</meta>
	<meta name="source">https://doi.org/10.1051/0004-6361/202039498</meta>
	<meta name="contentLevel">Research</meta>
	<meta name="type">Catalog</meta>  <!-- or Archive, Survey, Simulation -->

	<meta name="coverage.waveband">Optical</meta>

	<STREAM id="main-table-columns">
		<primary>source_id</primary>

		<column original="source_id"/>
		<column name="ra" type="double precision"
			unit="deg" ucd="pos.eq.ra;meta.main"
			tablehead="RA"
			description="ICRS right ascension from Gaia eDR3."
			verbLevel="1"/>
		<column name="dec" type="double precision"
			unit="deg" ucd="pos.eq.dec;meta.main"
			tablehead="Dec"
			description="ICRS declination from Gaia eDR3."
			verbLevel="1"/>

		<LOOP listItems="ra_error dec_error parallax parallax_error pmra
			pmra_error pmdec pmdec_error phot_g_mean_mag phot_g_mean_flux_over_error
			phot_bp_mean_mag phot_bp_mean_flux_over_error phot_rp_mean_mag
			phot_rp_mean_flux_over_error phot_bp_rp_excess_factor
			ruwe">
			<events>
				<column original="\item"/>
			</events>
		</LOOP>

		<column name="ipd_frac_multi_peak" type="smallint" required="True"
			ucd="meta.code.multip"
			tablehead="Double?"
			description="Percentage of distance windows in which a double peak
				was seen (high values mean high likelihood of a resolved double
				star)."
			verbLevel="5"/>

		<column name="adoptedrv"
			ucd="phys.veloc;pos.heliocentric"
			tablehead="ad. RV"
			unit="km/s"
			description="Adopted Radial Velocity"
			verbLevel="15"/>
		<column name="adoptedrv_error"
			ucd="stat.error;phys.veloc;pos.heliocentric"
			unit="km/s"
			tablehead="Err. RV"
			description="Error in adopted RV"
			verbLevel="25"/>
		<column name="adoptedrv_refname" type="text"
			ucd="meta.bib.bibcode"
			tablehead="Src RV"
			description="Bibcode for the source of the radial velocity"
			verbLevel="25"
			displayHint="type=bibcode"/>
		<column name="radial_velocity_is_valid" type="smallint" required="True"
			ucd="meta.code.qual"
			tablehead="RV?"
			description="1 if this object has a radial velocity in eDR3, 0 otherwise"
			verbLevel="25"/>
		<column name="gcns_prob"
			ucd="stat.fit.goodness"
			tablehead="Astrom?"
			description="Probability that the astrometry is reliable"
			verbLevel="15"/>
		<column name="wd_prob"
			ucd="stat.likelihood;src.class"
			tablehead="WD?"
			description="probability that this is a white dwarf."
			verbLevel="15"/>

		<column name="dist_1"
			ucd="stat.value;pos.distance"
			unit="kpc"
			tablehead="Dist1"
			description="1st percentile of the distance PDF, used in GCNS selection"
			verbLevel="20"/>
		<column name="dist_16"
			ucd="stat.value;pos.distance"
			unit="kpc"
			tablehead="Dist16"
			description="16th percentile of the distance PDF (1 σ lower bound)"
			verbLevel="15"/>
		<column name="dist_50"
			ucd="pos.distance;stat.median"
			unit="kpc"
			tablehead="Dist50"
			description="Median of the distance PDF"
			verbLevel="10"/>
		<column name="dist_84"
			ucd="stat.value;pos.distance"
			unit="kpc"
			tablehead="Dist84"
			description="84th percentile of the distance PDF (1 σ upper bound)"
			verbLevel="20"/>

		<LOOP listItems="x y z">
			<events>
				<column name="\item\+coord_50"
					ucd="pos.cartesian.\item;stat.median"
					unit="pc"
					tablehead="\upper{\item}"
					description="Median \item coordinate in the Galactic frame
						assuming dist_50"
					verbLevel="5"/>
				<column name="\item\+coord_16"
					ucd="stat.value;pos.cartesian.\item"
					unit="pc"
					tablehead="Lo \upper{\item}"
					description="1 σ lower bound of Galactic frame \item coordinate"
					verbLevel="15"/>
				<column name="\item\+coord_84"
					ucd="stat.value;pos.cartesian.\item"
					unit="pc"
					tablehead="Hi \upper{\item}"
					description="1 σ upper bound of Galactic frame \item coordinate"/>
			</events>
		</LOOP>

		<LOOP>
			<csvItems>
				vel, coo
				u, x
				v, y
				w, z
			</csvItems>
			<events>
				<column name="\vel\+vel_50"
					ucd="phys.veloc;pos.cartesian.\coo;stat.median"
					unit="km/s"
					tablehead="\upper{\vel}"
					description="Median velocity \vel in the Galactic frame,
						direction positive \coo"
					verbLevel="5"/>
				<column name="\vel\+vel_16"
					ucd="stat.value;phys.veloc;pos.cartesian.\coo"
					unit="km/s"
					tablehead="Lo \upper{\vel}"
					description="1 σ lower bound for \vel"
					verbLevel="15"/>
				<column name="\vel\+vel_84"
					ucd="stat.value;phys.veloc;pos.cartesian.\coo"
					unit="km/s"
					tablehead="Hi \upper{\vel}"
					description="1 σ upper bound for \vel"
					verbLevel="15"/>
			</events>
		</LOOP>

		<column name="name_gunn" type="text"
			ucd="meta.id.cross"
			tablehead="Gunn Name"
			description="Object Name from PanSTARRS/SDSS/SkyMapper survey"
			verbLevel="15"/>
		<column name="refname_gunn" type="text"
			ucd="meta.bib.bibcode"
			tablehead="Ref. griz"
			description="Reference for the source of the Gunn photometry"
			verbLevel="25"/>
		<LOOP>
			<csvItems>
				item,  ucd
				g, V
				r, R
				i, I
				z, I
			</csvItems>
			<events>
				<column name="\item\+mag_gunn"
					ucd="phot.mag;em.opt.\ucd"
					unit="mag"
					tablehead="m_\item"
					description="Gunn \upper{\item} band magnitude (when from SDSS,
						g, when from Skymapper, g_psf)"
					verbLevel="15"/>
				<column name="e_\item\+mag_gunn"
					ucd="stat.error;phot.mag;em.opt.\ucd"
					unit="mag"
					tablehead="Err. m_\item"
					description="Uncertainty in \upper{\item} band magnitude"
					verbLevel="25"/>
			</events>
		</LOOP>

		<column name="name_2mass" type="text"
			ucd="meta.id.cross"
			tablehead="2MASS name"
			description="Name of this object in 2MASS"
			verbLevel="15"/>
		<LOOP listItems="j h k">
			<events>
				<column name="\item\+_m_2mass"
					ucd="phot.mag;em.IR.\upper{\item}"
					unit="mag"
					tablehead="m_\upper{\item}"
					description="2MASS \upper{\item} band magnitude"
					verbLevel="15"/>
				<column name="\item\+_msig_2mass"
					ucd="stat.error;phot.mag;em.IR.\upper{\item}"
					unit="mag"
					tablehead="Err. m_\upper{\item}"
					description="Uncertainty in 2MASS \upper{\item} band magnitude"
					verbLevel="25"/>
			</events>
		</LOOP>

		<column name="name_wise" type="text"
			ucd="meta.id.cross"
			tablehead="WISE name"
			description="Name of this object in WISE"
			verbLevel="15"/>
		<LOOP>
			<csvItems>
				band, source, weirdo, ucd
				w1, CATWISE, _pm, em.IR.3-4um
				w2, CATWISE, _pm, em.IR.4-8um
				w3, CATWISE, , em.IR.8-15um
				w4, ALLWISE, , em.IR.15-30um
			</csvItems>
			<events>
				<column name="\band\+mpro\weirdo\+_wise"
					ucd="phot.mag;\ucd"
					unit="mag"
					tablehead="m_\upper{\band}"
					description="\source \upper{\band} band magnitude"
					verbLevel="15"/>
				<column name="\band\+sigmpro\weirdo\+_wise"
					ucd="stat.error;phot.mag;\ucd"
					unit="mag"
					tablehead="Err. m_\upper{\band}"
					description="Uncertainty in \source \upper{\band} band magnitude"
					verbLevel="25"/>
			</events>
		</LOOP>
	</STREAM>

	<coverage>
		<spatial>0/0-11</spatial>
	</coverage>

	<table id="main" onDisk="True" mixin="//scs#q3cindex" adql="True"
			namePath="gaia/q3#edr3lite">
		<meta name="title">eDR3 Gaia Catalogue of Nearby Stars (GCNS)</meta>
		<meta name="description">This is the main catalogue.  Additional
			resources include: gcns.resolvedss (resolved stellar systems),
			gcns.missing_10mas (objects missing from eDR3 that have been
			suspected of being within 100 pc before), and gcns.hyacob (probable
			members of the Hyades and the Coma Berenices open cluster).
		</meta>
		<meta name="table-rank">1</meta>

		<FEED source="main-table-columns"/>
	</table>

	<STREAM id="elements-for-import">
		<sources pattern="data/\src"/>

		<fitsTableGrammar lowerKeys="True" nanIsNULL="True"/>

		<make table="\tablename">
			<rowmaker idmaps="*">
				<LOOP>
					<csvItems>
					col, nullLiteral
					adoptedrv_refname,'             NaN'
					refname_gunn,' NaN'
					name_2mass,'...'
					name_wise,'...'
					</csvItems>
					<events>
						<map dest="\col" source="\col" nullExpr="\nullLiteral"/>
					</events>
				</LOOP>
				<apply procDef="//procs#dictMap">
					<bind name="mapping">{'T': 1, 'F': 0}</bind>
					<bind name="key">"radial_velocity_is_valid"</bind>
				</apply>
			</rowmaker>
		</make>

	</STREAM>

	<data id="import">
		<FEED source="elements-for-import"
			src="GCNS_cat.fits.gz"
			tablename="main"/>
	</data>


	<table id="rejected" onDisk="True" mixin="//scs#q3cindex" adql="True"
			namePath="gaia/q3#edr3lite">
		<meta name="title">eDR3 GCNS: Rejected Objects</meta>
		<meta name="description">This is the catalogue of objects in the 8mas
			sample that were rejected for the main Gaia Catalogue of
			Nearby Stars as having a zero probability of being inside
			100pc or indicated as a spurious astrometric solution.
		</meta>

		<FEED source="main-table-columns"/>
	</table>

	<data id="import-rejected">
		<FEED source="elements-for-import"
			src="GCNS_reject.fits.gz"
			tablename="rejected"/>
	</data>


	<table id="resolvedss" onDisk="True" adql="True">
		<meta name="title">eDR3 GCNS Resolved Binary Candidates</meta>
		<meta name="description" format="rst">
			Resolved binary candidates in the GCNS catalogue as discussed in
			https://doi.org/10.1051/0004-6361/202039498, “stellar multiplicity:
			resolved systems”.  You probably want to join this table to gaia.edr3lite
			using source_id1 and/or source_id2.
		</meta>
		<column name="source_id1" type="bigint" required="True"
			ucd="meta.id.part"
			tablehead="Primary Id"
			description="Gaia EDR3 source_id of the primary star"
			verbLevel="1"/>
		<column name="source_id2" type="bigint" required="True"
			ucd="meta.id.part"
			tablehead="Secondary Id"
			description="Gaia EDR3 source_id of secondary start"
			verbLevel="1"/>
		<column name="separation"
			unit="arcsec" ucd="pos.angDistance"
			tablehead="Separation"
			description="Angular separation of the two sources."
			verbLevel="1"/>
		<column name="mag_diff"
			unit="mag" ucd="phot.mag;arith.diff;em.opt.V"
			tablehead="ΔG"
			description="G magnitude difference between the two components"
			verbLevel="15"/>
		<column name="proj_sep"
			unit="AU" ucd="phys.size"
			tablehead="Projected Sep."
			description="Projected separation of the pair"
			verbLevel="15"/>
		<column name="bin" required="True"
			ucd="meta.code.multip" type="smallint"
			tablehead="Bin?"
			description="1 if the system is probably made up of more than
				two stars, 0 otherwise."
			verbLevel="15"/>
		<column name="bound" required="True"
			ucd="meta.code" type="smallint"
			tablehead="Bound?"
			description="1 if the system is probably gravitationally bound,
				0 otherwise"
			verbLevel="15"/>
	</table>

	<data id="import_rss">
		<sources pattern="data/Table3_ResolvedStellarSystems.dat.gz"/>
		<reGrammar names="source_id1, source_id2, separation, mag_diff,
			proj_sep, bin, ignored, ignored, bound" preFilter="gunzip"/>
		<make table="resolvedss">
			<rowmaker idmaps="*">
				<map dest="bin">{"true": 1, "false": 0}[@bin]</map>
				<map dest="bound">{"true": 1, "false": 0}[@bound]</map>
			</rowmaker>
		</make>
	</data>

	<table id="missing_10mas" onDisk="True" adql="True" mixin="//scs#q3cindex">
		<meta name="title">eDR3 GCNS list of possibly nearby stars missing</meta>
		<meta name="description">A table of 1258 objects with published
			parallaxes greater than 10mas that are not or have no parallax in
			Gaia eDR3 and are hence not listed in gcns.main.
		</meta>
		<column name="main_id" type="text"
			ucd="meta.id;meta.main"
			tablehead="Name"
			description="Source name from Simbad"
			verbLevel="1"/>
		<column name="ra" type="double precision"
			unit="deg" ucd="pos.eq.ra;meta.main"
			tablehead="RA"
			description="ICRS RA from Simbad"
			verbLevel="1"/>
		<column name="dec" type="double precision"
			unit="deg" ucd="pos.eq.dec;meta.main"
			tablehead="Dec"
			description="ICRS Dec from Simbad"
			verbLevel="1"/>
		<column name="plx_value"
			unit="mas" ucd="pos.parallax"
			tablehead="Parallax"
			description="Parallax from Simbad"
			verbLevel="1"/>
		<column name="plx_bibcode" type="text"
			ucd="meta.bib.bibcode"
			tablehead="Source"
			description="Source reference for the parallax"
			verbLevel="1"
			displayHint="type=bibcode"/>
		<column name="otype" type="text"
			ucd="meta.code.class"
			tablehead="Type"
			description="Simbad object type"
			verbLevel="1"/>
	</table>

	<data id="import_10mas">
		<sources pattern="data/missing_10mas.dat.gz"/>
		<columnGrammar preFilter="zcat">
			<colDefs>
				main_id:1-26
				ra:  29-38
				dec:  43-52
				plx_value:  57-63
				plx_bibcode:  74-92
				otype: 101-103
			</colDefs>
		</columnGrammar>
		<make table="missing_10mas">
			<rowmaker idmaps="*">
				<map dest="otype" source="otype" nullExpr="''"/>
			</rowmaker>
		</make>
	</data>

	<table id="hyacob" onDisk="True" adql="True">
		<meta name="title">eDR3 GCNS open cluster membership table</meta>
		<meta name="description">
			A list of 920+212 probable Hyades and ComaBer members in
			the eDR3 GCNS sample.
		</meta>
		<foreignKey inTable="main" source="source_id" metaOnly="True"/>
		<column original="main.source_id"/>
		<column name="name" type="text"
			ucd="meta.id"
			tablehead="Cluster"
			description="Name of the cluster this object probably belongs to"
			verbLevel="1"/>
		<column name="c_cluster"
			ucd="stat.likelihood"
			tablehead="P"
			description="Dimensionless chi-square test statistic. Small
				values indicate highly probable members (cf. eq. 4 in
				2018MNRAS.477.3197R)"
			verbLevel="1"/>
		<column name="dist_cluster"
			ucd="pos.distance" unit="pc"
			tablehead="D"
			description="Distance of each star from the cluster barycentre."
			verbLevel="1"
			note="d"/>

		<meta name="note" tag="d">
			This is computed using the median xcoord, ycoord, zcoord from gcns.main.
			The cluster barycentre is computed as the average (X, Y, Z) coordinate of
			all stars in the central region of the cluster (two tidal radii),
			assuming equal masses for all stars.
		</meta>
	</table>

	<data id="import_hyacob">
		<sources pattern="data/Hyades_ComaBer.dat.gz"/>
		<columnGrammar preFilter="zcat">
			<colDefs>
				source_id:  1-21
				name: 25-31
				c_cluster:  34-39
				dist_cluster:  46- 52
			</colDefs>
		</columnGrammar>
		<make table="hyacob">
			<rowmaker idmaps="*">
			</rowmaker>
		</make>
	</data>

	<LOOP listItems="5 6 7">
		<events>
			<table id="maglims\item" onDisk="True" adql="True">
				<meta name="title">Magnitude distribution over \item-HEALPixes</meta>
				<meta name="description">
The G magnitude distribution percentiles per level \item HEALpixes for all
Gaia sources with a parallax and a G magnitude measurement. Can be used
to approximate the G magnitude limit for Gaia at that position of the
sky. Sources up to a limiting magnitude equal to 'magnitude_70' are 98%
complete when compared to PS1. The 80th and 90th percentile decrease the
completeness in Gaia to 97% and 95%, respectively. These cuts can be
very useful, when trying to compare Gaia data to models, e.g. the
GeDR3mock catalog (gedrmock.main).
				</meta>
				<meta name="table-rank">2</meta>
				<column name="hpx"
					ucd="pos.healpix"
					tablehead="\item-HEALPix"
					description="HEALPix on level \item these statistics are for"/>
				<column name="magnitude_70"
					unit="mag" ucd="stat.param"
					tablehead="70th percentile"
					description="70th percentle of the G-magnitude distribution
						in Gaia eDR3 for all objects with both parallax and a G
						magnitude"/>
				<column name="magnitude_80"
					unit="mag" ucd="stat.param"
					tablehead="80th percentile"
					description="80th percentle of the G-magnitude distribution
						in Gaia eDR3 for all objects with both parallax and a G
						magnitude"/>
				<column name="magnitude_90"
					unit="mag" ucd="stat.param"
					tablehead="90th percentile"
					description="90th percentle of the G-magnitude distribution
						in Gaia eDR3 for all objects with both parallax and a G
						magnitude"/>
				<column name="sourcecount" type="integer" required="True"
					ucd="meta.number"
					tablehead="# Objs"
					description="Number of objects contributing to the distribution"/>
			</table>

			<data id="import-maglims_\item">
				<sources pattern=
					"data/maglims_hpxlvl_\item\+_all_percentages_g_parallax_edr3int3.fits"/>
				<fitsTableGrammar/>
				<make table="maglims\item">
					<rowmaker idmaps="*">
						<map key="magnitude_70" source="p_70"/>
						<map key="magnitude_80" source="p_80"/>
						<map key="magnitude_90" source="p_90"/>
					</rowmaker>
				</make>
			</data>
		</events>
	</LOOP>

	<data id="pub" auto="False">
		<publish/>
		<make table="main"/>
		<make table="resolvedss"/>
		<make table="missing_10mas"/>
		<make table="hyacob"/>
		<make table="maglims5"/>
		<make table="maglims6"/>
		<make table="maglims7"/>
	</data>

	<service id="cone" allowed="form,scs.xml,static">
		<property name="staticData">data</property>
		<meta name="shortName">eDR3 GCNS SCS</meta>
		<meta name="testQuery">
			<meta name="ra">1.7924</meta>
			<meta name="dec">45.2415</meta>
			<meta name="sr">0.001</meta>
		</meta>

		<publish render="form" sets="ivo_managed, local"/>
		<publish render="scs.xml" sets="ivo_managed"/>

		<scsCore queriedTable="main">
			<FEED source="//scs#coreDescs"/>
			<condDesc buildFrom="parallax"/>
			<condDesc buildFrom="dist_50"/>
			<condDesc buildFrom="xcoord_50"/>
			<condDesc buildFrom="ycoord_50"/>
			<condDesc buildFrom="zcoord_50"/>
		</scsCore>
	</service>

	<regSuite title="gcns regression">
		<regTest title="GCNS SCS serves some data">
			<url RA="1.79247"
					DEC="45.24152" SR="0.001"
					VERB="3"
				>cone/scs.xml</url>
			<code>
				row = self.getFirstVOTableRow()
				self.assertEqual(row["uvel_50"], None)
				self.assertAlmostEqual(row['h_m_2mass'], 11.916000366210938)
				self.assertEqual(row['source_id'], '386447898732453888')
				self.assertEqual(row['radial_velocity_is_valid'], 0)
			</code>
		</regTest>

		<regTest title="GCNS binary star query">
			<url parSet="TAP" query="select proj_sep, bound, a.dist_50,
				b.dist_50, b.name_gunn, b.name_gunn
				from gcns.resolvedss as cat
				join gcns.main as a
					on (cat.source_id1=a.source_id)
				join gcns.main as b
					on (cat.source_id2=b.source_id)
				where distance(a.ra, a.dec, 3, 38.8)&lt;0.2">/tap/sync</url>
			<code>
				row = self.getFirstVOTableRow()
				self.assertAlmostEqual(row["proj_sep"], 340.0213928222)
				self.assertEqual(row["bound"], 1)
			</code>
		</regTest>

		<regTest title="GCNS Hyades star query">
			<url parSet="TAP" query="
				select dist_cluster, c_cluster from
				gcns.main
				natural join gcns.hyacob
				where name='Hyades'
				and 0.02>distance(ra, dec, 2, 47.27)">/tap/sync</url>
			<code>
				row = self.getFirstVOTableRow()
				self.assertAlmostEqual(row["dist_cluster"], 59.4700012207)
			</code>
		</regTest>

		<regTest title="GCNS maglim dist test">
			<url parSet="TAP" QUERY="select * from gcns.maglims5 where hpx=42"
				>/tap/sync</url>
			<code>
				row = self.getFirstVOTableRow()
				self.assertAlmostEqual(row["magnitude_70"], 19.70000076)
				self.assertEqual(row["sourcecount"], 8760)
			</code>
		</regTest>
	</regSuite>
</resource>
