diff --git a/src/back.c b/src/back.c index 1c4b05f..56e325b 100644 --- a/src/back.c +++ b/src/back.c @@ -7,7 +7,11 @@ * * This file part of: SExtractor * -* Copyright: (C) 1993-2020 IAP/CNRS/SorbonneU +* Copyright: (C) 1994,1997 ESO +* (C) 1995,1996 Leiden Observatory +* (C) 1998-2021 IAP/CNRS/SorbonneU +* (C) 2021-2023 CFHT/CNRS +* (C) 2023-2025 CEA/AIM/UParisSaclay * * License: GNU General Public License * @@ -22,7 +26,7 @@ * You should have received a copy of the GNU General Public License * along with SExtractor. If not, see . * -* Last modified: 23/09/2020 +* Last modified: 25/03/2025 * *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -92,13 +96,13 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) wfcurpos = wfcurpos2 = 0; /* to avoid gcc -Wall warnings */ QFTELL(field->file, fcurpos, field->filename); #ifdef HAVE_CFITSIO - currentElement = (tab->currentElement == 0) ? 1 : tab->currentElement; + currentElement = (tab->cfitsio_currentElement == 0) ? 1 : tab->cfitsio_currentElement; #endif if (wfield) { QFTELL(wfield->file, wfcurpos, wfield->filename); #ifdef HAVE_CFITSIO - wcurrentElement = (wtab->currentElement == 0) ? 1 : wtab->currentElement; + wcurrentElement = (wtab->cfitsio_currentElement == 0) ? 1 : wtab->cfitsio_currentElement; #endif } @@ -189,12 +193,12 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) /*---- Image size too big, we have to skip a few data !*/ QFTELL(field->file, fcurpos2, field->filename); #ifdef HAVE_CFITSIO - currentElement2 = (tab->currentElement == 0) ? 1 : tab->currentElement; + currentElement2 = (tab->cfitsio_currentElement == 0) ? 1 : tab->cfitsio_currentElement; #endif if (wfield){ QFTELL(wfield->file, wfcurpos2, wfield->filename); #ifdef HAVE_CFITSIO - wcurrentElement2 = (wtab->currentElement == 0) ? 1 : wtab->currentElement; + wcurrentElement2 = (wtab->cfitsio_currentElement == 0) ? 1 : wtab->cfitsio_currentElement; #endif } if (j == ny-1 && (n=field->height%field->backh)) @@ -218,7 +222,7 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) QFSEEK(field->file, bufshift*(OFF_T2)field->bytepix, SEEK_CUR, field->filename); #ifdef HAVE_CFITSIO - tab->currentElement += bufshift; + tab->cfitsio_currentElement += bufshift; #endif buft = buf; for (i=nlines; i--; buft += w) @@ -228,7 +232,7 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) QFSEEK(field->file, jumpsize*(OFF_T2)field->bytepix, SEEK_CUR, field->filename); #ifdef HAVE_CFITSIO - tab->currentElement += jumpsize; + tab->cfitsio_currentElement += jumpsize; #endif } } @@ -239,7 +243,7 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) QFSEEK(wfield->file, bufshift*(OFF_T2)wfield->bytepix, SEEK_CUR, wfield->filename); #ifdef HAVE_CFITSIO - wtab->currentElement += bufshift; + wtab->cfitsio_currentElement += bufshift; #endif wbuft = wbuf; for (i=nlines; i--; wbuft += w) @@ -250,7 +254,7 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) QFSEEK(wfield->file, jumpsize*(OFF_T2)wfield->bytepix, SEEK_CUR, wfield->filename); #ifdef HAVE_CFITSIO - wtab->currentElement += jumpsize; + wtab->cfitsio_currentElement += jumpsize; #endif } } @@ -259,7 +263,7 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) wfield?wfield->weight_thresh:0.0); QFSEEK(field->file, fcurpos2, SEEK_SET, field->filename); #ifdef HAVE_CFITSIO - tab->currentElement = currentElement2; + tab->cfitsio_currentElement = currentElement2; #endif bm = backmesh; for (m=nx; m--; bm++) @@ -271,7 +275,7 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) { QFSEEK(wfield->file, wfcurpos2, SEEK_SET, wfield->filename); #ifdef HAVE_CFITSIO - wtab->currentElement = wcurrentElement2; + wtab->cfitsio_currentElement = wcurrentElement2; #endif wbm = wbackmesh; for (m=nx; m--; wbm++) @@ -328,12 +332,12 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag) /* Go back to the original position */ QFSEEK(field->file, fcurpos, SEEK_SET, field->filename); #ifdef HAVE_CFITSIO - tab->currentElement = currentElement; + tab->cfitsio_currentElement = currentElement; #endif if (wfield) { QFSEEK(wfield->file, wfcurpos, SEEK_SET, wfield->filename); #ifdef HAVE_CFITSIO - wfield->tab->currentElement = wcurrentElement; + wfield->tab->cfitsio_currentElement = wcurrentElement; #endif } diff --git a/src/fits/fitsbody.c b/src/fits/fitsbody.c index 90bcd27..2dd860b 100644 --- a/src/fits/fitsbody.c +++ b/src/fits/fitsbody.c @@ -7,7 +7,11 @@ * * This file part of: AstrOmatic FITS/LDAC library * -* Copyright: (C) 1995-2023 CFHT/IAP/CNRS/SorbonneU +* Copyright: (C) 1994,1997 ESO +* (C) 1995,1996 Leiden Observatory +* (C) 1998-2021 IAP/CNRS/SorbonneU +* (C) 2021-2023 CFHT/CNRS +* (C) 2023-2025 CEA/AIM/UParisSaclay * * License: GNU General Public License * @@ -23,7 +27,7 @@ * along with AstrOmatic software. * If not, see . * -* Last modified: 25/02/2023 +* Last modified: 25/03/2025 * *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -63,13 +67,14 @@ PURPOSE Allocate memory for and read a FITS data body (read-only). If not INPUT Table (tab) structure. OUTPUT Pointer to the mapped data if OK, or NULL otherwise. NOTES The file pointer must be positioned at the beginning of the data. -AUTHOR E. Bertin (IAP) -VERSION 02/10/2017 +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 25/03/2025 ***/ PIXTYPE *alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix)) { FILE *file; PIXTYPE *buffer; + int n; size_t npix, size, sizeleft, spoonful; if (!body_ramflag) @@ -90,7 +95,12 @@ PIXTYPE *alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix)) /* Decide if the data will go in physical memory or on swap-space */ #ifdef HAVE_CFITSIO - npix = tab->naxisn[0] * tab->naxisn[1]; + if (tab->isTileCompressed) { + npix = (size_t)tab->naxisn[0]; + for (n=1; nnaxis; n++) + npix *= (size_t)tab->naxisn[n]; + } else + npix = tab->tabsize/tab->bytepix; #else npix = tab->tabsize/tab->bytepix; #endif @@ -102,7 +112,7 @@ PIXTYPE *alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix)) { QFSEEK(tab->cat->file, tab->bodypos, SEEK_SET, tab->cat->filename); #ifdef HAVE_CFITSIO - tab->currentElement = 1; + tab->cfitsio_currentElement = 1; #endif read_body(tab, (PIXTYPE *)tab->bodybuf, npix); /*---- Apply pixel processing */ @@ -132,7 +142,7 @@ PIXTYPE *alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix)) spoonful = DATA_BUFSIZE; QFSEEK(tab->cat->file, tab->bodypos, SEEK_SET, tab->cat->filename); #ifdef HAVE_CFITSIO - tab->currentElement = 1; + tab->cfitsio_currentElement = 1; #endif read_body(tab, buffer, spoonful/sizeof(PIXTYPE)); /*-- Apply pixel processing */ @@ -172,8 +182,8 @@ PURPOSE Allocate memory for and read a FITS integer data body (read-only). INPUT Table (tab) structure. OUTPUT Pointer to the mapped data if OK, or NULL otherwise. NOTES The file pointer must be positioned at the beginning of the data. -AUTHOR E. Bertin (IAP) -VERSION 02/10/2017 +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 21/03/2025 ***/ FLAGTYPE *alloc_ibody(tabstruct *tab, void (*func)(FLAGTYPE *ptr, int npix)) @@ -208,7 +218,7 @@ FLAGTYPE *alloc_ibody(tabstruct *tab, { QFSEEK(tab->cat->file, tab->bodypos, SEEK_SET, tab->cat->filename); #ifdef HAVE_CFITSIO - tab->currentElement = 1; + tab->cfitsio_currentElement = 1; #endif read_ibody(tab, (FLAGTYPE *)tab->bodybuf, npix); /*---- Apply pixel processing */ @@ -238,7 +248,7 @@ FLAGTYPE *alloc_ibody(tabstruct *tab, spoonful = DATA_BUFSIZE; QFSEEK(tab->cat->file, tab->bodypos, SEEK_SET, tab->cat->filename); #ifdef HAVE_CFITSIO - tab->currentElement = 1; + tab->cfitsio_currentElement = 1; #endif read_ibody(tab, buffer, spoonful/sizeof(FLAGTYPE)); /*-- Apply pixel processing */ @@ -322,19 +332,24 @@ void free_body(tabstruct *tab) ***/ void readTileCompressed(tabstruct *tab, size_t spoonful, void *bufdata0) { - int status, hdutype; + catstruct *cat; + int status, hdutype; - // first of all, move to correct HDU status = 0; - fits_movabs_hdu(tab->infptr, tab->hdunum, &hdutype, &status); + // Exit if no parent catalog or CFITSIO information + if (!(cat = tab->cat) || !cat->cfitsio_infptr) + return; + + // Move to correct HDU + fits_movabs_hdu(cat->cfitsio_infptr, tab->cfitsio_hdunum, &hdutype, &status); if (status != 0) { - printf("Error moving to HDU %d\n", tab->hdunum); + fprintf(stderr, "Error moving to HDU %d\n", tab->cfitsio_hdunum); fits_report_error(stderr, status); } // pixels count from 1 - if (!tab->currentElement) - tab->currentElement = 1; + if (!tab->cfitsio_currentElement) + tab->cfitsio_currentElement = 1; // now read section of image int datatype; @@ -364,24 +379,24 @@ void readTileCompressed(tabstruct *tab, size_t spoonful, void *bufdata0) { // turn off any scaling so that we copy raw pixel values status = 0; - fits_set_bscale(tab->infptr, bscale, bzero, &status); + fits_set_bscale(cat->cfitsio_infptr, bscale, bzero, &status); // now read the image status = 0; - fits_read_img(tab->infptr, datatype, tab->currentElement, spoonful, &nulval, - bufdata0, &anynul, &status); + fits_read_img(cat->cfitsio_infptr, datatype, tab->cfitsio_currentElement, + spoonful, &nulval, bufdata0, &anynul, &status); // report reading error if (status) { - printf("CFITSIO ERROR reading start=%d end=%d absolute end=%d\n", - tab->currentElement, - (tab->currentElement + spoonful), + fprintf(stderr, "CFITSIO ERROR reading start=%d end=%d absolute end=%d\n", + tab->cfitsio_currentElement, + (tab->cfitsio_currentElement + spoonful), (tab->naxisn[0]*tab->naxisn[1])); fits_report_error(stderr, status); } // update file 'pointer' - tab->currentElement += spoonful; + tab->cfitsio_currentElement += spoonful; } #endif // HAVE_CFITSIO @@ -394,8 +409,8 @@ INPUT A pointer to the tab structure, the number of elements to be read. OUTPUT -. NOTES . -AUTHOR E. Bertin (CFHT/IAP/CNRS/SorbonneU) -VERSION 25/02/2023 +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 21/03/2025 ***/ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size) { @@ -439,7 +454,7 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size) bufdata = (char *)bufdata0; #ifdef HAVE_CFITSIO - if (tab->isTileCompressed && tab->infptr) + if (tab->isTileCompressed && cat->cfitsio_infptr) readTileCompressed(tab, spoonful, (void *)bufdata0); else QFREAD(bufdata, spoonful*tab->bytepix, cat->file, cat->filename); @@ -954,8 +969,8 @@ INPUT A pointer to the tab structure, the number of elements to be written. OUTPUT -. NOTES . -AUTHOR E. Bertin (IAP) -VERSION 26/08/2020 +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 21/03/2025 ***/ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size) { @@ -1073,7 +1088,7 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size) *(bufdata++) = (*(ptr++)-bz)/bs; #ifdef HAVE_CFITSIO - if (!tab->infptr && bswapflag) + if (!cat->cfitsio_infptr && bswapflag) #else if (bswapflag) #endif @@ -1100,7 +1115,7 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size) #ifdef HAVE_CFITSIO // if cfitsio output file has been set up, then proceed to write - if (tab->infptr) { + if (cat->cfitsio_infptr) { // now read section of image int datatype; switch(tab->bitpix) { @@ -1132,20 +1147,19 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size) int status = 0; - fits_set_bscale(tab->infptr, bscale, bzero, &status); + fits_set_bscale(cat->cfitsio_infptr, bscale, bzero, &status); status = 0; - fits_write_img(tab->infptr, datatype, tab->currentElement, spoonful, - cbufdata0, &status); + fits_write_img(cat->cfitsio_infptr, datatype, + tab->cfitsio_currentElement, spoonful, cbufdata0, &status); if (status) { - - printf("CFITSIO ERROR writing start=%d end=%d absolute end=%d\n", - tab->currentElement, (tab->currentElement + spoonful), + fprintf(stderr, "CFITSIO ERROR writing start=%d end=%d absolute end=%d\n", + tab->cfitsio_currentElement, (tab->cfitsio_currentElement + spoonful), (tab->naxisn[0]*tab->naxisn[1])); fits_report_error(stderr, status); } - tab->currentElement = tab->currentElement + spoonful; + tab->cfitsio_currentElement = tab->cfitsio_currentElement + spoonful; } else // otherwise, continue with usual AstrOmatic fits writing routine QFWRITE(cbufdata0, spoonful*tab->bytepix, cat->file, cat->filename); diff --git a/src/fits/fitscat.c b/src/fits/fitscat.c index dac7757..d0bd5aa 100644 --- a/src/fits/fitscat.c +++ b/src/fits/fitscat.c @@ -7,7 +7,11 @@ * * This file part of: AstrOmatic FITS/LDAC library * -* Copyright: (C) 1995-2024 CEA/AIM/UParisSaclay +* Copyright: (C) 1994,1997 ESO +* (C) 1995,1996 Leiden Observatory +* (C) 1998-2021 IAP/CNRS/SorbonneU +* (C) 2021-2023 CFHT/CNRS +* (C) 2023-2025 CEA/AIM/UParisSaclay * * License: GNU General Public License * @@ -23,6 +27,8 @@ * along with AstrOmatic software. * If not, see . * +* Last modified: 21/03/2025 +* *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #ifdef HAVE_CONFIG_H @@ -150,37 +156,74 @@ PURPOSE Close a FITS catalog. INPUT catalog structure. OUTPUT RETURN_OK if everything went as expected, RETURN_ERROR otherwise. NOTES the file structure member is set to NULL; -AUTHOR E. Bertin (IAP & Leiden observatory) -VERSION 22/06/2001 +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 21/03/2025 ***/ int close_cat(catstruct *cat) { + int status = RETURN_OK; + if (cat->file && fclose(cat->file)) - { - cat->file = NULL; - return RETURN_ERROR; - } + status = RETURN_ERROR; cat->file = NULL; - return RETURN_OK; + if (cat->cfitsio_infptr && close_cfitsio(cat)) + status = RETURN_ERROR; + + cat->cfitsio_infptr = NULL; + + return status; } + #ifdef HAVE_CFITSIO +/****** open_cfitsio *********************************************************** +PROTO int close_cfitsio(catstruct *cat) +PURPOSE Open a file with cfitsio +INPUT Pointer to the catalog. + access type (can be WRITE_ONLY or READ_ONLY). +OUTPUT RETURN_OK if everything went as expected (exit in error otherwise). +NOTES -. +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 25/03/2025 +***/ +int open_cfitsio(catstruct *cat, access_type_t at) { + + int status; + + if (cat->cfitsio_flag && !cat->cfitsio_infptr) { + // Trigger CFITSIO file opening + fits_open_file( + &cat->cfitsio_infptr, + cat->filename, + at==WRITE_ONLY? 1 : 0, + &status + ); + if (status != 0) { + fits_report_error(stderr, status); + return RETURN_ERROR; + } + } + + return RETURN_OK; +} + + /****** close_cfitsio ********************************************************** -PROTO int close_cfitsio(fitsfile **infptr) +PROTO int close_cfitsio(catstruct *cat) PURPOSE Close a file previously opened by cfitsio -INPUT fitsfile structure. +INPUT Catalog structure. OUTPUT RETURN_OK if everything went as expected (exit in error otherwise). -NOTES the fitsfile pointer is set to NULL; +NOTES - . AUTHOR E. Bertin (CEA/AIM/UParisSaclay) -VERSION 11/10/2024 +VERSION 21/03/2025 ***/ int close_cfitsio(catstruct *cat) { - if ((cat) && (cat->infptr)) { - int status = 0; fits_close_file(cat->infptr, &status); + if ((cat) && (cat->cfitsio_infptr)) { + int status = 0; fits_close_file(cat->cfitsio_infptr, &status); if (status != 0) { fits_report_error(stderr, status); @@ -188,7 +231,7 @@ int close_cfitsio(catstruct *cat) { cat->filename); } else { // Successfully closed FITS file with cfitsio - cat->infptr = NULL; + cat->cfitsio_infptr = NULL; // Free random seed in CFITSIO. QFREE(fits_rand_value); } @@ -206,8 +249,8 @@ INPUT Pointer to a catalog structure, Number of catalogs. OUTPUT -. NOTES Unallocated pointers should have been put to NULL. -AUTHOR E. Bertin (CFHT/IAP/CNRS/SorbonneU) -VERSION 25/02/2023 +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 21/03/2025 ***/ void free_cat(catstruct **cat, int ncat) @@ -222,10 +265,6 @@ void free_cat(catstruct **cat, int ncat) if ((*thecat)->file) close_cat(*thecat); remove_tabs(*thecat); -#ifdef HAVE_CFITSIO - // Free resources allocated for CFITSIO - close_cfitsio(*thecat); -#endif free(*(thecat++)); } @@ -346,14 +385,17 @@ PURPOSE Explores the whole FITS file INPUT catalog structure. OUTPUT RETURN_OK if at least one table was found, RETURN_ERROR otherwise. NOTES Memory space for the array of fits structures is reallocated. -AUTHOR E. Bertin (CFHT/IAP/CNRS/SorbonneU) -VERSION 25/02/2023 +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 21/03/2025 ***/ int map_cat(catstruct *cat) { - int ntab; tabstruct *tab, *prevtab; + int ntab; +#ifdef HAVE_CFITSIO + int hdunum = 1; +#endif // HAVE_CFITSIO /*scan through the file until we reach the end*/ prevtab = NULL; @@ -361,10 +403,6 @@ int map_cat(catstruct *cat) tab->cat = cat; QFTELL(cat->file, tab->headpos, cat->filename); -#ifdef HAVE_CFITSIO - fitsfile *infptr; - int status, hdutype, hdunum = 1; -#endif // HAVE_CFITSIO for (ntab=0; !get_head(tab); ntab++) { @@ -374,20 +412,11 @@ int map_cat(catstruct *cat) tab->nseg = tab->seg = 1; #ifdef HAVE_CFITSIO - if (tab->isTileCompressed) { - // Trigger CFITSIO file opening - status = 0; - if (!cat->infptr) { - fits_open_file(&cat->infptr, cat->filename, READONLY, &status); - if (status != 0) { - fits_report_error(stderr, status); - error(EXIT_FAILURE, - "Could not open FITS file with cfitsio: %s\n", cat->filename); - } - } - tab->infptr = cat->infptr; - } - tab->hdunum = hdunum++; + if (tab->isTileCompressed && !cat->cfitsio_flag) { + cat->cfitsio_flag = 1; + open_cfitsio(cat, READ_ONLY); + } + tab->cfitsio_hdunum = hdunum++; #endif // HAVE_CFITSIO if (tab->tabsize) QFSEEK(cat->file, PADTOTAL(tab->tabsize), SEEK_CUR, cat->filename); @@ -415,11 +444,6 @@ int map_cat(catstruct *cat) else return RETURN_ERROR; -/*rewind to the beginning*/ -/* - QFSEEK(cat->file, 0, SEEK_SET, cat->filename); -*/ - return RETURN_OK; } @@ -453,12 +477,13 @@ INPUT catalog structure, access type (can be WRITE_ONLY or READ_ONLY). OUTPUT RETURN_OK if the cat is found, RETURN_ERROR otherwise. NOTES If the file was already opened by this catalog, nothing is done. -AUTHOR E. Bertin (IAP & Leiden observatory) -VERSION 29/08/2012 +AUTHOR E. Bertin (CEA/AIM/UParisSaclay) +VERSION 21/03/2025 ***/ int open_cat(catstruct *cat, access_type_t at) { + int status = RETURN_OK; if (cat->access_type == READ_ONLY && at == WRITE_ONLY) error(EXIT_FAILURE, "*Internal Error*: Trying to write to the " @@ -467,11 +492,16 @@ int open_cat(catstruct *cat, access_type_t at) if (!cat->file) { if ((cat->file = fopen(cat->filename, at==WRITE_ONLY?"wb":"rb")) == NULL) - return RETURN_ERROR; + status = RETURN_ERROR; cat->access_type = at; } - return RETURN_OK; +#ifdef HAVE_CFITSIO + if (cat->cfitsio_flag && open_cfitsio(cat, at)) + status = RETURN_ERROR; +#endif // HAVE_CFITSIO + + return status; } diff --git a/src/fits/fitscat.h b/src/fits/fitscat.h index c038ac5..37c9899 100644 --- a/src/fits/fitscat.h +++ b/src/fits/fitscat.h @@ -8,7 +8,11 @@ * * This file part of: AstrOmatic FITS/LDAC library * -* Copyright: (C) 1995-2023 CFHT/IAP/CNRS/SorbonneU +* Copyright: (C) 1994,1997 ESO +* (C) 1995,1996 Leiden Observatory +* (C) 1998-2021 IAP/CNRS/SorbonneU +* (C) 2021-2023 CFHT/CNRS +* (C) 2023-2025 CEA/AIM/UParisSaclay * * License: GNU General Public License * @@ -24,7 +28,7 @@ * along with AstrOmatic software. * If not, see . * -* Last modified: 25/02/2023 +* Last modified: 21/03/2025 * *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -154,7 +158,8 @@ typedef struct structcat int ntab; /* number of tables included */ access_type_t access_type; /* READ_ONLY or WRITE_ONLY */ #ifdef HAVE_CFITSIO - fitsfile *infptr; /* a cfitsio pointer to the file */ + int cfitsio_flag; /* True if CFITSIO read/write required */ + fitsfile *cfitsio_infptr; /* Pointer to the CFITSIO structure */ #endif } catstruct; @@ -199,9 +204,8 @@ typedef struct structtab unsigned int bodysum; /* Checksum of the FITS body */ int isTileCompressed; /* is this a tile compressed image? */ #ifdef HAVE_CFITSIO - fitsfile *infptr; /* a cfitsio pointer to the file */ - int hdunum; /* FITS HDU number for this 'table' */ - long currentElement; /* tracks the current image pixel */ + int cfitsio_hdunum; /* FITS HDU number for this 'table' */ + long cfitsio_currentElement; /* tracks the current image pixel */ #endif } tabstruct; @@ -284,6 +288,7 @@ extern int about_cat(catstruct *cat, FILE *stream), blank_keys(tabstruct *tab), close_cat(catstruct *cat), #ifdef HAVE_CFITSIO + open_cfitsio(catstruct *cat, access_type_t at), close_cfitsio(catstruct *cat), #endif copy_key(tabstruct *tabin, char *keyname, tabstruct *tabout, diff --git a/src/fits/fitstab.c b/src/fits/fitstab.c index a663c7e..021f570 100644 --- a/src/fits/fitstab.c +++ b/src/fits/fitstab.c @@ -7,7 +7,9 @@ * * This file part of: AstrOmatic FITS/LDAC library * -* Copyright: (C) 1995-2023 CFHT/IAP/CNRS/SorbonneU +* Copyright: (C) 2002-2021 IAP/CNRS/SorbonneU +* (C) 2021-2023 CFHT/CNRS +* (C) 2023-2025 CEA/AIM/UParisSaclay * * License: GNU General Public License * @@ -23,7 +25,7 @@ * along with AstrOmatic software. * If not, see . * -* Last modified: 25/02/2023 +* Last modified: 21/03/2025 * *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -35,10 +37,6 @@ #include #include -#ifdef HAVE_CFITSIO -#include CFITSIO_H -#endif - #include "fitscat_defs.h" #include "fitscat.h" @@ -275,7 +273,7 @@ INPUT Pointer to the original catalog, OUTPUT -. NOTES -. AUTHOR E. Bertin (IAP/SorbonneU) -VERSION 25/02/2023 +VERSION 20/03/2025 ***/ void copy_tab_fromptr(tabstruct *tabin, catstruct *catout, int pos) @@ -322,11 +320,6 @@ void copy_tab_fromptr(tabstruct *tabin, catstruct *catout, int pos) prevtab->nexttab = nexttab; nexttab->prevtab = prevtab; -#ifdef HAVE_CFITSIO - // Do not copy CFitsIO file pointer - tabout->infptr = NULL; -#endif - return; } diff --git a/src/readimage.c b/src/readimage.c index b2c94d0..1ff758b 100644 --- a/src/readimage.c +++ b/src/readimage.c @@ -7,7 +7,11 @@ * * This file part of: SExtractor * -* Copyright: (C) 1993-2020 IAP/CNRS/SorbonneU +* Copyright: (C) 1994,1997 ESO +* (C) 1995,1996 Leiden Observatory +* (C) 1998-2021 IAP/CNRS/SorbonneU +* (C) 2021-2023 CFHT/CNRS +* (C) 2023-2025 CEA/AIM/UParisSaclay * * License: GNU General Public License * @@ -22,7 +26,7 @@ * You should have received a copy of the GNU General Public License * along with SExtractor. If not, see . * -* Last modified: 23/09/2020 +* Last modified: 25/03/2025 * *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -95,7 +99,7 @@ void *loadstrip(picstruct *field, picstruct *wfield) else { #ifdef HAVE_CFITSIO - tab->currentElement = 1; + tab->cfitsio_currentElement = 1; #endif read_body(tab, data, nbpix); }