aboutsummaryrefslogtreecommitdiff
path: root/src/analysis/cf_make_all_exp.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-03-04 21:21:30 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-03-04 21:21:30 -0500
commitd54fe7c1f704a63824c5bfa0ece65245572e9b27 (patch)
treeafc52015ffc2c74e0266653eecef1c8ef8ba5d91 /src/analysis/cf_make_all_exp.c
downloadcalfuse-d54fe7c1f704a63824c5bfa0ece65245572e9b27.tar.gz
Initial commit
Diffstat (limited to 'src/analysis/cf_make_all_exp.c')
-rw-r--r--src/analysis/cf_make_all_exp.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/analysis/cf_make_all_exp.c b/src/analysis/cf_make_all_exp.c
new file mode 100644
index 0000000..926ac2c
--- /dev/null
+++ b/src/analysis/cf_make_all_exp.c
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * Johns Hopkins University
+ * Center For Astrophysical Sciences
+ * FUSE
+ *****************************************************************************
+ *
+ * Synopsis: cf_make_all_exp output_filename input1 input2 input3 input4
+ *
+ * Description: For a single exposure, copies header of channel with largest
+ * value of EXPTIME into an otherwise empty "all" file.
+ * Input files should represent each of the four FUSE channels.
+ *
+ *
+ * History: 08/11/05 wvd v1.0 Based on cf_quicklook.
+ *
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "calfuse.h"
+
+static char CF_PRGM_ID[]= "cf_make_all_exp";
+static char CF_VER_NUM[]= "1.0";
+
+int main(int argc,char *argv[]){
+
+ char *corrected_filename, *string_pointer;
+ char comment[FLEN_CARD], datestr[FLEN_CARD];
+ int i, nextend=0, ref_file=2, timeref;
+ int status=0;
+ float exptime, max_exptime;
+
+ fitsfile *infits,*outfits;
+
+ if (argc != 6) {
+ printf("Incorrect number of arguments.\n");
+ printf("Calling sequence: cf_make_all_exp output_filename "
+ "input1 input2 input3 input4\n");
+ exit(1);
+ }
+
+ /* Initialize error checking. */
+ cf_error_init(CF_PRGM_ID, CF_VER_NUM, stderr);
+ cf_timestamp(CF_PRGM_ID, CF_VER_NUM, "Started execution.");
+
+ /* Determine the channel with the longest exposure time */
+
+ max_exptime = 0;
+ for (i = 0; i < 4; i++) {
+ FITS_open_file(&infits, argv[2+i], READONLY, &status);
+ FITS_read_key(infits, TFLOAT, "EXPTIME", &exptime, NULL, &status);
+ if (exptime >= max_exptime) {
+ ref_file = 2 + i;
+ max_exptime = exptime;
+ }
+ FITS_close_file(infits, &status);
+ }
+
+ /* Copy header from the reference file to the exposure-level "all" file. */
+
+ FITS_open_file(&infits, argv[ref_file], READONLY, &status);
+ FITS_create_file(&outfits, argv[1], &status);
+ FITS_copy_hdu(infits, outfits, 0, &status);
+
+ /* Modify a few header keywords. */
+ string_pointer = strrchr(argv[1],'/');
+ if (string_pointer == NULL) corrected_filename = argv[1];
+ else corrected_filename = &(string_pointer[1]);
+ FITS_update_key(outfits, TINT, "NEXTEND", &nextend, NULL, &status);
+ FITS_write_date(outfits, &status);
+ FITS_update_key(outfits, TSTRING, "FILENAME", corrected_filename, NULL, &status);
+ FITS_update_key(outfits, TSTRING, "FILETYPE", "EXPOSURE-LEVEL STATUS FILE", NULL, &status);
+
+ /* Add a note warning that this file contains no data. */
+ FITS_write_comment(outfits, " ", &status);
+ FITS_write_comment(outfits,
+ "This file contains no data.", &status);
+ FITS_write_comment(outfits,
+ "Its header keywords are used by the DADS cataloging software.", &status);
+ fits_get_system_time(datestr, &timeref, &status);
+ sprintf(comment, "CalFUSE v%s %.10s", CALFUSE_VERSION, datestr);
+ FITS_write_comment(outfits, comment, &status);
+ FITS_write_comment(outfits, " ", &status);
+
+
+ FITS_close_file(infits, &status);
+ FITS_close_file(outfits,&status);
+
+ return EXIT_SUCCESS;
+}