<resource schema="boydende">
	<meta name="creationDate">2014-11-24T10:27:00Z</meta>
	<meta name="schema-rank">1000</meta>
	<meta name="title">Boyden Station ADH Plates in Germany</meta>
	<meta name="description">The Armagh-Dunsink-Harvard Becker-Schmidt
	Telescope was deployed at Boyden Station, Maselspoort South Africa between
	1965 and 1970.  During that time, astronomers from Bamberg, Heidelberg,
	Hamburg and Münster took astronomical images there, with a focus on old star
	clusters, the Magellanic clouds, and the southern milky way.  This service
	provides scans of the plates obtained.
	</meta>

	<meta name="creator">Tsvetkov, M.; Demleitner, M.</meta>

	<meta name="source">1998IrAJ...25..129A</meta>

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

	<meta name="facility">Boyden Station, Maselspoort</meta>
	<meta name="instrument">Armagh-Dunsink-Harvard Becker-Schmidt Telescope</meta>
	<meta name="instrument.altIdentifier">handle:21.11157/e3918d95-d413-43b7-906e-cfd5cd054997</meta>

	<meta name="_related" title="hppunion VO service">/hppunion/q/im/info</meta>
	
	<meta name="coverage">
		<meta name="waveband">Optical</meta>
	</meta>

	<FEED source="//procs#license-cc-by"
		what="The Boyden Station ADH plate scans"/>

	<table id="data" onDisk="True" mixin="//siap#pgs" adql="True">
		<index columns="pub_did"/>
		<index columns="bandpassLo"/>
		<index columns="bandpassHi"/>

		<mixin
			accessURL="datalink_url"
			size="10"
			mime="'application/x-votable+xml;content=datalink'"
			calibLevel="1"
			collectionName="'Boyden-de'"
			expTime="exposure"
			facilityName="'Boyden Station, SA'"
			instrumentName="'ADH Schmidt'"
			tMin="start_time"
			tMax="end_time"
			targetName="object"
		>//obscore#publishSIAP</mixin>
		<meta name="_associatedDatalinkService">
			<meta name="serviceId">dl</meta>
			<meta name="idColumn">pub_did</meta>
		</meta>
		
		<publish sets="ivo_managed" services="//tap#run,hppunion/q#im"/>

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

		<column name="exposure"
			tablehead="Exp. time"
			ucd="time.duration;obs.exposure" unit="s"
			description="Effective exposure time"
			verbLevel="15"/>
		<column name="object" type="text"
			tablehead="Targ. Obj."
			ucd="meta.id"
			description="Special object on plate"
			verbLevel="15"/>
		<column name="start_time" type="double precision"
			tablehead="Start"
			ucd="time.start;obs" unit="d"
			description="Start of exposure"
			verbLevel="15"
			displayHint="type=humanDate"/>
		<column name="end_time" type="double precision"
			tablehead="End"
			ucd="time.end;obs" unit="d"
			description="End of exposure"
			verbLevel="15"
			displayHint="type=humanDate"/>
		<column name="wfpdb_id" type="text"
			ucd="meta.id"
			tablehead="WFPDB"
			description="Plate identifier as in the WFPDB"
			verbLevel="15"/>
		<column name="quality" type="text"
			tablehead="Quality"
			ucd="meta.note"
			description="Plate Quality"
			verbLevel="18"/>
		<column name="filter" type="text"
			tablehead="Filter"
			ucd="meta.id;instr.filter"
			description="Filter used (NULL if clear)"
			verbLevel="18"/>
		<column name="emulsion" type="text"
			tablehead="Emulsion"
			ucd="instr.plate.emulsion"
			description="Plate emulsion"
			verbLevel="18"/>
		<column name="obsnotes" type="text"
			tablehead="Notes"
			ucd="meta.note"
			description="Observation Notes"
			verbLevel="18"/>
		<column name="datalink_url" type="text"
			tablehead="Datalink"
			ucd="meta.ref.url"
			description="URL to a datalink document for this plate
				(ancillary files, cutouts)"
			displayHint="type=url"
			verbLevel="15"/>
		<column name="envelope" type="text"
			tablehead="Envelope"
			ucd="meta.ref.url"
			description="Plate envelope with plate metadata"
			displayHint="type=url"
			verbLevel="15"/>
		<column name="pub_did" type="text"
			tablehead="pubDID"
			description="Globally unique dataset identifier"
			verbLevel="5"/>
	</table>

	<coverage>
		<updater sourceTable="data"/>
		<temporal>36154.8 40334.9</temporal>
		<spatial>4/1040,1888,2081-2082 5/4119,4168,6170,6181,6192,7194-7195,7216-7217,7272-7273,7275-7276,7278,7467,7556,7561,7564,8238-8239,8321,8323,8332,9333,9482,9504,10359,10364-10365,10407,10413,10416,10418,10424-10426,10437-10439,10445,10448,10450-10451,10456,10530-10531,10536-10537,10539-10542 6/16469-16471,16501,16658,16664,16666,16676,24637-24639,24674-24675,24684,24686,24721,24733,24772-24774,24776,28735,28771,28774,28794,28820-28821,28823,28872-28873,28875-28876,28880,29069-29071,29082,29097,29110,29116,29444-29445,29535,29862-29863,29865-29867,29880,29882-29883,30228,30230,30232,30234-30235,30240-30241,30243,30252-30253,30260,30264,32943,32950-32951,33283,33289-33291,33332-33334,33336-33338,33344,33408-33409,33411-33414,35753-35756,35758-35759,37245-37247,37329-37331,37337,37340-37341,37932,37934-37935,38020-38022,38024-38025,41407,41431,41435,41450-41451,41469,41578-41579,41621-41623,41627,41660-41661,41663,41668,41670,41676,41678,41708,41747,41777,41789,41796,41798-41799,41816,41818,41828-41830,41832-41833,42114,42138-42139,42142-42143,42152-42153,42155,42172,42174,42208,42210,42512,43029,43072</spatial>
		<spectral>2.11324e-19 6.30618e-19</spectral>
	</coverage>

	<data id="import" recreateAfter="hppunion/q#import">
		<sources pattern="data/fits/*.fits"/>
		<fitsProdGrammar>
			<rowfilter procDef="//products#define">
				<bind key="table">"\schema.data"</bind>
			</rowfilter>
			<rowfilter>
				<doc>
					Yields only calibrated rows/products
				</doc>
				<code>
					if "WCSAXES" in row:
						yield row
				</code>
			</rowfilter>
		</fitsProdGrammar>

		<make table="data">
			<rowmaker>
				<apply name="cleanup_emulsion" procDef="//procs#dictMap">
					<bind name="key">"EMULSION"</bind>
					<bind name="mapping">{
						"Kodak 103aO": "103a-O",
						"PerutzAstro": "PerutzAstro",
						"103aF": "103a-F",
						"103aO": "103a-O",
						"Kodak IIaO": "IIa-O",
						"Kodak 103aG": "103a-G",
						"Kodak103aD": "103a-D",
						"103aD": "103a-D",
						"Kodak103aO": "103a-O",
						"Kodak 103aD": "103a-D",
						"Kodak103aE": "103a-E",
						"103aE": "103a-E",
						"KodakIIaO": "103a-O",
						"IIaO": "IIa-O",
						"103a0": "103a-O",
						"UG2": "UG2",
					}</bind>
				</apply>

				<apply name="cleanup_filter" procDef="//procs#dictMap">
					<bind name="key">"FILTER"</bind>
					<bind name="mapping">{
						"": None,
						"GG18": "GG18",
						"UG2": "UG2",
						"BG12+18": "BG12_18",
						"+G5": "GG5",
						"GG11": "GG11",
						"GG5": "GG5",
						"RG1": "RG1",
						"UG21": "UG21",
						"no": None,
						"clear": None,
						"G18": "G18",
					}
					</bind>
				</apply>

				<apply procDef="//siap#computePGS"/>
				<apply procDef="//procs#mapValue">
					<bind name="destination">"OBJECT"</bind>
					<bind name="failuresMapThrough">True</bind>
					<bind name="value">@OBJECT</bind>
					<bind name="sourceName">"boydende/res/namemap.txt"</bind>
				</apply>
				<apply procDef="//siap#setMeta" name="setMeta">
					<bind name="dateObs">@DATE_OBS</bind>
					<bind name="instrument">@TELESCOP</bind>
					<bind name="pixflags">None</bind>
					<bind name="title">"Boyden %s %s"%(@DATE_OBS, @OBJECT)</bind>
					<bind name="bandpassId">"+".join(v for v in
						[@EMULSION, @FILTER] if v)</bind>
				</apply>
				<apply procDef="//siap#getBandFromFilter"/>

				<simplemaps>
					wfpdb_id: WFPDB_ID,
					exposure: EXPTIME,
					object: OBJECT,
					quality: PQUALITY,
					obsnotes: OBSNOTES,
					filter: FILTER
				</simplemaps>

				<map key="start_time">dateTimeToMJD(parseISODT(@DATE_OBS))</map>
				<map key="end_time">dateTimeToMJD(parseISODT(@DATE_END))</map>
				<map key="emulsion" nullExcs="KeyError">@EMULSION</map>
				<map key="envelope"
					>"\internallink{\rdId/dl/static/envelopes/%s.jpg}"%(
						@WFPDB_ID.replace(" ", "_"))</map>
				<map key="pub_did">\standardPubDID</map>
				<map key="datalink_url"
					>\dlMetaURI{dl}</map>
			</rowmaker>
		</make>
	</data>

	<service id="dl" allowed="dlget,dlmeta,static">
		<meta name="title">Boyden Station ADH Plates datalink service</meta>
		<property name="staticData">data/static</property>

		<datalinkCore>
			<descriptorGenerator procDef="//soda#fits_genDesc"/>
			<FEED source="//soda#fits_standardDLFuncs"
				accrefStart="boydende"/>
			<metaMaker semantics="#documentation">
				<code>
					svc = rd.getById("dl")
					basename = descriptor.accref.split("/")[-1].split(".")[0]
					envPath = "data/static/envelopes/{0}.jpg".format(basename)

					yield descriptor.makeLinkFromFile(
						envPath,
						description="Scan of the plate envelope",
						contentType="image/jpeg")
				</code>
			</metaMaker>
		</datalinkCore>
	</service>

	<service id="web" allowed="form">
		<meta name="title">Boyden Station ADH Plates Web Service</meta>
		<meta name="shortName">Boydende Web</meta>

		<publish render="form" sets="local"/>

		<dbCore queriedTable="data">
			<condDesc original="//siap#humanInput"/>
			<condDesc buildFrom="wfpdb_id"/>
			<condDesc buildFrom="dateObs"/>
			<condDesc>
				<inputKey original="object" multiplicity="multiple" showItems="5">
					<values fromdb="object from \schema.data order by object"/>
				</inputKey>
			</condDesc>
		</dbCore>

		<outputTable>
			<outputField original="accref"/>
			<outputField original="accsize"/>
			<outputField original="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>

			<LOOP listItems="dateObs centerAlpha centerDelta
				object wfpdb_id imageTitle instId exposure emulsion
				obsnotes datalink_url envelope">
				<events>
					<outputField original="\item"/>
				</events>
			</LOOP>
		</outputTable>
	</service>

	<regSuite title="boyden regressions">
		<regTest title="boyden service delivers some data">
			<url
				ID="ivo://org.gavo.dc/~?boydende/data/fits/HAR081_007020.fits"
				CIRCLE="231.017 -58.753 0.003"
			>dl/dlget</url>
			<code>
				self.assertHasStrings(
					"NAXIS1  =                   31",
					"OBJECT  = 'Circinus'",
					b"\\xae\\x54\\xae\\xa6\\xad\\xe5")
			</code>
		</regTest>

		<regTest title="boyden web page delivers some data">
			<url parSet="form" object="Circinus Field I">web/form</url>
			<code>
				self.assertHasStrings("1963-08-15T17:19:39Z",
					"dl/static/envelopes/HAR081_007020.jpg",
					"boydende/q/dl/dlmeta?ID=ivo%3A//org.gavo.dc/"
						"~%3Fboydende/data/fits/HAR081_007020.fits")
			</code>
		</regTest>
	</regSuite>
</resource>
