<resource schema="plts">
	<meta name="creationDate">2015-12-01T11:00:00</meta>
	<meta name="schema-rank">100</meta>
	<meta name="doi">10.21938/8jkMIdbl9xGrJn6_GDTzWA</meta>
	<meta name="title">Scans of the Palomar-Leiden Trojan Survey Plates</meta>
	<meta name="creator">van Houten-Groeneveld, I.; van Houten, C.J.;
		Wisse-Schouten, M.; Bardwell, C.; Gehrels, T.</meta>
	<meta name="description" format="rst">
		This service publishes plate scans of the Palomar-Leiden Troian
		surveys conducted between 1960 and 1977.  The surveys led to the
		discovery of more than 2,000 asteroids (1,800 with orbital information),
		with another 2,400 asteroids, including 19 Trojans, found after further
		analysis of the plates.

		Note that because of the large size of the plates, in this service each
		original plate is contained in two parts, marked with "_1" and "_2",
		respectively.  The central parts
		of the two parts overlap.
	</meta>

	<meta name="subject">jupiter-trojans</meta>
	<meta name="subject">trojan-asteroids</meta>
	<meta name="subject">wide-field-telescopes</meta>
	<meta name="subject">orbit-determination</meta>

	<meta name="source">1989A&amp;A...224..299V</meta>
	<meta name="type">Survey</meta>
	<meta name="instrument">122-cm Schmidt telescope</meta>
	<meta name="facility">Palomar Observatory</meta>

	<meta name="servedBy">ivo://org.gavo.dc/hppunion/q/im</meta>
	<meta name="_related" title="hppunion VO service">/hppunion/q/im/info</meta>

	<meta>
		date: 2023-11-08
		date.role: ExportRequested
	</meta>

	<meta name="_copyright">
		Based on photographic plates obtained with the Samuel Oschin telescope
		at Palomar Observatory.

		Digitization project by the Astronomisches Rechen-Institut (ARI/ZAH),
		Heidelberg in collaboration with the Institut fuer Erdmessung (IFE),
		Hannover and funded by the Klaus Tschira Foundation gGmbH.
	</meta>

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

	<meta name="_longdoc" format="rst"><![CDATA[
		Emulsion and Filter
		===================

		Most plates had a Kodak 103a-O emulsion, exposed through a WG-2 filter.

		One pair per field was taken each month on Kodak 103a-D emulsion,
		using a Y-6 filter.

		Best effort is made in determining emulsion and filter;
		metadata regarding those values are incomplete.
	]]></meta>

	<table id="data" mixin="//siap#pgs" onDisk="True">
		<publish sets="ivo_managed" services="//tap#run,hppunion/q#im"/>

		<index columns="object"/>
		<index columns="bandpassHi"/>
		<index columns="bandpassLo"/>

		<mixin
			calibLevel="1"
			collectionName="'PLTS'"
			facilityName="'Palomar Observatory'"
			instrumentName="'122-cm Schmidt'"
			expTime="exposure"
			tMin="dateObs-exposure/86400"
			tMax="dateObs+exposure/86400"
		>//obscore#publishSIAP</mixin>

		<column original="accref">
    <property name="targetType"
			>application/x-votable+xml;content=datalink</property>
			<property name="targetTitle">Datalink</property>
		</column>

		<column name="dateObs"  type="double precision"  xtype="mjd"
			unit="d"
			ucd="VOX:Image_MJDateObs"
			tablehead="Obs. date"
			description="Epoch at midpoint of observation"
			displayHint="type=humanDate"
			verbLevel="0">
			<values min="37201.277071759105" max="43438.480023148004"/>
		</column>
		<column name="platenum" type="text"
			tablehead="Plate ID"
			ucd="meta.id"
			description="Plate ID"
			verbLevel="1"/>
		<column name="platepart" type="smallint" required="True"
			tablehead="Plate Part"
			ucd="meta.id.part"
			description="Scan index.  Since the scanner used to digitise
				the plate was physically smaller than the plates, each plate
				scan consists of two parts. This number is either 1 or 2
				correspondingly."
			verbLevel="15"/>
		<column name="wfpdb_id" type="text"
			ucd="meta.id"
			tablehead="WFPDB"
			description="Plate identifier as in the WFPDB"
			verbLevel="15"/>
		<column name="exposure"
			tablehead="Exp. time"
			ucd="time.duration;obs.exposure" unit="s"
			description="Effective exposure time"
			verbLevel="15"/>
		<column name="obsnotes" type="text"
			tablehead="Notes"
			ucd="meta.note"
			description="Observation Notes"
			verbLevel="18"/>
		<column name="emulsion"  type="text"
			ucd="instr.plate.emulsion"
			tablehead="Emulsion"
			description="Emulsion of the original plate"
			verbLevel="21" note="e"/>
		<column name="pub_did" type="text"
			ucd="meta.id;meta.main"
			tablehead="PubDID"
			description="Publisher data set id; this is an identifier for
				the dataset in question and can be used to retrieve the data through,
				e.g., datalink."
			verbLevel="1"/>
		<column name="object" type="text"
			tablehead="Targ. Obj."
			ucd="meta.id"
			description="Special object on plate"
			verbLevel="15"/>

		<meta name="note" tag="e">
		Most exposures were made on Kodak 103a-O emulsion, with a WG2 filter.

		One pair per field was taken each month on Kodak 103a-D emulsion,
		using a Y-6 filter.

		Best effort is made in this service to reliably identify
		the emulsion and filter used in each exposure, but
		plate metadata has been incomplete.  Use the information with
		caution.
		</meta>
	</table>

	<coverage>
		<updater spaceTable="data" spectralTable="data" mocOrder="6"/>
		<spectral>3.00977e-19 6.01953e-19</spectral>
		<temporal>37190 37250</temporal>
		<temporal>38776 38802</temporal>
		<temporal>41022 41107</temporal>
		<temporal>41387 41409</temporal>
		<temporal>41936 41979</temporal>
		<temporal>43416 43454</temporal>
		<spatial>2/70,102 3/10,80-82,96-97,160,162,270-271,275,284,286-287,293,304-305,307-310,397,399,403,432,434-435,439,441,443-444,446,700-701,703 4/32,34-35,44,46,128-130,279,285,299,302,332-334,336-338,353,392-393,395-398,402,646,652,654,672-673,1071,1075,1077-1079,1091,1094-1095,1097,1099,1112,1114-1115,1140,1142-1143,1168-1169,1171,1180-1181,1224-1225,1244-1245,1253,1264,1567,1593,1595,1609-1611,1626,1648,1684-1685,1687,1693,1732,1734-1735,1751-1752,1754,1761,1763,1771,1781,1788,1790,1952,1954-1955,1960,2783,2808-2809,2811</spatial>
			
	</coverage>

	<data id="import" recreateAfter="hppunion/q#import">
		<property key="previewDir">previews</property>
		<sources recurse="True">
			<pattern>data/*.fits</pattern>
			<ignoreSources pattern="data/SubPlates/*"/>
		</sources>
		<fitsProdGrammar>
			<rowfilter procDef="//products#define">
				<bind key="table">"\schema.data"</bind>
				<bind key="path">\dlMetaURI{dl}</bind>
				<bind key="mime">'application/x-votable+xml;content=datalink'</bind>
				<bind name="preview_mime">"image/jpeg"</bind>
        <bind name="preview">\standardPreviewPath</bind>
			</rowfilter>
			<rowfilter>
				<doc>
					Yield only calibrated rows/products
				</doc>
				<code>
					if "WCSAXES" in row:
						yield row
				</code>
			</rowfilter>
		</fitsProdGrammar>

		<make table="data">
			<rowmaker id="pls_rmk">
				<apply procDef="//procs#dictMap">
					<bind name="key">"EMULSION"</bind>
					<bind name="mapping">{
						"103-aD": "103a-D",
						"103-aO": "103a-O",
						"103a-D": "103a-D",
						"103a-O": "103a-O",
						"103a-D": "103a-D",
						"103a-O": "103a-O",
					}</bind>
				</apply>

				<apply>
					<code>
						@bandpass = "+".join(
							a for a in [@EMULSION, @FILTER] if a is not None)
					</code>
				</apply>

				<apply procDef="//siap#computePGS"/>
				<apply procDef="//siap#setMeta">
					<bind name="dateObs"
						>dateTimeToMJD(datetime.datetime.strptime(
							@DATE_OBS, '%Y-%m-%dT%H:%M:%S'))</bind>
					<bind name="bandpassId">@bandpass</bind>
					<bind name="title">"Palomar/Leiden %s %s"%tuple(
						\inputRelativePath[:-5].split("/")[-2:])</bind>
					<bind name="instrument">'122-cm Schmidt telescope'</bind>
				</apply>
				<apply procDef="//siap#getBandFromFilter"/>

				<simplemaps>
					platenum: PLATENUM,
					platepart: PLATPART,
					wfpdb_id: WFPDB_ID,
					exposure: EXPTIME,
					emulsion: EMULSION
				</simplemaps>

				<map key="platenum">@PLATENUM.split("_")[0]</map>
				<map key="obsnotes">vars.get("OBSNOTES")</map>
				<map key="pub_did">\standardPubDID</map>
				<map key="object">None</map>
			</rowmaker>
		</make>
	</data>

	<service id="dl" allowed="dlget,dlmeta,static">
		<property key="staticData">data/static</property>

		<meta name="title">PLTS Datalink</meta>
		<meta name="description">This service lets you access cutouts
			from the Palomar/Leiden Trojan plates and retrieve scaled versions.
		</meta>
		<datalinkCore>
			<descriptorGenerator procDef="//soda#fits_genDesc"
				name="genFITSDesc">
				<bind key="accrefPrefix">'plts/data'</bind>
				<bind key="descClass">DLFITSProductDescriptor</bind>
			</descriptorGenerator>

			<FEED source="//soda#fits_standardDLFuncs" stcs=" "/>

			<metaMaker semantics="#auxiliary">
				<code>
					service = rd.getById("dl")

					yield descriptor.makeLink(
						service.getURL("dlget")+"?SCALE=4&amp;ID="+urllib.parse.quote(
							descriptor.pubDID),
						contentType="application/fits",
						description="FITS, scaled by 1/4",
						contentLength=descriptor.estimateSize()/16.)

					yield descriptor.makeLink(
						service.getURL("dlget")+"?SCALE=16&amp;ID="+urllib.parse.quote(
							descriptor.pubDID),
						contentType="application/fits",
						description="FITS, scaled by 1/16",
						semantics="#preview-image",
						contentLength=descriptor.estimateSize()/256.)
				</code>
			</metaMaker>

			<metaMaker name="make_index_card_link" semantics="#documentation">
				<code>
					plateno = descriptor.accref.split("/")[-1][:-5
						].split("_")[0].lstrip("0")
					yield descriptor.makeLinkFromFile(
						"data/static/indexcards/PLTS_{}.jpg".format(plateno),
						description="Index card for this observation",
						semantics="#documentation")
					yield descriptor.makeLinkFromFile(
						"data/static/marked/{}.jpg".format(plateno),
						description="Plate photos with original marks by van Houten"
							" (before cleaning).",
						semantics="#documentation")

				</code>
			</metaMaker>
		</datalinkCore>
	</service>

	<service id="web">
		<meta name="shortName">plts plates</meta>
		<publish sets="local" render="form"/>
		<dbCore queriedTable="data">
			<condDesc buildFrom="imageTitle"/>
			<condDesc buildFrom="dateObs"/>
			<condDesc>
				<inputKey name="hscs_pos" type="text"
					description= "Coordinates (as h m s, d m s or decimal degrees)
					or SIMBAD-resolvable object the plate must contain"
					tablehead="Plate contains"/>
				<phraseMaker>
					<setup original="//scs#scsSetup"/>
					<code>
						ra, dec = getRADec(inPars, outPars)
						yield "spoint(%%(%s)s, %%(%s)s) @ coverage"%(
							base.getSQLKey("RA", ra*DEG, outPars),
							base.getSQLKey("Dec", dec*DEG, outPars))
					</code>
				</phraseMaker>
			</condDesc>
		</dbCore>

		<outputTable namePath="plates"
			autoCols="accref, accsize, imageTitle, centerAlpha, centerDelta,
				dateObs, exposure, emulsion, bandpassId"/>
	</service>

	<regSuite title="PLTS services">
		<regTest title="PLTS web">
			<url parSet="form"
				hscs_pos="5.05 14.05"
				dateObs="1960-09-24T06:38:58 +/- 0.2">/plts/q/web/form</url>
			<code><![CDATA[
				self.assertHasStrings(
					"getproduct/plts/data/1960Sep_PLS/04573_1.fits",
					"<td>600.0</td>",
					"<td>1960-09-24T06:38:59Z</td>")
			]]></code>
		</regTest>

		<regTest title="PLTS preview">
			<url>/getproduct/plts/data/1960Sep_PLS/04573_1.fits?preview=True</url>
			<code>
				self.assertHasStrings("JFIF")
			</code>
		</regTest>

		<regTest title="PLTS datalink">
			<url httpHonorRedirects="True"
				>/getproduct/plts/data/1960Sep_PLS/04573_1.fits</url>
			<code>
				bySemantics = {}
				for r in self.getVOTableRows():
					bySemantics.setdefault(r["semantics"], []).append(r)

				self.assertTrue(bySemantics["#this"][0]["access_url"
					].endswith("plts/q/dl/dlget?ID=ivo%3A//org.gavo.dc/"
						"~%3Fplts/data/1960Sep_PLS/04573_1.fits"))
				self.assertEqual(bySemantics["#this"][0]["content_type"],
					"application/fits")
				self.assertEqual(bySemantics["#this"][0]["content_qualifier"],
					"#image")

				self.assertTrue(bySemantics["#auxiliary"][0]["access_url"
					].endswith("/plts/q/dl/dlget?SCALE=4&amp;ID=ivo%3A//org.gavo.dc/"
						"~%3Fplts/data/1960Sep_PLS/04573_1.fits"))
				self.assertEqual(bySemantics["#auxiliary"][0]["content_type"],
					"application/fits")

				self.assertTrue(bySemantics["#preview-image"][0]["access_url"
					].endswith("/plts/q/dl/dlget?SCALE=16&amp;ID=ivo%3A//org.gavo.dc/"
						"~%3Fplts/data/1960Sep_PLS/04573_1.fits"))
				self.assertEqual(bySemantics["#auxiliary"][0]["content_type"],
					"application/fits")
		
			</code>
		</regTest>

		<regTest title="datalink scaling gives a FITS">
			<url SCALE="16"
				ID="ivo://org.gavo.dc/~?plts/data/1960Sep_PLS/04573_1.fits"
				>dl/dlget</url>
			<code>
				self.assertHasStrings(
					"DATEORIG= '1960-09-24.27708'",
					"PLATENUM= '04573   '",
					"IMSHRINK= 'Image scaled down 16-fold by DaCHS'")
			</code>
		</regTest>

		<regTest title="PLTS is in hppunion">
			<url
				POS="5.05,14.05"
				SIZE="0.1,0.1"
				dateObs="37201.25/37201.3"
				>/hppunion/q/im/siap.xml</url>
			<code>
				row = self.getFirstVOTableRow(rejectExtras=False)
				self.assertEqual(row["mime"],
					"application/x-votable+xml;content=datalink")
				self.assertTrue(row["accref"].endswith(
					"getproduct/plts/data/1960Sep_PLS/04573_1.fits"))
				self.assertAlmostEqual(row["bandpassLo"], 3.3e-07)
			</code>
		</regTest>

		<regTest title="PLTS is in obscore">
			<url parSet="TAP"
				QUERY="SELECT * FROM ivoa.obscore WHERE
					t_min&gt;37201 and t_max&lt;37201.29
					AND 1=CONTAINS(POINT('ICRS', 5, 14), s_region)"
				>/tap/sync</url>
			<code>
				row = self.getFirstVOTableRow(rejectExtras=False)
				self.assertAlmostEqual(row["em_min"], 3.3e-7)
				self.assertEqual(row["obs_title"], "Palomar/Leiden 1960Sep_PLS 04573_1")
				self.assertEqual(row["obs_publisher_did"],
					"ivo://org.gavo.dc/~?plts/data/1960Sep_PLS/04573_1.fits")
				self.assertEqual(row["instrument_name"], '122-cm Schmidt')
			</code>
		</regTest>
	</regSuite>
</resource>
