kstars
fitsrw.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #ifndef FITS_MAX_AXIS
00028
00029 #include <stdio.h>
00030
00031 #define FITS_CARD_SIZE 80
00032 #define FITS_RECORD_SIZE 2880
00033 #define FITS_MAX_AXIS 999
00034
00035 #define FITS_NADD_CARDS 128
00036
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040
00041
00045 typedef unsigned char FITS_BITPIX8;
00046
00050 typedef short FITS_BITPIX16;
00051
00055 typedef long FITS_BITPIX32;
00056
00060 typedef float FITS_BITPIXM32;
00061
00065 typedef double FITS_BITPIXM64;
00066
00067 typedef int FITS_BOOL;
00068 typedef long FITS_LONG;
00069 typedef double FITS_DOUBLE;
00070 typedef char FITS_STRING[FITS_CARD_SIZE];
00071
00072 typedef enum {
00073 typ_bitpix8, typ_bitpix16, typ_bitpix32, typ_bitpixm32, typ_bitpixm64,
00074 typ_fbool, typ_flong, typ_fdouble, typ_fstring
00075 } FITS_DATA_TYPES;
00076
00082 typedef struct {
00083 double pixmin, pixmax;
00084 double datamin, datamax;
00085 double replacement;
00086 char dsttyp;
00087 } FITS_PIX_TRANSFORM;
00088
00089 typedef union {
00090 FITS_BITPIX8 bitpix8;
00091 FITS_BITPIX16 bitpix16;
00092 FITS_BITPIX32 bitpix32;
00093 FITS_BITPIXM32 bitpixm32;
00094 FITS_BITPIXM64 bitpixm64;
00095
00096 FITS_BOOL fbool;
00097 FITS_LONG flong;
00098 FITS_DOUBLE fdouble;
00099 FITS_STRING fstring;
00100 } FITS_DATA;
00101
00105 typedef struct fits_record_list {
00106 unsigned char data[FITS_RECORD_SIZE];
00107 struct fits_record_list *next_record;
00108 } FITS_RECORD_LIST;
00109
00115 typedef struct fits_hdu_list {
00116 long header_offset;
00117 long data_offset;
00118 long data_size;
00119 long udata_size;
00120 int bpp;
00121 int numpic;
00122 int naddcards;
00123 char addcards[FITS_NADD_CARDS][FITS_CARD_SIZE];
00124 struct {
00125 char nan_value;
00126 char blank_value;
00128 char blank;
00129 char datamin;
00130 char datamax;
00131 char simple;
00132 char xtension;
00133 char gcount;
00134 char pcount;
00135 char bzero;
00136 char bscale;
00137 char groups;
00138 char extend;
00139 } used;
00140 double pixmin, pixmax;
00141
00142 int naxis;
00143 int naxisn[FITS_MAX_AXIS];
00144 int bitpix;
00145
00146
00147 long blank;
00148 double datamin, datamax;
00149 char xtension[FITS_CARD_SIZE];
00150 long gcount, pcount;
00151 double bzero, bscale;
00152 int groups;
00153 int extend;
00155 FITS_RECORD_LIST *header_record_list;
00156 struct fits_hdu_list *next_hdu;
00157 } FITS_HDU_LIST;
00158
00162 typedef struct {
00163 FILE *fp;
00164 char openmode;
00166 int n_hdu;
00167 int n_pic;
00168 int nan_used;
00169 int blank_used;
00171 FITS_HDU_LIST *hdu_list;
00172 } FITS_FILE;
00173
00174
00175
00180
00186 FITS_FILE *fits_open (const char *filename, const char *openmode);
00187
00191 void fits_close (FITS_FILE *ff);
00192
00197 FITS_HDU_LIST *fits_add_hdu (FITS_FILE *ff);
00198
00206 int fits_add_card (FITS_HDU_LIST *hdulist, char *card);
00207
00211 void fits_print_header (FITS_HDU_LIST *hdr);
00212
00218 int fits_write_header (FITS_FILE *ff, FITS_HDU_LIST *hdulist);
00219
00226 FITS_HDU_LIST *fits_image_info (FITS_FILE *ff, int picind, int *hdupicind);
00227
00234 FITS_HDU_LIST *fits_seek_image (FITS_FILE *ff, int picind);
00235
00242 FITS_DATA *fits_decode_card (const char *card, FITS_DATA_TYPES data_type);
00243
00250 char *fits_search_card (FITS_RECORD_LIST *rl, const char *keyword);
00251
00261 int fits_read_pixel (FITS_FILE *ff, FITS_HDU_LIST *hdulist,
00262 int npix, FITS_PIX_TRANSFORM *trans, void *buf);
00263
00267 char *fits_get_error (void);
00268
00271 int fits_nan_32 (unsigned char *v);
00272 int fits_nan_64 (unsigned char *v);
00273
00274
00275 #define FITS_NO_DEMO
00276 int fits_to_pgmraw (char *fitsfile, char *pgmfile);
00277 int pgmraw_to_fits (char *pgmfile, char *fitsfile);
00278
00279 #ifdef __cplusplus
00280 }
00281 #endif
00282
00283 #endif