/*++++++++++++++
.IDENTIFICATION ucac_def.h
.LANGUAGE       C
.AUTHOR         Francois Ochsenbein [CDS]
.ENVIRONMENT    USNO-A2.0 Catalogue
.KEYWORDS       CDS Catalogue Server
.VERSION  1.0   20-Apr-2001
.COMMENTS       Structures & Definitions concerning the UCAC1 Catalog
		only for internal usage.
	The compacted record is made of 17 bytes = 136 bits with
	RA  = 24 bits (3 bytes)
	SPD = 21 bits
	Ep  = 11 bits (Origin = 1998)
	sx  =  8 bits
	sy  =  8 bits
	mag = 10 bits (750 .. 1699 = 950 values, then table)
	no  =  5 bits (values 2..17, then tablo)
	nc  =  5 bits (values 2..33)
	mux = 13 bits (values -2048..+2047, then tablem)
	sx  =  9 bits
	muy = 13 bits (values -2048..+2047, then tablem)
	sy  =  9 bits

Top of each file:
#UCAC1-17(80chunks)12-1234: Zxxx = xxxxx-xxxx\n
+ 4*80 offsets for starting points of each chunk (only 78 used)

Head of each chunk
  i4  total length of chunk (Nids = (TotalLength - HeaderLength)/17), rounded 4
  i4  IDmin Number of 1st ID
  i2  Length of header (bytes)
  i1  Chunk # (first byte of RA)
  i1  n(m4) Number of suppl. mus (4 bytes) starting 11...
  i1  n(mu) Number of suppl. mus (2 bytes) starting 10...
  i1  n(mV) Number of suppl. magnitudes
  i1*16 values of no > 17
  i2  unused
  i4*n(m4)  4-byte pm's
  i2*n(mu)  2-byte pm's
  i2*n(mV)  2-byte magnitudes
Chunk Body
---------------*/

#ifndef UCAC_DEF_def
#define UCAC_DEF_def	0
#ifndef _ARG
#ifdef __STDC__
#define _ARG(A)	A    /* ANSI */
#else
#define _ARG(A)	()  /* non-ANSI */
#define const
#endif
#endif

#define Dstep	1800000		/* Number of mas in a file in Declination */
#define Astep	(1<<24)		/* Number of mas in a chunk in RightAsc.  */

/*===========================================================================
		Structures 
 *===========================================================================*/

static char header_text[] = "#UCAC1-17#12-1234(80chunks)#1998#750: Z" ;

/* The header of a Chunk  a chunk is normally loaded into memory */
typedef struct ucachunk {
    int len, pos ;		/* Chunk parameters	*/
    short zone ;		/* The zone concerned	*/
    unsigned char chunkno;	/* 0 .. 77, leftmost RA	*/
    unsigned char reclen;	/* 17 or 18		*/
    long  id0, ra0, sd0, id1, ra1, sd1 ;
    long   ep0 ;		/* Epoch origin = 1998	*/
    short omag, nmag, npm2, npm4;
    char  overno[16] ;		/* no over 17 limit	*/
    short *amag, *amu2; 
    int *amu4 ;
    unsigned char  *chunk ;	/* Chunk body		*/
    int headlen ;		/* Header length (file)	*/
} CHUNK;

static long UCAC1[] = { 		/* Zone 0 doesn't exist */
    1, 909, 3521, 7994, 14358, 
    22318, 31336, 42423, 55276, 70354,
    87112, 105306, 124014, 144751, 167096, 
    190859, 215797, 242880, 271117, 301539,
    335101, 371613, 409345, 451725, 495939,
    539722, 583997, 634759, 689355, 748887,
    811762, 879292, 951404, 1027668, 1108933,
    1193590, 1282969, 1382218, 1485878, 1597808,
    1717769, 1844706, 1981147, 2128273, 2283441,
    2436217, 2594547, 2763230, 2948476, 3141195,
    3341347, 3544847, 3750978, 3969244, 4186146,
    4406693, 4646240, 4903188, 5172271, 5447783,
    5708001, 5963164, 6223595, 6482678, 6741191,
    6988253, 7232330, 7482230, 7733351, 7984537,
    8243270, 8508901, 8774112, 9039064, 9293805,
    9538043, 9782509, 10025567, 10268208, 10511152,
    10750734, 10991910, 11226045, 11460514, 11703625,
    11939529, 12174719, 12419092, 12658810, 12894408,
    13142307, 13389956, 13631959, 13864996, 14096206,
    14314899, 14543781, 14785427, 15023790, 15254977,
    15489066, 15731139, 15980851, 16236459, 16495023,
    16748698, 16986003, 17228490, 17472527, 17720758,
    17960468, 18206500, 18454341, 18702703, 18955084,
    19203318, 19460189, 19733139, 20010758, 20287529,
    20572070, 20851208, 21128972, 21409221, 21676169,
    21935856, 22182614, 22436885, 22684987, 22930867,
    23180702, 23427921, 23673523, 23926171, 24180404,
    24418170, 24651951, 24889194, 25111138, 25318075,
    25513945, 25702983, 25895421, 26087269, 26275104,
    26457041, 26626738, 26787525, 26916736, 27026975,
    27114442, 27180701, 27221814, 27254697, 27285004,
    27309655, 27329801, 27346370, 27360551, 27373894,
    27384571, 27392729, 27399504, 27405765, 27411426,
    27416331, 27420556, 27423838, 27425276, 
    27425434	/* LAST+1 Number */
} ;

/*===========================================================================
		Some useful macros
 *===========================================================================*/

#define ITEMS(a)	(sizeof(a)/sizeof(a[0]))
#define MASK(b)		((1<<(b))-1)
 
#endif
