Commit b6e8c209 authored by Teake Nutma's avatar Teake Nutma
Browse files

Add #ifdef HAVE_CFITSIO statements

parent 59dd1ec4
...@@ -297,7 +297,7 @@ void free_body(tabstruct *tab) ...@@ -297,7 +297,7 @@ void free_body(tabstruct *tab)
return; return;
} }
#ifdef HAVE_CFITSIO
void readTileCompressed(tabstruct *tab, size_t spoonful, double* bufdata0) { void readTileCompressed(tabstruct *tab, size_t spoonful, double* bufdata0) {
int status, hdutype; int status, hdutype;
...@@ -352,6 +352,7 @@ void readTileCompressed(tabstruct *tab, size_t spoonful, double* bufdata0) { ...@@ -352,6 +352,7 @@ void readTileCompressed(tabstruct *tab, size_t spoonful, double* bufdata0) {
// update file 'pointer' // update file 'pointer'
tab->currentElement += spoonful; tab->currentElement += spoonful;
} }
#endif
/******* read_body ************************************************************ /******* read_body ************************************************************
PROTO read_body(tabstruct *tab, PIXTYPE *ptr, long size) PROTO read_body(tabstruct *tab, PIXTYPE *ptr, long size)
...@@ -409,10 +410,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size) ...@@ -409,10 +410,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
spoonful = size; spoonful = size;
bufdata = (char *)bufdata0; bufdata = (char *)bufdata0;
// CFITSIO #ifdef HAVE_CFITSIO
if (tab->isTileCompressed) if (tab->isTileCompressed)
readTileCompressed(tab, spoonful, bufdata0); readTileCompressed(tab, spoonful, bufdata0);
else else
#endif
QFREAD(bufdata, spoonful*tab->bytepix, cat->file, cat->filename); QFREAD(bufdata, spoonful*tab->bytepix, cat->file, cat->filename);
switch(tab->bitpix) switch(tab->bitpix)
...@@ -732,9 +734,11 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size) ...@@ -732,9 +734,11 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
bufdata = (char *)bufdata0; bufdata = (char *)bufdata0;
// CFITSIO // CFITSIO
#ifdef HAVE_CFITSIO
if (tab->isTileCompressed) if (tab->isTileCompressed)
readTileCompressed(tab, spoonful, bufdata0); readTileCompressed(tab, spoonful, bufdata0);
else else
#endif
QFREAD(bufdata, spoonful*tab->bytepix, cat->file, cat->filename); QFREAD(bufdata, spoonful*tab->bytepix, cat->file, cat->filename);
switch(tab->bitpix) switch(tab->bitpix)
...@@ -1033,6 +1037,7 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size) ...@@ -1033,6 +1037,7 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
} }
// CFITSIO - if cfitsio output file has been set up, then proceed to write using cfitsio // CFITSIO - if cfitsio output file has been set up, then proceed to write using cfitsio
#ifdef HAVE_CFITSIO
if (0 && tab->infptr != NULL) { // TODO if (0 && tab->infptr != NULL) { // TODO
int status = 0; fits_write_img(tab->infptr, TFLOAT, tab->currentElement, spoonful, cbufdata0, &status); int status = 0; fits_write_img(tab->infptr, TFLOAT, tab->currentElement, spoonful, cbufdata0, &status);
...@@ -1047,6 +1052,7 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size) ...@@ -1047,6 +1052,7 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
} }
// otherwise, continue with usual AstrOmatic fits writing routine // otherwise, continue with usual AstrOmatic fits writing routine
else else
#endif
QFWRITE(cbufdata0, spoonful*tab->bytepix, cat->file, cat->filename); QFWRITE(cbufdata0, spoonful*tab->bytepix, cat->file, cat->filename);
} }
break; break;
......
...@@ -166,6 +166,7 @@ int close_cat(catstruct *cat) ...@@ -166,6 +166,7 @@ int close_cat(catstruct *cat)
} }
#ifdef HAVE_CFITSIO
int close_cfitsio(catstruct *cat) int close_cfitsio(catstruct *cat)
{ {
...@@ -184,6 +185,7 @@ int close_cfitsio(catstruct *cat) ...@@ -184,6 +185,7 @@ int close_cfitsio(catstruct *cat)
} }
//printf("NO CFITSIO FILE TO CLOSE\n"); //printf("NO CFITSIO FILE TO CLOSE\n");
} }
#endif
/****** free_cat *************************************************************** /****** free_cat ***************************************************************
PROTO void free_cat(catstruct **cat, int ncat) PROTO void free_cat(catstruct **cat, int ncat)
...@@ -343,6 +345,7 @@ int map_cat(catstruct *cat) ...@@ -343,6 +345,7 @@ int map_cat(catstruct *cat)
tab->cat = cat; tab->cat = cat;
QFTELL(cat->file, tab->headpos, cat->filename); QFTELL(cat->file, tab->headpos, cat->filename);
#ifdef HAVE_CFITSIO
// CFITSIO // CFITSIO
fitsfile *infptr; fitsfile *infptr;
int status, hdutype, hdunum; int status, hdutype, hdunum;
...@@ -352,6 +355,7 @@ int map_cat(catstruct *cat) ...@@ -352,6 +355,7 @@ int map_cat(catstruct *cat)
printf("ERROR could not open FITS file with cfitsio: %s\n", cat->filename); printf("ERROR could not open FITS file with cfitsio: %s\n", cat->filename);
} }
hdunum = 1; hdunum = 1;
#endif
for (ntab=0; !get_head(tab); ntab++) for (ntab=0; !get_head(tab); ntab++)
{ {
...@@ -360,7 +364,7 @@ int map_cat(catstruct *cat) ...@@ -360,7 +364,7 @@ int map_cat(catstruct *cat)
QFTELL(cat->file, tab->bodypos, cat->filename); QFTELL(cat->file, tab->bodypos, cat->filename);
tab->nseg = tab->seg = 1; tab->nseg = tab->seg = 1;
// CFITSIO #ifdef HAVE_CFITSIO
tab->hdunum = hdunum; tab->hdunum = hdunum;
tab->infptr = infptr; tab->infptr = infptr;
status = 0; fits_movabs_hdu(tab->infptr, tab->hdunum, &hdutype, &status); status = 0; fits_movabs_hdu(tab->infptr, tab->hdunum, &hdutype, &status);
...@@ -368,14 +372,15 @@ int map_cat(catstruct *cat) ...@@ -368,14 +372,15 @@ int map_cat(catstruct *cat)
//tab->tabsize = infptr->Fptr->rowlength; //tab->tabsize = infptr->Fptr->rowlength;
//printf("TABSIZE = %ld\n", tab->tabsize); //printf("TABSIZE = %ld\n", tab->tabsize);
#endif
if (tab->tabsize) { if (tab->tabsize) {
#ifdef HAVE_CFITSIO
// IMPORTANT: moving to start of next header using fseek and cfitsio position rather than table size, as done previously // IMPORTANT: moving to start of next header using fseek and cfitsio position rather than table size, as done previously
fseek(cat->file, infptr->Fptr->headstart[hdunum], SEEK_SET); fseek(cat->file, infptr->Fptr->headstart[hdunum], SEEK_SET);
#else
// this is how it was done previously // this is how it was done previously
//QFSEEK(cat->file, PADTOTAL(tab->tabsize), SEEK_CUR, cat->filename); QFSEEK(cat->file, PADTOTAL(tab->tabsize), SEEK_CUR, cat->filename);
#endif
} }
if (prevtab) if (prevtab)
{ {
...@@ -389,8 +394,9 @@ int map_cat(catstruct *cat) ...@@ -389,8 +394,9 @@ int map_cat(catstruct *cat)
tab->cat = cat; tab->cat = cat;
QFTELL(cat->file, tab->headpos, cat->filename); QFTELL(cat->file, tab->headpos, cat->filename);
// CFITSIO #ifdef HAVE_CFITSIO
hdunum++; hdunum++;
#endif
} }
cat->ntab = ntab; cat->ntab = ntab;
......
...@@ -36,8 +36,9 @@ ...@@ -36,8 +36,9 @@
#include <sys/types.h> #include <sys/types.h>
#endif #endif
// CFITSIO #ifdef HAVE_CFITSIO
#include FITSIO_H #include FITSIO_H
#endif
#define MAXCHARS 256 /* max. number of characters */ #define MAXCHARS 256 /* max. number of characters */
#define WARNING_NMAX 1000 /* max. number of recorded warnings */ #define WARNING_NMAX 1000 /* max. number of recorded warnings */
...@@ -196,8 +197,9 @@ typedef struct structtab ...@@ -196,8 +197,9 @@ typedef struct structtab
char swapname[MAXCHARS]; /* name of the swapfile */ char swapname[MAXCHARS]; /* name of the swapfile */
unsigned int bodysum; /* Checksum of the FITS body */ unsigned int bodysum; /* Checksum of the FITS body */
// CFITSIO #ifdef HAVE_CFITSIO
fitsfile *infptr; /* a cfitsio pointer to the file */ fitsfile *infptr; /* a cfitsio pointer to the file */
#endif
int hdunum; /* FITS HDU number for this 'table' */ int hdunum; /* FITS HDU number for this 'table' */
int isTileCompressed; /* is this a tile compressed image? */ int isTileCompressed; /* is this a tile compressed image? */
long currentElement; /* tracks the current image pixel */ long currentElement; /* tracks the current image pixel */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment