<resource schema="gaia">
	<meta name="title">Selections from Gaia Data Release 3 (DR3)</meta>
	<meta name="description" format="rst">
		This schema contains data re-published from the official
		Gaia mirrors (such as ivo://uni-heidelberg.de/gaia/tap) either to
		support combining its data with local tables (the various Xlite tables)
		or to make the data more accessible to VO clients (e.g., epoch fluxes).

		Other Gaia-related data is found in, among others, the gdr3mock,
		gdr3spec, gedr3auto, gedr3dist, gedr3mock, and gedr3spur schemas.
	</meta>
	<meta name="creator">
		<meta name="name">GAIA Collaboration</meta>
	</meta>
	<meta name="content">
		<meta name="type">Catalog</meta>
	</meta>
	<meta name="coverage.waveband">Optical</meta>
	<meta name="creationDate">2020-11-17T11:00:00Z</meta>
	<meta name="schema-rank">20</meta>

	<meta name="subject">stars</meta>
	<meta name="subject">surveys</meta>
	<meta name="subject">astrometry</meta>
	<meta name="subject">proper-motions</meta>

	<meta name="facility">Gaia</meta>

	<meta name="_news" author="MD" date="2022-08-23">
		Updated from eDR3 to DR3.  We keep the previous edr3lite table since
		it has been in use by third parties, but it is now just an alias for
		dr3lite.  This means that the (dr2) radial velocities in previous edr3lite
		in effect have changed (the columns are now simply gone).
	</meta>

	<meta name="copyright" format="rst">
		If you use public Gaia DR3 data in a paper, please take note of
		`ESAC's guide`_ on how to acknowledge and cite it.

		.. _ESAC's guide: https://gea.esac.esa.int/archive/documentation/GDR3/Miscellaneous/sec_credit_and_citation_instructions/
	</meta>

	<coverage>	
		<temporal>2015-06-01 2015-06-01</temporal>
		<spatial>0/0-11</spatial>
		<spectral>1.986e-19 4.966e-19</spectral>
	</coverage>

	<STREAM id="dr3litecolumns">
		<stc>
			Position ICRS BARYCENTER SPHER3 Epoch J2016.0 "ra" "dec" "parallax"
					Error "ra_error" "dec_error" "parallax_error"
				Velocity "pmra" "pmdec" "radial_velocity"
					Error "pmra_error" "pmdec_error" "radial_velocity_error"
		</stc>

		<column name="source_id" type="bigint"
			ucd="meta.id;meta.main"
			tablehead="Source Id"
			description="Gaia DR3 unique source identifier.  Note that this *cannot*
				be matched against the DR1 or DR2 source_ids."
			verbLevel="1" note="id">
			<values nullLiteral="-1"/>
			<property name="statisticsTarget">10000</property>
		</column>
		<column name="ra" type="double precision"
			ucd="pos.eq.ra;meta.main" unit="deg"
			tablehead="RA (ICRS)"
			description="Barycentric Right Ascension in ICRS at epoch J2016.0"
			verbLevel="1">
			<property name="statisticsTarget">10000</property>
		</column>
		<column name="dec" type="double precision"
			ucd="pos.eq.dec;meta.main" unit="deg"
			tablehead="Dec (ICRS)"
			description="Barycentric Declination in ICRS at epoch J2016.0"
			verbLevel="1">
			<property name="statisticsTarget">10000</property>
		</column>
		<column name="ra_error"
			ucd="stat.error;pos.eq.ra" unit="mas"
			tablehead="Err. RA"
			description="Standard error of ra (with cos δ applied)."/>
		<column name="dec_error"
			ucd="stat.error;pos.eq.dec" unit="mas"
			tablehead="Err. Dec"
			description="Standard error of dec" />

		<column name="pmra"
			ucd="pos.pm;pos.eq.ra" unit="mas/yr"
			tablehead="µ(RA)"
			description="Proper motion in right ascension of the source in ICRS
				at J2016.0. This is the tangent plane projection (i.e., multiplied by
				cos(δ)) of the proper
				motion vector in the direction of increasing right ascension."
			verbLevel="1"/>
		<column name="pmdec"
			ucd="pos.pm;pos.eq.dec" unit="mas/yr"
			tablehead="µ(Dec)"
			description="Proper motion in declination at J2016.0."
			verbLevel="1"/>
		<column name="pmra_error"
			ucd="stat.error;pos.pm;pos.eq.ra" unit="mas/yr"
			tablehead="Err. PM(RA)"
			description="Standard error of pmra"/>
		<column name="pmdec_error"
			ucd="stat.error;pos.pm;pos.eq.dec" unit="mas/yr"
			tablehead="Err. PM(Dec)"
			description="Standard error of pmdec"/>

		<column name="parallax"
			ucd="pos.parallax" unit="mas"
			tablehead="Parallax"
			description="Absolute barycentric stellar parallax of the source at the
			reference epoch J2016.0.  If looking for a distance, consider joining
			with gedr3dist.main and using the distances from there."
			verbLevel="1">
			<property name="statisticsTarget">10000</property>
		</column>
		<column name="parallax_error"
			ucd="stat.error;pos.parallax" unit="mas"
			tablehead="Parallax_error"
			description="Standard error of parallax" />

		<column name="phot_g_mean_mag"
			ucd="phot.mag;em.opt;stat.mean" unit="mag"
			tablehead="m_G"
			description="Mean magnitude in the G band. This is computed from the
				G-band mean flux applying the magnitude zero-point in the Vega
				scale.  To obtain error estimates, see phot_g_mean_flux_over_error."
			verbLevel="1" note="phot">
			<property name="statisticsTarget">5000</property>
		</column>
		<column name="phot_g_mean_flux_over_error"
			ucd="stat.snr;phot.flux;em.opt;stat.mean" unit=""
			tablehead="SNR G"
			description="Integrated mean G flux divided by its
				error. Errors are computed from the dispersion about the weighted
				mean of the input calibrated photometry."
			note="e"/>

		<LOOP>
			<csvItems>
				band, ucd
				rp,   R
				bp,   B
			</csvItems>
			<events>
				<column name="phot_\band\+_mean_flux_over_error"
					ucd="stat.snr;phot.flux;em.opt.\ucd"
					tablehead="SNR \upper{\band}"
					description="Integrated mean \upper{\band} flux divided by its
						error. Errors are computed from the dispersion about the weighted
						mean of the input calibrated photometry."
					note="e"/>
				<column name="phot_\band\+_mean_mag"
					unit="mag" ucd="phot.mag;em.opt.\ucd"
					tablehead="Mag \upper{\band}"
					description="Mean magnitude in the integrated \upper{\band} band.
						This is computed from the \upper{\band}-band mean flux
						applying the magnitude zero-point in the Vega scale.
						To obtain error estimates, see
						phot_\band\+_mean_flux_over_error."
					verbLevel="1" note="phot">
					<property name="statisticsTarget">5000</property>
				</column>
			</events>
		</LOOP>
		<column name="phot_bp_rp_excess_factor"
			ucd="stat.fit.goodness"
			tablehead="BP/RP excess"
			description="BP/RP excess factor estimated from the comparison of the sum
				of integrated BP and RP fluxes with respect to the flux in the G band.
				This measures the excess of flux in the BP and RP integrated photometry
				with respect to the G band. This excess is believed to be caused by
				background and contamination issues affecting the BP and RP data.
				Therefore a large value of this factor for a given source indicates
				systematic errors in the BP and RP photometry."/>
		<column name="astrometric_excess_noise"
			unit="mas" ucd="stat.fit.goodness"
			tablehead="ε_i"
			description="This is the excess noise of the source, measuring
			the disagreement, expressed as an angle, between the observations of
			a source and the best-fitting standard astrometric model (using five
			astrometric parameters).  A value of 0 signifies a well-behaved source,
			a positive value signifies that the residuals are larger than expected."
			verbLevel="15"/>

		<column name="radial_velocity"
			unit="km/s" ucd="spect.dopplerVeloc.opt;em.opt.I"
			tablehead="RV"
			description="Spectroscopic radial velocity in the solar barycentric
				reference frame.  For stars brighter than about 12 mag, this is the
				median of all single-epoch measurements.  For fainter stars, RV
				estimation is from a co-added spectrum."
				verbLevel="1"/>
		<column name="radial_velocity_error"
			unit="km/s" ucd="stat.error;spect.dopplerVeloc"
			tablehead="Err. RV"
			description="Error in radial_velocity; this is the error of the median
				for bright stars.  For faint stars, it is derived from the
				cross-correlation function."/>

		<column name="pseudocolour"
			unit="um**-1" ucd="em.wavenumber;phot.color"
			tablehead="P.-colour"
			description="Effective wavenumber of the source estimated in the final
				astrometric processing.  The pseudocolour is the astrometrically
				estimated effective wavenumber of the photon flux distribution in the
				astrometric (G) band, estimated from the chromatic displacements
				of image centroids.  The field is empty when
				chromaticity was instead taken into account using the photometrically
				determined ν_eff given in the field nu_eff_used_in_astrometry."
			verbLevel="15"/>
		<column name="pseudocolour_error"
			unit="um**-1" ucd="stat.error;em.wavenumber;phot.color"
			tablehead="Err. PC"
			description="Standard error of the pseudocolour."
			verbLevel="25"/>
		<column name="visibility_periods_used" type="smallint" required="True"
			ucd="meta.number;obs"
			tablehead="#VP"
			description="Number of visibility periods (groups of observations
			at least 4 days apart) used in the astrometric solution.  A small
			value (less than 10) indicates that the calculated parallax could
			be more vulnerable to error not reflected in the formal uncertainties."
			verbLevel="25"/>
		<column name="astrometric_params_solved" type="smallint"
			ucd="meta.code"
			tablehead="PS"
			description="This is a binary code indicating which astrometric
				parameters were estimated for the source. A set bit means the
				parameter was estimated. The least-significant bit represents α,
				the next bits δ, parallax, PM(RA) and PM(De). For Gaia DR2 the
				only relevant values are 31 (all five parameters solved) and 3
				(only positions).">
			<values nullLiteral="-1"/>
		</column>

		<column name="random_index" type="bigint" required="True"
			ucd="meta.code"
			tablehead="Random"
			description="Random index that can be used to deterministically
				select subsets"/>

		<column name="ruwe"
			ucd="stat.weight"
			tablehead="RUWE"
			description="Renormalized Unit Weight Error; this is a revised
				measure for the overall consistency of the solution as defined
				by GAIA-C3-TN-LU-LL-124-01.  A suggested cut on this is
				RUWE &lt;1.40) See the note for details."
			verbLevel="5" note="ruwe"/>

		<meta name="note" tag="id">
			For the contents of Gaia DR3,
			the source ID consists of a 64-bit integer, least
			significant bit = 1 and most significant bit = 64, comprising:

			* a HEALPix index number (sky pixel) in bits 36 - 63; by definition the
				smallest HEALPix index number is zero.
			* a 3-bit Data Processing Centre code in bits 33 - 35; for example
				MOD(source_id / 4294967296, 8) can be used to distinguish between
				sources initialised via the Initial Gaia Source List by the Torino DPC
				(code = 0) and sources otherwise detected and assigned by Gaia
				observations (code &gt; 0)
			* a 25-bit plus 7 bit sequence number within the HEALPix pixel in bits 1
				to 32 split into:

				* a 25 bit running number in bits 8 - 32; the running numbers are
					defined to be positive, i.e. never zero (except in the case of forced
					empty windows)
				* a 7-bit component number in bits 1 - 7

			This means that the HEALpix index level 12 of a given source is contained
			in the most significant bits. HEALpix index of 12 and lower levels can
			thus be retrieved as follows:

			* HEALpix level 12 = source_id / 34359738368
			* HEALpix level 11 = source_id / 137438953472
			* HEALpix level 10 = source_id / 549755813888
			* HEALpix level n = source_id / 2^35 * 4^(12 - level).
		</meta>

		<meta name="note" tag="ruwe"><![CDATA[
			The Renormalized Unit Weight Error (RUWE) is defined in
			L. Lindegren: Re-normalising the astrometric chi-square in Gaia DR2
			(Gaia tech note `GAIA-C3-TN-LU-LL-124-01
			<http://www.rssd.esa.int/doc_fetch.php?id=3757412>`_).  This is
			essentially the astrometric_chi2 from the DR2 release, but corrected
			for its strong dependency on magnitude and colour.  For quality
			cuts, this is the recommended quantity to use.  Lindegren suggests
			using RUWE<1.4 as a quality cut for “good” solutions based on
			the shape of the distribution.

			The values given here were calculated independently of DPAC and do
			not use interpolation on the grids provided by Lindegren et al.  Thus,
			minor differences from the “official” RUWE values are expected.
			As Lindegren et al point out, such differences should not matter
			in science applications, though.
		]]></meta>

		<meta name="note" tag="e">
			As long as the SNR is larger than 10 or so, 1.09*mag/snr is a reasonable
			approximation for an roughly symmetric magnitude error.  For smaller
			SNR, the error distribution of the magnitude becomes very asymmetric
			and highly non-Gaussian.
		</meta>
	</STREAM>


	<table id="dr3lite" onDisk="True" primary="source_id" adql="True"
			mixin="//scs#q3cindex" nrows="1811709771">

		<meta name="title">Gaia DR3 source catalogue "light"</meta>
		<meta name="description">
			This is gaia_source from the Gaia Data Release 3, stripped to just
			enough columns to enable basic science (but therefore a bit faster and
			simpler to deal with than the full gaia_source table).

			Note that on this server, there is also The gedr3dist.main, which gives
			distances computed by Bailer-Jones et al.  Use these in preference
			to working with the raw parallaxes.

			This server also carries the gedr3mock schema containing a simulation
			of gaia_source based on a state-of-the-art galaxy model, computed
			by Rybizki et al.

			The full DR3 is available from numerous places in the VO (in particular
			from the TAP services ivo://uni-heidelberg.de/gaia/tap and
			ivo://esavo/gaia/tap).
		</meta>

		<index columns="pmra"/>
		<index columns="pmdec"/>
		<index columns="parallax"/>
		<index columns="phot_g_mean_mag"/>
		<index columns="phot_bp_mean_mag"/>
		<index columns="phot_rp_mean_mag"/>
		<index columns="random_index"/>
		<mixin>//scs#pgs-pos-index</mixin>
		<FEED source="dr3litecolumns"/>
		<publish sets="ivo_managed,local"/>
	</table>

	<table id="edr3lite" onDisk="True" adql="True" nrows="1811709771">

		<meta name="title">Gaia eDR3 source catalogue "light"</meta>
		<meta name="description">
			This is a “light” version of the full Gaia DR3 gaia_source table.
			It is just a view copying gaia.dr3lite, which should preferentially
			be used in new queries.  This table is being kept around in order
			to keep legacy queries from breaking unnecessarily.  However, it is
			actually DR3 data rather than eDR3.  The minute differences did not
			seem to warrant keeping two copies of the relatively massive data
			around.
		</meta>

		<FEED source="dr3litecolumns"/>

		<FEED source="//procs#declare-indexes-from"
			sourceTables="dr3lite"/>

		<viewStatement>
			CREATE VIEW \qName AS (SELECT \colNames FROM gaia.dr3lite)
		</viewStatement>
	</table>

	<data id="import">
		<recreateAfter>make-view</recreateAfter>
		<sources pattern="data3/sources-dump.txt.gz"/>
		<directGrammar id="booster"
			cBooster="res/booster3func.c"
			type="split"
			autoNull="\N"
			splitChar="\t"
			preFilter="zcat">
		</directGrammar>
		<make table="dr3lite"/>
	</data>

	<data id="make-view">
		<make table="edr3lite"/>
	</data>

	<service id="cone" allowed="form,scs.xml">
		<meta name="title">Gaia DR3 Lite Cone Search</meta>
		<meta name="shortName">DR3 lite Cone</meta>
		<meta name="testQuery.ra">303.29074137</meta>
		<meta name="testQuery.dec">40.9302920611415004</meta>
		<meta name="testQuery.sr">0.001</meta>
		<publish render="scs.xml" sets="ivo_managed"/>
		<scsCore queriedTable="dr3lite">
			<FEED source="//scs#coreDescs"/>
			<LOOP listItems="parallax phot_g_mean_mag phot_bp_mean_mag
					phot_rp_mean_mag source_id">
				<events>
					<condDesc buildFrom="\item"/>
				</events>
			</LOOP>
		</scsCore>
	</service>

	<regSuite title="Gaia DR3 regression">
		<regTest title="Gaia DR3 table present">
			<url parSet="TAP"
				QUERY="SELECT * FROM gaia.dr3lite
					WHERE source_id=2062596647361326720">/tap/sync</url>
			<code>
				row = self.getFirstVOTableRow()
				self.assertEqual(len(row), 27)
				self.assertEqual(row["radial_velocity"], None)
				self.assertAlmostEqual(row["ra"], 303.285115764069)
				self.assertAlmostEqual(row["ruwe"], 1.05832231)
			</code>
		</regTest>

		<regTest title="Gaia DR3 cone search">
			<url RA="303.29074137" DEC="40.9302920611415004"
				SR="0.001">cone/scs.xml</url>
			<code>
				row = self.getFirstVOTableRow(rejectExtras=False)
				self.assertEqual(row['source_id'], '2062596647361324032')
				self.assertEqual(row["parallax"], None)
				self.assertEqual(row["astrometric_params_solved"], 3)
			</code>
		</regTest>
	</regSuite>
</resource>
