# include # include /* calloc */ # include # include # include "../acs.h" # include "../acsinfo.h" # include "../acserr.h" /* This function builds the PHOTMODE string for the image header. The string will be used as input to 'synphot' for determining the values of the photometric keywords. */ int PhotMode (ACSInfo *acs2d, SingleGroup *x) { /* arguments: ACSInfo *acs i: calibration switches, etc SingleGroup *x io: image to be calibrated; primary header is modified */ extern int status; char *photstr; /* the photmode string */ char *scratch; int cenwave; /* central wavelength */ int GetKeyInt (Hdr *, char *, int, int, int *); int GetKeyStr (Hdr *, char *, int, char *, char *, int); int PutKeyStr (Hdr *, char *, char *, char *); photstr = calloc (ACS_LINE+1, sizeof (char)); scratch = calloc (ACS_FITS_REC+1, sizeof (char)); if (photstr == NULL || scratch == NULL) return (status = OUT_OF_MEMORY); strcpy (photstr, "ACS"); strcat (photstr, " "); strcat (photstr, acs2d->aperture); /* If the detector is the CCD, include the gain. */ if (acs2d->detector != MAMA_DETECTOR) { sprintf (scratch, " A2D%d", acs2d->ccdgain); strcat (photstr, scratch); } if (strcmp ("CLEAR", acs2d->filter1) != 0) { strcat (photstr, " "); strcat (photstr, acs2d->filter1); } if (strcmp ("CLEAR", acs2d->filter2) != 0) { strcat (photstr, " "); strcat (photstr, acs2d->filter2); } if (acs2d->detector == MAMA_DETECTOR) strcat (photstr, " SBC"); else if (acs2d->detector == HRC_CCD_DETECTOR) strcat (photstr, " HRC"); else if (acs2d->detector == WFC_CCD_DETECTOR) strcat (photstr, " WFC"); /* May not have a spectroscopic mode, but will still need some way of identifying when to add LRFWAVE to the PHOTMODE string. */ if (GetKeyStr (x->globalhdr, "OBSTYPE", USE_DEFAULT, "unknown", scratch, ACS_FITS_REC)) return (status); if (strcmp (scratch, "SPECTROSCOPIC") == 0) { if (GetKeyInt (x->globalhdr, "LRFWAVE", USE_DEFAULT, -1, &cenwave)) return (status); if (cenwave > 0) { sprintf (scratch, " %d", cenwave); strcat (photstr, scratch); } } /* Update PHOTMODE in the primary header. */ if (PutKeyStr (x->globalhdr, "PHOTMODE", photstr, "list of components")) return (status); free (scratch); free (photstr); return (status); }