home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / plug-ins / fits / fitsrw.h < prev   
Encoding:
C/C++ Source or Header  |  1998-03-22  |  6.8 KB  |  157 lines

  1. /******************************************************************************/
  2. /*                      Peter Kirchgessner                                    */
  3. /*                      e-mail: pkirchg@aol.com                               */
  4. /*                      WWW   : http://members.aol.com/pkirchg                */
  5. /******************************************************************************/
  6. /*  #BEG-HDR                                                                  */
  7. /*                                                                            */
  8. /*  Package       : FITS reading/writing library                              */
  9. /*  Modul-Name    : fitsrw.h                                                  */
  10. /*  Description   : Include file for FITS-r/w-library                         */
  11. /*  Function(s)   :                                                           */
  12. /*  Author        : P. Kirchgessner                                           */
  13. /*  Date of Gen.  : 12-Apr-97                                                 */
  14. /*  Last modified : 17-May-97                                                 */
  15. /*  Version       : 0.10                                                      */
  16. /*  Compiler Opt. :                                                           */
  17. /*  Changes       :                                                           */
  18. /*                                                                            */
  19. /*  #END-HDR                                                                  */
  20. /******************************************************************************/
  21.  
  22. #ifndef FITS_MAX_AXIS
  23.  
  24. #include <stdio.h>
  25.  
  26. #define FITS_CARD_SIZE      80
  27. #define FITS_RECORD_SIZE  2880
  28. #define FITS_MAX_AXIS      999
  29.  
  30. #define FITS_NADD_CARDS    128
  31.  
  32. /* Data representations */
  33. typedef unsigned char FITS_BITPIX8;
  34. typedef short         FITS_BITPIX16;
  35. typedef long          FITS_BITPIX32;
  36. typedef float         FITS_BITPIXM32;
  37. typedef double        FITS_BITPIXM64;
  38.  
  39. typedef int           FITS_BOOL;
  40. typedef long          FITS_LONG;
  41. typedef double        FITS_DOUBLE;
  42. typedef char          FITS_STRING[FITS_CARD_SIZE];
  43.  
  44. typedef enum {
  45.  typ_bitpix8, typ_bitpix16, typ_bitpix32, typ_bitpixm32, typ_bitpixm64,
  46.  typ_fbool, typ_flong, typ_fdouble, typ_fstring
  47. } FITS_DATA_TYPES;
  48.  
  49. /* How to transform FITS pixel values */
  50. typedef struct {
  51.  double pixmin, pixmax;    /* Pixel values [pixmin,pixmax] should be mapped */
  52.  double datamin, datamax;  /* to [datamin,datamax] */
  53.  double replacement;       /* datavalue to use for blank or NaN pixels */
  54.  char dsttyp;              /* Destination typ ('c' = char) */
  55. } FITS_PIX_TRANSFORM;
  56.  
  57. typedef union {
  58.  FITS_BITPIX8   bitpix8;
  59.  FITS_BITPIX16  bitpix16;
  60.  FITS_BITPIX32  bitpix32;
  61.  FITS_BITPIXM32 bitpixm32;
  62.  FITS_BITPIXM64 bitpixm64;
  63.  
  64.  FITS_BOOL   fbool;
  65.  FITS_LONG   flong;
  66.  FITS_DOUBLE fdouble;
  67.  FITS_STRING fstring;
  68. } FITS_DATA;
  69.  
  70. typedef struct fits_record_list {        /* Record list */
  71.  char data[FITS_RECORD_SIZE];
  72.  struct fits_record_list *next_record;
  73. } FITS_RECORD_LIST;
  74.  
  75.  
  76. typedef struct fits_hdu_list {    /* Header and Data Unit List */
  77.  long header_offset;              /* Offset of header in the file */
  78.  long data_offset;                /* Offset of data in the file */
  79.  long data_size;                  /* Size of data in the HDU (including pad)*/
  80.  long udata_size;                 /* Size of used data in the HDU (excl. pad) */
  81.  int  bpp;                        /* Bytes per pixel */
  82.  int numpic;                      /* Number of interpretable images in HDU */
  83.  int naddcards;                   /* Number of additional cards */
  84.  char addcards[FITS_NADD_CARDS][FITS_CARD_SIZE];
  85.  struct {
  86.    char nan_value;                /* NaN's found in data ? */
  87.    char blank_value;              /* Blanks found in data ? */
  88.                                /* Flags specifying if some cards are used */
  89.    char blank;                    /* The corresponding data below is only */
  90.    char datamin;                  /* valid, if the flag is set. */
  91.    char datamax;
  92.    char simple;                   /* This indicates a simple HDU */
  93.    char xtension;                 /* This indicates an extension */
  94.    char gcount;
  95.    char pcount;
  96.    char bzero;
  97.    char bscale;
  98.    char groups;
  99.    char extend;
  100.  } used;
  101.  double pixmin, pixmax;           /* Minimum/Maximum pixel values */
  102.                              /* Some decoded data of the HDU: */
  103.  int naxis;                       /* Number of axes */
  104.  int naxisn[FITS_MAX_AXIS];       /* Sizes of axes (NAXIS1 --> naxisn[0]) */
  105.  int bitpix;                      /* Data representation (8,16,32,-16,-32) */
  106.                              /* When using the following data, */
  107.                              /* the used-flags must be checked before. */
  108.  long blank;                      /* Blank value */
  109.  double datamin, datamax;         /* Minimum/Maximum physical data values */
  110.  char xtension[FITS_CARD_SIZE];   /* Type of extension */
  111.  long gcount, pcount;             /* Used by XTENSION */
  112.  double bzero, bscale;            /* Transformation values */
  113.  int groups;                      /* Random groups indicator */
  114.  int extend;                      /* Extend flag */
  115.  
  116.  FITS_RECORD_LIST *header_record_list; /* Header records read in */
  117.  struct fits_hdu_list *next_hdu;
  118. } FITS_HDU_LIST;
  119.  
  120.  
  121. typedef struct {
  122.  FILE *fp;                    /* File pointer to fits file */
  123.  char openmode;               /* Mode the file was opened (0, 'r', 'w') */
  124.  
  125.  int n_hdu;                   /* Number of HDUs in file */
  126.  int n_pic;                   /* Total number of interpretable pictures */
  127.  int nan_used;                /* NaN's used in the file ? */
  128.  int blank_used;              /* Blank's used in the file ? */
  129.  
  130.  FITS_HDU_LIST *hdu_list;     /* Header and Data Unit List */
  131. } FITS_FILE;
  132.  
  133.  
  134. /* User callable functions of the FITS-library */
  135.  
  136. FITS_FILE     *fits_open (char *filename, char *openmode);
  137. void           fits_close (FITS_FILE *ff);
  138. FITS_HDU_LIST *fits_add_hdu (FITS_FILE *ff);
  139. int            fits_add_card (FITS_HDU_LIST *hdulist, char *card);
  140. int            fits_write_header (FITS_FILE *ff, FITS_HDU_LIST *hdulist);
  141. FITS_HDU_LIST *fits_image_info (FITS_FILE *ff, int picind, int *hdupicind);
  142. FITS_HDU_LIST *fits_seek_image (FITS_FILE *ff, int picind);
  143. void           fits_print_header (FITS_HDU_LIST *hdr);
  144. FITS_DATA     *fits_decode_card (const char *card, FITS_DATA_TYPES data_type);
  145. char          *fits_search_card (FITS_RECORD_LIST *rl, char *keyword);
  146. int            fits_read_pixel (FITS_FILE *ff, FITS_HDU_LIST *hdulist,
  147.                                 int npix, FITS_PIX_TRANSFORM *trans, void *buf);
  148.  
  149. char *fits_get_error (void);
  150.  
  151. /* Demo functions */
  152. #define FITS_NO_DEMO
  153. int fits_to_pgmraw (char *fitsfile, char *pgmfile);
  154. int pgmraw_to_fits (char *pgmfile, char *fitsfile);
  155.  
  156. #endif
  157.