<resource schema="tenpc" resdir="10pcsample">
  <meta name="creationDate">2021-05-03T09:52:10Z</meta>

  <meta name="title">The 10 parsec sample in the Gaia era</meta>
  <meta name="schema-rank">100</meta>
  <meta name="description">
    A catalogue of 541 nearby (within 10pc of the sun) stars, brown dwarfs, and
    confirmed exoplanets in 336 systems, as well 21 candidates, compiled from
    SIMBAD and several other sources. Where available, astrometry and
    photometry from Gaia eDR3 has been inserted.
  </meta>
  <meta name="subject">stellar-parallax</meta>
  <meta name="subject">exoplanets</meta>
  <meta name="subject">solar-neighborhood</meta>
  <meta name="subject">galaxy-stellar-content</meta>
  <meta name="subject">late-type-stars</meta>

  <meta name="_news" author="MD" date="2021-05-18">
    New upstream data pre-publication, deleting one object.
  </meta>
  <meta name="_news" author="MD" date="2023-02-03" format="rst">
    Updated data to version 2; changelog: https://zenodo.org/record/7576096.
  </meta>
  <meta name="version">2</meta>

  <meta name="_longdoc" format="rst">
  	Bulk Downloads
  	--------------

  	Bulk downloads of the dataset and its previous versions are availble:

  	* `Version 1`_
  	* `Version 2`_

  	.. _Version 1: /\rdId/cone/static/The10pcSample_v1.fits
  	.. _Version 2: /\rdId/cone/static/The10pcSample_v2.fits
  </meta>

  <meta name="creator">Reylé, C.; Jardine, K.; Fouqué, P.;
    Caballero, J. A.; Smart, R. L.; Sozzetti, A.</meta>

  <meta name="source">Astron. Astrophys., submitted</meta>
  <meta name="contentLevel">Research</meta>
  <meta name="contentLevel">General</meta>
  <meta name="type">Catalog</meta>

  <table id="main" onDisk="True" mixin="//scs#q3cindex" adql="True">
    <column name="nb_obj" type="smallint" required="True"
      ucd="meta.id;meta.main"
      tablehead="Obj. id"
      description="Running number for object, ordered by increasing distance"
      verbLevel="1"/>
    <column name="nb_sys" type="smallint" required="True"
      tablehead="System id"
      ucd="meta.id.parent"
      description="Running number for system, ordered by increasing distance"
      verbLevel="1"/>
    <column name="system_name" type="text"
      ucd="meta.id.parent"
      tablehead="System name"
      description="Name of the system"
      verbLevel="15"/>
    <column name="obj_cat" type="text"
      ucd="meta.code.class"
      tablehead="Category"
      description="One of Star (*), LM (low mass star), BD (brown dwarf),
        WD (white dwarf), or Planet"
      verbLevel="1">
      <values>
        <option title="Star">*</option>
        <option title="Low-mass Star">LM</option>
        <option title="Low-mass Star Cand.">LM?</option>
        <option title="Brown Dwarf">BD</option>
        <option title="Brown Dwarf Cand.">BD?</option>
        <option title="White Dwarf">WD</option>
        <option title="White Dwarf Cand.">WD?</option>
        <option title="Planet">Planet</option>
      </values>
    </column>
    <column name="obj_name" type="text"
      ucd="meta.id"
      tablehead="Object Name"
      description="Adopted name of the object"
      verbLevel="1"/>

    <column name="ra" type="double precision"
      unit="deg" ucd="pos.eq.ra;meta.main"
      tablehead="RA"
      description="Right ascension at epoch (ICRS)"
      verbLevel="1"
      displayHint="type=hms"/>
    <column name="dec" type="double precision"
      unit="deg" ucd="pos.eq.dec;meta.main"
      description="Declination at epoch (ICRS)"
      verbLevel="1"
      displayHint="type=dms"/>
    <column name="epoch" type="real"
      unit="yr" ucd="time.epoch"
      description="Epoch for ra and dec"
      verbLevel="25"/>
    <column name="parallax" type="double precision"
      unit="mas" ucd="pos.parallax.trig"
      description="Trigonometric parallax"
      verbLevel="1"
      displayHint="sf=3"/>
    <column name="parallax_error" type="double precision"
      unit="mas" ucd="stat.error;pos.parallax"
      tablehead="Err. π"
      description="Parallax uncertainty"
      verbLevel="15"
      displayHint="sf=2"/>
    <column name="parallax_bibcode" type="text"
      ucd="meta.bib;pos.parallax"
      tablehead="Src. π"
      description="Reference for the parallax; missing values here mean
        the parallax is taken from another member of the system"
      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="15"
      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="Proper motion uncertainty in right ascension"
      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="15"
      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="Proper motion uncertainty in declination"
      verbLevel="15"
      displayHint="sf=2"/>
    <column name="pm_bibcode" type="text"
      ucd="meta.ref;pos.pm;pos.eq.ra"
      tablehead="Src. PM"
      description="Reference for the proper motion; missing values here
        mean that the proper motion was taken from another member of
        the system"
      verbLevel="25"
      displayHint="type=bibcode"/>
    <column name="rv" type="real"
      unit="km/s" ucd="spect.dopplerVeloc"
      tablehead="RV"
      description="Line-of-sight velocity"
      verbLevel="1"
      displayHint="sf=2"/>
    <column name="rv_error" type="real"
      unit="km/s" ucd="stat.error;spect.dopplerVeloc"
      tablehead="Err. RV"
      description="Line-of-sight velocity uncertainty"
      verbLevel="15"
      displayHint="sf=3"/>
    <column name="rv_bibcode" type="text"
      ucd="meta.ref;spect.dopplerVeloc"
      tablehead="Src. RV"
      description="Reference for the line-of-sight velocity"
      verbLevel="25"
      displayHint="type=bibcode"/>
    <column name="sp_type" type="text"
      ucd="src.sptype"
      tablehead="Spectral"
      description="Spectral type"
      verbLevel="1"/>
    <column name="sp_bibcode" type="text"
      ucd="meta.ref;src.sptype"
      tablehead="Src. Spectral"
      description="Reference for spectral type"
      verbLevel="25"
      displayHint="type=bibcode"/>
    <column name="sp_method" type="text"
      ucd="meta.code"
      tablehead="Spec. Meth."
      description="Method used to derive the spectral type"
      verbLevel="25"/>
    <column name="g_code" type="smallint"
      ucd="meta.code;phot.mag;em.opt.V"
      tablehead="Src. G"
      description="Source of the value of the G magnitude (see note)"
      verbLevel="25"
      note="g">
      <values nullLiteral="-1"/>
    </column>
    <column name="mag_g" type="double precision"
      unit="mag" ucd="phot.mag;em.opt.V"
      tablehead="m_G"
      description="Gaia G band magnitude measured (when g_code is 2 or 3)"
      verbLevel="1"
      displayHint="sf=3"/>
    <column name="mag_g_estimate" type="real"
      unit="mag" ucd="phot.mag;em.opt.V"
      tablehead="Est. G"
      description="Estimated Gaia G band magnitude (when g_code is not 2 or 3)"
      verbLevel="1"
      displayHint="sf=1"/>
    <column name="mag_gbp" type="double precision"
      ucd="phot.mag;em.opt.B"
      tablehead="m_BP"
      description="Gaia BP band magnitude"
      verbLevel="15"
      displayHint="sf=2"/>
    <column name="mag_grp" type="double precision"
      ucd="phot.mag;em.opt.R"
      tablehead="m_RP"
      description="Gaia RP band magnitude"
      verbLevel="15"
      displayHint="sf=2"/>

    <LOOP>
      <csvItems>
        name, band, ucd
        u, U, opt.U
        b, B, opt.B
        v, V, opt.V
        r, R, opt.R
        i, I, opt.I
        j, J, ir.J
        h, H, ir.H
        k, K, ir.K
      </csvItems>
      <events>
        <column name="mag_\name" type="real"
          unit="mag" ucd="phot.mag;em.\ucd"
          description="Magnitude in \band"
          verbLevel="15"
          displayHint="sf=2"/>
      </events>
    </LOOP>

    <column name="system_bibcode" type="text"
      ucd="meta.ref"
      tablehead="Src. Multip."
      description="Reference for multiplicity or exoplanets"
      verbLevel="25"
      displayHint="type=bibcode"/>
    <column name="exoplanet_count" type="smallint"
      ucd="meta.number"
      tablehead="#Planets"
      description="Number of confirmed exoplanets"
      verbLevel="15">
      <values nullLiteral="-1"/>
    </column>
    <column name="gaia_dr2" type="bigint"
      ucd="meta.id.cross"
      tablehead="DR2 id"
      description="Gaia DR2 identifier"
      verbLevel="25">
      <values nullLiteral="-1"/>
    </column>
    <column name="gaia_edr3" type="bigint"
      ucd="meta.id.cross"
      tablehead="DR3 id"
      description="Gaia DR3 identifier"
      verbLevel="15">
      <values nullLiteral="-1"/>
    </column>
    <column name="simbad_name" type="text"
      ucd="meta.id.cross"
      tablehead="SIMBAD"
      description="Name resolved by SIMBAD"
      verbLevel="25"/>
    <column name="common_name" type="text"
      ucd="meta.id"
      tablehead="Common name"
      description="Common name"
      verbLevel="15"/>
    <column name="gj" type="text"
      ucd="meta.id.cross"
      tablehead="GJ id"
      description="Gliese and Jahreiß catalogue identifier"
      verbLevel="25"/>
    <column name="hd" type="text"
      ucd="meta.id.cross"
      tablehead="HD"
      description="Henry Draper catalogue identifier"
      verbLevel="25"/>
    <column name="hip" type="text"
      ucd="meta.id.cross"
      tablehead="HIP"
      description="Hipparcos catalogue identifier"
      verbLevel="25"/>
    <column name="comment" type="text"
      ucd="meta.note"
      description="Additional comments on exoplanets, multiplicity, etc"
      verbLevel="1"/>

    <meta name="note" tag="g">
      g_code is:

      :2:
        retrieved from Gaia DR2
      :3:
        retrieved from Gaia eDR3
      :10:
        Estimated from spectral type via the calibration of absolute
        magnitude versus spectral type computed within GCNS.
      :20:
        Estimated from M_G=25 (i.e., a lower limit).  This is
        used for late T and Y brown drawfs too faint for Gaia.
    </meta>
  </table>

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

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

  <data id="import">
    <sources pattern="data/The10pcSample_v2.1.fits"/>

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

    <make table="main">
      <rowmaker idmaps="*">
        <apply name="resolve_bibcode_xrefs">
          <!-- in the first version, there were cross references in
          a few bibcode columns.  This apply resolves these, and
          it can go when these cross references are gone. -->
          <setup>
            <code>
              MAPPINGS = [
                ("parallax_bibcode", {}),
                ("pm_bibcode", {}),]
            </code>
          </setup>
          <code>
            for colName, known_vals in MAPPINGS:
              val = utils.debytify(vars[colName])
              if val is None:
                continue
              if val.startswith("FROM:"):
                vars[colName] = known_vals.get(val[5:])
              else:
                known_vals[vars["obj_name"]] = val
          </code>
        </apply>

        <LOOP listItems="g g_estimate gbp grp u b v r i j h k">
          <events>
            <map key="mag_\item" source="\item"/>
          </events>
        </LOOP>

        <LOOP listItems="system_name rv_bibcode sp_type sp_bibcode sp_method
          system_bibcode simbad_name common_name gj hd hip ">
          <events>
            <map key="\item" nullExpr="''">@\item</map>
          </events>
        </LOOP>

        <map key="comment" nullExpr="'...'"/>
        <map key="g_code" nullExpr="-32768"/>
        <map key="gaia_dr2" nullExpr="-9223372036854775808"/>
        <map key="gaia_edr3" nullExpr="-9223372036854775808"/>
        <map key="exoplanet_count" nullExpr="-32768"/>
      </rowmaker>
    </make>
  </data>

  <service id="cone" allowed="form,scs.xml,static">
    <property name="staticData">data</property>
    <meta name="shortName">10pc SCS</meta>
    <meta name="testQuery">
      <meta name="ra">39.677</meta>
      <meta name="dec">-13.54</meta>
      <meta name="sr">0.1</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="obj_cat"/>
      <condDesc buildFrom="parallax"/>
      <condDesc buildFrom="mag_g"/>
      <condDesc buildFrom="mag_j"/>
    </scsCore>
  </service>

  <regSuite title="10pcsample regression">
    <regTest title="10pcsample SCS serves some data">
      <url RA="39.677"
          DEC="-13.54" SR="0.1"
        >cone/scs.xml</url>
      <code>
        row = self.getFirstVOTableRow()
        self.assertEqual(row["nb_sys"], 1018)
        self.assertAlmostEqual(row['mag_g_estimate'], 25.329999923706055)
        self.assertEqual(row["common_name"], "")
      </code>
    </regTest>

    <regTest title="Options properly rendered in HTML">
      <url parSet="form" obj_cat='LM?'>cone/form</url>
      <code><![CDATA[
        self.assertHasStrings("41 Ara Bb",
          '<option value="LM?" selected="selected">Low-mass Star Cand.</option>'
          )
      ]]></code>
    </regTest>
  </regSuite>
</resource>
<!-- vim:et:sw=2:sta
-->
