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

<resource schema="amanda">

	<!--
	!  ===========================
	!  Description of the Data Set
	!  ===========================
	!-->

	<meta name="title">AMANDA-II neutrino candidates</meta>
	<meta name="creationDate">2012-03-20T18:05:00Z</meta>
	<meta name="schema-rank">1000</meta>
	<meta name="description" format="plain">A list of neutrino candidate
		events recorded by the AMANDA-II neutrino telescope during the
		period 2000-2006.</meta>
	<meta name="copyright">This data set has been provided by the IceCube
		collaboration. It is available at
		http://icecube.wisc.edu/science/data/amanda/.</meta>
	<meta name="source">R. Abbasi et al., Phys. Rev. D 79, 062001 (2009)</meta>
	<meta name="creator">The IceCube Collaboration</meta>

	<meta name="subject">cosmological-neutrinos</meta>
	<meta name="subject">neutrino-astronomy</meta>
	<meta name="subject">particle-astrophysics</meta>

	<meta>
		coverage.waveband:Neutrino
		coverage.regionOfRegard: 1
	</meta>

	<meta name="_longdoc" format="rst"><![CDATA[
		This data set is a list of neutrino candidate events recorded by
		the AMANDA-II neutrino telescope during the period 2000-2006.
		The events are mostly from atmospheric neutrinos with a typical
		energy of several hundred GeV.  The events include a small
		fraction of misreconstructed cosmic ray muon tracks, where this
		contamination increases near the horizon.

		Included are the right ascension, the declination and the angular
		resolution (in degrees) for each event. Also included are the
		number of modules hit (in the experiment's jargon referred to as
		the number of channels, Nch), a quantity that provides a rough
		measure of the energy of the event, and the Modified Julian Day
		(MJD). The accuracy of the MJD values is one second.

		The final column is a flag indicating the subset of events used
		in the seven-year atmospheric neutrino analysis: R. Abbasi et al.,
		Phys. Rev. D79, 102005 (2009). In order to further reduce
		background contamination due to atmospheric muons, this analysis
		imposes additional quality criteria, for instance, a restricted
		declination and Nch range.
	]]></meta>


	<!--
	!  ================
	!  Table Definition
	!  ================
	!-->

	<table id="nucand" onDisk="True" adql="True" mixin="//scs#q3cindex"
			primary="id">
		<mixin>//scs#pgs-pos-index</mixin>
		<meta name="description">
			Detection parameters of neutrino candidates recorded by the
			AMANDA-II telescope. This table can be queried on the web
			at http://dc.g-vo.org/amanda/q/web
		</meta>

		<stc>
			Position ICRS "raj2000" "dej2000" Error "ang_error"
		</stc>
		
		<column name="id" type="text"
			required="True"
			ucd="meta.id;meta.main"
			tablehead="ID"
			description="Artifical primary key."
			verbLevel="1"/>
		<column name="raj2000"
			required="True"
			ucd="pos.eq.ra;meta.main" unit="deg"
			tablehead="RA"
			description="Neutrino arrival direction, RA"
			verbLevel="1"/>
		<column name="dej2000"
			required="True"
			ucd="pos.eq.dec;meta.main" unit="deg"
			tablehead="Dec"
			description="Neutrino arrival direction, Declination"
			verbLevel="1"/>
		<column name="nch"
			required="True"
			type="smallint"
			ucd="meta.number"
			tablehead="Nch"
			description="Number of optical modules hit in an event"
			verbLevel="15"/>
		<column name="ang_error"
			required="True"
			ucd="pos.angResolution" unit="deg"
			tablehead="Ang. res."
			description="Angular resolution of a neutrino event"
			verbLevel="10"/>
		<column name="mjd"
			required="True"
			ucd="time.epoch;obs" unit="d"
			tablehead="MJD"
			description="Observation time, Modified Julian Day"
			verbLevel="1">
			<values min="51590.6" max="54039.7"/>
		</column>
		<column name="atmoNuSubset"
			required="True"
			type="boolean"
			ucd="meta.code"
			tablehead="Atmosph."
			description="Subset of candidates used in AMANDA's seven-year
				atmospheric neutrino analysis"
			verbLevel="20"
			displayHint="type=checkmark"/>
		<column name="origin_est" type="scircle"
			ucd="pos.outline;obs.field"
			tablehead="Est. Origin"
			description="A circle around the most likely position with ang_error
				radius (for convenient matching)."
			verbLevel="30"/>
	</table>

	<coverage>
		<updater sourceTable="nucand" mocOrder="3"/>
			<temporal>51590.6 54039.7</temporal>
			<spatial>0/0-3 1/19,23,27,31 2/69-71,73-75,85-87,89-91,101-103,105-107,117-119,121-123 3/269-271,273-275,290-291,333-335,338-339,353-355,397-399,401-403,417-419,461-463,465-467,481-483,573-575,638-639,701-703,765-767</spatial>
	</coverage>

	<!--
	!  ==============================
	!  Input Parsing and Data Mapping
	!  ==============================
	!-->

	<data id="import_content">
		<sources pattern="data/*.txt"/>
		<columnGrammar>
			<topIgnoredLines>30</topIgnoredLines>
			<col key="dej2000">1-13</col>
			<col key="raj2000">14-25</col>
			<col key="nch">26-37</col>
			<col key="ang_error">38-49</col>
			<col key="year">50-61</col>
			<col key="utcday">62-73</col>
			<col key="utcsec">74-85</col>
			<col key="mjd">86-100</col>
			<col key="XIfAtmo">101</col>
		</columnGrammar>

		<make table="nucand">
			<rowmaker idmaps="*">
				<var key="id">@mjd.strip()+"d"+@raj2000.strip()</var>
				<var key="raj2000">float(@raj2000)*15.</var>
				<map dest="atmoNuSubset">@XIfAtmo=='X'</map>
				<map key="origin_est">pgsphere.SCircle(
					pgsphere.SPoint.fromDegrees(float(@raj2000), float(@dej2000)),
						float(@ang_error)*utils.DEG)</map>
			</rowmaker>
		</make>

	</data>

	<service id="cone" defaultRenderer="form" allowed="scs.xml,form">
		<meta name="shortName">amanda cone</meta>
		<meta>
			testQuery.ra:314
			testQuery.dec:36
			testQuery.sr:0.001
		</meta>
		<publish render="form" sets="local,ivo_managed"/>
		<publish render="scs.xml" sets="ivo_managed"/>
		<scsCore queriedTable="nucand">
			<condDesc silent="True">
				<FEED source="//pql#DALIPars"/>
			</condDesc>
			<condDesc original="//scs#humanInput">
				<phraseMaker original="//scs#humanSCSPhrase">
					<setup original="//scs#scsSetup" id="proxQuery">
						<code><![CDATA[
							def genQuery(_, inPars, outPars):
								return ("scircle(spoint(radians(%%(%s)s), radians(%%(%s)s)),"
									" radians(%%(%s)s)) && origin_est")%(
									base.getSQLKey("RA", inPars["RA"], outPars),
									base.getSQLKey("DEC", inPars["DEC"], outPars),
									base.getSQLKey("SR", inPars["SR"], outPars))
						]]></code>
					</setup>
				</phraseMaker>
			</condDesc>
			<condDesc original="//scs#protoInput">
				<phraseMaker original="//scs#scsPhrase">
					<setup original="proxQuery"/>
				</phraseMaker>
			</condDesc>
			<condDesc buildFrom="mjd"/>
		</scsCore>
	</service>

	<regSuite title="amanda">
		<regTest title="amanda cone SCS uses origin_est">
			<url RA="314" DEC="36" SR="0.001">cone/scs.xml</url>
			<code>
				rows = self.getVOTableRows()
				self.assertEqual(set([r['id'] for r in rows]),
					set(['52450.144201d20.9494', '51968.671539d20.9921',
						'53623.582002d20.9412', '52106.454653d21.0323',
						'53889.126759d21.0195', '52151.839514d20.9677',
						'53451.608900d20.8005', '53063.972222d20.7625',
						'52930.908553d20.9742']))
			</code>
		</regTest>
	</regSuite>
</resource>
