<!-- A template for a DaCHS EPN-TAP 2.0 service. 
To fill it out, search and replace %.*% 

Note that this assumes you want to publish files on your local disk.
If that's not true, you will probably want to remove the localfile mixin
and cut down on optional columns.

Note that this doesn't expose all features of DaCHS.  For advanced
projects, you'll still have to read documentation... -->
\tpldesc{Solar system data via EPN-TAP 2.0}

<resource schema="\resdir">
  <meta name="creationDate">\now</meta>

  \commonmeta
  <table id="epn_core" onDisk="True" adql="True">
    <publish sets="local,ivo_managed"/>
     <mixin
      spatial_frame_type="%one of celestial, body, cartesian, cylindrical, spherical, healpix, none%"
      optional_columns="%remove columns you don't need here%
        access_url access_format access_estsize access_md5
        thumbnail_url file_name species filter alt_target_name target_region
        feature_name bib_reference publisher spatial_coordinate_description
        spatial_origin time_origin time_scale"
      >//epntap2#table-2_0</mixin>
    <mixin>//epntap2#localfile-2_0</mixin>
    <!-- add non-standard columns here, like this:

    <column name="width" type="double precision"
      unit="m" ucd="phys.size"
      tablehead="Width"
      description="Object width in its rest frame, measured with the
        researcher's child's ruler."/>  -->
  </table>

  <data id="import">
    <sources pattern="%resdir-relative pattern, like data/*.txt%"/>

    <!-- the grammar really depends on your input material.  See
      http://docs.g-vo.org/DaCHS/ref.html#grammars-available,
      in particular cdfHeaderGrammar, fitsProdGrammar, or pdsGrammar.
      If nothing else fits, try a customGrammar. 
      
      If parsing from files, do not forget to use the products#define
      rowfilter (http://docs.g-vo.org/DaCHS/ref.html#products-define)
      as shown below. -->

      <rowfilter procDef="//products#define">
        <bind key="table">'\\schema.epn_core'</bind>
      </rowfilter>
    <fitsProdGrammar/>

    <make table="epn_core">
      <rowmaker idmaps="*">
        <!-- in the following, you can write python expressions (e.g., strings
          are in single or double quotes), and/or pull things from the
          records your grammar spits out with @key

          Just delete bind elements you can't fill.
          
          Refer to http://docs.g-vo.org/DaCHS/ref.html#epntap2-populate-2-0
          for more information on the parameters.
          -->

        <apply procDef="//epntap2#populate-2_0" name="fillepn">
          <bind key="c1_resol_max">%upper limit of spatial resolution in coordinate 1%</bind>
          <bind key="c1_resol_min">%lower limit of spatial resolution in coordinate 1%</bind>
          <bind key="c1min">%coverage, lower limit in the first coordinate%</bind>
          <bind key="c1max">%coverage, upper limit in the first coordinate%</bind>
          <bind key="c2_resol_max">%upper limit of spatial resolution in coordinate 2%</bind>
          <bind key="c2_resol_min">%lower limit of spatial resolution in coordinate 2%</bind>
          <bind key="c2min">%coverage, lower limit in the second coordinate%</bind>
          <bind key="c2max">%coverage, upper limit in the second coordinate%</bind>
          <bind key="c3_resol_max">%upper limit of spatial resolution in coordinate 3%</bind>
          <bind key="c3_resol_min">%lower limit of spatial resolution in coordinate 3%</bind>
          <bind key="c3min">%coverage, lower limit in the third coordinate%</bind>
          <bind key="c3max">%coverage, upper limit in the third coordinate%</bind>

          <bind key="creation_date">%Date of first entry of this granule%</bind>
          <bind key="dataproduct_type">%'im' for image, 'sp' for spectrum; see http://dc.g-vo.org/tableinfo/titan.epn_core#note-et_prod for what values are defined here.%</bind>
          <bind key="emergence_max">%Emergence angle during data acquisition, upper limit%</bind>
          <bind key="emergence_min">%Emergence angle during data acquisition, lower limit.%</bind>
          <bind key="granule_gid">%set to equal values to group related granules; make it a constant string if you don't have groups%</bind>
          <bind key="granule_uid">%Unique id for this thing (within this table; use \\srcstem if publishing files)%</bind>
          <bind key="incidence_max">%Incidence angle (solar zenithal angle) during data acquisition, upper limit%</bind>
          <bind key="incidence_min">%Incidence angle (solar zenithal angle) during data acquisition, lower limit.%</bind>
          <bind key="instrument_host_name">%see http://www.minorplanetcenter.net/iau/lists/ObsCodesF.html or http://nssdc.gsfc.nasa.gov/nmc/ for terms to use here%</bind>
          <bind key="instrument_name">%use complete name + usual acronym, as in 'VISIBLE AND INFRARED THERMAL IMAGING SPECTROMETER VIRTIS'%</bind>
          <bind key="measurement_type">%UCD(s) defining the data, with multiple entries separated by hash (#) characters.%</bind>
          <bind key="modification_date">%Date of last modification (used to handle mirroring; have a datetime instance or an ISO string here)%</bind>
          <bind key="obs_id">%Should be identical for granules resulting from the same observation; put in the file name if you have nothing else.%</bind>
          <bind key="phase_max">%Phase angle during data acquisition, upper limit%</bind>
          <bind key="phase_min">%Phase angle during data acquisition, lower limit.%</bind>
          <bind key="processing_level">%CODMAC calibration level; see http://dc.g-vo.org/tableinfo/titan.epn_core#note-et_cal for what values are defined here.%</bind>
          <bind key="release_date">%Start of public access period%</bind>
          <bind key="s_region">%A spatial footprint of a dataset located on a spherical coordinate system%</bind>
          <bind key="service_title">%An acronym helpful when combining rows from multiple services%</bind>
          <bind key="spectral_range_max">%Spectral range, upper limit, in Hz%</bind>
          <bind key="spectral_range_min">%Spectral range, lower limit, in Hz%</bind>
          <bind key="spectral_resolution_max">%Spectral resolution, upper limit, in Hz%</bind>
          <bind key="spectral_resolution_min">%Spectral resolution, lower limit, in Hz%</bind>
          <bind key="spectral_sampling_step_max">%Spectral sampling step, upper limit, in Hz%</bind>
          <bind key="spectral_sampling_step_min">%Spectral sampling step, lower limit, in Hz%</bind>
          <bind key="target_class">%Choose from asteroid, dwarf_planet, planet, satellite, comet, exoplanet, interplanetary_medium, ring, sample, sky, spacecraft, spacejunk, star, UNKNOWN%</bind>
          <bind key="target_name">%Name of the target object, preferably according to the official IAU nomenclature. As appropriate, take these from the exoplanet encyclopedia http://exoplanet.eu, the meteor catalog at http://www.lpi.usra.edu/meteor/, the catalog of stardust samples at http://curator.jsc.nasa.gov/stardust/catalog/%</bind>
          <bind key="target_region">%Substructure observed (e.g., Atmosphere, Surface). Take terms from them Spase dictionary at http://www.spase-group.org/docs/dictionary%</bind>

          <!-- for times, use dateTimeToJdn() to turn datetime instances 
            into the JD values required by epn-tap. -->
          <bind key="time_exp_max">%Integration time of the measurement, upper limit, in s%</bind>
          <bind key="time_exp_min">%Integration time of the measurement, lower limit, in s%</bind>
          <bind key="time_max">%Acquisition stop time (in JD)%</bind>
          <bind key="time_min">%Acquisition start time (in JD)%</bind>
          <bind key="time_sampling_step_max">%Sampling time for measurements of dynamical phenomena, upper limit, in s%</bind>
          <bind key="time_sampling_step_min">%Sampling time for measurements of dynamical phenomena, lower limit, in s%</bind>
          <bind key="time_scale">%Time scale used for the various times. Choose from TT, TDB, TOG, TOB, TAI, UTC, GPS, UNKNOWN%</bind>
          <bind key="time_origin">%Reference position used for the various times. The standard is a bit vague at this time. Remove this if unsure.%</bind>
        </apply>

        <apply procDef="//epntap2#populate-localfile-2_0"/>

        <!-- fill your custom columns with elements like
          <map dest="my_col_name">"foo"+@bar+"quux"</map>
        -->
      </rowmaker>
    </make>
  </data>				



  <regSuite title="\resdir regression">
    <regTest title="\resdir EPN-TAP serves some data">
      <url parSet="TAP" QUERY="SELECT * from \resdir.epn_core
          WHERE granule_uid='foo/bar'"
        >/tap/sync</url>
      <code>
        rec = self.getFirstVOTableRow()
        print(rec)
        self.fail("write some assertions about the record just shown")
      </code>
    </regTest>
  </regSuite>
</resource>
