<?xml version="1.0" encoding="utf-8"?>

<resource resdir="lswscans" schema="lsw">

	<meta name="creationDate">2007-11-10T12:00:00Z</meta>
	<meta name="schema-rank">20</meta>
	<meta name="description">Scans of plates kept at Landessternwarte
		Heidelberg-Königstuhl. They were obtained at location, at the
		German-Spanish Astronomical Center (Calar
		Alto Observatory), Spain, and at La Silla, Chile.  The
		plates cover a time span between 1880 and 1999.
		
		Specifically, HDAP is essentially complete for the plates taken
		with the Bruce telescope, the Walz reflector, and Wolf's
		Doppelastrograph at both the original location in Heidelberg and
		its later home on Königstuhl.</meta>
	<meta name="title">HDAP -- Heidelberg Digitized Astronomical Plates</meta>
	<meta name="creator">
		<meta name="name">Mandel, H.</meta></meta>
	<meta name="creator">
		<meta name="name">Birkle, K.</meta></meta>
	<meta name="creator">
		<meta name="name">Demleitner, M.</meta></meta>
	<meta name="creator">
	<meta name="name">Landessternwarte Heidelberg</meta></meta>

	<meta name="subject">history-of-astronomy</meta>
	<meta name="subject">astrophotography</meta>

	<meta name="source">
		http://www.lsw.uni-heidelberg.de/projects/scanproject</meta>
	<meta name="facility">Landessternwarte Heidelberg-Königstuhl</meta>
	<meta name="facility">Max-Planck-Institut für Astronomie Heidelberg</meta>
	<meta>
		instrument:Bruce Double Astrograph
		instrument.altIdentifier: handle:21.11157/e3c244b9-0463-4bb8-b344-371a3a125bbd
		instrument:Calar Alto Schmidt Telescope
		instrument.altIdentifier: handle:21.11157/9109c874-6594-4f7f-be2e-5bf468e666d7
		instrument:Calar Alto 1.23m Cassegrain
		instrument.altIdentifier: handle:21.11157/cf02228a-ad05-49a8-845c-f63375fbfe6c
		instrument:72cm Walz Reflector
		instrument.altIdentifier: handle:21.11157/4cc8b2fb-accd-49d2-b42b-6ed97cf9a084
		instrument:Calar Alto 2.2m Cassegrain
		instrument.altIdentifier: handle:21.11157/69257fe4-78c8-4aab-b210-9fcf0a807822

		instrument:Calar Alto 3.5m 3-lens corrected
		instrument.altIdentifier: handle:21.11157/4e51e0be-1907-43a5-b7eb-4e7ba22c9927
		instrument:Calar Alto 3.5m 2-lens corrected
		instrument.altIdentifier: handle:21.11157/69257fe4-78c8-4aab-b210-9fcf0a807822
		instrument:2.2m MPG telescope at La Silla
		instrument.altIdentifier: handle:21.11157/fecb2a8f-d30c-4e95-9d08-645ef73b93ef
		instrument:Wolf's 15cm Doppelastrograph Königstuhl
		instrument.altIdentifier: handle:21.11157/504726ca-6721-481b-b1d6-b8044ae64e55
		instrument:Wolf's 15cm Doppelastrograph Märzgasse
		instrument.altIdentifier: handle:21.11157/c480a798-0a23-4db9-bf2a-6f6923ca160f
	</meta>
	<meta name="copyright" format="rst">If you use
		this data, please
		acknowledge: "This work made use of the HDAP which was produced at
		Landessternwarte Heidelberg-Königstuhl under grant No. 00.071.2005
		of the Klaus-Tschira-Foundation."
		
		The data in this service was calibrated using Astrometry.net,
		:bibcode:`2010AJ....139.1782L`.
	
	</meta>
	<FEED source="//procs#license-cc0" what="the HDAP scans"/>

	<meta name="sia.maxImageExtent.long">360</meta>
	<meta name="sia.maxImageExtent.lat">6</meta>
	<meta name="doi">10.21938/haTEMZmoaCTEK6XZvGU.fQ</meta>

	<meta name="_longdoc" format="rst"><![CDATA[
The scanning of the plate archive at Landessternwarte Heidelberg
was initiated by Holger Mandel and Kurt Birkle in 2006 and was funded by the
Klaus-Tschira-Foundation.  Almost all usable direct plates in the archives
are now scanned, and the funded phase of the project is over.  Only
minor additions are expected any more.


Sources
=======

The plate archive consists of plates from many different sources.
The following table gives an overview of the instruments at which
the plates were taken:

+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| plate  |    name          | eff. focal | aperture | scale   | plate size | latitude  | longitude | height |
| letter |                  | length [mm]| ratio    | [as/mm] |            |           |           |        |
+========+==================+============+==========+=========+============+===========+===========+========+
| A      | Calar Alto       | 2400       | f/3      | 86      | 24x24cm    | 37.22417  | +2.5375   | 2168 m |
|        | Schmidt telescope|            |          |         |            | N         | W         |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| B      | Königstuhl       | 2000       | f/5      | 103     | 24x30cm or | 49.39861  | -8.72083  | 560 m  |
|        | Bruce telescope  |            |          |         | 30x30cm    | N         | E         |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| C      | 1.23m in Casseg. | 9857       | f/8      | 20.9    | 24x24cm    | 37.22361  | +2.5461   | 2138 m |
|        | focus with       |            |          |         |            | N         | W         |        |
|        | corrector        |            |          |         |            |           |           |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| D      | 72cm Walz-       | 2815       | f/3.9    | 73.3    | 13x18cm or | 49.39861  | -8.72083  | 560 m  |
|        | Reflektor        |            |          |         | 9x12cm     | N         | E         |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| E      | 2.2m in          | 17037      | f/7.744  | 12.1    | 20x25cm    | 37.22361  | +2.5461   | 2138 m |
|        | Cassegrain focus |            |          |         | (8x10in) or| N         | W         |        |
|        | with corrector   |            |          |         | 24x24 cm   |           |           |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| F      | 3.5m in primary  | 13761      | f/3.93   | 15      | 20x25cm    | 37.22361  | +2.5461   | 2138 m |
|        | focus with       |            |          |         | (8x10in)   | N         | W         |        |
|        | 3-lens corrector |            |          |         |            |           |           |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| F      | 3.5m in primary  | 12195      | f/3.48   | 16.9    | 12.5x20    | 37.22361  | +2.5461   | 2138 m |
|        | focus with       |            |          |         | (5x8in)    | N         | W         |        |
|        | 2-lens corrector |            |          |         |            |           |           |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| H      | 2.2m MPG         | 17679      | f/8      | 12      | 20x25cm    | -29.257225| +70.734595| 2335 m |
|        | ESO/La Silla     |            |          |         |            | S         | W         |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| G      | Wolf's Doppel-   | 900mm      | f/6      | 230     | 13x18cm or | +49.39861 | -8.72083  | 560m   |
|        | astrograph (15cm)|            |          |         | 9x12cm     | N         | E         |        |
|        | on Königstuhl    |            |          |         |            |           |           |        |
|        | (7/1897-1909)    |            |          |         |            |           |           |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+
| G      | Wolf's Doppel-   | 900mm      | f/6      | 230     | 13x18cm or | +49.60988 | -8.69387  | 110m   |
|        | astrograph (15cm)|            |          |         | 9x12cm     | N         | E         |        |
|        | in Märzgasse     |            |          |         |            |           |           |        |
|        | (1887-7/1897)    |            |          |         |            |           |           |        |
+--------+------------------+------------+----------+---------+------------+-----------+-----------+--------+

Unfortunately, instrument data on the 2.2m MPG telescope on La Silla are
lost.  If anyone can help out, please contact
gavo@ari.uni-heidelberg.de.

The Observation logs of the more ancient observations are available from
UB Heidelberg.

* `Bruce Refractor 1900 through 1916 <http://digi.ub.uni-heidelberg.de/diglit/zah_lsw_bruce_bd1>`_ (Plates B0001 through  B3768)
* `Bruce Refractor 1916 through 1959 <http://digi.ub.uni-heidelberg.de/diglit/zah_lsw_bruce_bd2>`_ (Plates B3769 through  B8764)
* `Bruce Refractor 1959 through 1990 <http://digi.ub.uni-heidelberg.de/diglit/zah_lsw_bruce_bd3>`_ (Plates B8765 through  B9769)
* `Waltz Reflector 1906 through 1918 <http://digi.ub.uni-heidelberg.de/diglit/zah_lsw_waltz_bd1>`_ (Plates D0001 through D1638)
* `Waltz Reflector 1918 through 1933 <http://digi.ub.uni-heidelberg.de/diglit/zah_lsw_waltz_bd2>`_ (Plates D1639 through D4427)
* `Waltz Reflector 1933 through 1942 <http://digi.ub.uni-heidelberg.de/diglit/zah_lsw_waltz_bd3>`_ (Plates D4428 through D5199)

More Information
================

The project was discussed on a `poster shown at the 2007 meeting`_ of the
Astronomische Gesellschaft in Würzburg.

A `slightly more technical article`_ appeared in the proceedings of the 2014
Astroplate conference.

.. _poster shown at the 2007 meeting: /lswscans/res/positions/q/static/2007-hdap-poster.pdf
.. _slightly more technical article: /lswscans/res/positions/q/static/2014-astroplate-koenigstuhl.pdf

Trivia
======

This is what the photographic plates these scans were prepared from
look like --

.. image:: /lswscans/res/positions/q/static/bruceplate.jpg


The archive of plates from Wolf's eight-inch telescope --

.. image:: /lswscans/res/positions/q/static/eightarchive.jpg

The Bruce archive -- the rack's bend indicates the plates are kept
beneath an observatory dome --

.. image:: /lswscans/res/positions/q/static/platearchive.jpg

The scanner used by this project (Heidelberg Nexscan F4100; the resolution
is 100 pixels per millimeter at 200 pixels per millimeter optical scanner
resolution) --

.. image:: /lswscans/res/positions/q/static/scanner.jpg
	]]></meta>

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

	<!-- newest news first -->
	<meta name="_news" author="MD" date="2014-11-14">There's now a web
		page showing the Wolf-Palisa survey as part of HDAP.</meta>
	<meta name="_news" author="MD" date="2013-08-02">New plate catalogue,
		including many very early Wolf plates.  14277 plates in the database.</meta>
	<meta name="_news" author="MD" date="2011-08-22">Full plate access now
		supports returning scaled plates and supports querying by position.</meta>
	<meta name="_news" author="MD" date="2011-03-18">New plate catalogue, plus
		there are now uncalibrated plates in the database.  Search for those using
		the plate search.  There are now 8001 plates in DB.</meta>
	<meta name="_news" author="MD" date="2010-12-19">New plate catalogue, 7479
		plates in DB</meta>
	<meta name="_news" author="MD" date="2010-05-19">New plate catalogue, 6677
		plates in DB</meta>
	<meta name="_news" author="MD" date="2010-02-19">New plate catalogue, 6159
		plates in DB.  B3282b was deleted since it really was a different plate.
		The real B3282b is unusable.</meta>
	<meta name="_news" author="MD" date="2009-12-03">New plate catalogue, 6160
		plates in DB.</meta>

	<table id="plates" onDisk="True" adql="True" mixin="//siap#pgs">
		<meta name="_associatedDatalinkService">
			<meta name="serviceId">dl</meta>
			<meta name="idColumn">pub_did</meta>
		</meta>
		<mixin
			collectionName="'HDAP'"
			targetName="object"
			expTime="exposure"
			mime="'application/x-votable+xml;content=datalink'"
			accessURL="'\internallink{\rdId/dl/dlmeta}?ID='||gavo_urlescape(pub_did)"
			size="10"
			tMin="(to_char(startTime, 'J')::double precision-2400000.5)"
			tMax="(to_char(endTime, 'J')::double precision-2400000.5)"
			createDIDIndex="true"
		>//obscore#publishSIAP</mixin>

		<meta name="description">
			The main catalog of the plates contained in the archive.
		</meta>

		<index columns="plateID"/>
		<index columns="dateObs"/>
		<index columns="bandpassLo"/>
		<index columns="bandpassHi"/>

		<column name="exposure"
			tablehead="Exp. time" unit="s" ucd="time.duration;obs.exposure"
			description="Effective exposure time" verbLevel="15"/>
		<column name="airmass"
			tablehead="Airmass" ucd="obs.airMass"
			description="Airmass at mean epoch" verbLevel="21"/>
		<column name="object"  type="text"
			tablehead="Targ. Obj." ucd="meta.id"
			description="Special object on plate" verbLevel="15"/>
		<column name="emulsion"  type="text"
			tablehead="Emulsion" verbLevel="21" ucd="instr.plate.emulsion"
			description="Emulsion of the original plate"/>
		<column name="filter"  type="text"
			tablehead="Filter" verbLevel="15"
			ucd="meta.id;instr.filter;meta.main"
			description="Filter description"/>
		<column name="observer"  type="text"
			tablehead="Observer" verbLevel="21" ucd="obs.observer"
			description="Observer"/>
		<column name="startTime"  type="timestamp"
			tablehead="Start" unit="d" ucd="time.start;obs"
			description="UT at start of exposure" verbLevel="15"
			displayHint="type=humanTime"/>
		<column name="endTime"  type="timestamp"
			tablehead="End" unit="d" ucd="time.end;obs"
			description="UT at end of exposure" verbLevel="15"
			displayHint="type=humanTime"/>
		<column name="plateID" type="text" tablehead="Plate" description=
			"Plate name as specified in observation catalogue" verbLevel="15"/>
		<column name="pub_did" type="text"
			ucd="meta.ref.url"
			tablehead="Pub. DID"
			description="Dataset identifier assigned by the publisher."
			verbLevel="5"/>
	</table>

	<coverage>
		<updater sourceTable="plates" mocOrder="6"/>
			<temporal>-7801.04 51784.9</temporal>
	</coverage>

	<table id="wolfpalisa" onDisk="True" adql="True">
		<meta name="description">
			A mapping between HDAP plate identifiers and Wolf-Palisa
			survey plate numbers.
		</meta>
		
		<column name="w_p_id" type="text"
			ucd="meta.id"
			tablehead="Wolf-Palisa"
			description="Plate number in the Wolf-Palisa survey"
			verbLevel="5"/>
		<column original="plates.plateID"/>
	</table>

	<rowmaker id="make_plates">
		<var name="dateObs">parseTimestamp(@DATE_OBS, "%Y-%m-%d") if @DATE_OBS!="--" else None</var>
		<var name="startTime">parseTime(@TM_START)</var>
		<var name="endTime">parseTime(@TM_END)</var>


		<apply name="buildImageTitle">
			<code><![CDATA[
				title = "%s %s"%(vars["PLATE_ID"], vars["DATE_OBS"])
				if vars["OBJECT"]:
					title = title+" "+vars["OBJECT"]
				vars["imageTitle"] = title
			]]></code>
		</apply>

		<apply procDef="//siap#setMeta">
			<bind key="title">vars["imageTitle"]</bind>
			<bind key="instrument">"%s, %s"%(vars["OBSERVAT"],
				vars["TELESCOP"])</bind>
			<bind key="dateObs">vars["dateObs"]+vars["startTime"]+(
				vars["endTime"]-vars["startTime"])/2</bind>
			<bind key="bandpassId">vars["FILTER"]</bind>
		</apply>

		<apply procDef="//siap#computePGS">
			<bind name="missingIsError">False</bind>
		</apply>

		<apply name="nukeBadCoverages">
			<code>
				# we let through some really terrible coverages, which then
				# make pgsphere bomb when trying to convert the coverages
				# to MOCs.  We catch these here by trying to make MOCs
				# right away.
				if result["coverage"] is not None:
					try:
						_ = result["coverage"].asSMoc(8)
					except:
						result["coverage"] = None
			</code>
		</apply>

		<apply name="supply_defaults">
			<code>
				for key in ["AIRMASS"]:
					if key not in vars:
						vars[key] = None
			</code>
		</apply>
	
		<map key="startTime">@dateObs+@startTime</map>
		<map key="endTime">@dateObs+@endTime</map>
		<map key="filter" nullExpr='"no"'>@FILTER</map>
		<map key="pub_did">\standardPubDID</map>
		
		<simplemaps>exposure:EXPTIME, airmass:AIRMASS, object:OBJECT,
			emulsion:EMULSION, filter:FILTER, observer:OBSERVER,
			plateID: PLATE_ID</simplemaps>
	</rowmaker>

	<STREAM id="importing_stuff">
		<make table="plates" rowmaker="make_plates"/>
		<fitsProdGrammar qnd="True" id="impGrammar">
			<rowfilter procDef="//products#define">
				<bind key="table">"lsw.plates"</bind>
			</rowfilter>
			<ignoreOn name="Skip plates not yet or incomplete in plate cat">
				<keyMissing key="DATE_OBS"/>
				<keyIs key="DATE_OBS" value="--"/></ignoreOn>
		</fitsProdGrammar>
	</STREAM>

	<data id="reimport" auto="False">
		<FEED source="importing_stuff"/>
		<sources recurse="True" id="allSources">
			<pattern>data/part1/*.fits</pattern>
			<pattern>data/part2/*.fits</pattern>
		</sources>
	</data>

	<data id="import" updating="True">
		<FEED source="importing_stuff"/>
		<sources original="allSources">
			<ignoreSources fromdb="select accref from lsw.plates"/>
		</sources>
	</data>

	<data id="import_wolfpalisa">
		<sources pattern="res/wolf-palisa_mapping.txt"/>
		<reGrammar lax="True" commentPat="#.*">
			<names>w_p_id, ignore, ignore, ignore, ignore,
				ignore, ignore, ignore, ignore,
				plateno, tube</names>
		</reGrammar>
		<make table="wolfpalisa" id="bork">
			<rowmaker>
				<idmaps>w_p_id</idmaps>
				<map key="plateID">"B%s%s"%(@plateno.lstrip("0"), @tube)</map>
			</rowmaker>
		</make>
	</data>

	<table id="bibliography" onDisk="True">
		<meta name="title">HDAP bibliography</meta>
		<meta name="description" format="rst">Where people tell us about them, we
			will have pairs of bibliographic identifiers and plate ids
			in this table.  This has been created as a proving ground
			for https://www.ivoa.net/documents/BibVO, and at least
			early data in here may not exactly match the intentions of
			the authors for the cited papers.
		</meta>
		<index columns="bibref"/>
		<foreignKey inTable="plates" source="plateid" metaOnly="True"/>

		<column name="bibref" type="text"
			ucd="meta.bib.bibcode"
			description="Bibcode of a paper using or citing a plate."/>
		<column name="plateid" type="text"
			ucd="meta.id"
			description="HDAP plate identifier of the referenced plate."/>
	</table>

	<data id="import-bibliography">
		<sources pattern="res/bibliography.txt"/>
		<embeddedGrammar><iterator><code>
			with open(self.sourceToken) as f:
				for line in f:
					parts = line.split()
					for plateid in parts[1:]:
						yield {"bibref": parts[0], "plateid": plateid}
		</code></iterator></embeddedGrammar>
		<make table="bibliography">
			<script type="postCreation" lang="python" name="make biblinks">
from gavo.protocols import biblinks

rd = table.tableDef.rd
biblinks.clearLinks(table.connection, rd)

base_link = rd.getById("biblanding").getURL("qp")
new_links = []
for nlinks, bibref in table.connection.query("""
		SELECT count(*) as nlinks, bibref
		FROM {}
		GROUP BY bibref""".format(table.tableDef.getQName())):
	new_links.append(
		(bibref, "Cites", f"{base_link}/"+urllib.parse.quote(bibref), nlinks))

biblinks.defineLinks(table.connection,
	table.tableDef.rd,
	new_links)
			</script>
		</make>
	</data>

	<service id="biblanding" allowed="qp">
		<meta name="title">HDAP Plates Per Publication</meta>
		<property name="queryField">bibref</property>
		<template key="resultline">//productselect.html</template>
		<template key="resulttable">//productselect.html</template>

		<fancyQueryCore queriedTable="plates">
			<query>
				select plateid, accref, dateObs, bandpassLo, bandpassHi,
					exposure, centerAlpha, centerDelta,
					'\getConfig{web}{serverURL}/\rdId/dl/dlmeta?ID='
						|| gavo_urlescape(pub_did) as datalink,
					accref as checks
				from lsw.plates
				join lsw.bibliography
					using (plateid)
				%s
			</query>
			<condDesc>
				<inputKey original="bibliography.bibref"/>
			</condDesc>
			<outputTable
				autoCols="plateID, accref, dateObs,
					exposure, centerAlpha, centerDelta">
				<outputField name="checks" type="text" tablehead="Select">
					<formatter>
						return T.input(type="checkbox", name="accref", value=data)
					</formatter>
				</outputField>
				<outputField name="datalink" type="text"
					ucd="meta.ref.url"
					tablehead="DL"
					description="URL of a datalink document for this dataset."
					displayHint="type=url" verbLevel="1">
					<property name="targetType"
						>application/x-votable+xml;content=datalink</property>
					<property name="targetTitle">Datalink</property>
				</outputField>
			</outputTable>
		</fancyQueryCore>
	</service>

	<service id="dl" allowed="dlget,dlmeta">
		<meta name="title">HDAP Datalink</meta>
		<meta name="description">This service lets you access cutouts
			from HDAP plates and retrieve scaled versions.</meta>
		<datalinkCore>
			<descriptorGenerator procDef="//soda#fits_genDesc" name="genFITSDesc">
				<bind key="accrefPrefix">'lswscans'</bind>
			</descriptorGenerator>

			<FEED source="//soda#fits_standardDLFuncs" stcs=" "/>
			<metaMaker semantics="#auxiliary">
				<code>
					yield descriptor.makeLink(
						makeProductLink(descriptor.accref+"?scale=4"),
						contentType="application/fits",
						description="FITS, scaled by 1/4",
						contentLength=descriptor.estimateSize()/16.,
						contentQualifier="#image")
				</code>
			</metaMaker>
		</datalinkCore>
	</service>

	<service id="wpshow" allowed="form,static">
		<meta name="title">Wolf-Palisa Survey</meta>
		<meta name="description">The photographic plates published here
			were the source of the first star atlas based on photographic plates,
			prepared by Max Wolf and Johann Palisa.  It was published sucessively
			in 1899, 1902, and 1908.  Think of it as the POSS of the dawn of
			astrophotography.
		</meta>
		<meta name="source">1932ApJ....75R..68K</meta>
		<meta name="_related" title="Full HDAP Cutout Service">/lswscans/res/positions/q/form</meta>
		<template key="form">res/wolfpalisa.html</template>

		<property name="staticData">Wolf_Palisa_charts</property>
		<fixedQueryCore query="SELECT w_p_id, plateID,
			accref as acc4, w_p_id as map_image, accref,
			accsize, centerAlpha, centerDelta, imageTitle,
			dateObs, exposure, observer, pub_did as datalink FROM \schema.wolfpalisa
				NATURAL LEFT OUTER JOIN \schema.plates order by w_p_id">
			<outputTable>
				<LOOP listItems="w_p_id plateID">
					<events>
						<outputField original="wolfpalisa.\item"/>
					</events>
				</LOOP>

				<outputField name="datalink" type="text" id="datalink_output"
					ucd="meta.ref.url"
					select="'\getConfig{web}{serverURL}/\rdId/dl/dlmeta?ID='
						|| gavo_urlescape(pub_did)"
					tablehead="DL"
					description="URL of a datalink document for this dataset."
					displayHint="type=url" verbLevel="1">
					<property name="targetType"
						>application/x-votable+xml;content=datalink</property>
					<property name="targetTitle">Datalink</property>
				</outputField>

				<outputField original="plates.accref" name="acc4"
					tablehead="Scaled 1/4"
					description="Original plate scaled to 25%"
					select="accref">
					<formatter><![CDATA[
						if data:
							return T.a(href=makeProductLink(data+"?scale=4"))[
								"[Scaled 25%]"]
						else:
							return ""
					]]></formatter>		
				</outputField>

				<outputField original="wolfpalisa.w_p_id"
					name="map_image"
					tablehead="Map image"
					description="Scanned map as produced by Wolf and Palisa.">
					<formatter>
						base = "/lswscans/res/positions/wpshow/static/"
						return T.a(href="%sWP_%s.jpg"%(base, data))[
							T.img(src=
								"%sthumb_WP_%s.jpg"%(base, data), alt="[Map Image]")]
					</formatter>
				</outputField>

				<LOOP listItems="accref accsize centerAlpha centerDelta
						imageTitle dateObs exposure observer">
					<events>
						<outputField original="plates.\item"/>
					</events>
				</LOOP>
			</outputTable>
		</fixedQueryCore>
	</service>

	<siapCutoutCore id="qhsiap" queriedTable="plates">
		<condDesc original="//siap#protoInput"/>
		<condDesc original="//siap#humanInput" required="True"/>
		<condDesc buildFrom="dateObs"/>
		<condDesc silent="True">
			<inputKey name="cutoutSize" unit="deg"
				tablehead="Cutout size"
				description="Size of the cutout image [degrees]">0.5</inputKey>
		</condDesc>
	</siapCutoutCore>

	<service id="q" core="qhsiap" allowed="form,static">
		<meta name="sia.type">Pointed</meta>
		<meta name="_related" title="Full Plates"
			>/lswscans/res/positions/fullplates/form</meta>
		<meta name="_related" title="Wolf Palisa Subset"
			>/lswscans/res/positions/wpshow/form</meta>
		<meta name="shortName">hdap_web</meta>
		<meta name="_intro" format="rst"><![CDATA[
			Through this service you will only find
			astrometrically calibrated plates.  To search by
			object (e.g., comets), use the
			\RSTservicelink{/lswscans/res/positions/fullplates/form}{plates form}
			or \RSTservicelink{/adql}{ADQL} on the
			`lsw.plates table </__system__/dc_tables/show/tableinfo/lsw.plates>`_.
		]]></meta>

		<property name="staticData">static</property>

		<outputTable namePath="plates">
			<outputField original="imageTitle"/>
			<outputField original="dateObs" displayHint="type=humanDate"/>
			<outputField name="plateCenter" type="spoint"
				select="spoint(RADIANS(centeralpha),RADIANS(centerdelta))"
				tablehead="Plate Center"
				description="Plate Canter RA and Dec">
			</outputField>

			<outputField original="datalink_output"/>

			<outputField original="accref" tablehead="Image"
				displayHint="type=product,width=100"/>
			<outputField original="observer"/>
			<outputField original="exposure"/>
			<outputField name="fullPlate" type="text"
				select="plateId"
				tablehead="Full Plate"
				description="Link to the full plate"
				displayHint="noxml=true">
				<formatter>
					return T.a(href=base.makeSitePath(
						"/lswscans/res/positions/fullplates/qp/"+data))[
						"[Plate Row]"]
				</formatter>
			</outputField>
		</outputTable>
	</service>

	<service id="siap" core="qhsiap" allowed="siap.xml">
		<publish render="siap.xml" sets="ivo_managed"/>
		<publish render="form" sets="ivo_managed,local" service="q"/>

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

		<meta name="sia.type">Pointed</meta>
		<meta name="_related" title="Full Plates"
			>/lswscans/res/positions/fullplates/form</meta>
		<meta name="shortName">hdap_siap</meta>
		<meta name="testQuery.pos.ra">230.444</meta>
  	<meta name="testQuery.pos.dec">52.929</meta>
  	<meta name="testQuery.size.ra">0.1</meta>
  	<meta name="testQuery.size.dec">0.1</meta>

  	<FEED source="//pql#DALIPars"/>
	</service>

	<dbCore id="fullplatescore" queriedTable="plates">
		<condDesc buildFrom="imageTitle"/>
		<condDesc>
			<inputKey original="plateID" description="Image title; to look for
				a plate by plate number, use something like '~B345*'"
				type="vexpr-string"/>
		</condDesc>
		<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>
<!-- Maybe this is better than the fromdb thingy?  Dunno...
		<condDesc id="objectselect">
			<inputKey original="object" type="vexpr-string">
				<description>Designated object on the plate (i.e.,
				the object the observers entered into their journal).
				You can use wildcards if your prefix your expression with "~".
				</description>
				<widgetFactory
					>widgetFactory(StringFieldWithBlurb, additionalMaterial=
					T.a(href="/__system__/adql/query/form?__nevow_form__=genForm"
					"&amp;query=select%20object%2C%20count(*)%20as%20nObs%20from%20l"
					"sw.plates%20group%20by%20object%20order%20by%20object")[
					"[List of known objects]"])</widgetFactory>
			</inputKey>
		</condDesc> -->

		<condDesc id="objectselect">
			<inputKey original="object" showItems="10" multiplicity="multiple">
				<description>Designated object on the plate (i.e.,
				the object the observers entered into their journal).</description>
				<values fromdb="object from lsw.plates order by object"/>
			</inputKey>
		</condDesc>

	</dbCore>

	<service id="fullplates" core="fullplatescore" allowed="form,qp">
		<meta name="shortName">hdap_plates</meta>
		<meta name="title">Full plate access to Heidelberg Digitized
			Astronomical Plates</meta>
		<meta name="_related" title="Cutout Service">/lswscans/res/positions/q/form</meta>
		<meta name="_related" title="Wolf Palisa Subset"
			>/lswscans/res/positions/wpshow/form</meta>
		<meta name="_intro">Please note that the scans are about 1 GB per
		plate.</meta>

		<property name="queryField">plateId</property>

		<outputTable namePath="plates">
			<outputField original="imageTitle"/>
			<outputField original="object"/>
			<outputField original="centerAlpha"/>
			<outputField original="centerDelta"/>
			<outputField original="dateObs"/>
			<outputField original="exposure"/>
			<outputField original="accsize"/>
			<outputField original="datalink_output"/>
			<outputField original="accref"/>
			<outputField original="accref" name="acc4" tablehead="Scaled 1/4"
				description="Original plate scaled to 25%"
				select="accref">
				<formatter><![CDATA[
					return T.a(href=makeProductLink(data+"?scale=4"))[
						"[Scaled 25%]"]
				]]></formatter>		
			</outputField>
			<outputField original="accref" name="acc16" tablehead="Scaled 1/16"
				description="Original plate scaled to 6.25%"
				select="accref">
				<formatter><![CDATA[
					return T.a(href=makeProductLink(data+"?scale=16"))[
						"[Scaled 6.25%]"]
				]]></formatter>		
			</outputField>

			<outputField original="observer"/>
			<outputField name="more"
					select="array[centerAlpha,centerDelta]" tablehead="More"
					description="More exposures near the center of this plate">
				<formatter><![CDATA[
					if data[0] is None:
						return "N/A"
					else:
						return T.a(href=base.makeSitePath("/lswscans/res/positions/q/form?"
							"hPOS=%s,%s&hSIZE=1&INTERSECT=OVERLAPS&cutoutSize=0.5&__nevow_form__=genForm"%tuple(data)
							))["More"] ]]>
				</formatter>
			</outputField>
		</outputTable>
	</service>

	<regSuite title="HDAP service tests" id="s1">
		<regTest title="LSW plate service gives plausible answer">
			<url parSet="form" cutoutSize="0.5" hSIZE="0.5" hFORMAT="application/fits"
				hPOS="1.5,6.3" hINTERSECT="OVERLAPS">q/form</url>
			<code>
				self.assertHasStrings("Obs. date", "B2866b")
			</code>
		</regTest>

		<regTest title="LSW cutout delivers plausible FITS">
			<url sdec="0.5" dec="2.0" ra="2.0" sra="0.5"
				>/getproduct/lswscans/data/part1/Bruceplatten/FITS/B2866b.fits</url>
			<code>
				self.assertHasStrings("SIMPLE  =                    T",
					"OBSERVER= 'F.Kaiser'",
					"NAXIS1",
					"TM_START= '20:11:56'")
			</code>
		</regTest>

		<regTest title="LSW cutout preview looks like a JPEG">
			<url dec="6.0" sdec="0.1" sra="0.1" ra="2.0"
				preview="true">/getproduct/lswscans/data/part1/Bruceplatten/FITS/B2866b.fits</url>
			<code>
				self.assertHasStrings("JFIF", "\1\1\1")
			</code>
		</regTest>
	</regSuite>

	<regSuite title="HDAP DaCHS regressions">
		<regTest title="Tar of cutouts works" tags="bigserver">
			<url parSet="form" MAXREC="2" cutoutSize="0.1"
				hSIZE="0.1" _DBOPTIONS_ORDER="dateObs" _FORMAT="tar"
				hPOS="56,45">q/form</url>
			<code>
				self.assertHasStrings("dc_data/", "SIMPLE  =")
			</code>
		</regTest>

		<regTest title="SIAP reply looks like a SIAP VOTable">
			<url POS="168,22" SIZE="0.5" RESPONSEFORMAT="votabletd"
				>siap/siap.xml</url>
			<code><![CDATA[
				self.assertHasStrings("wcs_equinox", "<TD>", 'POS_EQ_DEC_MAIN')
			]]></code>
		</regTest>

		<regTest title="SIAP parameter syntax error looks all right" id="ct">
				<url POS="168,22" SIZE="b">siap/siap.xml</url>
			<code><![CDATA[
				self.assertHasStrings("VOTABLE",
					'value="ERROR"',
					'Size specification has to be &lt;degs&gt; or &lt;degs&gt;,'
						'&lt;degs&gt;</INFO>')
			]]></code>
		</regTest>

		<regTest title="SIAP error reporting is a VOTable and
				includes parameter names">
			<url POSS="168,22" SIZE="2">siap/siap.xml</url>
			<code><![CDATA[
				self.assertHasStrings('value="ERROR"',
				"Field POS: Required parameter 'POS' missing.</INFO>")
			]]></code>
		</regTest>

		<regTest title="SIAP services include custom arguments">
			<url dateObs="&lt; 1950-01-01" POS="168,22" SIZE="0.5"
				>siap/siap.xml</url>
			<code>
				self.assertLacksStrings("1985-10-31")
			</code>
		</regTest>

		<regTest title="SIAP reply in TDENC works">
			<url RESPONSEFORMAT="votabletd" POS="168,22"
				SIZE="0.5">siap/siap.xml</url>
			<code><![CDATA[
				self.assertHasStrings("wcs_equinox", "</TD>", "<TD>Heidelberg")
			]]></code>
		</regTest>

		<regTest title="Full plate service works">
			<url parSet="form" plateID="B2866b">fullplates/form</url>
			<code><![CDATA[
				self.assertHasStrings("<td>B2866b 1911-09-16</td>")
			]]></code>
		</regTest>

		<regTest title="Wolf-Palisa service shows plates" tags="bigserver">
			<url>wpshow/form</url>
			<code>
				self.assertHasStrings(
					'getproduct/lswscans/data/part1/Bruceplatten/FITS/B1213a.fits"')
			</code>
		</regTest>

		<regTest title="hdap datalink metadata">
			<url
				ID="ivo://org.gavo.dc/~?lswscans/data/part1/Bruceplatten/FITS/B2866b.fits"
				>dl/dlmeta</url>
			<code>
				self.assertHasStrings("getproduct/lswscans/data/part1/Bruceplatten/"
						"FITS/B2866b.fits?preview=True",
					'name="POLYGON"')
			</code>
		</regTest>

		<regTest title="hdap SODA">
			<url
				ID="ivo://org.gavo.dc/~?lswscans/data/part1/Bruceplatten/FITS/B2866b.fits"
				CIRCLE="1.5 6.25 0.001"
				>dl/dlget</url>
			<code>
				self.assertHasStrings("NAXIS1  =                    8",
					"DATE-OBS= '1911-09-16'")
			</code>
		</regTest>
	</regSuite>

</resource>
