<resource schema="ucac3">
	<meta name="creationDate">2009-10-01T13:30:00</meta>
	<meta name="schema-rank">1000</meta>
	<meta name="title">UCAC3 nocross</meta>
	<meta name="description">The Third US Naval Observatory CCD
	Astrograph catalogue (UCAC3) is an all-sky catalgoue containing just over 100
	million objects covering about R = 8-16 mag.  This table contains
	the original data content of UCAC3 but leaves out the data objetained
	by crossmatching to other catalogs.</meta>
	<meta name="source">2010AJ....139.2184Z</meta>

	<meta name="subject">stars</meta>
	<meta name="subject">surveys</meta>
	<meta name="subject">astrometry</meta>
	<meta name="subject">proper-motions</meta>

	<!-- corrections below largely follow the usno-ppmxl corrections.
	We should probably figure out some way to unify these. -->
	
	<table id="main" onDisk="True" adql="True" mixin="//scs#q3cindex">
		<meta name="description">The UCAC3 all-sky CCD astrograph catalogue, minus
		the fields from 2MASS and SuperCosmos and matching/object flags (which
		can be recovered with a local crossmatch).
		</meta>

		<publish sets="ivo_managed,local"/>

		<column name="raj2000" type="double precision" unit="deg"
			ucd="pos.eq.ra;meta.main" tablehead="RA"
			description="Right ascension at  epoch (ICRS)"
			note="1" verbLevel="1"/>
		<column name="dej2000" type="double precision" unit="deg"
			ucd="pos.eq.dec;meta.main" tablehead="Dec"
			description="Declination at epoch (ICRS)"
			note="1" verbLevel="1"/>
		<column name="mmag" unit="mag" ucd="phot.mag;em.opt" tablehead="Mag. Fit"
			description="UCAC fit model magnitude" note="2" verbLevel="8"/>
		<column name="maper" unit="mag" ucd="phot.mag;em.opt"
			tablehead="Mag. Aper." description="UCAC aperture magnitude"
			note="2" verbLevel="12"/>
		<column name="sigmag" unit="mag" ucd="stat.error;phot.mag;em.opt"
			tablehead="Mag. Err." verbLevel="12" note="3"
			description="UCAC error on magnitude (larger of obs. scatter and model error)"/>
		<column name="objt" type="char" ucd="src.class"
			tablehead="Ob. Type" description="Object type" note="4"
			verbLevel="18">
			<values nullLiteral=" "/>
		</column>
		<column name="dsf" type="char" ucd="meta.code"
			tablehead="Double?" description="Double star flag"
			note="5" verbLevel="18">
			<values nullLiteral=" "/>
		</column>
		<column name="sigra" ucd="stat.error;pos.eq.ra" tablehead="Err. RA"
			unit="deg" description="s.e. at central epoch in RA (*cos Dec)"
			verbLevel="12"/>
		<column name="sigdc" ucd="stat.error;pos.eq.dec" tablehead="Err. Dec"
			unit="deg" description="s.e. at central epoch in Dec"
			verbLevel="12"/>
		<column name="na1" type="smallint" required="True"
			ucd="meta.number" tablehead="#Images Av."
			description="Total number of CCD images of this star"
			verbLevel="29"/>
		<column name="nu1" type="smallint" required="True"
			ucd="meta.number;stat.fit" tablehead="#Images Used"
			description="Number of CCD images used for this star"
			verbLevel="22" note="6"/>
		<column name="us1" type="smallint" required="True"
			ucd="meta.number" tablehead="#Cats PM"
			verbLevel="29"
			description="Number of catalogs/epochs used for proper motions"/>
		<column name="cn1" type="smallint" required="True"
			ucd="meta.number" tablehead="#Cats init"
			verbLevel="29"
			description="Number of catalogs/epochs in initial match"/>
		<column name="cepra" type="date" tablehead="Ep. RA" ucd="time.epoch"
			description="Central epoch for mean RA" verbLevel="19"/>
		<column name="cepdc" type="date" tablehead="Ep. Dec" ucd="time.epoch"
			description="Central epoch for mean Declination" verbLevel="19"/>
		<column name="pmra" unit="deg/yr" tablehead="PM(RA)"
			ucd="pos.pm;pos.eq.ra"
			description="Proper motion in RA, cos(Dec) applied"
			verbLevel="9"/>
		<column name="pmde" unit="deg/yr" tablehead="PM(Dec)"
			ucd="pos.pm;pos.eq.dec"
			description="Proper motion in Declination"
			verbLevel="9"/>
		<column name="sigpmra" unit="deg/yr" tablehead="Err. PM(RA)"
			ucd="stat.error;pos.pm;pos.eq.ra"
			description="Error in proper motion in RA, cos(Dec) applied"
			verbLevel="15"/>
		<column name="sigpmde" unit="deg/yr" tablehead="Err. PM(Dec)"
			ucd="stat.error;pos.pm;pos.eq.dec"
			description="Error in proper motion in Declination"
			verbLevel="15"/>


		<meta name="note" tag="1">
			Positions are on the International Celestial Reference
			System (ICRS) as represented by the Hipparcos / Tycho-2  catalogs.
			The epoch for the positions of all stars is J2000.0; the weighted
			mean catalog position was updated using the provided proper
			motions.  The observational UCAC position is but one of several
			going into these values and is not given in the UCAC3, thus the
			original UCAC observation cannot be recovered from these data.
		</meta>

		<meta name="note" tag="2">
			Systematic errors are expected to be below 0.1 mag for im1, im2
			photometric results obtained from the UCAC CCD pixel data.  The aperture
			photometry is considered more robust, particularly for "odd" cases, while
			the model fit magnitude is expected to be more accurate for "well
			behaved" stars.
		</meta>

		<meta name="note" tag="3">
			For many stars a photometric error based on the scatter from
			individual observations of that star on different CCD frames
			could be obtained.  A model error was also attempted to be
			assigned, based on the S/N ratio.  The error quoted here is
			the larger of the 2.  If that error exceeds 0.9 mag the error
			was set to 0.9 mag.
		</meta>

		<meta name="note" tag="4">
			The object type flag is used to identify possible problems
			with a star and has the following meaning:

			====== ===============================================
			  S    warning: object could be from possible streak
			  N    warning: object is near overexposed star
			blank  good star
			  c    good star (data copied from another entry)
			  o    warning: contains at least 1 overexposed image
			  O    warning: all images are overexposed or "bad"
			====== ===============================================
		</meta>

		<meta name="note" tag="5">
			The dsf flag is a double star flag used to indicate the
			type/quality of double star fit with the following meaning:

			=  ============================================================
			0  single star
			1  primary of pair with unreal secondary = single
			2  forced separation, on same frame
			3  blended image, some CCD frames show single star, some double
			4  forced separation, 2 objects on same frame number
			5  primary   component of real double
			6  secondary component of real double
			7  other "odd" case
			=  ============================================================
		</meta>

		<meta name="note" tag="6">
			A zero for the number of used images indicates that all images
			have some "problem" (such as overexposure).  In that case an unweighted
			mean over all available images (na) is taken to derive the mean
			position, while normally a weighted mean was calculated based on
			the "good" images, excluding possible problem images (nu &lt;= na).
		</meta>

	</table>

	<coverage>
		<updater spaceTable="main" timeTable="main" mocOrder="4"/>
		<spatial>0/0-11</spatial>
		<spectral>2.649e-19 4.414e-19</spectral>
	</coverage>

	<table id="ppmxlcross" onDisk="True" adql="True">
		<meta name="description">A crossmatch between UCAC3 and PPMXL,
			created solely based on positions with a window of 1.5 arcsec radius.
		</meta>
		<index name="ppmxl" columns="ppmxlid"/>
		<index name="ucac3" columns="ucac3id"/>
		<column name="ucac3id" type="bigint" required="True"
			ucd="meta.id"
			description="ipix of UCAC3 object"
			tablehead="ucac3" verbLevel="5"/>
		<column original="ppmxl/q#main.ipix" name="ppmxlid"
			description="PPMXL ipix"/>
	</table>

	<table id="icrscorr" onDisk="True" adql="True" mixin="//scs#q3cindex">
		<mixin>//scs#pgs-pos-index</mixin>
		<meta name="description">Corrections between UCAC3
			and the ICRS as represented by PPMXL on a grid of degrees,
			obtained by substracting
			UCAC3 from PPMXL in cones of radius sqrt(2)/2 degrees around
			the given center position.</meta>

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

		<column name="nob" type="integer" required="True"
			tablehead="N"
			description="Number of objects the correction is based on"
			ucd="meta.number" verbLevel="18"/>
		<column name="alpha" type="real" ucd="pos.eq.ra;meta.main"
			description="Center for field, RA" verbLevel="1"
			tablehead="Center RA" unit="deg"/>
		<column name="delta" type="real" ucd="pos.eq.dec;meta.main"
			description="Center for field, Dec" verbLevel="1"
			tablehead="Center Dec" unit="deg"/>
		<column name="d_alpha" type="real" tablehead="PPMXL-UCAC3, RA"
			description="Correction PPMXL-UCAC3 in alpha (Epoch 2000.0)"
			verbLevel="1" ucd="pos.eq.ra;arith.diff" unit="deg"/>
		<column name="d_delta" type="real" tablehead="PPMXL-UCAC3, Dec"
			description="Correction PPMXL-UCAC3 in delta (Epoch 2000.0)"
			verbLevel="1" ucd="pos.eq.dec;arith.diff" unit="deg"/>
		<column name="d_pmalpha" type="real" tablehead="PPMXL-UCAC3, PM RA"
			description="Correction PPMXL-UCAC3 in proper motion alpha*cos(delta)"
			verbLevel="1" ucd="pos.pm;pos.eq.ra;arith.diff" unit="deg/yr"/>
		<column name="d_pmdelta" type="real" tablehead="PPMXL-UCAC3, PM Dec"
			description="Correction PPMXL-UCAC3 in delta"
			verbLevel="1" ucd="pos.pm;pos.eq.dec;arith.diff" unit="deg/yr"/>
	</table>

	<data id="import" auto="False">
		<sources pattern="data/z*"/>
		<directGrammar id="boost" cBooster="res/boosterfunc.c" recordSize="84"
			type="bin"/>
		<make table="main"/>
	</data>

	<data id="compute_cross" auto="False">
		<make table="ppmxlcross">
			<script type="preIndex" lang="SQL" name="PPMXL crossmatch">
				SET work_mem=5120000;
				INSERT INTO \curtable (
					SELECT
						q3c_ang2ipix(ucac.raj2000, ucac.dej2000),
						ppmxl.ipix
					FROM
						ucac3.main AS ucac
					JOIN
						ppmxl.main AS ppmxl
					ON (q3c_join(ppmxl.raj2000, ppmxl.dej2000,
						ucac.raj2000, ucac.dej2000, 1.5/3600)))
			</script>
		</make>
	</data>

	<data id="compute_corr" auto="False">
		<make table="icrscorr">
			<script type="preIndex" lang="SQL" name="compute corrections">
				<![CDATA[
					DROP TABLE \schema.icrscorr;
					CREATE TABLE \schema.icrscorr AS (
WITH tmpcross AS (
	SELECT
			ppmxl.raj2000 as pra,
			ppmxl.dej2000 as pde,
			ppmxl.pmra as pprma,
			ppmxl.pmde as ppmde,
			ucac.raj2000 as ura,
			ucac.dej2000 as ude,
			ucac.pmra as uprma,
			ucac.pmde as upmde
		FROM (
			SELECT
				ipix,
				raj2000,
				dej2000,
				pmra,
				pmde
			FROM ppmxl.main) as ppmxl
		JOIN (
			SELECT pmatch.ppmxlid, rawucac.* FROM (
				SELECT
					raj2000,
					dej2000,
					pmra,
					pmde
				FROM ucac3.main) as rawucac
				JOIN ucac3.ppmxlcross as pmatch
					ON (pmatch.ucac3id=q3c_ang2ipix(raj2000, dej2000))
			) AS ucac
		ON (ucac.ppmxlid=ppmxl.ipix))
SELECT
	count(*) as nob,
	round(pra)+0.5 as alpha,
	round(pde)+0.5 as delta,
	avg(CASE
		WHEN pra-ura<-10 THEN pra-ura+360
		WHEN pra-ura>10 THEN pra-ura-360
		ELSE pra-ura END)::REAL AS d_alpha,
	avg(pde-ude)::REAL AS d_delta,
	avg(pprma-uprma)::REAL as d_pmalpha,
	avg(ppmde-upmde)::REAL as d_pmdelta
FROM
	tmpcross
GROUP BY alpha, delta)
				]]></script>
		</make>
	</data>

	<dbCore id="corrcore" queriedTable="icrscorr">
	  <condDesc original="//scs#humanInput">
			<phraseMaker original="__system__/scs#humanSCSPhrase">
				<setup original="__system__/scs#scsSetup" id="proxQuery">
					<code><![CDATA[
						def genQuery(_, inPars, outPars):
							if abs(inPars["DEC"])>=90:
								inPars["DEC"] = 89.5*inPars["DEC"]/abs(inPars["DEC"])
							return ("alpha=floor(%%(%s)s)+0.5 "
								" and delta=floor(%%(%s)s)+0.5")%(
									base.getSQLKey("RA", inPars["RA"], outPars),
									base.getSQLKey("DEC", inPars["DEC"], outPars))
					]]></code>
				</setup>
			</phraseMaker>
			<inputKey name="hscs_sr" description="Ignored"
				tablehead="Ignored" widgetFactory="Hidden">0.1</inputKey>
		</condDesc>

		<condDesc original="//scs#protoInput">
			<phraseMaker original="//scs#scsPhrase">
				<setup original="proxQuery"/>
			</phraseMaker>
		</condDesc>
	</dbCore>

	<service id="corr" core="corrcore" allowed="static,form">
		<property name="staticData">static</property>
		<meta name="shortName">UCAC3 ICRS corr</meta>
		<publish render="form" sets="local,ivo_managed"/>

		<meta name="title">Corrections between UCAC3 and PPMXL</meta>
		<meta name="_related" title="PPMXL">/ppmxl/q/cone/form</meta>
		<meta name="description" format="rst"><![CDATA[
			Differences between UCAC3 and PPMXL in positions and proper
			motions, on
			an all-sky one-degree grid. At each gridpoint we give the
			differences X(PPMXL)- X(UCAC3) averaged over all stars in
			a sqrt(2)/2-degrees environment around the gridpoint given. The
			corrections given here should bring UCAC3 based astrometry to the ICRS.
			]]></meta>

		<meta name="_intro" format="rst"><![CDATA[
			For information on how to obtain the full correction tables
			or do bulk corrections, see the `service info <./info>`_.
			]]></meta>

		<meta name="coverage">
			<meta name="waveband">Optical</meta>
			<meta name="regionOfRegard">1</meta>
		</meta>

		<meta name="_longdoc" format="rst"><![CDATA[
			Observers using UCAC3 for the reduction of their CCD frames get
			positions of their targets which are not on the ICRS. Such positions
			can neither be used to derive inertial stellar proper motions, nor
			should they be used for in orbit determinations
			in the case of solar system bodies.

			To aid in reducing these observations to ICRS, we present systematic
			correction tables from UCAC3 to PPMXL for positions at epoch 2000.0
			and for proper motions.
			The tables give means of the differences in positions and
			proper motions between PPMXL and UCAC3 in circles of radius
			sqrt(2)/2 around the centers of 360 by 180 spherical squares covering
			the sky.  The application of these tables is straighforward. Suppose you
			have an observation (α,δ) based on UCAC3 at epoch T (in
			years). To locate the corrections in downloaded tables (see below), compute
			floor(α)+0.5, floor(δ)+0.5 or use the
			\RSTservicelink{/ucac3/q/corr/form}{web service}.

			The conversion to ICRS is given by
			
			.. image:: ./static/simplecorr.png

			In applying these formulae note that they are not rigorous, with
			the approximations used breaking down close to the poles.
			Also, be careful when crossing α=0 during the correction.

			The full correction table can be downloaded as
			`VOTable </ucac3/q/corr/static/ucac3corr.vot.gz>`_ or
			`plain text </ucac3/q/corr/static/ucac3corr.ascii.gz>`_.
			
			Here are maps of the corrections over the entire sky for
			RA, Declination and the proper motions:

			.. image:: ./static/icrscorrplots.png
		]]></meta>


	</service>
</resource>
