10B format.

To save 10 bits data a special format is needed. This is a first attempt to explain the format. Note: C-based. Please let me know if something is not clear.

Header.

The header is 16000 bytes. This sounds much but is still a very small fraction of a typical HRPT file. Most of the space is reserved for color maps for all channels (not used yet).

Here is the header description in C.
Note:


#define HRPTSIGN "HRPT"
#define CHRPTSIGN "CHRP"
#define SEAWSIGN "SEAW"
#define ENDHDR "END_HDR_"
#define CMAPLEN10B 1024
#define FRAMESTART "FRAME"
#define LENSATNAME 16
#define LENSIGN 4
#define ENDFLG 8

/* Sub-record for time, similar to "tm", but with 2-bytes shorts 
   (important for portability to e.g. Linux) */
struct tm_sh
{
  short tm_sec,tm_min,tm_hour;
  short tm_mday,tm_mon,tm_year,tm_wday,tm_yday;
  short tm_isdst;
};

/* Sub-record with Kepler info */
typedef struct 
{
  long noradnr;
  long internat;
  long year;
  float daynr;
  float decayrate;
  float inclination;
  float raan;
  float exentricity;
  float perigee;
  float anomaly;
  float revs;
  long rev_orbit;
} KEPLER;


The actual header of the file:

typedef struct
{
  char sign[LENSIGN];
  char satname[LENSATNAME];
  char chan_tot;
  char filetype;
  short width,height;              /* width < 2048 if zoomed  */
  short depth;
  char offset_gmt,offset_sec;
  struct tm_sh tm_comp;            /* 48 */
  KEPLER kepler;

  char hdr_version[ENDFLG];           /*  */
  short hdrlen;                    /* length of header */
  short x_offset,y_offset;         /* Offset from original if zoomed  */
  char satdir,reserve2;            /*  */

  struct tm_sh tm_satstrt;
  char tm_comp_sat_vlg;
  char fill1;                       /* See note! */

  float offset_lon;
  short dmin[8],dmax[8];
  short ro,go,bo;
  short fill2;                      /* See note! */

  float kr[8],kg[8],kb[8];          /* linear combination of channels */
  char channel[9];                  /* selected channels; 0 = header recorded */
  char fill3;                       /* See note!  */

  short widthmax;
  float alphamax;
  char r[5][CMAPLEN10B],g[5][CMAPLEN10B],b[5][CMAPLEN10B];
  char reserve[348];                /* reserved-bytes */
  char endhdr[ENDFLG];              /* 15786 */
} HRPTHDR;

Note: The element:

  short hdrlen;                    /* length of header */
gives the possibility to change header lengths without compability problems between vesrions of software used to record and versions used to process.

Data part.

Data is grouped in pieces of 4 words: E.g.: The first 4 words in a frame are part of the 6 words synchronisation part. These are in hex:

In bits:

In the 10B format this is:

So, in hex:

Each data frame is separated by a sub-header of 7 bytes:

The 2-bytes word doesn't include the 7 bytes of the sub-header.
Example: If the file contains all channels including frame header, and if it contains all 2048 pixels per channel per horizontal line the number is 13865 (hex 3629). So:
F R A M E 29 36 [13865 bytes] F R A M E 29 36 [13865 bytes] ....
etc. Calculation this number can be done as:
(nr_x*nr_ch + 852)*5/4
If no frame header is recorded then ommit the number '852'.
(Note: The frame header contains 750 words; each line contains 100 extra "auxiliarly sync words'. Together 850; however, this doesn't give a integer after multiplying with 5/4. Therefore 2 extra words are added.)

Order of words are the same as how they are transmitted. So, if 3 channels are recorded:

Etc.

The complete 10B format looks like:

Note that, to extract a channel from this format, it is necessary to know how much channels are recorded. This can be found in the header in: Meaning:

CHRPT-header

The only difference between the HRPT and CHRPT-header is the last part of the header.

typedef struct
{
  char sign[LENSIGN];
  char satname[LENSATNAME];
  char chan_tot;
  char filetype;
  short width,height;
  short depth;
  char offset_gmt,offset_sec;
  struct tm_sh tm_comp;
  KEPLER kepler;

  char hdr_version[ENDFLG];
  short hdrlen;
  short x_offset,y_offset;
  char satdir,reserve2;

  struct tm_sh tm_satstrt;
  char tm_comp_sat_vlg;
  char fill1;                         /* See note!  */

  float offset_lon;
  short dmin[10],dmax[10];
  short ro,go,bo;
  short fill2;                        /* See note!  */

  float kr[10],kg[10],kb[10];
  char channel[11];
  char fill3;                         /* See note!  */

  short widthmax;
  char fill4[2];                      /* See note!  */

  float alphamax;
  char r[5][CMAPLEN10B],g[5][CMAPLEN10B],b[5][CMAPLEN10B];
  char reserve[330];
  char endhdr[ENDFLG];
} CHRPTHDR;