int AcsSum (char *input, char *output, char *mtype, int printtime, int verbose) { extern int status; IRAFPointer tpin; AcsSumInfo acs; IODescPtr im; /* descriptor for input image */ Hdr phdr; /* primary header for input image */ int nimgs; int i; char acs_input[CHAR_FNAME_LENGTH]; int FileExists (char *); void TimeStamp (char *, char *); void PrBegin (char *); void PrEnd (char *); void PrFileName (char *, char *); void PrHdrInfo (char *, char *, char *, char *); int MkName (char *, char *, char *, char *, char *, int); void WhichError (int); void InitSumTrl (char *input, char *output); void FindAsnRoot (char *, char *); int mkNewSpt (char *, char *, char *); /* Determine input and output trailer files, then initialize output file by combining inputs into output file */ InitSumTrl (input, output); PrBegin ("ACSSUM"); nimgs = 0; if (printtime) TimeStamp ("ACSSUM started", ""); /* open the input file template */ tpin = c_imtopen (input); nimgs = c_imtlen(tpin); /* Initialize structure containing acssum information. */ AcsInit (&acs,nimgs); /* Copy command-line arguments into acs. */ for (i = 0; i < nimgs; i++) { c_imtgetim (tpin, acs.input[i], CHAR_FNAME_LENGTH); PrFileName ("input", acs.input[i]); } /* close file template */ c_imtclose (tpin); strcpy (acs.output, output); acs.printtime = printtime; acs.verbose = verbose; PrFileName ("output", acs.output); FindAsnRoot (output, acs.rootname); initHdr (&phdr); /* Check whether the output file already exists. */ if (FileExists (acs.output)) { FreeAcsInput (acs.input, nimgs); return (status); } strcpy(acs_input,acs.input[0]); /* Open input image in order to read its primary header. */ im = openInputImage (acs_input, "", 0); if (hstio_err()) { FreeAcsInput (acs.input, nimgs); return (status = OPEN_FAILED); } getHeader (im, &phdr); /* get primary header */ if (hstio_err()) { FreeAcsInput (acs.input, nimgs); return (status = OPEN_FAILED); } closeImage (im); /* Get keyword values from primary header. */ if (GetSumKeyInfo (&acs, &phdr)) { FreeAcsInput (acs.input, nimgs); return (status); } freeHdr (&phdr); /* Print information about this image. */ PrHdrInfo (acs.aperture, acs.filter1, acs.filter2, acs.det); if (acs.printtime) TimeStamp ("Begin processing", acs.rootname); /* Sum all imsets. */ if (SumGrps (&acs,mtype)){ FreeAcsInput (acs.input, nimgs); return (status); } /* create new SPT file for output product */ if (mkNewSpt (input, mtype, output)) { return(status); } /* Done... */ trlmessage ("\n"); PrEnd ("ACSSUM"); if (acs.printtime) TimeStamp ("ACSSUM completed", acs.rootname); /* Write out temp trailer file to final file */ WriteTrlFile (); FreeAcsInput (acs.input, nimgs); return (status); }
int CalStis11 (char *inwav, char *insci, char *output, int printtime, int verbose) { int status; StisInfo11 wavecal, scidata; /* calibration switches, etc. */ IODescPtr imWav; /* descriptor for input wavecal */ IODescPtr imSci; /* descriptor for input science file */ Hdr phdrWav; /* primary header for input wavecal */ Hdr phdrSci; /* primary header for input science file */ int subscicorr; /* PERFORM if CCD and sclamp is HITM1 or 2 */ int GetKeyInfo11 (StisInfo11 *, Hdr *); int SubSci (StisInfo11 *, StisInfo11 *); PrBegin (11); if (printtime) TimeStamp ("CALSTIS-11 started", ""); /* Initialize structure containing calstis information. */ StisInit11 (&wavecal, &scidata); /* Copy command-line arguments into wavecal & scidata. */ strcpy (wavecal.input, inwav); strcpy (scidata.input, insci); strcpy (wavecal.output, output); wavecal.printtime = printtime; scidata.printtime = printtime; wavecal.verbose = verbose; scidata.verbose = verbose; PrFileName ("wavecal", wavecal.input); PrFileName ("science", scidata.input); PrFileName ("output", wavecal.output); initHdr (&phdrWav); initHdr (&phdrSci); /* Check whether the output file already exists. */ if ((status = FileExists (wavecal.output))) return (status); /* Read primary header of input wavecal. */ imWav = openInputImage (wavecal.input, "", 0); if (hstio_err()) return (OPEN_FAILED); getHeader (imWav, &phdrWav); if (hstio_err()) return (OPEN_FAILED); closeImage (imWav); /* Get keyword values from wavecal primary header. */ if ((status = GetKeyInfo11 (&wavecal, &phdrWav))) return (status); freeHdr (&phdrWav); /* Print information about the input wavecal. */ PrHdrInfo (wavecal.obsmode, wavecal.aperture, wavecal.opt_elem, wavecal.det); /* Do we need to subtract the science image from the wavecal? */ subscicorr = PERFORM; /* initial value */ if (wavecal.detector != CCD_DETECTOR) { subscicorr = OMIT; printf ("Warning Detector is %s\n", wavecal.det); } if (strcmp (wavecal.sclamp, "HITM1") != 0 && strcmp (wavecal.sclamp, "HITM2") != 0) { subscicorr = OMIT; printf ("Warning Wavecal SCLAMP is `%s', not HITM1 or HITM2\n", wavecal.sclamp); } if (wavecal.texpstrt >= EXT_SHUTTER_CLOSED) { subscicorr = OMIT; printf ( "Warning TEXPSTRT=%.2f implies external shutter is closed.\n", wavecal.texpstrt); } if (subscicorr != PERFORM) { printf ( "Warning Science data will not be subtracted from wavecal.\n"); return (NOTHING_TO_DO); } /* Read primary header of input science file. */ imSci = openInputImage (scidata.input, "", 0); if (hstio_err()) return (OPEN_FAILED); getHeader (imSci, &phdrSci); if (hstio_err()) return (OPEN_FAILED); closeImage (imSci); if (wavecal.printtime) TimeStamp ("Begin processing", wavecal.rootname); /* Get keyword values from science file primary header. */ if ((status = GetKeyInfo11 (&scidata, &phdrSci))) return (status); freeHdr (&phdrSci); /* Detector, central wavelength, grating, and aperture must be the same in the wavecal and science file. */ if (wavecal.detector != scidata.detector || wavecal.cenwave != scidata.cenwave || strcmp (wavecal.opt_elem, scidata.opt_elem) != 0 || strcmp (wavecal.aperture, scidata.aperture) != 0) { printf ("Warning Wavecal and science file do not match; \\\n"); printf ("Warning the science file will not be subtracted.\n"); return (NOTHING_TO_DO); } /* Subtract the science image from the wavecal. */ if ((status = SubSci (&wavecal, &scidata))) return (status); printf ("\n"); PrEnd (11); if (wavecal.printtime) TimeStamp ("CALSTIS-11 completed", wavecal.rootname); return (0); }