<resource schema="hamburg_eso" resdir=".">
	<meta name="creationDate">2025-11-19T10:27:26Z</meta>
	<meta name="schema-rank">100</meta>

	<meta name="title">Hamburg/ESO Survey Spectra</meta>
	<meta name="description" format="rst">
		The Hamburg/ESO survey (HES) is a digital objective prism survey covering
		the total southern extragalactic sky. It is based on Kodak IIIa-J plates
		which have been taken with the 1m ESO Schmidt telescope and its 4° prism.
		The spectral coverage is 3200-5300 Å, at an resolution of 15 Å at H gamma.
		The magnitude range covered is roughly between 18.5 and 11 mag in B_J.

		This is a collection of uniformly reduced spectra prepared by Norbert
		Christlieb.  It is also intended as a sort-of resolver for HES names
		(“identifiers“) like ”HE 2301-7732” (these are B1950 coordinates) or
		“HE000000m090649d2856” (these are J2000). The shorter form usually matches
		multiple objects, and you will need to apply domain knowledge in order to
		find the object actually being referred to when resolving a short HE
		identifier.
	</meta>
	<meta name="subject">spectroscopy</meta>
	<meta name="subject">surveys</meta>
	<meta name="subject">schmidt-cameras</meta>
	<meta name="subject">astronomical-object-identification</meta>

	<meta name="creator">Reimers, D.; Wisotzki, L; Christlieb, N.</meta>
	<meta name="instrument">1m ESO Schmidt</meta>
	<meta name="facility">Hamburger Sternwarte; ESO La Silla</meta>

	<meta name="source">A&amp;A...358...77W</meta>
	<meta name="contentLevel">Research</meta>
	<meta name="type">Survey</meta>

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

	<meta name="ssap.dataSource">survey</meta>
	<meta name="ssap.creationType">archival</meta>
	<meta name="productType">spectrum</meta>
	<meta name="ssap.testQuery">MAXREC=1</meta>

	<!-- λ calibration: Christlieb 2000 gives the following relationship
		between the scan length in μm and λ in Angstrom:

		x = 2953.588 + 8.218377e10 / λ^2 + 7.675455e16 / λ^4

		Inverting this is a bit troublesome.  2025-12: We're waiting for input
		by Lutz Wisowski as to a table for these wavelenghts.  For now, let's just
		make something numeric.  Here's my version:
	-->

	<execute on="loaded" title="init RD">
		<job><code>
			# the wavelengths (in angstrom) at the coordinates along axis 1
			# of the spectrum FITSes computed by res/calib.py
			rd.lambdas = [5752.560175491419, 5730.763596550914, 5709.221636881887,
				5687.929405212022, 5666.882140644632, 5646.075208226229,
				5625.504094696857, 5605.164404414354, 5585.051855444196,
				5565.162275807008, 5545.491599876322, 5526.03586491949, 5506.7912077751,
				5487.753861660555, 5468.920153103873, 5450.286498993956,
				5431.849403744061, 5413.6054565632985, 5395.55132883136,
				5377.683771571889, 5359.99961302015, 5342.495756280844,
				5325.169177072178, 5308.016921552434, 5291.036104225514,
				5274.223905922082, 5257.577571853106, 5241.094409732739,
				5224.771787967667, 5208.6071339101145, 5192.597932171941,
				5176.7417229972525, 5161.036100691204, 5145.47871210267,
				5130.0672551586395, 5114.799477448255, 5099.6731748545235,
				5084.686190231809, 5069.836412127317, 5055.121773544848,
				5040.540250749167, 5026.089862109444, 5011.768666980247,
				4997.574764618663, 4983.506293136178, 4969.561428483996,
				4955.73838347056, 4942.035406810053, 4928.450782200756,
				4914.982827432138, 4901.629893519639, 4888.39036386614,
				4875.262653449144, 4862.245208032736, 4849.3365034034605,
				4836.53504462923, 4823.839365340473, 4811.248027032726,
				4798.759618389922, 4786.372754627649, 4774.086076855692,
				4761.898251459188, 4749.807969497768, 4737.813946122026,
				4725.914920006812, 4714.1096528006965, 4702.396928591095,
				4690.775553384548, 4679.244354601622, 4667.802180585964,
				4656.447900127043, 4645.18040199611, 4633.998594494987,
				4622.901405017222, 4611.887779621242, 4600.956682615112,
				4590.107096152515, 4579.338019839619, 4568.6484703524675,
				4558.037481064572, 4547.5041016843825, 4537.047397902332,
				4526.666451047147, 4516.360357751158, 4506.128229624309,
				4495.969192936619, 4485.882388308829, 4475.866970410984,
				4465.92210766872, 4456.046981977014, 4446.2407884211825,
				4436.502735004908, 4426.832042385083, 4417.227943613276,
				4407.6896838836265, 4398.216520286965, 4388.807721571007,
				4379.462567906411, 4370.18035065855, 4360.960372164845,
				4351.801945517458, 4342.704394351251, 4333.667052636809,
				4324.689264478415, 4315.770383916826, 4306.909774736724,
				4298.106810278695, 4289.360873255637, 4280.671355573445,
				4272.037658155879, 4263.459190773491, 4254.93537187649,
				4246.465628431464, 4238.049395761828, 4229.686117391916,
				4221.375244894603, 4213.1162377423825, 4204.908563161791,
				4196.751695991096, 4188.645118541167, 4180.588320459435,
				4172.5807985968695, 4164.622056877891, 4156.711606173139,
				4148.848964175029, 4141.033655276016, 4133.265210449513,
				4125.543167133369, 4117.867069115874, 4110.236466424202,
				4102.650915215239, 4095.1099776687347, 4087.6132218827292,
				4080.160221771178, 4072.750556963742, 4065.383812707671,
				4058.0595797717465, 4050.777454352212, 4043.537037980664,
				4036.337937433839, 4029.179764645264, 4022.0621366187083,
				4014.9846753434144, 4007.9470077110445, 4000.9487654343197,
				3993.989584967293, 3987.069107427238, 3980.1869785180966,
				3973.342848455456, 3966.536371893026, 3959.767207850568,
				3953.0350196432523, 3946.339474812406, 3939.6802450576206,
				3933.057006170185, 3926.469437967819, 3919.917224230672,
				3913.4000526385626, 3906.917614709422, 3900.4696057389306,
				3894.0557247413003, 3887.675674391195, 3881.3291609667476,
				3875.0158942936655, 3868.7355876903835, 3862.4879579142553,
				3856.2727251087517, 3850.089612751645, 3843.9383476041603,
				3837.818659661071, 3831.730282101716, 3825.672951241923,
				3819.6464064868123, 3813.65039028447, 3807.684648080462,
				3801.7489282731767, 3795.842982169983, 3789.9665639441732,
				3784.1194305926897, 3778.3013418946034, 3772.5120603703413,
				3766.7513512416385, 3761.0189823922037, 3755.3147243290846,
				3749.6383501447094, 3743.989635479605, 3738.3683584857636,
				3732.774299790656, 3727.207242461867, 3721.666971972351,
				3716.1532761662884, 3710.665945225531, 3705.2047716366264,
				3699.76955015841, 3694.360077790151, 3688.9761537402405,
				3683.6175793954176, 3678.2841582905107, 3672.975696078698,
				3667.6920005022575, 3662.4328813638285, 3657.1981504981354,
				3651.9876217441947, 3646.8011109179793, 3641.6384357855427,
				3636.499416036584, 3631.3838732584486, 3626.2916309105617,
				3621.2225142992756, 3616.1763505531317, 3611.1529685985292,
				3606.15219913578, 3601.1738746155625, 3596.2178292157487,
				3591.2838988186113, 3586.3719209883893, 3581.4817349492205,
				3576.613181563423, 3571.766103310123, 3566.9403442642238,
				3562.135750075706, 3557.352167949256, 3552.5894466242153,
				3547.8474363548466, 3543.1259888909017, 3538.4249574585037,
				3533.7441967413197, 3529.083562862027, 3524.442913364068,
				3519.8221071936846, 3515.2210046822343, 3510.6394675287693,
				3506.0773587828917, 3501.5345428278642, 3497.0108853639804,
				3492.5062533921887, 3488.0205151979594, 3483.553540335405,
				3479.105199611628, 3474.6753650713135, 3470.2639099815465,
				3465.8707088168608, 3461.4956372445054, 3457.138572109936,
				3452.7993914225153, 3448.477974341429, 3444.17420116181,
				3439.8879533010595, 3435.619113285381, 3431.3675647364976,
				3427.1331923585735, 3422.915881925321, 3418.715520267296,
				3414.5319952593745, 3410.3651958084142, 3406.2150118410923,
				3402.0813342919146, 3397.964055091402, 3393.8630671544406,
				3389.778264368801, 3385.70954158382, 3381.656794599241,
				3377.619920154215, 3373.598815916454, 3369.593380471541,
				3365.6035133123823, 3361.6291148288183, 3357.6700862973676,
				3353.726329871124, 3349.7977485697866, 3345.884246269833,
				3341.9857276948246, 3338.1020984058478, 3334.2332647920857,
				3330.379134061519, 3326.539614231755, 3322.7146141209814,
				3318.9040433390423, 3315.107812278636, 3311.3258321066332,
				3307.5580147555115, 3303.804272914903, 3300.064520023261,
				3296.338670259636, 3292.626638535555, 3288.928340487023,
				3285.24369246662, 3281.5726115357047, 3277.9150154567274,
				3274.2708226856366, 3270.639952364392, 3267.0223243135706,
				3263.417859025077, 3259.8264776549427, 3256.2481020162195,
				3252.6826545719723, 3249.130058428356, 3245.5902373277845,
				3242.0631156421887, 3238.5486183663625, 3235.04667111139]
		</code></job>
	</execute>

	<table id="meta" onDisk="True" adql="True"
			namePath="//ssap#instance">
		<mixin>//products#table</mixin>
		<mixin>//ssap#plainlocation</mixin>
		<mixin>//ssap#simpleCoverage</mixin>
		<FEED source="//scs#splitPosIndex"
			columns="ssa_location"
			long="degrees(long(ssa_location))"
			lat="degrees(lat(ssa_location))"/>

		<index columns="hes_name"/>
		<index columns="hes_id"/>

		<column name="hes_name" type="text"
			ucd="meta.id"
			tablehead="HES name"
			description="HES designation, consisting of the letters 'HE', the first
			four digits of the right ascension at equinox B1950.0, and the first four
			digits of the declination at equinox B1950.0. Example: HE 2301-7732."
			verbLevel="1" note="hes"/>
		<column name="hes_id" type="text"
			ucd="meta.id;meta.main"
			tablehead="HES id"
			description="Alternative, more precise HES identifier consisting of
				the letters 'HE',
				the first six digits of the right ascension at equinox 2000.0, the
				first six digits of the declination at equinox 2000.0, the plate
				quarter (a, b, c, or d), and the HES plate number. Example: For HE
				0107−5240, which is located on quarter c of plate 2052 and at
				coordinates α = 01h09m29s.1, δ = −52◦24'34'', the HESid is
				HE0109291m522434c2052."
			verbLevel="1"/>
		<column name="field" type="integer" required="True"
			ucd="meta.id;obs.field"
			tablehead="ESO-SRC"
			description="Field number in the ESO/SRC (or ESO/SERC) sky atlas."
			verbLevel="15"/>
		<column name="plate" type="integer" required="True"
			ucd="meta.id;instr.plate"
			tablehead="Plate #"
			description="Plate number of the HES objective prism plate in the ESO
				archive."
			verbLevel="25"/>
		<column name="quadrant" type="char" required="True"
			ucd="meta.id;instr.plate"
			tablehead="Quadrant"
			description="HES plate quadrant (i.e., a, b, c, or d)."
			verbLevel="25" note="qua"/>

		<column name="objtype" type="text"
			ucd="src.class"
			tablehead="Type"
			description="Morphological source type [stars/ext/bright],
				discriminating between different extraction schemes used for the
				spectra, also impacting the sizes of the actual extraction apertures.
				'stars' means point source, 'ext' means extended object (mostly
				galaxies), 'bright' means sources with partly saturated spectra,
				typically occuring for stars brighter than B_J ≈ 14 mag"
			verbLevel="5" note="ob"/>

		<column name="ra" type="double precision"
			unit="deg" ucd="pos.eq.ra;meta.main"
			tablehead="RA"
			description="Right ascension for equinox J2000. The coordinates were
				derived from the DSS-I, and they are typically accurate to within 1
				arcsec (rms)."
			verbLevel="1"/>
		<column name="dec" type="double precision"
			unit="deg" ucd="pos.eq.dec;meta.main"
			tablehead="Dec"
			description="Declination for equinox J2000. The coordinates were
				derived from the DSS-I, and they are typically accurate to within 1
				arcsec (rms)."
			verbLevel="1"/>

		<column name="ovl" type="smallint" required="True"
			ucd="meta.code.qual"
			tablehead="Overlap"
			description="Binary flag [0/1]. A value of 1 signals that the
				spectrum suffers contamination from another object located in
				dispersion direction."
			verbLevel="15" note="ovl" displayHint="type=checkmark"/>
		<column name="bj_dss"
			unit="mag" ucd="phot.mag;em.opt.B"
			tablehead="B_J"
			description="Magnitude in the B_J band, measured on the relevant
				DSS-I plate and calibrated to a small number of reference stars."
			verbLevel="15" note="bj"/>
		<column name="sn_bj"
			ucd="stat.snr"
			tablehead="SNR"
			description="Average signal to noise ratio per pixel of the HES
				spectra in the B_J band. See Christlieb et al. (2001,
				2001A&amp;A...366..898C) for a description of how this parameter was
				estimated."
			verbLevel="15"/>
		<column name="b_v_hes"
			unit="mag" ucd="phot.color;em.opt.b;em.opt.v"
			tablehead="B-V"
			description="Approximate B-V colour derived from the spectrum
				and calibrated against stellar samples with known multiband
				photometry. For details see Christlieb et al. (2001,
				2001A&amp;A...366..898C)."
			verbLevel="15"/>
		<column name="u_b_hes"
			unit="mag" ucd="phot.color;em.opt.u;em.opt.b"
			tablehead="U-B"
			description="Approximate U-B colour derived from the spectrum
				and calibrated against stellar samples with known multiband
				photometry. For details see Christlieb et al. (2001,
				2001A&amp;A...366..898C)."
			verbLevel="15"/>
		<column name="mag_b_hes"
			unit="mag" ucd="phot.mag;em.opt.b"
			tablehead="Mag. B"
			description="Approximate photographic magnitude in the Johnson B band
				derived by combining the B_J magnitude and the B-V colour."
			verbLevel="5" note="b"/>

		<column name="strc1"
			ucd="spect.index;em.opt"
			tablehead="C1"
			description="Stroemgren c1 index measured in the HES spectrum."
			verbLevel="15"/>
		<column name="balmsum"
			ucd="spect.index;em.opt"
			tablehead="Balmer"
			description="Sum of equivalent widths of Hbeta, Hgamma and Hdelta,
				measured in the HES spectrum by means of fits of Gaussians to these
				lines."
			verbLevel="15"/>
		<column name="kphes"
			ucd="spect.index;em.opt"
			tablehead="Ca K index"
			description="Line index for the Ca II K line measured in the HES
				spectrum (for details, see Christlieb et al. 2008,
				2008A&amp;A...484..721C)."
			verbLevel="15"/>
		<column name="gphes"
			ucd="spect.index;em.opt"
			tablehead="G Index"
			description="Line index for the G band of CH measured in the HES spectrum
				(for details, see Christlieb et al. 2008, 2008A&amp;A...484..721C)."
			verbLevel="15"/>

		<LOOP>
			<csvItems>
				name, label, ucd
				c2idx1, C2 feature at 5165Á, em.opt
				c2idx2, C2 feature at 4737Á, em.opt
				cnidx1, CN feature at 4216Á, em.opt
				cnidx3, CN feature at 3883Á, em.uv
			</csvItems>
			<events>
				<column name="\name"
					unit="mag" ucd="spect.index;\ucd"
					tablehead="\label"
					description="Band index for the \label measured in the HES
						spectrum (for details, see Christlieb et al. 2001,
						2001A&amp;A...375..366C)."
					verbLevel="15"/>
			</events>
		</LOOP>

		<meta name="note" tag="hes">This naming convention was originally
			adopted in 1990 when the HES was conceived as a wide-angle quasar
			survey, following similar schemes of earlier quasar surveys in the
			1980s. Later it turned out that HES spectra could be used for several
			other purposes, in particular for stellar work, made it clear that
			the concept was not appropriate as multiple HES sources can have the
			same HE name. For this reason an alternative HES identifier was
			retrospectively added, see entry "hes_id".
		</meta>

		<meta name="note" tag="qua">As the ESO Schmidt plates were physically
			too large for the PDS scanner at Hamburg Observatory, they had to be
			scanned in four quarters with the following orientation: a refers to
			the South-Western (SW) quadrant of the scanned field, b to the SE, c to
			the NE, and d to the NW.</meta>

		<meta name="note" tag="ob">For point-like objects ("stars") a PSF-weighted
			extraction was used with an extraction aperture equal to the typical
			PSF FWHM, approximately 1 arcsec. The spectra of extended sources were
			extracted with Gaussian weights based on the actual width of the
			object, but with an upper limit on the extraction aperture of 9.5
			arcsec full width (+/-4.75 arcsec) around the centroid trace. Partly
			saturated ("bright") objects were extracted as unweighted sum over 12
			arcsec (full width). For these objects the spectral values are
			unreliable because of the saturation and not even approximately
			proportional to fluxes. Absorption lines can however still be discerned
			in many spectra.</meta>

		<meta name="note" tag="ovl">In such cases the colour information of a
			HES spectrum is not to be trusted. Absorption or emission lines may
			still be traced correctly, depending on the nature of the overlapping
			source. Even for a flag value of 0, contamination by a faint object or
			an overlap at a wavelength shorter than 390.0 nm is still
			possible.
		</meta>

		<meta name="note" tag="bj">The photographic B_J band approximately covers
			the wavelength range 395.0-540.0nm. The photometric calibration of DSS
			magnitudes in all HES fields is only an approximate one, often based on
			just a few reference stars. (This was done before calibrated all-sky
			data became available.) The calibration relation was obtained as a
			Chebychev polynomial fit, which by construction gives meaningful
			results only over a predefined magnitude interval, typically around B_J
			~ 10 as bright and B_J ~ 20 as faint limit. Outside of these intervals,
			in particular for brighter objects, the "calibrated" magnitudes can
			take almost arbitrary values. This divergence behaviour of the
			Chebychev polynomials varies from field to field but is similar for all
			objects within one field, so that the resulting magnitude distributions
			of very bright stars will show artificial clustering in magnitude
			space.
		</meta>

		<meta name="note" tag="b">The conversion between B_J and Johnson B is
			based on the transformation B = B_J + 0.28 · (B − V), valid for main
			sequence stars in the colour range −0.1 &lt; (B − V) &lt; 1.6
			(Hewett et al.  1995, 1995AJ....109.1498H). The 1σ uncertainty of
			BHES is typically around 0.2 mag (Christlieb et al. 2001,
			2001A&amp;A...366..898C)."
		</meta>
	</table>

	<data id="import">
		<recreateAfter>make_view</recreateAfter>
		<property key="previewDir">previews</property>
		<sources recurse="True" pattern="data/f*.dat"/>

		<columnGrammar>
			<colDefs>
sequence: 1-9
hes_name: 11-22
hes_unique: 24-43
field: 45-49
plate: 51-55
quadrant: 57-57
objtype: 59-64
ra: 66-75
dec: 77-85
l: 87-94
b: 96-103
xpos: 105-114
ypos: 116-125
xspc: 127-138
yspc: 140-151
x_hpp1: 153-159
x_hpp2: 161-167
x_hpp3: 169-175
x_qd: 177-183
ovl: 185-190
bj_dss: 192-197
sn_bj: 199-204
hes_b: 206-209
hes_v: 211-214
hes_u: 216-219
BminVHES: 221-226
UminBHES: 228-233
strc1: 235-239
balmsum: 241-246
kphes: 248-253
gphes: 255-260
c2idx1: 262-267
c2idx2: 269-274
cnidx1: 276-281
cnidx3: 283-288
			</colDefs>

			<rowfilter>
				<code>
					@accref = \inputRelativePath{False}[:-4]+"/"+str(int(@sequence))
					yield row
				</code>
			</rowfilter>

			<rowfilter procDef="//products#define">
				<bind key="table">"\schema.meta"</bind>
				<bind key="accref">@accref</bind>
				<bind key="fsize">10000</bind>
				<bind key="mime">"application/x-votable+xml"</bind>
				<bind key="path">\fullDLURL{sdl}{@accref}</bind>
				<bind key="preview">\splitPreviewPath{.png}</bind>
			</rowfilter>
		</columnGrammar>

		<make table="meta">
			<rowmaker idmaps="*">
				<var key="ra">hmsToDeg(@ra)</var>
				<var key="dec">dmsToDeg(@dec)</var>
				<var key="aperture">{
					"stars": 1/3600.,
					"ext": 9/3600.,
					"bright": 12/3600.}[@objtype]
				</var>
				<apply procDef="//ssap#fill-plainlocation">
					<bind key="ra">@ra</bind>
					<bind key="dec">@dec</bind>
					<bind key="aperture">@aperture</bind>
				</apply>

				<LOOP listItems="strc1 c2idx1 c2idx2 cnidx1 cnidx3 kphes gphes">
					<events>
						<map key="\item">parseWithNull(@\item, float, "*")</map>
					</events>
				</LOOP>

				<map key="hes_id" source="hes_unique"/>

			</rowmaker>
		</make>
	</data>


	<table id="data" onDisk="True" adql="True">
		<meta name="_associatedDatalinkService">
			<meta name="serviceId">sdl</meta>
			<meta name="idColumn">ssa_pubDID</meta>
		</meta>

		<mixin
			sourcetable="meta"
			copiedcolumns="*"
			ssa_aperture="1/3600."
			ssa_dstitle="hes_name"
			ssa_fluxunit="''"
			ssa_specstart="3.24e-7"
			ssa_specend="4.3e-7"
			ssa_specext="2.45e-7"
			ssa_specmid="5.69e-7"
			ssa_spectralunit="'Angstrom'"
			ssa_bandpass="'Optical'"
			ssa_collection="'Hamburg-ESO Survey'"
			ssa_fluxcalib="'Uncalibrated'"
			ssa_fluxucd="'phot.flux.density;em.wl'"
			ssa_speccalib="'ABSOLUTE'"
			ssa_spectralucd="'em.wl'"
			ssa_targclass="NULL"
		>//ssap#view</mixin>

		<mixin
			createDIDIndex="True"
			calibLevel="2"
			coverage="ssa_region"
			sResolution="ssa_spaceRes"
			oUCD="ssa_fluxucd"
			emUCD="ssa_spectralucd"
			>//obscore#publishSSAPMIXC</mixin>
	</table>

	<data id="make_view" auto="False">
		<make table="data"/>
	</data>

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


	<table id="instance" onDisk="False">
		<meta name="title">HES spectrum</meta>
		<mixin ssaTable="data"
			spectralDescription="Wavelength (calibration as per A&amp;A...358...77W)"
			fluxDescription="Photographic density in this (linear offset) bin.
				This is roughly proportional to the flux."
			>//ssap#sdm-instance</mixin>
		<meta name="description">Hamburg-ESO objective prism spectrum.</meta>

		<meta name="!description">These spectra were extracted from objective
			prism spectra on the HES plates.  For non-saturated sources, the
			flux column is roughly linear.  For extended sources, the given
			aperture is an upper limit; actually, a Gaussian-weighted extraction
			based on the the actual FWHM with an upper limit of 9.5 arcsec was
			performed.  For bright sources, extraction used the unweighted sum
			over 12 arcsec (full width).  Because of the saturation, for these
			objects the spectral values are unreliable and not even approximately
			proportional to flux. Absorption lines may however still be traced
			correctly.
		</meta>

		<column name="x"
			ucd="pos.cartesian.x;em.opt" unit="um"
			tablehead="Spec Pixel"
			description="Linear spectral offset relative to the expected
				location of the 5360 Angstrom point of the source."/>
	</table>

	<data id="build_spectrum" auto="False">
		<embeddedGrammar>
			<iterator>
				<setup imports="gavo.protocols.products,gavo.utils.pyfits"/>
				<code>
					accparts = urllib.parse.unquote(
						self.sourceToken["accref"].split('?', 1)[-1]).split("/")
					path = "/".join(accparts[:-1])+".fits"
					row = int(accparts[-1])

					hdus = pyfits.open(base.getConfig("inputsDir") / path)
					row = hdus[0].data[row]
					hdus.close()

					for x, (spec, flux) in enumerate(zip(rd.lambdas, row)):
						yield {"x": 20*x-400, "spectral": spec, "flux": flux}
				</code>
			</iterator>
		</embeddedGrammar>
		<make table="instance">
			<parmaker>
				<apply procDef="//ssap#feedSSAToSDM"/>
			</parmaker>
		</make>
	</data>

	<service id="sdl" allowed="dlget,dlmeta,static">
		<meta name="title">\schema Datalink Service</meta>
		<meta name="description">This service produces Hamburg-ESO spectra
			in a variety of formats.</meta>
		<property name="staticData">data</property>
		<datalinkCore>
			<descriptorGenerator procDef="//soda#sdm_genDesc">
				<bind key="ssaTD">"\rdId#data"</bind>
			</descriptorGenerator>
			<dataFunction procDef="//soda#sdm_genData">
				<bind key="builder">"\rdId#build_spectrum"</bind>
			</dataFunction>
			<FEED source="//soda#sdm_format"/>

	 		<metaMaker semantics="#progenitor">
				<code>
					if descriptor.pubDID is None:
						return

					parts = descriptor.pubDID.split("?")[-1].split("/")
					row = parts[-1]
					yield descriptor.makeLinkFromFile(
						base.getConfig("inputsDir") / ("/".join(parts[:-1])+".fits"),
						description="The original FITS produced by Norbert Christlieb;"
							" this is a stack of spectra, and the current spectrum is"
							f" in row {row}.")
				</code>
			</metaMaker>

		</datalinkCore>
	</service>


	<service id="web" defaultRenderer="form">
		<meta name="shortName">\schema Web</meta>
		<meta name="title">Hamburg/ESO Survey Browser Service</meta>

		<dbCore queriedTable="data">
			<condDesc buildFrom="ssa_location"/>
			<condDesc buildFrom="hes_name"/>
			<condDesc>
				<inputKey original="hes_id" type="vexpr-string">
					<preparse>
						if input and re.match(r"\d\d\d\d\d\d[pm]", input):
							# this is probably a naked HE identifier without a leading HE.
							return "HE"+input
						return input
					</preparse>
				</inputKey>
			</condDesc>
		</dbCore>

		<outputTable>
			<outputField original="accref">
				<property key="anchorText">SDM Spectrum</property>
			</outputField>
			<outputField original="ovl"/>
			<autoCols>hes_name, hes_id, bj_dss, sn_bj, objtype, strc1</autoCols>
			<FEED source="//ssap#atomicCoords"/>
		</outputTable>
	</service>

	<service id="ssa" allowed="form,ssap.xml">
		<meta name="shortName">\schema SSAP</meta>
		<meta name="title">Hamburg/ESO service SSAP</meta>
		<meta name="ssap.complianceLevel">full</meta>

		<publish render="ssap.xml" sets="ivo_managed"/>
		<publish render="form" sets="ivo_managed,local" service="web"/>

		<ssapCore queriedTable="data">
			<property key="previews">auto%delete this line if you have no previews; else delete just this.%</property>
			<FEED source="//ssap#hcd_condDescs"/>
		</ssapCore>
	</service>

	<regSuite title="hamburg_eso regression">
		<regTest title="hamburg_eso SSAP serves some data">
			<url REQUEST="queryData"
				PUBDID="ivo://org.gavo.dc/~?hamburg_eso/data/f718_p9159/185"
				>ssa/ssap.xml</url>
			<code>
				row = self.getFirstVOTableRow()
				self.assertEqual(row["ssa_dstitle"], "HE 1250-1235")
				self.assertEqual(row["hes_id"], "HE125239m125148a9159")
				self.assertAlmostEqual(row["ra"], 193.16125)
				self.assertAlmostEqual(row['ssa_specend'], 4.3e-07)
				self.assertAlmostEqual(row['sn_bj'], 1.85)
			</code>
		</regTest>

		<regTest title="hamburg_eso web resolves unmarked HES identifiers">
			<url parSet="form" hes_id="125239m125148a9159">web/form</url>
			<code>
				# This will fail if DaCHS' preparse on inputKeys fails.
				self.assertHasStrings("193.1612500")
			</code>
		</regTest>

		<regTest title="hamburg_eso Datalink metadata looks about right.">
			<url ID="ivo://org.gavo.dc/~?hamburg_eso/data/f718_p9159/185"
				>sdl/dlmeta</url>
			<code>
					by_sem = self.datalinkBySemantics()
					self.assertTrue(
						by_sem["#progenitor"][0]["description"].endswith(
						"and the current spectrum is in row 185."))
					self.assertEqual(
						by_sem["#progenitor"][0]["content_type"],
						"application/fits")
					self.assertTrue(
						by_sem["#this"][0]["access_url"].endswith(
							"getproduct/hamburg_eso/data/f718_p9159/185"))
			</code>
		</regTest>

		<regTest title="hamburg_eso delivers some data.">
			<url ID="ivo://org.gavo.dc/~?hamburg_eso/data/f718_p9159/185"
				>sdl/dlget</url>
			<code>
				self.assertXpath(
					"//v:PARAM[@utype='spec:Spectrum.Char.SpatialAxis.Coverage.Location.Value']",
					{"value": "193.16125000183936 -12.863055554902795"})
			</code>
		</regTest>
	</regSuite>
</resource>
