<resource schema="cns5" resdir=".">
	<STREAM id="globalmeta">
		<meta name="creationDate">2022-06-08T14:49:39Z</meta>
		<meta name="schema-rank">20</meta>

		<meta name="title">The Fifth Catalogue of Nearby Stars (CNS5)</meta>
		<meta name="description" format="plain">
		The Fifth Catalogue of Nearby Stars (CNS5) aims to provide the most
		volume-complete sample of stars in the solar neighbourhood. The CNS5 is
		compiled based on trigonometric parallaxes from Gaia EDR3 and Hipparcos, and
		supplemented with astrometric data from Spitzer and ground-based surveys
		carried out in the infrared.  The CNS5 catalogue is statistically complete
		down to 19.7 mag in G-band and 11.8 mag in W1-band absolute magnitudes,
		corresponding to a spectral type of L8.

		Continuous updates of observational data for nearby stars from all sources
		were collected and evaluated. For all known stars in the 25 pc sphere around
		the Sun, the best values of positions in space, velocities, and magnitudes in
		different filters are presented.
		</meta>

		<meta name="subject">solar-neighborhood</meta>
		<meta name="subject">catalogs</meta>
		<meta name="subject">hertzsprung-russell-diagram</meta>
		<meta name="subject">sky-surveys</meta>
		<meta name="subject">parallax</meta>
		<meta name="subject">kolmogorov-smirnov-test</meta>
		<meta name="subject">astrometry</meta>
		<meta name="subject">luminosity-function</meta>
		<meta name="subject">white-dwarf-stars</meta>
		<meta name="subject">brown-dwarfs</meta>
		<meta name="subject">main-sequence</meta>
		<meta name="subject">galaxy-stellar-content</meta>

		<meta name="creator">Golovin, Alex; Reffert, Sabine; Just, Andreas;
			Jordan, Stefan; Vani, Akash; Jahreiß, Hartmut</meta>

		<meta name="source">2023A&amp;A...670A..19G</meta>
		<meta name="contentLevel">Research</meta>
		<meta name="type">Catalog</meta>

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

	<FEED source="globalmeta"/>

	<meta name="_related" title="CNS5 continuously updated"
		>\internallink{cns5update/q/cone/form}</meta>

	<meta name="_news" author="MD" date="2023-08-31">
		Minor update to the data: Missing proper motion values for 22 objects have
		been added.  This affects objects with the following cns5_id:
		40, 142, 293, 453, 841, 1292, 1692, 1829, 3095, 3258, 3655, 3718, 3808,
		3816, 4021, 4439, 4562, 4836, 5073, 5194, 5650, 5927.
	</meta>
	<meta name="_news" author="MD" date="2023-04-24">
		Minor update to the data: 22 duplicates removed, several wrong GJ numbers
		corrected.
	</meta>

	<table id="main" onDisk="True" mixin="//scs#q3cindex" adql="True">
		<!-- a copy of this (with only minor corrections) is in
		cns5update/q.  If you fix things here, you will probably want
		to fix it there, too -->
		<stc>
			Position ICRS SPHER3 "ra" "dec" "parallax"
				Velocity "pmra" "pmdec" "rv"
		</stc>
	
		<column name="cns5_id" type="bigint" required="True"
			ucd="meta.id;meta.main"
			tablehead="Id"
			description="CNS5 designation"
			verbLevel="1"/>
		<column name="gj_id" type="text"
			ucd="meta.id.cross"
			tablehead="GJ"
			description="Gliese-Jahreiss number"
			verbLevel="15"/>
		<column name="component_id" type="text"
			ucd="meta.code.multip"
			tablehead="Comp"
			description="Suffix for a component of binary or multiple system"
			verbLevel="1"/>
		<column name="n_components" type="smallint"
			ucd="meta.number"
			tablehead="#C"
			description="Total number of components in the system"
			verbLevel="25">
			<values nullLiteral="-1"/>
		</column>
		<column name="primary_flag" type="smallint"
			ucd="meta.code"
			tablehead="P?"
			description="True for the primary of a multiple system"
			verbLevel="15">
			<values nullLiteral="-1"/>
		</column>
		<column name="gj_system_primary" type="text"
			ucd="meta.id.cross"
			tablehead="GJ_p"
			description="Gliese-Jahriess number of the primary component
				of the system"
			verbLevel="15"/>
		<column name="gaia_edr3_id" type="bigint"
			ucd="meta.id.cross"
			tablehead="DR3 id"
			description="Source identifier in Gaia EDR3"
			verbLevel="15">
			<values nullLiteral="-1"/>
		</column>
		<column name="hip_id" type="integer"
			ucd="meta.id.cross"
			tablehead="HIP"
			description="Hipparcos identifier"
			verbLevel="25">
			<values nullLiteral="-1"/>
		</column>

		<column name="ra" type="double precision"
			unit="deg" ucd="pos.eq.ra;meta.main"
			tablehead="RA"
			description="Right ascension"
			verbLevel="1" displayHint="sf=8"/>
		<column name="dec" type="double precision"
			unit="deg" ucd="pos.eq.dec;meta.main"
			tablehead="Dec"
			description="Declination"
			verbLevel="1" displayHint="sf=8"/>
		<column name="epoch" type="double precision"
			unit="yr" ucd="time.epoch"
			tablehead="Epoch"
			description="Reference epoch for coordinates"
			verbLevel="15"/>
		<column name="coordinates_bibcode" type="text"
			ucd="meta.bib;pos.eq"
			tablehead="Src Pos"
			description="Source of the position"
			verbLevel="25" displayHint="type=bibcode"/>

		<column name="parallax" type="double precision"
			unit="mas" ucd="pos.parallax.trig"
			tablehead="ϖ"
			description="Absolute trigonometric parallax"
			verbLevel="1" displayHint="sf=2"/>
		<column name="parallax_error" type="real"
			unit="mas" ucd="stat.error;pos.parallax.trig"
			tablehead="Err. ϖ"
			description="Error in parallax"
			verbLevel="15" displayHint="sf=2"/>
		<column name="parallax_bibcode" type="text"
			ucd="meta.bib;pos.parallax.trig"
			tablehead="Src ϖ"
			description="Source of the parallax"
			verbLevel="25" displayHint="type=bibcode"/>

		<column name="pmra" type="double precision"
			unit="mas/yr" ucd="pos.pm;pos.eq.ra"
			tablehead="PM RA"
			description="Proper motion in right ascension"
			verbLevel="1" displayHint="sf=2"/>
		<column name="pmra_error" type="double precision"
			unit="mas/yr" ucd="stat.error;pos.pm;pos.eq.ra"
			tablehead="Err. PM RA"
			description="Error in pmra"
			verbLevel="15" displayHint="sf=2"/>
		<column name="pmdec" type="double precision"
			unit="mas/yr" ucd="pos.pm;pos.eq.dec"
			tablehead="PM Dec"
			description="Proper motion in declination"
			verbLevel="1" displayHint="sf=2"/>
		<column name="pmdec_error" type="double precision"
			unit="mas/yr" ucd="stat.error;pos.pm;pos.eq.dec"
			tablehead="Err. PM Dec"
			description="Error of pmdec"
			verbLevel="15" displayHint="sf=2"/>
		<column name="pm_bibcode" type="text"
			ucd="meta.bib;pos.pm"
			tablehead="Src. PM"
			description="Source of the proper motion"
			verbLevel="25" displayHint="type=bibcode"/>

		<column name="rv" type="double precision"
			unit="km/s" ucd="phys.veloc;pos.barycenter"
			tablehead="RV"
			description="Spectroscopic radial velocity"
			verbLevel="1" displayHint="sf=2"/>
		<column name="rv_error" type="double precision"
			unit="km/s" ucd="stat.error;phys.veloc;pos.barycenter"
			tablehead="Err. RV"
			description="Error in rv"
			verbLevel="15" displayHint="sf=2"/>
		<column name="rv_bibcode" type="text"
			ucd="meta.bib;phys.veloc;pos.barycenter"
			tablehead="Src. RV"
			description="Source of the radial velocity"
			verbLevel="25" displayHint="type=bibcode"/>

		<column name="g_mag" type="real"
			unit="mag" ucd="phot.mag;em.opt"
			tablehead="G"
			description="G band mean magnitude (corrected)"
			verbLevel="1" displayHint="sf=5"/>
		<column name="g_mag_error" type="double precision"
			unit="mag" ucd="stat.error;phot.mag;em.opt"
			tablehead="Err. G"
			description="Error in g_mag"
			verbLevel="15" displayHint="sf=2,displayUnit=mmag"/>
		<column name="bp_mag" type="real"
			unit="mag" ucd="phot.mag;em.opt.b"
			tablehead="BP"
			description="Gaia eDR3 integrated BP mean magnitude"
			verbLevel="1" displayHint="sf=4"/>
		<column name="bp_mag_error" type="double precision"
			unit="mag" ucd="stat.error;phot.mag;em.opt.b"
			tablehead="Err. BP"
			description="Error in bp_mag"
			verbLevel="15" displayHint="sf=2,displayUnit=mmag"/>
		<column name="rp_mag" type="real"
			unit="mag" ucd="phot.mag;em.opt.r"
			tablehead="RP"
			description="Gaia eDR3 integrated RP mean magnitude"
			verbLevel="1" displayHint="sf=4"/>
		<column name="rp_mag_error" type="double precision"
			unit="mag" ucd="stat.error;phot.mag;em.opt.r"
			tablehead="Err. RP"
			description="Error in rp_mag"
			verbLevel="15" displayHint="sf=2,displayUnit=mmag"/>

		<column name="g_mag_from_hip" type="double precision"
			unit="mag" ucd="phot.mag;em.opt"
			tablehead="G HIP"
			description="Hipparcos Hp magnitude converted to the G band"
			verbLevel="15" displayHint="sf=2"/>
		<column name="g_mag_from_hip_error" type="double precision"
			unit="mag" ucd="stat.error;phot.mag;em.opt"
			tablehead="Err. G HIP"
			description="Error in g_mag_from_hip"
			verbLevel="25" displayHint="sf=2"/>
		<column name="g_rp_from_hip" type="double precision"
			unit="mag" ucd="phot.color;em.opt.r;em.opt"
			tablehead="G-RP HIP"
			description="G - RP colour computed from Hipparcos V and I"
			verbLevel="15" displayHint="sf=2"/>
		<column name="g_rp_from_hip_error" type="double precision"
			unit="mag" ucd="stat.error;phot.color;em.opt.r;em.opt"
			tablehead="Err. G-RP HIP"
			description="Error in g_rp_from_hip"
			verbLevel="25" displayHint="sf=2"/>

		<column name="g_mag_resulting" type="real"
			unit="mag" ucd="phot.mag;em.opt"
			tablehead="G_r"
			description="Resulting (e.g., deblended) G band magnitude"
			verbLevel="1" displayHint="sf=5"/>
		<column name="g_mag_resulting_error" type="double precision"
			unit="mag" ucd="stat.error;phot.mag;em.opt"
			tablehead="Err. G_r"
			description="Error in g_mag_resulting"
			verbLevel="15" displayHint="sf=2,displayUnit=mmag"/>
		<column name="g_rp_resulting" type="double precision"
			unit="mag" ucd="phot.color;em.opt.r;em.opt"
			tablehead="(G-RP)_r"
			description="Resulting (e.g., deblended) G - RP colour"
			verbLevel="15" displayHint="sf=2"/>
		<column name="g_rp_resulting_error" type="double precision"
			unit="mag" ucd="stat.error;phot.color;em.opt.r;em.opt"
			tablehead="Err. (G-RP)_r"
			description="Error in g_rp_resulting"
			verbLevel="25" displayHint="sf=2"/>
		<column name="g_rp_resulting_flag" type="smallint"
			ucd="meta.code;phot.mag"
			tablehead="G-RP?"
			description="0 – G-RP is deblended; 1 – G-RP is uncorrected vs. eDR3;
				2 – G-RP is converted from Hipparcos"
			verbLevel="25">
			<values nullLiteral="-1"/>
		</column>

		<column name="j_mag" type="real"
			unit="mag" ucd="phot.mag;em.ir.j"
			tablehead="J"
			description="2MASS J band magnitude"
			verbLevel="15"/>
		<column name="j_mag_error" type="real"
			unit="mag" ucd="stat.error;phot.mag;em.ir.j"
			tablehead="Err. J"
			description="Error in j_mag"
			verbLevel="25"/>
		<column name="h_mag" type="real"
			unit="mag" ucd="phot.mag;em.ir.h"
			tablehead="H"
			description="2MASS H band magnitude"
			verbLevel="15"/>
		<column name="h_mag_error" type="real"
			unit="mag" ucd="stat.error;phot.mag;em.ir.h"
			tablehead="Err. H"
			description="Error in h_mag"
			verbLevel="25"/>
		<column name="k_mag" type="real"
			unit="mag" ucd="phot.mag;em.ir.k"
			tablehead="Ks"
			description="2MASS Ks band magnitude"
			verbLevel="15"/>
		<column name="k_mag_error" type="real"
			unit="mag" ucd="stat.error;phot.mag;em.ir.k"
			tablehead="Err. Ks"
			description="Error in k_mag"
			verbLevel="25"/>
		<column name="jhk_mag_bibcode" type="text"
			ucd="meta.bib;phot.mag;em.ir"
			tablehead="Src. NIR"
			description="Source of NIR magnitudes"
			verbLevel="25" displayHint="type=bibcode"/>

		<column name="w1_mag" type="real"
			unit="mag" ucd="phot.mag;em.ir.3-4um"
			tablehead="W1"
			description="WISE W1 band magnitude"
			verbLevel="15"/>
		<column name="w1_mag_error" type="real"
			unit="mag" ucd="stat.error;phot.mag;em.ir.3-4um"
			tablehead="Err. W1"
			description="Error in w1_mag"
			verbLevel="25"/>
		<column name="w2_mag" type="real"
			unit="mag" ucd="phot.mag;em.ir.4-8um"
			tablehead="W2"
			description="WISE W2 band magnitude"
			verbLevel="1"/>
		<column name="w2_mag_error" type="real"
			unit="mag" ucd="stat.error;phot.mag;em.ir.4-8um"
			tablehead="Err. W2"
			description="Error in w2_mag"
			verbLevel="25"/>
		<column name="w3_mag" type="real"
			unit="mag" ucd="phot.mag;em.ir.8-15um"
			tablehead="W3"
			description="WISE W3 band magnitude"
			verbLevel="15"/>
		<column name="w3_mag_error" type="real"
			unit="mag" ucd="stat.error;phot.mag;em.ir.8-15um"
			tablehead="Err. W3"
			description="Error in w3_mag"
			verbLevel="25"/>
		<column name="w4_mag" type="real"
			unit="mag" ucd="phot.mag;em.ir.15-30um"
			tablehead="W4"
			description="WISE W4 band magnitude"
			verbLevel="15"/>
		<column name="w4_mag_error" type="real"
			unit="mag" ucd="stat.error;phot.mag;em.ir.15-30um"
			tablehead="Err. W4"
			description="Error in w4_mag"
			verbLevel="25"/>
		<column name="wise_mag_bibcode" type="text"
			ucd="meta.bib;phot.mag;em.ir"
			tablehead="Src. MIR"
			description="Source of MIR magnitudes"
			verbLevel="25" displayHint="type=bibcode"/>
	</table>

	<coverage>
		<updater sourceTable="main"/>
	</coverage>

	<data id="import">
		<sources pattern="data/cns*.fits"/>

		<fitsTableGrammar/>

		<make table="main">
			<rowmaker idmaps="*">
				<apply name="map_nans">
					<code>
						for k,v in vars.items():
							if v!=v:
								vars[k] = None
							elif v=="":
								vars[k] = None
					</code>
				</apply>
				<map key="gaia_edr3_id" nullExpr="-9223372036854775808"/>
				<map key="hip_id" nullExpr="-2147483648"/>
				<map key="g_rp_resulting_flag" nullExpr="-32768"/>
				<map key="n_components" nullExpr="-32768"/>
				<map key="primary_flag" nullExpr="16959"/>
			</rowmaker>
		</make>
	</data>

	<service id="cone" allowed="form,scs.xml">
		<meta name="shortName">CNS5</meta>
		<meta name="testQuery">
			<meta name="ra">312.27882</meta>
			<meta name="dec">37.4712279</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="g_mag_resulting"/>
			<condDesc buildFrom="parallax"/>
			<condDesc buildFrom="cns5_id"/>
			<condDesc buildFrom="gj_id"/>
		</scsCore>
	</service>

	<regSuite title="cns5 regression">
		<regTest title="cns5 SCS serves some data">
			<url RA="312.2788230257468"
					DEC="37.47122796548486" SR="0.001"
					VERB="3"
				>cone/scs.xml</url>
			<code>
				row = self.getFirstVOTableRow()
				self.assertEqual(row['coordinates_bibcode'], '2020yCat.1350....0G')
				self.assertEqual(row['w2_mag_error'], None)
				self.assertAlmostEqual(row['g_mag'], 13.035794258117676)
			</code>
		</regTest>
	</regSuite>
</resource>
