Packed Binary Format

The telescope pointing information recorded during Bolocam Phase 1 engineering run is in packed binary format. Each entry consists of 30 bytes: 2-byte unsigned integer is followed by 28-byte packed binary structure. The tables below explain the format in detail. Note that the byte ordering is big-endian, and MSBs (most significant bits) and LSBs (least significant bits) are shown as b7 and b0, respectively:

Offset
(bytes)
+0 +1 +2 +3
b7 b6 b5 b4 b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0
0 × × × #ticks (10 msec) #days since Jan. 0, 2000 (= MJD - 51543)  
4 #minutes from midnight Flags × × Local apparent sidereal time (10 msec)
8   Apparent right ascension (10 msec)
12 Apparent declination (100 mas)  
16 Parallactic angle (100 mas) Azimuth (100 mas)
20   Elevation (100 mas)  
24 Error in azimuth (100 mas)  
28 Error in elevation (100 mas)  

It is proven to be really tricky to decode this format. Here is a reference implementation (plog2_read.c) that retrieves and decodes entries in a relatively portable way (it still assumes that integers are 4-byte wide and two's complement format is used for negative values). Note that LSTs and RAs may have negative values, i.e., recoded value range may be [-12:00:00.00, +12:00:00.00), instead of [00:00:00.00, 24:00:00.00). If a negative LST or RA is found, 24 hours should be added to obtain a true value.

Offset
(bits)
Width
(bits)
Type Description
From To
0 0 1   Not used
1 1 1   Not used
2 2 1   Not used
3 15 13 unsigned integer #ticks in the minute (10 msec)
16 29 14 unsigned integer #days since Jan. 0, 2000 (= MJD - 51543)
30 40 11 unsigned integer #minutes from midnight
41 41 1 boolean TRACKING
42 42 1 boolean ACQUIRED
43 43 1 boolean SCANNING
44 44 1 boolean TRANSITED
45 45 1 boolean CELESTIAL
46 46 1   Not used
47 47 1   Not used
48 71 24 signed integer Local apparent sidereal time (10 msec)
72 95 24 signed integer Requested apparent right ascension (10 msec)
96 118 23 signed integer Requested apparent declination (100 mas)
119 142 24 signed integer Parallactic angle (100 mas)
143 167 25 signed integer Requested azimuth (100 mas)
168 190 23 signed integer Requested elevation (100 mas)
191 215 25 signed integer Error in azimuth (100 mas)
216 239 24 signed integer Error in elevation (100 mas)