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

<resource schema="arigfh">
<!-- Note: the master cat master.2 was taken from
proj-data/s07/ident.linux/ari. This seemed the most recent one.
-->

	<meta name="title">ARIGFH object catalog</meta>
	<meta name="creationDate">2011-05-06T11:10:00Z</meta>
	<meta name="schema-rank">100</meta>
	<meta name="description">ARI's "Geschichte des Fixsternhimmels" is
	an attempt to collect all astrometrically useful observations
	from before ca. 1970 in a way comparable to what has been done
	to construct the FK* series of fundamental catalogs.  About 7e6 published
	positions are included.
	
	In GAVO's DC, we provide tables of identified and non-identified
	stars together with the master catalog that objects were identified
	against.</meta>
	<meta name="doi">10.21938/7p:fef29C9YeU6XdXdwSVw</meta>

	<FEED source="//procs#license-cc-by" what="catalog data"/>

	<meta name="_longdoc" format="rst"><![CDATA[
		ARIGFH (ARI's "Geschichte des Fixsternhimmels") was a project
		running from at least 1990 until the early 2000s at Astronomisches
		Rechen-Institut Heidelberg (today a part of Zentrum für Astronomie
		of Heidelberg University).
		It strived to become the successor to `Geschichte des Fixsternhimmels`_
		(see below) and succeeded in digitizing roughly 2500 and cross-matching
		about 1600 historical catalogs but petered out in the early 2000s for
		various reasons.

		What is left is a large set of published positions, many matched against a
		master catalog, quite a few unresolved.  There are also rough catalog
		descriptions, the raw catalogs in ASCII format, and FORTRAN subroutines (of
		admittedly varying quality) to parse the raw catalogs.

		Some work has been done on bringing the systems of some of those catalogs
		to the ICRS and do further processing with the aim of producing
		proper motions of the objects.  You are welcome to contact the
		operators if you are interested in taking up this work.  Note
		that some command of German would certainly help a lot in this
		case.

		Locating Data
		=============

		Two main entry points might be interesting for the casual user --
		for one, the \RSTservicelink{arigfh/q/cone/form}{cone search} that
		gives you, for a given object or ICRS position, all observations
		that were matched to master objects near that position.  Note that
		the first columns from the result tables come from the master catalog,
		i.e., they are all identical for the same star.  The later quantities
		(e.g., raCat and decCat) give what is in the catalog.  Of course, positions
		and other data are for the equinoxes and epochs specified with
		each row.

		The second entry point for the casual user is
		\RSTservicelink{arigfh/katkat/q/form}{katkat}, the catalog of
		catalogs.  Look for data for particular epochs, search by
		titles or authors, or just browse (links for doing that are in
		the \RSTservicelink{arigfh/katkat/q/info}{katkat service info}).
		Catalogs that have Teleki numbers have links into ARIGFH leading
		to the objects identified and not identfied from these tables.

		Advanced users will want to directly access the tables.

		The Tables
		===========

		The arigfh schema consists of several tables.  The most important one is
		the \RSTtable{arigfh.gfh} table, containing almost all published data.  In
		it, positions and proper motions are largely as they were published, i.e.,
		in a wild mixture of equinoxes for a wild mixture of epochs.  Also, not all
		objects have both a usable RA and Dec.  Therefore, there is no spatial
		index on the table.  We have indexed RA and Dec separately, though.

		The primary way to approach the gfh table (apart from sequential scans,
		which due to the moderate size of the table should be no big issue) is
		through ``catid`` (the catalog id, formed like tNNNNpNN; see
		\RSTservicelink{arigfh/katkat/q/form}{katkat} for details) and
		``catan`` (the ARIGFH-assigned running number within the catalog, as
		opposed to ``catcn``, the published catalog number).
		
		Within the \RSTtable{arigfh.gfh} table,  there should for most objects be
		sufficient metadata to at least precess the objects. What ARIGFH actually
		did to crossmatch the objects was to precess and transform a master
		catalog (in the \RSTtable{arigfh.master} table) to the published
		epoch and equinox and use that to crossmatch the objects.

		The result of this matching is in the \RSTtable{arigfh.identified}
		table.  It connects each identified position from the gfh table via
		the ``catid``/``catan`` pair to a position in the master catalog
		(via the ``masterNo`` column).  These relationships are flattened
		out in the \RSTtable{arigfh.id} table.  This is the basis for the
		SCS and web services since it contains ICRS positions as well as the
		historic observations.

		Analoguosly, there is the \RSTtable{arigfh.unidenfied} table, giving
		``catid`` and ``catan`` for the objects from gfh that could not be
		matched to the master catalog.  Selecting those from the gfh table
		yields \RSTtable{arigfh.nid}.  There's a simple web frontend for
		that table at \RSTservicelink{arigfh/q/nidweb/form}.
		Most of what is in there these probably just represents typos, but if you
		look, you will certainly find all kinds of weird things.
		Who knows -- maybe you could even find the optical counterpart
		of a historic GRB...

		
		The FORTRAN subroutines
		=======================

		Where available, the
		\RSTservicelink{arigfh/katkat/q/form}{katkat service} lets you
		download the FORTRAN subroutines that were used to parse the
		data files.  To understand them, please refer to to the
		\RSTservicelink{/arigfh/q/nidweb/static}{(German) descriptions} or
		ask the operators for the documents to be translated; of course,
		all comments in the FORTRAN code are in German, too.  On the other
		hand, those comments are not terribly useful in the first place.

		The subroutines use some functions that we have not yet published,
		mainly because they might be embarrassing to the anonymous
		authors.  If you actually intend to use the subroutines, let us know
		and we will try to cook up a source file that contains all
		functions used.

		While working on the import of the old data, many subroutines needed
		to be fixed.  Most changes fixed spurious line feeds, uninitialized
		variables, changes in the FORTRAN compiler's way to evaluate
		string comparisons, etc.  Since the original routines are still
		stored, it would be possible to reconstruct the changes, but since
		they are unlikely to have introduced additional problems, we do
		not list changes here.

		However, with this experience in mind, it is certain that additional
		problems connected to changing FORTRAN semantics lurk in the parsing
		subroutines and thus the data.  Bug reports are welcome.

		Having said all that, the only thing the subroutines should probably
		used for is to glean metadata from them.  The student assistants
		who wrote the subroutines were supposed to carefully study the
		introductions to the catalogs in order to fill out the metadata
		fields (kennx4/8), and quite a number of them actually did.


		Geschichte des Fixsternhimmels
		==============================

		ARIGFH's predecessor or inspiration, "Geschichte des Fixsternhimmels"
		(Paetsch et al) or GFH, "The history of the stellar sky", is a massive
		collection of stellar positions from almost all published catalogs for the
		18th and 19th centuries.

		The endeavor started in 1898 with a memorandum by Friedrich Wilhelm
		Ristenpart of Heidelberger Sternwarte (with input by Arthur von Auwers, who
		had suggested a similar project some 20 years before) to the Prussian
		Academy of Sciences proposing the generation of a "Thesaurus positionum
		stellarum affixarum".  Auwers then applied for funding and got it for
		fiscal year 1898/99.  Ristenpart was appointed director of the
		project.

		The source material of GFH consisted of 442 catalogs with roughly 250000
		objects and about a million individual positions.  These had to be
		brought to equinox B1875.0 and crossmatched, all without the help
		of modern digital computers.

		One first result of Ristenpart's activities was the "Fehlerverzeichnis
		zu den Sternkatalogen des 18. und 19. Jahrhunderts" ("Directory of
		Errors in the Star Catalogs of the 18th and 19th centuries"), published
		in 1908.  When Ristenpart moved to Santiago de Chile, Hans Paetsch
		took over.  Due to Auwer's death, World War I, and problems in
		the preprint phase, the first volume of GFH, covering 0h in RA on the
		northern sky, was only published in 1922.

		In the 1920s, work was significantly delayed when temporarily Paetsch
		was the only person actually working on GFH.  Starting 1926, personnel
		was re-allotted to GFH, such that by 1936 the northen part of GFH was
		finished.

		The publication of the southern part of GFH began in 1937, after Johannes
		Haas had taken over from Paetsch when the latter had retired in 1929.
		World War II and the split of the program into a western part in Bonn
		and a dormant eastern part in Potsdam had brought GFH to a standstill until
		IAU's executive committee passed a decision noting the importance
		of the volumes still missing.

		The last volume of the original GFH (full catalog set reduced to equinox
		B1875.0) was published by the East German GFH project in 1966; somewhat
		earlier, the Bonn group published their last volume in 1958, but they
		were missing some catalogs that they considered sufficiently covered
		by the Hamburg Index.
		
		This section is heavily based on `1972S&W....11..224A`_.  The bibliography
		there lists the following items that are not yet in ADS:

		* Dick, J., 1959: "Die Geschichte des Fixsternhimmels", Die Sterne 29, 129
		* Prager, R., 1926: "Die Geschichte des Fixsternhimmels", Die Sterne 3, 102
		* Felsmann, G., 1966: "Sternpositionen aus zwei Jahrhunderten", Die Sterne 42, 81
		* Guthnik, P., 1928: "Bericht über die Geschichte des Fixsternhimmels", Sitzungsberichte der Preußischen Akademie der Wissenschaften, phil.-hist. Klasse, S. XXVIIf

		.. _1972S&W....11..224A: http://ads.g-vo.org/abs/1972S%26W....11..224A
	]]></meta>

	<meta name="subject">stars</meta>
	<meta name="subject">history-of-astronomy</meta>
	<meta name="subject">catalogs</meta>
	<meta name="subject">astrometry</meta>

	<meta name="creator">Schwan, H.; Demleitner, M.; Wielen, R.</meta>

  <meta name="coverage.waveband">Optical</meta>
  <coverage>
  	<spatial>0/0-11</spatial>
  	<temporal>1700-01-01 2005-12-31</temporal>
  </coverage>

	<meta name="source">1989AGAb....2...33W</meta>

	<meta name="_related" title="Catalog of catalogs"
		>/arigfh/katkat/q/form</meta>

	<table onDisk="True" id="master" mixin="//scs#q3cindex"
			primary="catno" adql="True">
		<mixin>//scs#pgs-pos-index</mixin>
		<meta name="description">The master catalog against which all
		ARIGFH historical observations were matched.</meta>
		<meta name="table-rank">5</meta>

		<stc>
			Position ICRS Epoch J2000 "raj2000" "dej2000"
			Velocity "pmra" "pmde"
		</stc>

		<column name="catno" type="integer" required="True"
			ucd="meta.id;meta.main"
			tablehead="id#"
			description="Identification number in the ARIGFH master catalog"
			verbLevel="1"/>
		<column name="raj2000" type="double precision"
			ucd="pos.eq.ra;meta.main" unit="deg"
			tablehead="RA"
			description="Master Right Ascension, Epoch and Equinox J2000"
			verbLevel="1" displayHint="sf=8"/>
		<column name="dej2000" type="double precision"
			ucd="pos.eq.dec;meta.main" unit="deg"
			tablehead="Dec"
			description="Master Declination, Epoch and Equinox J2000"
			verbLevel="1" displayHint="sf=8"/>
		<column name="pmra" type="double precision"
			ucd="pos.pm;pos.eq.ra" unit="deg/yr"
			tablehead="PM(RA)"
			description="Master Proper Motion in RA, Epoch and
				Equinox J2000, cos(delta) applied"
			verbLevel="11" displayHint="sf=1,displayUnit=mas/yr"/>
		<column name="pmde" type="double precision"
			ucd="pos.pm;pos.eq.dec" unit="deg/yr"
			tablehead="PM(Dec)"
			description="Master Proper motion in Declination,
				Epoch and Equinox J2000"
			verbLevel="11" displayHint="sf=1,displayUnit=mas/yr"/>
		<column name="mv"
			ucd="phot.mag;em.opt.V" unit="mag"
			tablehead="m_V"
			description="Visual magnitude in the master catalog"
			verbLevel="18" displayHint="sf=1"/>
		<column name="mb"
			ucd="phot.mag;em.opt.B" unit="mag"
			tablehead="m_B"
			description="Blue magnitude in the master catalog"
			verbLevel="18" displayHint="sf=1"/>
		<column name="component" type="char"
			ucd="meta.code.multip"
			tablehead="Comp"
			description="Component designation in a multiple system in the master
				catalog"
			verbLevel="19">
			<values nullLiteral=" "/>
		</column>

		<meta name="note" tag="cis">
			The source of the color index is the Hipparcos catalog
			if this field is 1 and the Kharchenko catalog if this field is 2.
		</meta>
	</table>

	<table onDisk="True" id="identified" adql="True">
		<meta name="description">Matches between the master catalog and
			the historical catalogs.</meta>
		<meta name="table-rank">6</meta>

		<index columns="masterNo"/>
		<index columns="catid"/>
		<index columns="catan"/>
		<index columns="catan,catid"/>
		<column name="dist" type="double precision"
			ucd="pos.angDistance" unit="deg"
			tablehead="Offset"
			description="Offset between master catalog position at catalog
				epoch and equinox and the catalog position"
			verbLevel="1" displayHint="displayUnit=mas,sf=1"/>
		<column name="masterNo" type="integer" required="True"
			ucd="meta.id;meta.main"
			tablehead="Master#"
			description="Catalog number in master catalog (arigfh.master)"
			verbLevel="1"/>
		<column name="dcomp" type="char"
			ucd="meta.code.multip"
			tablehead="Comp"
			description="Component designation for multiple system, as in
				the master catalog"
			verbLevel="13">
			<values nullLiteral=" "/>
		</column>
		<column name="iq" type="smallint" required="True"
			ucd="meta.code.qual"
			tablehead="Match Qual."
			description="Quality of match, quality decreasing with
				values increasing from 2"
			verbLevel="25">
		</column>
		<column name="csort" type="smallint" required="True"
			ucd="meta.code"
			tablehead="Cat. type"
			description="Catalog type"
			verbLevel="25"
			note="ct"/>
		<column name="catid" type="text" required="True"
			ucd="meta.id.cross"
			tablehead="Cat. code"
			description="Catalog designation as in arigfh.katkat"
			verbLevel="1"/>
		<column name="catan" type="integer" required="True"
			ucd="meta.id"
			tablehead="ARI catno"
			description="Object number in source catalog, ARI assigned"
			verbLevel="25"/>

		<meta name="note" tag="ct">
			The csort column indicates the type of the catalog the row
			was generated from.  The following values are defined:

			======  ================================================
			  -1    Meridian circle or similar, only RA observed
			  -2    Meridian circle or similar, only Dec observed
			  -3    Meridian circle or similar, obs. in RA and Dec
			 -10    Photographic catalog
			 -20    Satellite observations
			 -70    Surveys of limited precision
			 -80    Other observational material
			-1000   Compilation catalog, Epoch=Equinox
			-2000   Compilation catalog on mean epoch
			-3000   Other compilation catalog
			======  ================================================
		</meta>

	</table>

	<table onDisk="True" id="unidentified" adql="True" namePath="identified">
		<meta name="description">The objects in the gfh table that
		could not be matched with objects in the master catalog
		by ARIGFH.</meta>
		<meta name="table-rank">6</meta>
		<index columns="catid,catan"/>
		<column original="catan"/>
		<column original="catid"/>
	</table>


	<table onDisk="True" id="gfh" adql="True">
		<meta name="description">The table of (almost) all objects
		read from the catalogs, together with most of the data
		given in them.
		</meta>
		<meta name="table-rank">1</meta>

		<stc>
			Position ICRS "raCat" "decCat"
				Error "e_RA" "e_Dec"
			Velocity "pmra" "pmde"
				Error "e_pmra" "e_pmde"
		</stc>

		<index columns="raCat"/>
		<index columns="decCat"/>
		<index columns="catan"/>
		<index columns="catid"/>
		<index columns="catan,catid"/>

		<column name="catid" type="text"
			ucd="meta.ref"
			tablehead="Cat."
			description="Catalog identifier as t(teleki no)p(part)(version)"
			verbLevel="15"/>
		<column original="identified.catan"/>
		<column name="catcn" type="integer" required="True"
			ucd="meta.id"
			tablehead="Cat id"
			description="Object number in source catalog, as in source"
			verbLevel="1"/>
		<column name="catca" type="text"
			ucd="meta.id"
			tablehead="Cat id suffix"
			description="Suffix to the designation in the source catalog"
			verbLevel="1"/>
		<column name="dscode" type="smallint" required="True"
			ucd="meta.code.multip"
			tablehead="Comp"
			description="Code for multiple star component designation"
			verbLevel="15" note="b"/>
		<column name="mag"
			ucd="phot.mag"
			tablehead="mag"
			description="Apparent magnitude as specified by magsys"
			verbLevel="15"/>
		<column name="magsys" type="text"
			ucd="meta.code;phot.mag"
			tablehead="Mag. Sys."
			description="System of mag"
			verbLevel="21" note="m"/>
		<column name="varflag" type="smallint" required="True"
			ucd="meta.code;src.var"
			tablehead="Var?"
			description="Code for photometric variability"
			verbLevel="21" note="v"/>

		<column name="raCat" type="double precision"
			ucd="pos.eq.ra" unit="deg"
			tablehead="RA (cat)"
			description="Right ascension at catalog equinox and epoch"
			verbLevel="1" displayHint="sf=7"/>
		<column name="eqRA"
			ucd="time.equinox;pos.eq.ra" unit="yr"
			tablehead="Eq. RA"
			description="Equinox of the catalog RA, Julian years"
			verbLevel="1"/>
		<column name="epRA"
			ucd="time.epoch;pos.eq.ra" unit="yr"
			tablehead="Ep. RA"
			description="Epoch of the catalog RA, Julian years"
			verbLevel="12"/>
		<column name="meanepRA"
			ucd="time.epoch" unit="yr"
			tablehead="Mean Ep. RA"
			description="Mean Epoch of RA, Julian years"
			verbLevel="27"/>
		<column name="e_RA"
			ucd="stat.error;pos.eq.ra;meta.main" unit="deg"
			tablehead="Err. RA"
			description="Mean error in right ascension as given in catalog"
			verbLevel="19"/>
		<column name="nobRA"
			ucd="meta.number;obs"
			tablehead="#(RA)"
			description="Number of observations combined into raCat"
			verbLevel="25"/>
		<column name="useRA" type="smallint"
			ucd="meta.code;pos.eq.ra"
			tablehead="Use RA?"
			description="0=RA unusable, 1=RA usable, 2=RA good, but epoch guessed"
			verbLevel="25">
			<values nullLiteral="-1"/>
		</column>
		<column name="raflags" type="integer" required="True"
			ucd="meta.code;pos.eq.ra"
			tablehead="RA flags"
			description="Details on observation and processing of RA (see note)"
			verbLevel="25"
			note="c"/>

		<column name="decCat" type="double precision"
			ucd="pos.eq.dec" unit="deg"
			tablehead="Dec (cat)"
			description="Declination at catalog equinox and epoch"
			verbLevel="1" displayHint="sf=7"/>
		<column name="eqDec"
			ucd="time.equinox;pos.eq.dec" unit="yr"
			tablehead="Eq. Dec"
			description="Equinox of the catalog declination, Julian years"
			verbLevel="1"/>
		<column name="epDec"
			ucd="time.epoch;pos.eq.dec" unit="yr"
			tablehead="Ep. Dec"
			description="Epoch of the catalog declination, Julian years"
			verbLevel="12"/>
		<column name="meanepDec"
			ucd="time.epoch" unit="yr"
			tablehead="Mean Ep. Dec"
			description="Mean Epoch of the declination, Julian years"
			verbLevel="27"/>
		<column name="e_Dec"
			ucd="stat.error;pos.eq.dec;meta.main" unit="deg"
			tablehead="Err. Dec"
			description="Mean error in declination as given in catalog"
			verbLevel="19"/>
		<column name="nobDec"
			ucd="meta.number;obs"
			tablehead="#(Dec)"
			description="Number of observations combined into decCat"
			verbLevel="25"/>
		<column name="useDec" type="smallint"
			ucd="meta.code;pos.eq.dec"
			tablehead="Use Dec?"
			description="0=Dec unusable, 1=Dec usable, 2=Dec good, but epoch guessed"
			verbLevel="25">
			<values nullLiteral="-1"/>
		</column>
		<column name="decflags" type="integer" required="True"
			ucd="meta.code;pos.eq.dec"
			tablehead="Dec flags"
			description="Details on observation and processing of dec (see note)"
			verbLevel="25"
			note="c"/>

		<column name="pmra"
			ucd="pos.pm;pos.eq.ra" unit="deg/yr"
			tablehead="PM (RA)"
			description="Cat. proper motion in RA"
			verbLevel="11"/>
		<column name="eqPmra"
			ucd="time.equinox;pos.pm;pos.eq.ra" unit="yr"
			tablehead="Eq. PM(RA)"
			description="Equinox of cat. PM in RA"
			verbLevel="21"/>
		<column name="epPmra"
			ucd="time.epoch;pos.pm;pos.eq.ra" unit="yr"
			tablehead="Ep. PM(RA)"
			description="Epoch of cat. PM in RA"
			verbLevel="21"/>
		<column name="e_pmra"
			ucd="stat.error;pos.pm;pos.eq.ra" unit="deg/yr"
			tablehead="Err. PM (RA)"
			description="Mean error in the proper motion in RA according to the
				catalog"
			verbLevel="19" displayHint="displayUnit=mas/yr,sf=2"/>
		<column name="nobpmra"
			ucd="meta.number;obs"
			tablehead="#PM (RA)"
			description="Number of observations combined into the proper
				motion in RA"
			verbLevel="25"/>
		<column name="pmraflag" type="smallint"
			ucd="meta.code;pos.pm;pos.eq.ra"
			tablehead="PM RA type"
			description="Type of PM RA; see note"
			verbLevel="19"
			note="p">
			<values nullLiteral="-1"/>
		</column>

		<column name="pmde"
			ucd="pos.pm;pos.eq.dec" unit="deg/yr"
			tablehead="PM (Dec)"
			description="Cat. proper motion in declination"
			verbLevel="11" displayHint="displayUnit=mas/yr,sf=2"/>
		<column name="eqPmde"
			ucd="time.equinox;pos.pm;pos.eq.dec" unit="yr"
			tablehead="Eq. PM(Dec)"
			description="Equinox of cat. PM in Dec"
			verbLevel="21"/>
		<column name="epPmde"
			ucd="time.epoch;pos.pm;pos.eq.dec" unit="yr"
			tablehead="Ep. PM(Dec)"
			description="Epoch of cat. PM in declination"
			verbLevel="21"/>
		<column name="e_pmde"
			ucd="stat.error;pos.pm;pos.eq.dec" unit="deg/yr"
			tablehead="Err. PM (Dec)"
			description="Mean error in the proper motion in Dec according to the
				catalog"
			verbLevel="19" displayHint="displayUnit=mas/yr,sf=2"/>
		<column name="nobpmde"
			ucd="meta.number;obs"
			tablehead="#PM (Dec)"
			description="Number of observations combined into the proper
				motion in Declination"
			verbLevel="25"/>
		<column name="pmdeflag" type="smallint"
			ucd="meta.code;pos.pm;pos.eq.dec"
			tablehead="PM Dec type"
			description="Type of PM Dec; see note"
			verbLevel="19"
			note="p">
			<values nullLiteral="-1"/>
		</column>

		<meta name="note" tag="b">
			The dscode gives a note on components of multiple star systems
			derived from what the original catalog gives.  It is formed as
			1000*n1 + 100*n2 + n3, where

			======  ==========================
			**n1**  **passage relation**
			------  --------------------------
			 0      not applicable
			 1      p, pr., first, or similar
			 2      s, sq., follow, or similar
			======  ==========================
			
			              **-**

			======  ==========================
			**n2**  **sky relation**
			------  --------------------------
			 0      not applicable
			 1      N, north, or similar
			 2      S, south, or similar
			======  ==========================

			              **-**

			======= ===================================================
			**n3**  **component designation**
			------- ---------------------------------------------------
			  0     not applicable
			1..15   A, B, C... Component
			  16    "P" Component
			  17    "Q" Component
			41..58  as 1..17, but lowercase
			  80    other designations, like "double", "triple", etc.
			  87    mean
			  88    c.g., center of gravity
			  89    as one star
			  90    additional specifications (like relative positions)
			======= ===================================================

		</meta>
		
		<meta name="note" tag="m">
			The magsys column is built from two characters as c1+c2.  Their meaning
			is

			======  ======================================
			**c1**   Magnitude use flag
			------  --------------------------------------
			 0      No magnitude observed
			 1      Magnitude was directly observed
			 2      Magniude is taken from another source
			 9      Inconsistent or unknown
			======  ======================================

			              **-**

			======  ==================================
			**c2**  Photometric system
			------  ----------------------------------
			 0      No magnitude observed
			 1      visual
			 2      photoelectric in the visual band
			 3      photographic
			 4      Tycho visual
			 5      Tycho blue
			 9      Inconsistent or unknown
			======  ==================================
		</meta>

		<meta name="note" tag="v">
			The variability flag takes the following values:

			===  =========================================
			 0   not variable (or not applicable)
			 1   variable without further information
			 2   maximum magnitude given
			 3   minimal magnitude given
			 4   mean magnitude given
			 5   RR Lyrae type variability
			 6   delta Cephei type variability
			 7   variability at a level of &lt;0.06 mag
			 8   variability at a level of 0.06 .. 0.6 mag
			 9   variability at a level of &gt;0.6 mag
			===  =========================================
		</meta>

		<meta name="note" tag="c">
			Declination and right ascension values given by the catalogue
			are described by numeric flags with up to five digits.
			The digit's meanings are, from most to least significant:

			=======  =============================================
			**msd**  **Treatment of upper and lower culmination**
			-------  ---------------------------------------------
			 0       no treatment of upper/lower culmination
			 1       value given was obtained at upper culmination
			 2       value given was obtained at lower culmination
			 3       direct observation
			 4       reflected observation
			 5       lower culmination and reflected observation
			=======  =============================================

			              **-**

			=========  ===========================================================
			2nd digit  **Type of data given**
			---------  -----------------------------------------------------------
			0          nothing given
			1          positions are observed or compiled as given
			2          catalog gives observed differences
			3          position was not observed but copied from some other source
			4          position only given approximately
			5          position was reconstructed from a difference
			=========  ===========================================================


			              **-**

			=========  ==============================================================
			3rd digit  **Position is for...**
			---------  --------------------------------------------------------------
			0          epoch of observation
			1          epoch of equinox and catalog PMs have been used
			2          some non-observation epoch, but catalog PMs have not been used
			3          sometimes for eoo, sometimes not
			9          (unclear)
			=========  ==============================================================

			              **-**

			=========  ============================================
			4th digit  **Treatment of elliptic aberration**
			---------  --------------------------------------------
			0          positions do not include elliptic aberration
			1          positions do include elliptic aberration
			9          unknown
			=========  ============================================

			              **-**
										
			=====  =====================================================
			 lsd   **Treatment of cos(delta) in RA differences and PMs**
			-----  -----------------------------------------------------
			0      no cos(delta) applied
			1      cos(delta) applied
			9      unknown
			=====  =====================================================
		</meta>

		<meta name="note" tag="p">
			The pmratype and pmdetype fields contain a single number describing
			what the proper motion given in the catalog is:

			====== =================================================
			 NULL  Nothing given
			  1    Proper motion is computed and given directly
			  2    Proper motion was taken from a different catalog
			  3    Catalog gives differences to another catalog (!)
			  4    Proper motion was given in North Polar Distance
			  9    Source of P.M. is unclear
			====== =================================================

			Note that in case 4 the sign of the proper motion has already
			been reversed.  In contrast, no attempt has been made to fix
			the relative proper motions in case 3.  Values with a flag
			of 3 are thus not usable.
		</meta>
	</table>


	<table onDisk="true" id="id" adql="True">
		<meta name="description">
			The stars from the gfh table having counterparts in the master
			catalog, together with those counterparts.
		</meta>
		<meta name="table-rank">2</meta>
		<column original="master.catno" name="masterNo"/>
		<column original="master.component" name="compMaster"/>
		<column original="master.raj2000"/>
		<column original="master.dej2000"/>
		<column original="master.pmra" name="pmraMaster"/>
		<column original="master.pmde" name="pmdeMaster"/>
		<column original="master.mv" name="mvMaster"/>
		<column original="master.mb" name="mbMaster"/>

		<LOOP listItems="catid catan dist iq">
			<events>
				<column original="identified.\item"/>
			</events>
		</LOOP>
		
		<LOOP>
			<codeItems>
				for col in context.getById("gfh"):
					yield {'item': col.name}
			</codeItems>
			<events>
				<column original="gfh.\item"/>
			</events>
		</LOOP>

		<viewStatement>
			CREATE VIEW \curtable AS (
				SELECT \colNames FROM
					(SELECT catno, raj2000, dej2000,
						pmra AS pmraMaster,
						pmde AS pmdeMaster,
						mv AS mvMaster,
						mb AS mbMaster,
						component AS compMaster FROM \schema.master) AS m
				JOIN
					\schema.identified AS idf
				ON (masterNo=catno)
				JOIN \schema.gfh
				USING (catid, catan))
		</viewStatement>
	</table>


	<table onDisk="true" id="nid" adql="True">
		<meta name="description">
			The stars from the gfh table that could not be matched with
			objects in the master catalog.
		</meta>
		<meta name="table-rank">2</meta>
		<LOOP>
			<codeItems>
				for col in context.getById("gfh"):
					yield {'item': col.name}
			</codeItems>
			<events>
				<column original="gfh.\item"/>
			</events>
		</LOOP>
		<viewStatement>
			CREATE VIEW \curtable AS (
				SELECT \colNames FROM \schema.gfh
				WHERE
					(catid,catan) in (select catid, catan from \schema.unidentified))
		</viewStatement>
	</table>


	<data id="import_master" auto="False" recreateAfter="gfhtables">
		<sources>data/master.2</sources>

		<binaryGrammar>
			<binaryRecordDef binfmt="big">
				catno(i) dej2000(d) raj2000(d) pmde(d) pmra(d)
				mv(f) mb(f) component(1s)
			</binaryRecordDef>
		</binaryGrammar>

		<make table="master">
			<rowmaker idmaps="*">
				<apply>
					<code>
						if vars["mb"]==-999:
							vars["mb"] = None
						if vars["mv"]==-999:
							vars["mv"] = None
					</code>
				</apply>
				<map dest="raj2000">@raj2000/utils.DEG</map>
				<map dest="dej2000">@dej2000/utils.DEG</map>
				<map dest="pmra" nullExcs="TypeError"
					>parseWithNull(@pmra, utils.identity, -999.)/utils.DEG</map>
				<map dest="pmde" nullExcs="TypeError"
					>parseWithNull(@pmde, utils.identity, -999.)/utils.DEG</map>
			</rowmaker>
		</make>
	</data>

	<data id="import_ids" auto="False" recreateAfter="gfhtables">
		<sources pattern="cats/arigfh/*.id" recurse="True"/>

		<binaryGrammar armor="fortran" skipBytes="462">
			<binaryRecordDef binfmt="packed">
				dist(d) masterNo(i) dcomp(h) iq(h) csort(h) cat(h)
				catpv(h) catan(i) catcn(i) catca(h) catdc(h)
			</binaryRecordDef>
		</binaryGrammar>

		<make table="identified">
			<rowmaker idmaps="*">

				<apply name="nukeBadDcomps">
					<code><![CDATA[
						# q'n'd lazyness: We swallow nonsensical dcomps
						if not 0<=@dcomp<=255:
							@dcomp = 32
					]]></code>
				</apply>
				<map dest="dist">@dist/3600.</map>
				<map dest="catid">"t%04dp%02d"%(@cat, @catpv)</map>
				<map dest="dcomp">chr(@dcomp)</map>
			</rowmaker>
		</make>
	</data>

	<procDef id="mapGFHTime">
		<doc>Converts an ARIGFH time spec to a julian year and stores
		it in the result record. See docs/xstar/kennung/timeunit1.htm
		for what's going on here.
		</doc>
		<setup>
			<par name="valKey" description="Grammar key of the time value"/>
			<par name="flagKey" description="Grammar key of the flag ('kennx')
				value"/>
			<par name="destKey" description="Record key for the result"/>
		</setup>
		<code>
			rawVal, flag = vars[valKey], vars[flagKey]
			if flag==0 or rawVal==-8888.:  # no epoch at all
				val = None
			elif flag==1:  # bessel year
				val = dateTimeToJYear(bYearToDateTime(rawVal))
			elif flag==2:  # julian year
				val = rawVal
			elif flag==3:  # julian date
				val = dateTimeToJYear(jdnToDateTime(rawVal))
			elif flag==4:  # civil date: How is this encoded, if it's there
				val = None
				base.ui.notifyError(
					"%s uses civil date, don't know what to do"%vars["catpv"])
			else:
				base.ui.notifyError(
					"%s has %s=%d -- unclear semantics, setting to NULL"%(
						vars["catpv"], flagKey, flag))
				val = None
			result[destKey] = val
		</code>
	</procDef>

	<procDef id="mapGFHPosErr">
		<doc>Converts an ARIGFH positional/pm error (xstar4(2,4,6,8)) to
			deg (or deg/yr) with cos(delta) applied.  See also
			docs/xstar/kennung/fehler.htm
		</doc>
		<setup id="errSetup">
			<par name="valKey" description="Grammar key of the pos/pm value"/>
			<par name="flagKey" description="Grammar key of the flag ('kennx')
				value"/>
			<par name="destKey" description="Record key for the result"/>
			<code>
				from gavo.stc import common as stccommon

				spaceConversionFactors = {
					# multiply these to values to get them in deg
					0: 1,   # nothing given
					1: 360./(60*60*24),  # "time" seconds
					2: 1./3600,          # arcsec
					3: 360./(60*60*24)/1000,  # milli "time" seconds
					4: 1./3600/100,      # 0.01 arcsec
					5: 1./3600/1000,     # mas
					6: 360./(60*60*24)/100,  # 0.01 "time" seconds
					7: 1./3600/10,       # 0.1 arcsec
					8: 360./(60*60*24)/10000,  # 0.1 milli "time" seconds
				}
				timeConversionFactors = {
					# multiply these to values to get them in 1/(julian yr)
					0: 1, # nothing given
					1: stccommon.tropicalYear/365.25/100, # tropical century
					2: stccommon.tropicalYear/365.25,     # tropical year
					3: 1/100.,   # julian century
					4: 1,        # julian year
				}
				raRelatedItems = set(["e_pmra", "e_RA"])
			</code>
		</setup>
		<code>
			val, flag = vars[valKey], vars[flagKey]
			if val==-8888.:
				result[destKey] = None
				return
			# We ignore the distiction between mean and probable errors;
			# Do we want to have a flag there?
			val *= spaceConversionFactors[(flag/100)%10
				]*timeConversionFactors[(flag/10)%10]

			# force cos(delta) applied if we're talking about RA-related
			# items
			if destKey in raRelatedItems:
				if (flag/10000)%10==0:
					val *= math.cos(vars["dec"])
			result[destKey] = val
		</code>
	</procDef>

	<procDef id="mapGFHPM">
		<doc>Maps the proper motions (with flags) for ARIGFH.  See
		docs/xstar/kennung/eigenbew.htm.</doc>
		<setup original="errSetup">
			<par name="destFlagKey" description="Record key for the source
				of pm-flag"/>
		</setup>
		<code>
			val, flag = vars[valKey], vars[flagKey]
			if val==-8888.:
				result[destKey] = None
				result[destFlagKey] = None
				return
			try:
				val *= spaceConversionFactors[(flag/100)%10
					]*timeConversionFactors[(flag/10)%10]
			except KeyError:
				raise base.ValidationError(
					"Cannot understand PM flag %s"%flag, flagKey)
			if (flag/10000)%10==0:
				val *= math.cos(vars["dec"])
			result[destKey] = val
			result[destFlagKey] = flag%10
		</code>
	</procDef>


	<data id="import_gfh" auto="False" recreateAfter="gfhtables">
		<sources pattern="cats/arigfh/lies.f" recurse="True"/>

		<customGrammar module="res/liesgrammar"/>

		<make table="gfh">
			<rowmaker id="make_gfh_rows">
				<idmaps>catan,catcn,catca</idmaps>

				<var name="catpv">"t%04dp%02d"%(@cat, @catpv)</var>

				<apply name="ignoreBrokenRecords">
					<doc>This proc filters out records too broken to ingest.
					for the set of catpv/catcn pairs defined in setup, raise
					IgnoreThisRow.
					</doc>
					<setup>
						<par name="toIgnore">set([
							('t0202p10', 332),
							('t2322p10', 1237),
							])
						</par>
					</setup>
					<code>
						if (@catpv, @catcn) in toIgnore:
							raise IgnoreThisRow("Manually ignored from RD")
					</code>
				</apply>

				<apply name="decodeCatCA">
					<code><![CDATA[
						catca = vars["catca"]
						if not catca:
							vars["catca"] = None
						elif catca<50:
							vars["catca"] = str(catca)
						else:
							vars["catca"] = chr(ord('a')+catca-51)
					]]></code>
				</apply>

				<LOOP>
					<csvItems>
						fromName, toName
						catmag,	  mag
						nobras,	  nobRA
						nobdec,	  nobDec
						nobpma,	  nobpmra
						nobpmd,	  nobpmde
					</csvItems>
					<events>
						<map dest="\toName" src="\fromName" nullExpr="-8888."/>
					</events>
				</LOOP>
				
				<LOOP>
					<csvItems>
						fromName, toName
						eqras,	  eqRA
						epras,	  epRA
						eqdec,	  eqDec
						epdec,	  epDec
						eqpma,	  eqPmra
						eppma,	  epPmra
						eqpmd,	  eqPmde
						eppmd,	  epPmde
						epmras,	  meanepRA
						epmdec,	  meanepDec
					</csvItems>
					<events>
						<apply procDef="mapGFHTime" name="map\fromName">
							<bind name="valKey">"\fromName"</bind>
							<bind name="flagKey">"k_\fromName"</bind>
							<bind name="destKey">"\toName"</bind>
						</apply>
					</events>
				</LOOP>

				<LOOP>
					<csvItems>
						fromName, toName
						mepmra,	  e_pmra
						merasc,	  e_RA
						medec,	  e_Dec
						mepmdc,	  e_pmde
					</csvItems>
					<events>
						<apply procDef="mapGFHPosErr" name="map\fromName">
							<bind name="valKey">"\fromName"</bind>
							<bind name="flagKey">"k_\fromName"</bind>
							<bind name="destKey">"\toName"</bind>
						</apply>
					</events>
				</LOOP>

				<LOOP>
					<csvItems>
						fromName, toName
						catdc,    dscode
						sysmag,   magsys
						indvar,   varflag
						qras,     useRA
						qdec,     useDec
					</csvItems>
					<events>
						<map dest="\toName" src="\fromName" nullExpr="-8888"/>
					</events>
				</LOOP>

				<apply procDef="mapGFHPM" name="mappmra">
					<bind name="valKey">"pma"</bind>
					<bind name="flagKey">"k_pma"</bind>
					<bind name="destKey">"pmra"</bind>
					<bind name="destFlagKey">"pmraflag"</bind>
				</apply>
				<apply procDef="mapGFHPM" name="mappmde">
					<bind name="valKey">"pmd"</bind>
					<bind name="flagKey">"k_pmd"</bind>
					<bind name="destKey">"pmde"</bind>
					<bind name="destFlagKey">"pmdeflag"</bind>
				</apply>

				<map dest="raflags">@k_ras</map>
				<map dest="decflags">@k_dec</map>
				<map dest="catid">@catpv</map>
				<map dest="raCat" nullExcs="TypeError"
					>parseWithNull(@ras, utils.identity, -8888.)/DEG</map>
				<map dest="decCat" nullExcs="TypeError"
					>parseWithNull(@dec, utils.identity, -8888.)/DEG</map>
			</rowmaker>
		</make>
	</data>

	<data id="import_nids" auto="false" recreateAfter="gfhtables">
		<sources pattern="cats/arigfh/idfailures.nid" recurse="True"/>

		<binaryGrammar armor="fortran" skipBytes="462">
			<!-- see README; this is *not* the plain arigfh nid format, we've
			added the k_ fields;  Also note that this record definition
			is also used by the custom grammar in import_gfh. -->
			<binaryRecordDef binfmt="packed" id="liesfOutputFormat">
				eqras(d) epras(d) ras(d)
				eqdec(d) epdec(d) dec(d)
				eqpma(d) eppma(d) pma(d)
				eqpmd(d) eppmd(d) pmd(d)
				epmras(d) epmdec(d)

				k_eqras(i) k_epras(i) k_ras(i)
				k_eqdec(i) k_epdec(i) k_dec(i)
				k_eqpma(i) k_eppma(i) k_pma(i)
				k_eqpmd(i) k_eppmd(i) k_pmd(i)

				catmag(f) merasc(f) nobras(f)
				medec(f) nobdec(f) mepmra(f)
				nobpma(f) mepmdc(f) nobpmd(f)

				k_catmag(i) k_merasc(i)
				k_nobras(i) k_medec(i)
				k_nobdec(i) k_mepmra(i)

				catan(i) catcn(i)
				k_epmras(i) k_epmdec(i)
				k_nobpma(i) k_mepmdc(i) k_nobpmd(i)
				integerpadding(12s)

				csort(h) cat(h) catpv(h) catca(h) catdc(h) quse(h) indvar(h)
				indmag(h) sysmag(h) ieras(h) qras(h) sysras(h) iedec(h) qdec(h)
				sysdec(h) ipma(h) qpma(h) syspma(h) iepmd(h) qpmd(h) syspmd(h)
				idflag(h) shortpadding(16s)
			</binaryRecordDef>
		</binaryGrammar>
		<make table="unidentified">
			<rowmaker simplemaps="catan:catan">
				<map dest="catid">"t%04dp%02d"%(@cat, @catpv)</map>
			</rowmaker>
		</make>
	</data>

	<data id="gfhtables" auto="False">
		<publish/>
		<make table="id"/>
		<make table="nid"/>
	</data>

	<service id="nidweb" allowed="form,static">
		<property name="staticData">docs/xstar</property>
		<property name="indexFile">docs/xstar/erlaeuterungen.htm</property>
		<meta name="title">ARIGFH unidentified objects</meta>
		<dbCore queriedTable="nid">
			<condDesc buildFrom="catid"/>
			<condDesc buildFrom="raCat"/>
			<condDesc buildFrom="decCat"/>
			<condDesc buildFrom="mag"/>
		</dbCore>
	</service>

	<service id="cone" allowed="form,scs.xml,static">
		<property name="staticData">cats/arigfh</property>
		<meta name="shortName">arigfh scs</meta>
		<meta name="title">ARIGFH identified objects</meta>
		<meta name="testQuery.ra">10</meta>
		<meta name="testQuery.dec">10</meta>
		<meta name="testQuery.sr">0.01</meta>
		<publish render="scs.xml" sets="ivo_managed"/>
		<publish render="form" sets="ivo_managed,local"/>

		<scsCore queriedTable="id">
		  <condDesc original="//scs#humanInput"/>
			<condDesc original="//scs#protoInput"/>
			<condDesc buildFrom="catid"/>
		</scsCore>
	</service>

	<regSuite title="ARIGFH regression">
		<regTest title="ARIGFH katkat delivers data and links">
			<url parSet="form" source="schlemmer galactic"
				>/arigfh/katkat/q/form</url>
			<code>
				self.assertHasStrings("1521.",
					"/arigfh/katkat/q/static/407-1-065-/data.txt")
			</code>
		</regTest>
	</regSuite>
</resource>
