1 /*
2  # This file is part of the Astrometry.net suite.
3  # Licensed under a 3-clause BSD style license - see LICENSE
4  */
5 
6 #ifndef UCAC4_H
7 #define UCAC4_H
8 
9 #include <stdint.h>
10 
11 #define UCAC4_RECORD_SIZE 78
12 
13 struct ucac4_entry {
14     // (in brackets are the name, format, and units in the UCAC4 data files)
15     // [degrees] (ra, I4: mas)
16     double ra;
17     // [degrees] (spd, I4: mas)
18     double dec;
19 
20 
21     // [degrees] (sigra, I1, mas)
22     // error in RA*cos(Dec)
23     float sigma_ra;
24     // [degrees] (sigdc, I1, mas)
25     float sigma_dec;
26     /* The range of values sigra and sigdc is 1 to 255 which is represented
27      as a signed 1-byte integer (range -127 to 127); thus add 128 to the
28      integer number found in the data file.  There is no 0 mas value;
29      data less than 1 mas have been set to 1 mas.  Original data larger
30      than 255 mas have been set to 255.
31      */
32 
33     // fit model mag
34     // [mag] (magm, I2: millimag)
35     // value 20.000 is used to flag errors
36     float mag;
37 
38     // aperture mag
39     // [mag] (maga, I2: millimag)
40     // value 20.000 is used to flag errors
41     float apmag;
42 
43     // [mag] (sigmag, I1: 1/100 mag)
44     float mag_err;
45 
46     // (objt, I1)
47     /*
48      0 = good, clean star (from MPOS), no known problem
49      1 = largest flag of any image = near overexposed star (from MPOS)
50      2 = largest flag of any image = possible streak object (from MPOS)
51      3 = high proper motion (HPM) star, match with external PM file (MPOS)
52      4 = actually use external HPM data instead of UCAC4 observ.data
53      (accuracy of positions varies between catalogs)
54      5 = poor proper motion solution, report only CCD epoch position
55      6 = substitute poor astrometric results by FK6/Hip/Tycho-2 data
56      7 = added supplement star (no CCD data) from FK6/Hip/Tycho-2 data,
57      and 2 stars added from high proper motion surveys
58      8 = high proper motion solution in UCAC4, star not matched with PPMXL
59      9 = high proper motion solution in UCAC4, discrepant PM to PPMXL
60      (see discussion of flags 8,9 in redcution section 2e above)
61      */
62     int8_t objtype;
63 
64     // (cdf, I1)
65     /*
66      The cdf flag is a combined double star flag used to indicate
67      the type/quality of double star fit.  It is a combination of 2 flags,
68      cdf = 10 * dsf + dst  with the following meaning:
69 
70      dsf = double star flag = overall classification
71      0 = single star
72      1 = component #1 of "good" double star
73      2 = component #2 of "good" double star
74      3 = blended image
75 
76      dst = double star type, from pixel data image profile fits,
77      largest value of all images used for this star
78      0 = no double star, not sufficient #pixels or elongation
79      to even call double star fit subroutine
80      1 = elongated image but no more than 1 peak detected
81      2 = 2 separate peaks detected -> try double star fit
82      3 = secondary peak found on each side of primary
83      4 = case 1 after successful double fit (small separ. blended image)
84      5 = case 2 after successful double fit (most likely real double)
85      6 = case 3 after successful double fit (brighter secondary picked)
86      */
87     int8_t doublestar;
88 
89     // (na1: I1)
90     // total # of CCD images of this star
91     uint8_t navail;
92 
93     // (nu1: I1)
94     // # of CCD images used for this star
95     uint8_t nused;
96 
97     // (cu1: I1)
98     // total numb. catalogs (epochs) used for proper motion
99     uint8_t nmatch;
100 
101     // Central epoch for mean RA/Dec
102     // [yr] (cepra/cepdc, I2, 0.01 yr - 1900.00)
103     float epoch_ra;
104     float epoch_dec;
105 
106     // Proper motion in RA*cos(Dec), Dec at central epoch
107     // [arcsec/yr] (pmrac/pmdc, I2, 0.1 mas/yr)
108     float pm_rac;
109     float pm_dec;
110 
111     // [arcsec/pr] (sigpmr/sigpmd, I2, 0.1 mas/yr)
112     float sigma_pm_ra;
113     float sigma_pm_dec;
114 
115     // 2MASS pts_key star identifier
116     // (pts_key, I4)
117     uint32_t twomass_id;
118 
119     // 2MASS J mag
120     // (j_m, I2, millimag)
121     float jmag;
122 
123     // 2MASS H mag
124     // (h_m, I2, millimag)
125     float hmag;
126 
127     // 2MASS K_s mag
128     // (k_m, I2, millimag)
129     float kmag;
130 
131     // e2mpho I*1 * 3         2MASS error photom. (1/100 mag)
132     float jmag_err;
133     float hmag_err;
134     float kmag_err;
135 
136     // icqflg I*1 * 3         2MASS cc_flg*10 + phot.qual.flag
137     /*
138      (cc_flg*10 + ph_qual) consisting of the contamination flag (0 to 5)
139      and the photometric quality flag (0 to 8).
140 
141      0 =  cc_flg  2MASS 0, no artifacts or contamination
142      1 =  cc_flg  2MASS p, source may be contaminated by a latent image
143      2 =  cc_flg  2MASS c, photometric confusion
144      3 =  cc_flg  2MASS d, diffraction spike confusion
145      4 =  cc_flg  2MASS s, electronic stripe
146      5 =  cc_flg  2MASS b, bandmerge confusion
147 
148      0 =  no ph_qual flag
149      1 =  ph_qual 2MASS X, no valid brightness estimate
150      2 =  ph_qual 2MASS U, upper limit on magnitude
151      3 =  ph_qual 2MASS F, no reliable estimate of the photometric error
152      4 =  ph_qual 2MASS E, goodness-of-fit quality of profile-fit poor
153      5 =  ph_qual 2MASS A, valid measurement, [jhk]snr>10 AND [jhk]cmsig<0.10857
154      6 =  ph_qual 2MASS B, valid measurement, [jhk]snr> 7 AND [jhk]cmsig<0.15510
155      7 =  ph_qual 2MASS C, valid measurement, [jhk]snr> 5 AND [jhk]cmsig<0.21714
156      8 =  ph_qual 2MASS D, valid measurement, no [jhk]snr OR [jhk]cmsig req.
157 
158      For example icqflg = 05 is decoded to be cc_flg=0, and ph_qual=5, meaning
159      no artifacts or contamination from cc_flg and 2MASS qual flag = "A" .
160      */
161     uint8_t twomass_jflags;
162     uint8_t twomass_hflags;
163     uint8_t twomass_kflags;
164 
165     //  APASS magnitudes B,V,g,r,i
166     // (apsm, 5 * I2, millimag)
167     float Bmag;
168     float Vmag;
169     float gmag;
170     float rmag;
171     float imag;
172     // APASS magnitudes error
173     // (apase, 5 * I2, 1/100 millimag)
174     float Bmag_err;
175     float Vmag_err;
176     float gmag_err;
177     float rmag_err;
178     float imag_err;
179 
180     // Yale SPM g-flag*10 c-flag
181     // (gcflg, I1)
182     /*
183      The g-flag from the Yale San Juan first epoch Southern
184      Proper Motion data (YSJ1, SPM) has the following meaning:
185 
186      0 = no info
187      1 = matched with 2MASS extended source list
188      2 = LEDA  galaxy
189      3 = known QSO
190 
191      The c-flag from the Yale San Juan first epoch Southern
192      Proper Motion data (YSJ1, SPM) indicates which input catalog
193      has been used to identify stars for pipeline processing:
194 
195      1 = Hipparcos
196      2 = Tycho2
197      3 = UCAC2
198      4 = 2MASS psc
199      5 = 2MASS xsc (extended sources, largely (but not all!) galaxies)
200      6 = LEDA  (confirmed galaxies, Paturel et al. 2005)
201      7 = QSO   (Veron-Cetty & Veron 2006)
202      */
203     uint8_t yale_gc_flag;
204 
205     // Catalog flags
206     // (icf, I4)
207     /*
208      That 4-byte integer has the value:
209      icf = icf(1)*10^8 + icf(2)*10^7 + ...  + icf(8)*10 + icf(9)
210 
211      The FK6-Hipparcos-Tycho-source-flag has the following meaning:
212      (= icf(1))
213      0 = not a Hip. or Tycho star
214      1 = Hipparcos 1997 version main catalog (not in UCAC4 data files)
215      2 = Hipparcos double star annex
216      3 = Tycho-2
217      4 = Tycho annex 1
218      5 = Tycho annex 2
219      6 = FK6 position and proper motion (instead of Hipparcos data)
220      7 = Hippparcos 2007 solution position and proper motion
221      8 = FK6      only PM substit. (not in UCAC4 data)
222      9 = Hipparcos 2007, only proper motion substituted
223 
224      The catflg match flag is provided for major catalogs used
225      in the computation of the proper motions.  Each match is analyzed
226      for multiple matches of entries of the 1st catalog to 2nd catalog
227      entries, and the other way around.  Matches are also classified
228      by separation and difference in magnitude to arrive at a confidence
229      level group.  The flag has the following meaning:
230 
231      0 = star not matched with this catalog
232      1 = unique-unique match,  not involving a double star
233      2 =  ... same, but involving a flagged double star
234      3 = multiple match but unique in high confidence level group, no double
235      4 =  ... same, but involving a flagged double star
236      5 = closest match, not involving a double, likely o.k.
237      6 =  ... same, but involving a flagged double star
238      7 = maybe o.k. smallest sep. match in both directions, no double
239      8 =  ... same, but involving a flagged double star
240      */
241     uint32_t catalog_flags;
242 
243     // LEDA galaxy match flag
244     // (leda, I1)
245     /*
246      This flag is either 0 (no match) or contains the log of
247      the apparent total diameter for I-band (object size) information
248      copied from the LEDA catalog (galaxies).  A size value of less
249      than 1 has been rounded up to 1.
250      */
251     uint8_t leda_flag;
252 
253     // 2MASS extend.source flag
254     // (x2m, I1)
255     /*
256      This flag is either 0 (no match) or contains the length of
257      the semi-major axis of the fiducial ellipse at the K-band
258      (object size) information copied from the 2MASS extended source
259      catalog.  If the size is larger than 127, the flag was set to 127.
260      */
261     uint8_t twomass_extsource_flag;
262 
263     // unique star identification number
264     // (rnm, I4)
265     /*
266      This unique star identification number is between 200001
267      and  321640 for Hipparcos stars, and between 1 and 9430 for non-
268      Hipparcos stars supplemented to the UCAC4 catalog (no CCD observ.).
269      For all other stars this unique star identification number is the
270      internal mean-position-file (MPOS) number + 1 million.
271      For both the Hipparcos and the supplement stars there is an entry
272      on the u4supl.dat file providing more information, including the
273      original Hipparcos star number.  Note, there are several thousand
274      cases where different UCAC4 stars link to the same Hipparcos star
275      number due to resolved binary stars with each component being a
276      separate star entry in UCAC4.
277      */
278     uint32_t mpos;
279 
280     // zone number of UCAC2
281     // (zn2, I2)
282     uint16_t ucac2_zone;
283     // running record number along UCAC2 zone
284     // (rn2, I4)
285     uint32_t ucac2_number;
286 };
287 
288 typedef struct ucac4_entry ucac4_entry;
289 
290 int ucac4_parse_entry(ucac4_entry* entry, const void* encoded);
291 
292 #endif
293