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

<resource resdir="liverpool" schema="liverpool">
	<meta name="_news" date="2009-11-30" author="MD">Ingested new SDSS-r data for H1413+117</meta>
	<meta name="title">Liverpool Quasar Lens Monitoring</meta>
	<meta name="creationDate">2007-07-17T18:24:01Z</meta>
	<meta name="schema-rank">1000</meta>
	<meta name="creator">Goicoechea, L.J.;  Shalyapin, V.;
		Gil-Merino, R.; Ullán, A.; The GLENDAMA Team</meta>

	<meta name="subject">quasars</meta>
	<meta name="subject">strong-gravitational-lensing</meta>
	<meta name="subject">observational-cosmology</meta>

	<meta name="_related" title="Federated Lens Image Search"
		>\internallink{/lensunion/q/im/form}</meta>

	<meta name="description">This collection includes optical monitorings of gravitationally
lensed quasars. The frames can be used to make light curves of quasar images
and field objects. From quasar light curves, one may measure time delays and
flux ratios, analyse variability and chromaticity, etc. These direct
analyses/measurements are basic tools for different astrophysical studies,
e.g., expansion rate of the Universe, mechanism of intrinsic variability in
quasars, accretion disk structure, supermassive black holes, dark halos of
galaxies (dust, collapsed dark matter, smoothly distributed dark matter,...)</meta>
	<meta name="referenceURL" title="GLENDAMA web site">http://grupos.unican.es/glendama/</meta>
	<meta name="facility">2m Liverpool robotic telescope (Canary Islands,
		Spain)</meta>
	<meta name="instrument">RATCam CCD camera and gri Sloan filters</meta>
	<meta name="copyright" format="rst">
		The Liverpool robotic telescope frames have been obtained
		from different observational programmes conducted by the
		GLENDAMA team, and are in the public domain. Additional
		information (Liverpool Quasar Lens Monitoring  project,
		data releases and other scientific outputs, etc) are
		available at the `GLENDAMA Web Site
		&lt;http://grupos.unican.es/glendama/&gt;`__.
	</meta>

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

	<table id="rawframes" adql="True" onDisk="True" mixin="//siap#pgs">
		<register services="lensunion/q#im"/>
		<mixin
			collectionName="'GLENDAMA'"
			instrumentName="'2m Liverpool robotic telescope'"
			targetName="object"
			targetClass="'GravLens'"
			expTime="exposure"
		>//obscore#publishSIAP</mixin>

		<column name="creation_date" type="date"
			unit="d" ucd="time.creation"
			tablehead="Creation Date"
			description="Date of FITS file creation"
			displayHint="type=humanDate"/>
		<column name="type" type="text"
				required="true" tablehead="Obs. Type"
				description="Type of the observation (Science, Flat...)"
				ucd="meta.code.class">
		</column>
		<column name="object" type="text"
			tablehead="Target Object" ucd="meta.id"
			description="Object observed, Simbad resolvable identifier"/>
		<column name="raw_object" type="text"
			tablehead="Target Object (Header)" ucd="meta.id"
			description="Object observed as given in the header"/>
		<column name="observatory" type="text"
			tablehead="Observed at" ucd="meta.id;instr.obsty"
			description="Observatory of origin for this frame"/>
		<column name="telescope" type="text"
			tablehead="Telescope"  ucd="instr.tel"
			description="Telescope used to obtain the frame"/>
		<column name="instrument" type="text"
			tablehead="Instrument"
			description="Identifier of the originating instrument"/>
		<column name="detector" type="text"
			tablehead="Detector" description="Detector used"
			ucd="meta.id;instr"/>
		<column name="exposure" type="real"
			tablehead="Exp. time" description="Exposure time"
			unit="s" ucd="time.duration;obs.exposure"/>
		<column name="airmass" tablehead="Air mass"
			description="Air mass at center of observation" unit=""
			ucd="obs.airMass"/>
		<column name="moonfrac" tablehead="Moon illum."
			description="Fraction of illuminated area of the moon at obs. time"
			ucd="obs.param;arith.ratio"/>
		<column name="moondist" tablehead="Lunar dist."
			description="Lunar distance from target" unit="deg"
			ucd="pos.angDistance"/>
		<column name="l1sat" type="boolean" required="True"
			tablehead="Saturated?"
			description="Is the brightest object in the field saturated?"
			ucd="instr.saturation;stat.max"/>
		<column name="background" tablehead="Background"
			description="Background in counts" unit="ct.s**-1"
			ucd="instr.background"/>
		<column name="seeing" unit="arcsec"
			tablehead="Seeing" ucd="instr.obsty.seeing"
			description="Estimate for seeing at observation time"/>
		<column name="startTime" type="timestamp"
			ucd="time.start" tablehead="UT of obs. start"
			description="UT at start of observation"/>
	</table>

	<coverage>
		<updater sourceTable="rawframes"/>
		<temporal>54009.2 54674.9</temporal>
		<spatial>5/1816,1856,4804 6/4574,4593,4596-4597,8705,8707,8710</spatial>
		<spectral>2.30982e-19 5.44232e-19</spectral>
	</coverage>
	
	<rowmaker id="make_rawframes">
		<apply name="fix_weird_filter_names">
			<setup>
				<code>
					liverpool2sane = {
						"SDSS-I": "SDSS i'",
						"SDSS-R": "SDSS r'",
						"SDSS-G": "SDSS g'",
					}
				</code>
			</setup>
			<code>
				vars["filter"] = liverpool2sane[
					"".join(f for f in [vars["FILTER1"], vars["FILTER2"]] if f!='clear')]
			</code>
		</apply>

		<apply procDef="//procs#mapValue">
			<bind key="sourceName">"maidanak/res/maydanak_targets.txt"</bind>
			<bind key="destination">"object"</bind>
			<bind key="value">vars["OBJECT"]</bind>
		</apply>

		<apply procDef="//siap#setMeta">
			<bind key="title">"JMU %s %s"%(vars["DATE_OBS"], vars["object"])</bind>
			<bind key="instrument">vars["CONFNAME"]</bind>
			<bind key="dateObs">parseTimestamp(vars["DATE_OBS"].split(".")[0])</bind>
		</apply>

		<apply procDef="//siap#getBandFromFilter">
			<bind key="sourceCol">"filter"</bind>
		</apply>

		<apply procDef="//siap#computePGS"/>

		<simplemaps>raw_object:OBJECT,observatory:ORIGIN,
			telescope:TELESCOP,instrument:INSTRUME,detector:DETECTOR,
			exposure:EXPTIME,airmass:AIRMASS,moonfrac:MOONFRAC,
			moondist:MOONDIST,background:BACKGRD,creation_date:DATE</simplemaps>
		<idmaps>object</idmaps>
		
		<map dest="l1sat">parseBooleanLiteral(@L1SAT)</map>
		<map dest="type">"SCIENCE"</map>
		<map dest="seeing">float(@SEEING)*float(@CCDSCALE)</map>
		<map dest="startTime">mjdToDateTime(result["dateObs"])</map>

	</rowmaker>

	<data id="content">
		<sources pattern="data/*.fits" recurse="True"/>
		<fitsProdGrammar qnd="True">
			<rowfilter procDef="//products#define">
				<bind key="table">"liverpool.rawframes"</bind>
				<bind key="owner">"liverpool"</bind>
				<bind key="embargo">"2005-12-31"</bind>
			</rowfilter>
			<ignoreOn name="skip non-calibrated">
				<not>
					<keyPresent key="A_2_0"/>
				</not>
			</ignoreOn>
		</fitsProdGrammar>
		<make table="rawframes" rowmaker="make_rawframes"/>
		<recreateAfter>lensunion/q#import</recreateAfter>
	</data>


	<dbCore id="qcore" queriedTable="rawframes">
		<condDesc>
			<inputKey original="object" showItems="5"
					required="true" type="text" multiplicity="multiple">
				<values fromdb="object FROM liverpool.rawframes WHERE type='SCIENCE'"/>
			</inputKey>
		</condDesc>
		<condDesc buildFrom="dateObs"/>
		<condDesc buildFrom="exposure"/>
		<condDesc buildFrom="airmass"/>
		<condDesc buildFrom="background"/>
		<condDesc buildFrom="seeing"/>
		<FEED source="//procs#negatableBoolean" column="l1sat"/>
		<condDesc>
			<inputKey original="bandpassId" showItems="3" multiplicity="multiple">
				<values fromdb="bandpassid FROM liverpool.rawframes"/>
			</inputKey>
		</condDesc>
	</dbCore>

	<service id="q" core="qcore">
		<meta name="shortName">LivQLensMon</meta>
		<publish render="form" sets="local"/>
		<outputTable namePath="rawframes">
			<outputField original="startTime" displayHint="type=humanDatetime"/>
			<outputField original="accref" displayHint="type=product,width=100"/>
			<LOOP listItems="object exposure bandpassId accsize
					airmass moonfrac moondist background seeing">
				<events>
					<outputField original="\item"/>
				</events>
			</LOOP>
		</outputTable>
	</service>

	<regSuite title="Liverpool regression">
		<regTest title="Liverpool service delivers form">
			<url>q/form</url>
			<code>
				self.assertHasStrings("&lt;h1>Liverpool", "QSO B0957+5608A")
			</code>
		</regTest>

		<regTest title="Liverpool service delivers data">
			<url parSet="form" object="QSO B0957+5608A"
				dateObs="&lt; 2007-12-31">q/form</url>
			<code>
				self.assertHasStrings("Product", "insertPreview(this")
			</code>
		</regTest>
	</regSuite>

	<regSuite title="DaCHS regression">
		<regTest title="Three-way boolean condition preselects ANY">
			<url>q/form</url>
			<code>
				self.assertXpath("//h:input[@name='l1sat'"
					" and @value='__DaCHS__ANY__']", {"checked": "checked"})
			</code>
		</regTest>

		<regTest title="Three-way boolean condition respects False">
			<url parSet="form" l1sat="No" object="QSO B0957+5608A"
				dateObs="2007-05-28">q/form</url>
				<!-- this is actually rather fragile, as the test still
				passes when l1sat is ignored.  I don't have a better test
				with my test data yet, though -->
			<code>
				self.assertHasStrings(
					"getproduct/liverpool/data/c_e_20070528_54_1_1_1.fits")
			</code>
		</regTest>
	</regSuite>
</resource>
