<resource schema="citigbot" resdir=".">
	<meta name="creationDate">2024-10-30T12:13:20Z</meta>

	<meta name="title">Citizen Science for GBOT</meta>
	<meta name="description" format="rst">
		This archive collects and re-publishes third-party, mostly amateur,
		images of the Gaia astrometry satellite to complemement the Ground Based
		Optical Tracking (GBOT) effort.

		Until Gaia passivation, there is a temporary upload facility
		at https://dc.g-vo.org/citigbot/q/upload/form.
	</meta>
	<meta name="subject">space-probes</meta>

	<meta name="creator">Demleitner, M.; Altmann, M.</meta>
	<meta name="instrument">Various</meta>
	<meta name="facility">Various</meta>

	<meta name="source">https://www.cosmos.esa.int/web/gaia/observe-gaia</meta>
	<meta name="contentLevel">Research</meta>
	<meta name="type">Archive</meta>

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

	<!-- TODO: Switch this off when the campaign is over -->
	<execute id="limits" every="36000" title="Citigbot limits">
		<job><code>
			execDef.spawn("dachs limits \rdId".split())
		</code></job>
	</execute>

	<table id="main" onDisk="True" mixin="//siap2#pgs" adql="True">

		<!-- Comment in the following element once you're ready to publish;
			it will add your data to the obscore view
		<mixin preview="NULL">//obscore#publishObscoreLike</mixin>
		-->
		<column name="upload_date" type="timestamp"
			ucd="time.release"
			tablehead="Uploaded"
			description="Timestamp the dataset was uploaded to the GAVO data centre."
			verbLevel="15"/>
		<column name="nick" type="text"
			ucd="obs.observer"
			tablehead="Nick"
			description="Observer nickname; this is some free string they
				put in during upload."
			verbLevel="15"/>
	</table>

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

	<data id="import">
		<property name="stagingDir">data</property>
		<sources pattern="data/*.fits"/>

		<fitsProdGrammar maxHeaderBlocks="100">
			<rowfilter procDef="//products#define">
				<bind key="table">"\schema.main"</bind>
			</rowfilter>
		</fitsProdGrammar>

		<make table="main">
			<rowmaker>
				<apply procDef="//siap2#computePGS"/>

				<apply procDef="//siap2#setMeta">
					<bind key="dateObs">@FILTER</bind>
					<bind key="dateObs">@DATE_OBS</bind>

			 		<bind key="dataproduct_type">"image"</bind>
					<bind key="dataproduct_subtype">None</bind>
					<bind key="calib_level">2</bind>
					<bind key="obs_collection">"citizen GBOT"</bind>
					<bind key="obs_id">None</bind>

					<!-- titles are what users usually see in a selection, so
						try to combine band, dateObs, object..., like
						"MyData {} {} {}".format(@DATE_OBS, @TARGET, @FILTER) -->
					<bind key="obs_title">"GBOT "+str(@DATE_OBS)</bind>
					<bind key="obs_publisher_did">\standardPubDID</bind>
					<bind key="obs_creator_did">None</bind>
					<bind key="target_name">'Gaia'</bind>
					<bind key="target_class">"space-probes"</bind>

					<bind key="t_exptime">@EXPTIME if "EXPTIME" in vars else @EXPOSURE</bind>

					<bind key="o_ucd">"phot.count"</bind>
					<bind key="facility_name">None</bind>
					<bind key="instrument_name">None</bind>

					<bind key="t_xel">1</bind>
					<bind key="em_xel">1</bind>
					<bind key="pol_xel">None</bind>
				</apply>

				<map key="upload_date" source="GAVO_UPLOADED"/>
				<map key="nick" source="GAVO_NICK"/>
			</rowmaker>
		</make>
	</data>

	<service id="upload" allowed="form">
		<meta name="shortName">citigbot upload</meta>
		<meta name="title">Citizen GBOT Upload</meta>
		<meta name="_related" title="Images already uploaded"
			>\internallink{\rdId/browse/form}</meta>
		<meta name="description" format="rst">
			We have shut down the upload facility for citizen science
			GBOT observations because we think we have all there were
			made.  If you really have more data to add, please
			contact us by mail.</meta>
<!--		<meta name="_longdoc" format="rst">
The browser form interface is mainly intended for one-shot uploads.  If you
have a large number of images to upload, consider writing a script.
With python requests, you would use something like::

    import requests
    with open("/PATH/TO/YOUR/FILE, "rb") as f:
        requests.post("https://dc.g-vo.org/citigbot/q/upload/form",
                data={"nick": "YOUR NICK"},
                files={"File": ("upload.fits", f, "application/fits")}
            ).raise_for_status()
            </meta>

		<meta name="_intro" format="rst">
On this service, you are welcome to upload images taken of
the Gaia spacecraft during the XY (url) campaign.

Only FITS images with standard space calibration (WCS) are accepted.
If you do not know how to calibrate your images, see
https://astrometry.net/use.html.

We also require the following headers:

* DATE_OBS containing a UTC timestamp of the form
  YYYY-mm-ddTHH-MM-SS.  Prefer the GPS timescale (but do not worry
  too much about this).
* FILTER containing a free text describing any filters that you used.
  Say “clear” for optical observations without any filters.
* EXPTIME (we also accept EXPOSURE), the exposure time in seconds.

We ask you to include the following headers:

* SITELONG, SITELAT, SITEELEV: geographical coordinates, elevation above
  some reasonable definition of sea level
* CONTACT: some way to contact you.  Note that this will be public
  (although we do not expect spammers to harvest FITS files); do not
  use valuable contact data here.  It is unlikely that we will try to
  contact you after, say, April 2025.
</meta>
	
		<customCore module="res/publicupload"/> -->
		<nullCore/>
	</service>

	<service id="browse" allowed="form">
		<meta name="shortName">citigbot web</meta>
		<meta name="title">Browser interface to Citizen GBOT images</meta>
		<dbCore queriedTable="main">
			<condDesc original="//siap2#humanInput"/>
			<condDesc buildFrom="t_min"/>
			<outputTable autoCols="access_estsize,t_min,upload_date,nick">
				<column original="access_url"/>
				<column original="s_ra" displayHint="type=hms"/>
				<column original="s_dec" displayHint="type=dms"/>
			</outputTable>
		</dbCore>
	</service>

	<service id="i" allowed="siap2.xml">
		<meta name="shortName">citigbot sia</meta>
		<meta name="title">Citizen GBOT Images SIAP</meta>
		<meta name="sia.type">Pointed</meta>
		<meta name="testQuery.pos.ra">12.8509</meta>
		<meta name="testQuery.pos.dec">-17.61898</meta>
		<meta name="testQuery.size.ra">0.1</meta>
		<meta name="testQuery.size.dec">0.1</meta>

		<publish render="siap2.xml" sets="ivo_managed"/>
		<publish render="form" sets="ivo_managed,local" service="browse"/>

		<dbCore queriedTable="main">
			<FEED source="//siap2#parameters"/>
			<condDesc buildFrom="nick"/>
			<condDesc buildFrom="upload_date"/>
		</dbCore>
	</service>

	<regSuite title="citigbot regression">
		<regTest title="citigbot SIAP serves some data">
			<url POS="CIRCLE 12.8509 -17.6189 0.01" TIME="54702.33 54702.34"
				>i/siap2.xml</url>
			<code>
				row = self.getFirstVOTableRow()
				self.assertEqual(row['obs_id'],
					'ivo://org.gavo.dc/~?citigbot/data/d034c431-6924-3e16-8931-143368cd1045.fits')
				self.assertEqual(row['nick'], 'test user')
			</code>
		</regTest>
	</regSuite>
</resource>
