Compare commits

...

2 Commits

Author SHA1 Message Date
tth
fd10739cc7 + doc on FITS files 2020-07-25 10:42:55 +02:00
tth
efc2807227 cosmetic clean 2020-07-25 10:34:18 +02:00
2 changed files with 32 additions and 18 deletions

View File

@ -627,8 +627,17 @@ To be done\index{XXX}
Ce format est essentiellement utilisé pour stocker des images Ce format est essentiellement utilisé pour stocker des images
d'astronomie, donc il peut aussi servir pour des images floues. d'astronomie, donc il peut aussi servir pour des images floues.
Cette partie est basée sur la bibliothèque \texttt{cfitsio} de
la NASA.
To be done\index{XXX} \begin{lstlisting}
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);
\end{lstlisting}
Bizarrement, l'image est stockée \textsl{upside-down} et je ne
sais pas encore comment régler ce petit détail.
Tous les flags doivent être à zéro.
\subsection{Utilitaires} \subsection{Utilitaires}

View File

@ -19,12 +19,11 @@ extern int verbosity;
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags) int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags)
{ {
fitsfile *fptr; /* pointer to the FITS file */ fitsfile *fptr; /* pointer to the FITS file */
int status, idx, k, sz; int status, sz;
int bitpix = FLOAT_IMG; int bitpix = FLOAT_IMG;
long naxis = 2; long naxis = 2;
long naxes[2]; long naxes[2];
// XXX float *array[1];
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__, src, outname, flags); fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__, src, outname, flags);
@ -39,23 +38,8 @@ if (fits_create_file(&fptr, outname, &status)) {
} }
naxes[0] = src->width; naxes[1] = src->height; naxes[0] = src->width; naxes[1] = src->height;
// XXX array = calloc(src->height, sizeof(float *));
if (verbosity) fimg_describe(src, "to be saved as FITS"); if (verbosity) fimg_describe(src, "to be saved as FITS");
/************************************************************
***** MAGIC CODE MUST COME HERE ?
array[0] = src->R;
#define REVERSE 1
for( idx=0; idx<naxes[1]; idx++ ) {
#if REVERSE
k = naxes[1] - idx - 1;
#else
k = idx;
#endif
array[idx] = src->R + (k*naxes[0]);
fprintf(stderr, " %6d %6d %p\n", idx, k, array[idx]);
}
**************************************************************/
if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) { if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) {
fits_report_error(stderr, status); fits_report_error(stderr, status);
@ -76,3 +60,24 @@ if ( fits_close_file(fptr, &status) ) {
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/************************************************************
***** MAGIC CODE FROM OUTERSPACE ?
function 'writeimage' from :
https://heasarc.gsfc.nasa.gov/docs/software/fitsio/cexamples/cookbook.c
float **array;
array = calloc(src->height, sizeof(float *));
array[0] = src->R;
#define REVERSE 1
for( idx=0; idx<naxes[1]; idx++ ) {
#if REVERSE
k = naxes[1] - idx - 1;
#else
k = idx;
#endif
array[idx] = src->R + (k*naxes[0]);
fprintf(stderr, " %6d %6d %p\n", idx, k, array[idx]);
}
**************************************************************/