| Line 7... |
Line 7... |
*
|
*
|
* Author: E.BERTIN, DeNIS/LDAC
|
* Author: E.BERTIN, DeNIS/LDAC
|
*
|
*
|
* Contents: functions for handling FITS keywords.
|
* Contents: functions for handling FITS keywords.
|
*
|
*
|
* Last modify: 21/09/2006
|
* Last modify: 12/06/2007
|
*
|
*
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
*/
|
*/
|
|
|
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
| Line 36... |
Line 36... |
OUTPUT line position or RETURN_ERROR if the keyword is invalid.
|
OUTPUT line position or RETURN_ERROR if the keyword is invalid.
|
NOTES For all keywords except commentary ones (like COMMENT, HISTORY or
|
NOTES For all keywords except commentary ones (like COMMENT, HISTORY or
|
blank), it is checked that they do not exist already.
|
blank), it is checked that they do not exist already.
|
Enough memory should be provided for the FITS header to contain one
|
Enough memory should be provided for the FITS header to contain one
|
more line of 80 char.
|
more line of 80 char.
|
AUTHOR E. Bertin (IAP & Leiden observatory)
|
AUTHOR E. Bertin (IAP & Leiden observatory) C. Marmo (IAP)
|
VERSION 13/06/2004
|
VERSION 13/06/2007
|
***/
|
***/
|
int fitsadd(char *fitsbuf, char *keyword, char *comment)
|
int fitsadd(char *fitsbuf, char *keyword, char *comment)
|
|
|
{
|
{
|
char *key_ptr;
|
char *key_ptr;
|
| Line 74... |
Line 74... |
if (headpos>0)
|
if (headpos>0)
|
headpos++;
|
headpos++;
|
else
|
else
|
return RETURN_ERROR;
|
return RETURN_ERROR;
|
}
|
}
|
|
/*-- Special case of PCOUNT/GCOUNT parameters */
|
|
if (!strncmp(keyword, "PCOUNT", 6))
|
|
{
|
|
headpos=fitsfind(fitsbuf, "NAXIS ");
|
|
sscanf(fitsbuf+80*headpos, "NAXIS = %d", &n);
|
|
if (headpos>0)
|
|
headpos+=(n+1);
|
|
else
|
|
return RETURN_ERROR;
|
|
}
|
|
if (!strncmp(keyword, "GCOUNT", 6))
|
|
{
|
|
headpos=fitsfind(fitsbuf, "NAXIS ");
|
|
sscanf(fitsbuf+80*headpos, "NAXIS = %d", &n);
|
|
if (headpos>0)
|
|
headpos+=(n+2);
|
|
else
|
|
return RETURN_ERROR;
|
|
}
|
|
|
key_ptr = fitsbuf+80*headpos;
|
key_ptr = fitsbuf+80*headpos;
|
memmove(key_ptr+80, key_ptr, 80*(headpos2-headpos+1));
|
memmove(key_ptr+80, key_ptr, 80*(headpos2-headpos+1));
|
|
|
if (commentflag)
|
if (commentflag)
|
sprintf(str, "%-8.8s %-71.71s",
|
sprintf(str, "%-8.8s %-71.71s",
|
| Line 86... |
Line 106... |
sprintf(str, "%-8.8s= / %-47.47s",
|
sprintf(str, "%-8.8s= / %-47.47s",
|
keyword, comment);
|
keyword, comment);
|
else
|
else
|
sprintf(str, "%-8.8s= %-47.47s",
|
sprintf(str, "%-8.8s= %-47.47s",
|
keyword, " ");
|
keyword, " ");
|
|
|
memcpy(key_ptr, str, 80);
|
memcpy(key_ptr, str, 80);
|
}
|
}
|
|
|
return headpos;
|
return headpos;
|
}
|
}
|
| Line 160... |
Line 179... |
pointer to a char * (where to put the comment).
|
pointer to a char * (where to put the comment).
|
OUTPUT RETURN_OK if something was found, RETURN_ERROR otherwise.
|
OUTPUT RETURN_OK if something was found, RETURN_ERROR otherwise.
|
NOTES -.
|
NOTES -.
|
AUTHOR E. Bertin (IAP),
|
AUTHOR E. Bertin (IAP),
|
E.R. Deul - Handling of NaN
|
E.R. Deul - Handling of NaN
|
VERSION 19/09/2006
|
VERSION 04/06/2007
|
***/
|
***/
|
int fitspick(char *fitsline, char *keyword, void *ptr, h_type *htype,
|
int fitspick(char *fitsline, char *keyword, void *ptr, h_type *htype,
|
t_type *ttype, char *comment)
|
t_type *ttype, char *comment)
|
|
|
{
|
{
|
| Line 231... |
Line 250... |
}
|
}
|
else
|
else
|
{
|
{
|
for (i=j; i<80 && fitsline[i]!=(char)'/' && fitsline[i]!=(char)'.'; i++);
|
for (i=j; i<80 && fitsline[i]!=(char)'/' && fitsline[i]!=(char)'.'; i++);
|
/*-- Handle floats*/
|
/*-- Handle floats*/
|
if (i==80)
|
if (fitsline[i]==(char)'.')
|
{
|
|
*((int *)ptr) = 0;
|
|
*htype = H_INT;
|
|
*ttype = T_LONG;
|
|
}
|
|
else if (fitsline[i]==(char)'.')
|
|
{
|
{
|
fixexponent(fitsline);
|
fixexponent(fitsline);
|
*((double *)ptr) = atof(fitsline+j);
|
*((double *)ptr) = atof(fitsline+j);
|
*htype = H_EXPO;
|
*htype = H_EXPO;
|
*ttype = T_DOUBLE;
|
*ttype = T_DOUBLE;
|