コード例 #1
0
ファイル: acssum.c プロジェクト: jhunkeler/hstcal
void InitSumTrl (char *input, char *output) {

    extern int status;
    IRAFPointer    tpin;
    int n;

    char *trl_in;     /* trailer filename for input */
    char trl_out[CHAR_LINE_LENGTH+1];     /* output trailer filename */
    char in_name[CHAR_FNAME_LENGTH+1];
    char out_name[CHAR_FNAME_LENGTH+1];

    int trl_len;

    char *isuffix[] = {"_crj", "_flt"};
    char *osuffix[] = {"_sfl", "_sfl"};
    char *trlsuffix[] = {"", ""};
    int nsuffix = 2;

    int MkOutName (char *, char **, char **, int, char *, int);
    int MkNewExtn (char *, char *);
    void WhichError (int);

    trl_in = realloc (NULL, (CHAR_LINE_LENGTH));
    trl_len = CHAR_LINE_LENGTH;

    if (trl_in == NULL) {
        trlerror ("Out of memory: Couldn't allocate for CRJ_TMP trailer file.");
         status = OUT_OF_MEMORY;
        trl_len = 0;
     }
    /* Initialize TRL filenames */
    trl_in[0] = '\0';
    trl_out[0] = '\0';

    /* open the input file template */
    tpin = c_imtopen (input);

     for (n = 0; n < c_imtlen(tpin); ++n) {
        c_imtgetim (tpin, in_name, CHAR_FNAME_LENGTH);
        out_name[0] = '\0';


        /* Start by stripping off suffix from input/output filenames */
        if (MkOutName (in_name, isuffix, trlsuffix, nsuffix, out_name, CHAR_LINE_LENGTH)) {
            WhichError (status);
            sprintf (MsgText, "Couldn't create trailer filename for %s", in_name);
            trlerror (MsgText);
            continue;
        }

        /* Now, convert trailer filename extensions from '.fits' to '.trl' */
        if (MkNewExtn (out_name, TRL_EXTN) ) {
            sprintf(MsgText, "Error with input trailer filename %s", out_name);
            trlerror (MsgText);
            WhichError (status);
        }

        if ( (strlen(out_name) + strlen(trl_in) + 1) >= trl_len) {
            /*
                Add 1 to out_name to account for comma to be appended.
                WJH  4 June 2002
            */
            trl_len += strlen(out_name) + 1;
            trl_in = realloc (trl_in, trl_len);
        }

        /* Append each filename to create list of input trailer files */
        strcat(trl_in, out_name);

        /* But don't put a comma after the last filename */
        if (n < (c_imtlen(tpin)-1)) strcat (trl_in, ",");

    }

    if (MkOutName (output, osuffix, trlsuffix, nsuffix, trl_out, CHAR_LINE_LENGTH)) {
        WhichError (status);
        sprintf (MsgText, "Couldn't create trailer filename for %s", output);
        trlerror (MsgText);
    }

    /* Now, convert trailer filename extensions from '.fits' to '.trl' */
    if (MkNewExtn (trl_out, TRL_EXTN) ) {
        sprintf(MsgText, "Error with input trailer filename %s", trl_out);
        trlerror (MsgText);
        WhichError (status);
    }
    /* Sets up temp trailer file for output and copies input
        trailer file into it.
    */
    InitTrlFile (trl_in, trl_out);

    /* Deallocate memory */
    free(trl_in);
    c_imtclose (tpin);
}
コード例 #2
0
ファイル: mainccd.c プロジェクト: brechmos-stsci/hstcal
int main (int argc, char **argv) {

	char *inlist;		/* input file name */
	char *outlist;		/* output blev file name */
	int switch_on = 0;	/* was any switch specified? */
	int printtime = NO;	/* print time after each step? */
	int verbose = NO;	/* print additional info? */
	int quiet = NO;		/* print additional info? */
	int too_many = 0;	/* too many command-line arguments? */
	int i, j;		/* loop indexes */

	IRAFPointer i_imt, o_imt;	/* imt list pointers */
	char *input;		/* name of input science file */
	char *output;		/* name of output file */
	int n_in, n_out;	/* number of files in each list */
	int n;

	/* Input and output suffixes. */
	char *isuffix[] = {"_raw", "_rac_tmp"};
	char *osuffix[] = {"_blv_tmp", "_blc_tmp"};

	int nsuffix = 2;

	/* A structure to pass the calibration switches to WF3CCD */
	CCD_Switch ccd_sw;

	/* reference file keywords and names */
	RefFileInfo refnames;
		
	void InitRefFile (RefFileInfo *);
	void FreeRefFile (RefFileInfo *);
	void initCCDSwitches (CCD_Switch *);

	int WF3ccd (char *, char *, CCD_Switch *, RefFileInfo *, int, int);
    int DefSwitch (char *);
	int MkName (char *, char *, char *, char *, char *, int);
	void WhichError (int);
	int CompareNumbers (int, int, char *);

/*===========================================================================*/

	/* Initialize IRAF interface environment */
	c_irafinit (argc, argv);

	/* Post HSTIO error handler */
	push_hstioerr (errchk);

	/* Allocate space for file names. */
	inlist  = calloc (SZ_LINE+1, sizeof (char));
	outlist = calloc (SZ_LINE+1, sizeof (char));
	input   = calloc (SZ_LINE+1, sizeof (char));
	output  = calloc (SZ_LINE+1, sizeof (char));

	if (inlist == NULL || outlist == NULL ||
	    input == NULL || output == NULL) {
	    printf ("Can't even begin; out of memory.\n");
	    exit (ERROR_RETURN);
	}
	inlist[0]  = '\0';
	outlist[0] = '\0';
	input[0]   = '\0';
	output[0]  = '\0';
	
	/* Initialize the lists of reference file keywords and names. */
	InitRefFile (&refnames);

	/* Initial values. */
	initCCDSwitches (&ccd_sw);

	/* Parse the command-line arguments */
	for (i = 1;  i < argc;  i++) {
	    if (!(strcmp(argv[i],"--version"))) {
		printf("%s\n",WF3_CAL_VER_NUM);
		exit(0);
	    }

	    if (strcmp (argv[i], "-dqi") == 0) {	/* turn on */
			ccd_sw.dqicorr = PERFORM;
			switch_on = 1;
	    } else if (strcmp (argv[i], "-atod") == 0) {
			ccd_sw.atodcorr = PERFORM;
			switch_on = 1;
	    } else if (strcmp (argv[i], "-blev") == 0) {
			ccd_sw.blevcorr = PERFORM;
			switch_on = 1;
	    } else if (strcmp (argv[i], "-bias") == 0) {
			ccd_sw.biascorr = PERFORM;
			switch_on = 1;
	    } else if (strcmp (argv[i], "-flash") == 0) {
			ccd_sw.flashcorr = PERFORM;
			switch_on = 1;
	    } else if (argv[i][0] == '-') {
		for (j = 1;  argv[i][j] != '\0';  j++) {
		    if (argv[i][j] == 't') {
			printtime = YES;
		    } else if (argv[i][j] == 'v') {
			verbose = YES;
		    } else if (argv[i][j] == 'q') {
			quiet = YES;
            } else if (argv[i][j] == 'r'){
                printf ("Current version: %s\n", WF3_CAL_VER);
                exit(0);
		    } else {
			printf (MsgText, "Unrecognized option %s\n", argv[i]);
			FreeNames (inlist, outlist, input, output);
			exit (1);
		    }
		}
	    } else if (inlist[0] == '\0') {
			strcpy (inlist, argv[i]);
	    } else if (outlist[0] == '\0') {
			strcpy (outlist, argv[i]);
	    } else {
			too_many = 1;
	    }
	}

	if (inlist[0] == '\0' || too_many) {
	    printf ("syntax:  wf3ccd [-t] [-v] [-q] [-r] input output\n");
	    printf ("  command-line switches:\n");
	    printf ("       -dqi  -atod -blev -bias\n");
	    FreeNames (inlist, outlist, input, output);
	    exit (ERROR_RETURN);
	}

	/* Initialize the structure for managing trailer file comments */
	InitTrlBuf ();
	
	/* Copy command-line value for QUIET to structure */
	SetTrlQuietMode(quiet);

	/* Was no calibration switch specified on command line? */
	if (!switch_on) {	/* default values (mostly PERFORM) */
	    ccd_sw.dqicorr  = DefSwitch ("dqicorr");
	    ccd_sw.atodcorr = DefSwitch ("atodcorr");
	    ccd_sw.blevcorr = DefSwitch ("blevcorr");
	    ccd_sw.biascorr = DefSwitch ("biascorr");
	    ccd_sw.flashcorr = DefSwitch ("flshcorr");
        ccd_sw.fluxcorr = DefSwitch ("fluxcorr");
        ccd_sw.pctecorr = DefSwitch ("pctecorr");
	}

	/* Expand the templates. */
	i_imt = c_imtopen (inlist);
	o_imt = c_imtopen (outlist);
	n_in  = c_imtlen (i_imt);
	n_out = c_imtlen (o_imt);

	/* The number of input and output files must be the same. */
	if (CompareNumbers (n_in, n_out, "output"))
	    status = 1;
	if (status) {
	    FreeNames (inlist, outlist, input, output);
	    CloseTrlBuf();
	    exit (ERROR_RETURN);
	}

	/* Loop over the list of input files. */
	for (n = 0;  n < n_in;  n++) {

	    i = c_imtgetim (i_imt, input, SZ_LINE);
		
	    if (n_out > 0) {
		    i = c_imtgetim (o_imt, output, SZ_LINE);
	    } else {
    		output[0] = '\0';
        }
        
	    if (MkOutName (input, isuffix, osuffix, nsuffix, output, SZ_LINE)) {
	        WhichError (status);
	        sprintf (MsgText, "Skipping %s", input);
	        trlmessage (MsgText);
	        continue;	    
        }

	    /* Calibrate the current input file. */
	    if (WF3ccd (input, output, &ccd_sw, &refnames, printtime, verbose)){
		    sprintf (MsgText, "Error processing %s.", input);
		    trlerror (MsgText);
		    WhichError (status);
	    }
	}

	/* Close lists of file names, and free name buffers. */
	c_imtclose (i_imt);
	c_imtclose (o_imt);
	CloseTrlBuf();
	FreeRefFile (&refnames);
	FreeNames (inlist, outlist, input, output);

	if (status)
	    exit (ERROR_RETURN);
	else
	    exit (0);
}
コード例 #3
0
ファイル: cs1.c プロジェクト: brechmos-stsci/hstcal
int main (int argc, char **argv) {

	int status;			/* zero is OK */

	char *inlist;		/* list of input file names */
	char *outlist;		/* list of output file names */
	char *blevlist;		/* list of output blev file names */
	int switch_on = 0;	/* was any switch specified? */
	int printtime = 0;	/* print time after each step? */
	int verbose = 0;	/* print additional info? */
	int too_many = 0;	/* too many command-line arguments? */
	int i, j;		/* loop indexes */
	int junk;

	IRAFPointer i_imt, o_imt, b_imt;	/* imt list pointers */
	char *input;		/* name of input science file */
	char *output;		/* optional name of output file */
	char *outblev;		/* optional file for blev values */
	int n_in, n_out, n_blev;	/* number of files in each list */
	int n;

	/* Input and output suffixes. */
	char *isuffix[] = {"_raw", "_blv_tmp", "_crj_tmp", "_wav"};
	char *osuffix[] = {"_flt", "_flt",     "_crj",     "_fwv"};
	int nsuffix = 4;

	/* A structure to pass the calibration switches to CalStis1 */
	cs1_switch cs1_sw;

	/* reference file keywords and names */
	RefFileInfo refnames;

	c_irafinit (argc, argv);

	/* Allocate space for file names. */
	inlist = calloc (1, sizeof (char));	/* allocated later */
	outlist = calloc (1, sizeof (char));
	blevlist = calloc (1, sizeof (char));
	input = calloc (STIS_LINE+1, sizeof (char));
	output = calloc (STIS_LINE+1, sizeof (char));
	outblev = calloc (STIS_LINE+1, sizeof (char));
	if (inlist == NULL || outlist == NULL || blevlist == NULL ||
		input == NULL || output == NULL || outblev == NULL) {
	    printf ("ERROR:  Can't even begin; out of memory.\n");
	    exit (ERROR_RETURN);
	}

	/* Initialize the lists of reference file keywords and names. */
	InitRefFile (&refnames);

	/* Initial values. */
	cs1_sw.dqicorr = OMIT;
	cs1_sw.atodcorr = OMIT;
	cs1_sw.blevcorr = OMIT;
	cs1_sw.doppcorr = OMIT;
	cs1_sw.lorscorr = OMIT;
	cs1_sw.glincorr = OMIT;
	cs1_sw.lflgcorr = OMIT;
	cs1_sw.biascorr = OMIT;
	cs1_sw.darkcorr = OMIT;
	cs1_sw.flatcorr = OMIT;
	cs1_sw.shadcorr = OMIT;
	cs1_sw.photcorr = OMIT;
	cs1_sw.statcorr = OMIT;

	strcpy (cs1_sw.darkscale_string, "");

	for (i = 1;  i < argc;  i++) {

	    if (strcmp (argv[i], "--version") == 0) {
		PrVersion();
		exit (0);
	    }
	    if (strcmp (argv[i], "-r") == 0) {
		PrFullVersion();
		exit (0);
	    }
	    if (strcmp (argv[i], "-dqi") == 0) {	/* turn on */
		cs1_sw.dqicorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-atod") == 0) {
		cs1_sw.atodcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-blev") == 0) {
		cs1_sw.blevcorr = PERFORM;
		switch_on = 1;

	    } else if (strcmp (argv[i], "-dopp") == 0) {
		cs1_sw.doppcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-lors") == 0) {
		cs1_sw.lorscorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-glin") == 0) {
		cs1_sw.glincorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-lflg") == 0) {
		cs1_sw.lflgcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-bias") == 0) {
		cs1_sw.biascorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-dark") == 0) {
		cs1_sw.darkcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-flat") == 0) {
		cs1_sw.flatcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-shad") == 0) {
		cs1_sw.shadcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-phot") == 0) {
		cs1_sw.photcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-stat") == 0) {
		cs1_sw.statcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-dscl") == 0) {
		strcpy (cs1_sw.darkscale_string, argv[++i]);
		switch_on = 1;
	    } else if (argv[i][0] == '-') {
		for (j = 1;  argv[i][j] != '\0';  j++) {
		    if (argv[i][j] == 't') {
			printtime = 1;
		    } else if (argv[i][j] == 'v') {
			verbose = 1;
		    } else {
			printf ("ERROR:  Unrecognized option %s\n", argv[i]);
			exit (1);
		    }
		}
	    } else if (inlist[0] == '\0') {
		free (inlist);
		if ((inlist = calloc (strlen(argv[i])+1, sizeof(char)))
			== NULL) {
		    printf ("ERROR:  Out of memory.\n");
		    exit (ERROR_RETURN);
		}
		strcpy (inlist, argv[i]);
	    } else if (outlist[0] == '\0') {
		free (outlist);
		if ((outlist = calloc (strlen(argv[i])+1, sizeof(char)))
			== NULL) {
		    printf ("ERROR:  Out of memory.\n");
		    exit (ERROR_RETURN);
		}
		strcpy (outlist, argv[i]);
	    } else if (blevlist[0] == '\0') {
		free (blevlist);
		if ((blevlist = calloc (strlen(argv[i])+1, sizeof(char)))
			== NULL) {
		    printf ("ERROR:  Out of memory.\n");
		    exit (ERROR_RETURN);
		}
		strcpy (blevlist, argv[i]);
	    } else {
		too_many = 1;
	    }
	}
	if (inlist[0] == '\0' || too_many) {
	    printf ("syntax:  cs1.e [-t] [-v] input output [outblev]\n");
	    printf ("  command-line switches:\n");
	    printf ("       -dqi  -atod -blev\n");
	    printf ("       -dopp -lors -glin -lflg\n");
	    printf ("       -bias -dark -flat -shad -phot -stat\n");
	    FreeNames (inlist, outlist, blevlist, input, output, outblev);
	    exit (ERROR_RETURN);
	}

	/* Was no calibration switch specified on command line? */
	if (!switch_on) {	/* default values (mostly PERFORM) */
	    cs1_sw.dqicorr  = DefSwitch ("dqicorr");
	    cs1_sw.atodcorr = DefSwitch ("atodcorr");
	    cs1_sw.blevcorr = DefSwitch ("blevcorr");
	    cs1_sw.doppcorr = DefSwitch ("doppcorr");
	    cs1_sw.lorscorr = DefSwitch ("lorscorr");
	    cs1_sw.glincorr = DefSwitch ("glincorr");
	    cs1_sw.lflgcorr = DefSwitch ("lflgcorr");
	    cs1_sw.biascorr = DefSwitch ("biascorr");
	    cs1_sw.darkcorr = DefSwitch ("darkcorr");
	    cs1_sw.flatcorr = DefSwitch ("flatcorr");
	    cs1_sw.shadcorr = DefSwitch ("shadcorr");
	    cs1_sw.photcorr = DefSwitch ("photcorr");
	    cs1_sw.statcorr = DefSwitch ("statcorr");
	}

	/* Expand the templates. */
	i_imt = c_imtopen (inlist);
	o_imt = c_imtopen (outlist);
	b_imt = c_imtopen (blevlist);
	n_in = c_imtlen (i_imt);
	n_out = c_imtlen (o_imt);
	n_blev = c_imtlen (b_imt);

	/* The number of input and output files must be the same. */
	status = 0;
	if (CompareNumbers (n_in, n_out, "output"))
	    status = ERROR_RETURN;
	if (CompareNumbers (n_in, n_blev, "outblev"))
	    status = ERROR_RETURN;
	if (status) {
	    FreeNames (inlist, outlist, blevlist, input, output, outblev);
	    exit (ERROR_RETURN);
	}

	/* Loop over the list of input files. */
	for (n = 0;  n < n_in;  n++) {

	    junk = c_imtgetim (i_imt, input, STIS_LINE);
	    if (n_out > 0)
		junk = c_imtgetim (o_imt, output, STIS_LINE);
	    else
		output[0] = '\0';
	    if (n_blev > 0)
		junk = c_imtgetim (b_imt, outblev, STIS_LINE);
	    else
		outblev[0] = '\0';

	    status = 0;
	    if ((status = MkOutName (input, isuffix, osuffix, nsuffix,
                                     output, STIS_LINE))) {
		WhichError (status);
		printf ("Skipping %s\n", input);
		continue;
	    }

	    /* Calibrate the current input file. */
	    if ((status = CalStis1 (input, output, outblev,
                                    &cs1_sw, &refnames, printtime, verbose))) {
		printf ("Error processing %s.\n", input);
		WhichError (status);
	    }
	}

	/* Close lists of file names, and free name buffers. */
	c_imtclose (i_imt);
	c_imtclose (o_imt);
	c_imtclose (b_imt);
	FreeRefFile (&refnames);
	FreeNames (inlist, outlist, blevlist, input, output, outblev);

	if (status)
	    exit (ERROR_RETURN);
	else
	    exit (0);
}
コード例 #4
0
ファイル: cs7.c プロジェクト: brechmos-stsci/hstcal
int main (int argc, char **argv) {

	int status;		/* zero is OK */
	char *inlist;		/* list of input file names */
	char *outlist;		/* list of output file names */
	int switch_on = 0;	/* was any switch specified? */
	int sgeocorr = OMIT;	/* calibration switches */
	int helcorr = OMIT;
	int fluxcorr = OMIT;
	int statcorr = OMIT;
	int err_algorithm = WGT_VARIANCE;
	int printtime = 0;	/* print time after each step? */
	int verbose = 0;	/* print additional info? */
	int center_target = 0;	/* center target in output image? */
	int too_many = 0;	/* too many command-line arguments? */
	int i, j;		/* loop indexes */
	double blazeshift = NO_VALUE;

	IRAFPointer i_imt, o_imt;	/* imt list pointers */
	char *input;		/* name of input science file */
	char *output;		/* optional name of output file */
	int n_in, n_out;	/* number of files in each list */
	int n;

	/* Input and output suffixes. */
	char *isuffix[] =
		{"_flt", "_crj", "_fwv", "_cwv", "_fwv_tmp", "_cwv_tmp"};
	char *osuffix[] =
		{"_x2d", "_sx2", "_w2d", "_w2d", "_w2d_tmp", "_w2d_tmp"};
	int nsuffix = 6;

	/* reference file keywords and names */
	RefFileInfo refnames;

	c_irafinit (argc, argv);

	inlist = calloc (STIS_LINE+1, sizeof (char));
	outlist = calloc (STIS_LINE+1, sizeof (char));
	input = calloc (STIS_LINE+1, sizeof (char));
	output = calloc (STIS_LINE+1, sizeof (char));
	if (inlist == NULL || outlist == NULL ||
		input == NULL || output == NULL) {
	    printf ("ERROR:  Can't even begin:  out of memory.\n");
	    exit (ERROR_RETURN);
	}

	/* Get command-line arguments. */
	for (i = 1;  i < argc;  i++) {
	    if (strcmp (argv[i], "-x2d") == 0 ||
		strcmp (argv[i], "-geo") == 0) {
		switch_on = 1;
	    } else if (strcmp (argv[i], "-sgeo") == 0) {	/* turn on */
		sgeocorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-hel") == 0) {
		helcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-flux") == 0) {
		fluxcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-stat") == 0) {
		statcorr = PERFORM;
		switch_on = 1;
	    } else if (strcmp (argv[i], "-wgt_err") == 0) {
		err_algorithm = WGT_ERROR;
	    } else if (argv[i][0] == '-') {
		if (strcmp (argv[i], "--version") == 0) {
		    PrVersion();
		    exit (0);
		}
		if (strcmp (argv[i], "-r") == 0) {
		    PrFullVersion();
		    exit (0);
		}
		for (j = 1;  argv[i][j] != '\0';  j++) {
		    if (argv[i][j] == 't') {
			printtime = 1;
		    } else if (argv[i][j] == 'v') {
			verbose = 1;
		    } else if (argv[i][j] == 'c') {
			center_target = 1;	/* yes, center target */
		    } else if (argv[i][j] == 'b') {
	                blazeshift = (double) atof (argv[++i]);
	                if (i == argc-1)
	                    break;
		    } else {
			printf ("ERROR:  Unrecognized option %s\n", argv[i]);
			exit (1);
		    }
		}
	    } else if (inlist[0] == '\0') {
		strcpy (inlist, argv[i]);
	    } else if (outlist[0] == '\0') {
		strcpy (outlist, argv[i]);
	    } else {
		too_many = 1;
	    }
	}
	if (inlist[0] == '\0' || too_many) {
	    printf (
"syntax:  cs7.e [-t] [-v] [-c] [-wgt_err] [-b blazeshift] input output\n");
	    printf ("  command-line switches:  -x2d -sgeo -hel -flux -stat\n");
	    FreeNames (inlist, outlist, input, output);
	    exit (ERROR_RETURN);
	}

	/* Was no calibration switch specified on command line? */
	if (!switch_on) {	/* default values (mostly PERFORM) */
	    sgeocorr = DefSwitch ("sgeocorr");
	    helcorr  = DefSwitch ("helcorr");
	    fluxcorr = DefSwitch ("fluxcorr");
	    statcorr = DefSwitch ("statcorr");
	}

	/* Initialize the list of reference file keywords and names. */
	InitRefFile (&refnames);

	/* Expand the templates. */
	i_imt = c_imtopen (inlist);
	o_imt = c_imtopen (outlist);
	n_in = c_imtlen (i_imt);
	n_out = c_imtlen (o_imt);

	/* The number of input and output files must be the same. */
	if (CompareNumbers (n_in, n_out, "output")) {
	    FreeNames (inlist, outlist, input, output);
	    exit (ERROR_RETURN);
	}

	/* Loop over the list of input files. */
	for (n = 0;  n < n_in;  n++) {

	    j = c_imtgetim (i_imt, input, STIS_LINE);
	    if (n_out > 0)
		j = c_imtgetim (o_imt, output, STIS_LINE);
	    else
		output[0] = '\0';

	    status = 0;
	    if ((status = MkOutName (input, isuffix, osuffix, nsuffix,
                                     output, STIS_LINE))) {
		WhichError (status);
		printf ("Skipping %s\n", input);
		continue;
	    }

	    /* Calibrate the current input file. */
	    if ((status = CalStis7 (input, output,
			sgeocorr, helcorr, fluxcorr, statcorr,
			&refnames, printtime, verbose, center_target,
                                    blazeshift, err_algorithm))) {
		printf ("Error processing %s.\n", input);
		WhichError (status);
	    }
	}

	/* Close lists of file names, and free name buffers. */
	c_imtclose (i_imt);
	c_imtclose (o_imt);
	FreeRefFile (&refnames);
	FreeNames (inlist, outlist, input, output);

	if (status)
	    exit (ERROR_RETURN);
	else
	    exit (0);
}
コード例 #5
0
ファイル: wf3cte.c プロジェクト: sosey/hstcal
int initCTETrl (char *input, char *output) {

    extern int status;

    char trl_in[SZ_LINE+1];     /* trailer filename for input */
    char trl_out[SZ_LINE+1];    /* output trailer filename */
    int exist;


    int MkName (char *, char *, char *, char *, char *, int);
    int TrlExists (char *);
    void SetTrlOverwriteMode (int);

    /* Initialize internal variables */
    trl_in[0] = '\0';
    trl_out[0] = '\0';
    exist = EXISTS_UNKNOWN;

	/* Input and output suffixes. */
	char *isuffix[] = {"_raw"};
	char *osuffix[] = {"_rac_tmp"};
	char *trlsuffix[] = {""};

	int nsuffix = 1;


	/* Start by stripping off suffix from input/output filenames */
	if (MkOutName (input, isuffix, trlsuffix, nsuffix, trl_in, SZ_LINE)) {
	    WhichError (status);
	    sprintf (MsgText, "Couldn't determine trailer filename for %s",
		     input);
	    trlmessage (MsgText);
	}
	if (MkOutName (output, osuffix, trlsuffix, nsuffix, trl_out, SZ_LINE)) {
	    WhichError (status);
	    sprintf (MsgText, "Couldn't create trailer filename for %s",
		     output);
	    trlmessage (MsgText);
	}

	/* NOW, CONVERT TRAILER FILENAME EXTENSIONS FROM '.FITS' TO '.TRL' */
    
	if (MkNewExtn (trl_in, TRL_EXTN) ) {
	    sprintf (MsgText, "Error with input trailer filename %s", trl_in);
	    trlerror (MsgText);
	    WhichError (status);
	}
	if (MkNewExtn (trl_out, TRL_EXTN) ) {
	    sprintf (MsgText, "Error with output trailer filename %s", trl_out);
	    trlerror (MsgText);
	    WhichError (status);
	}
    
 	/* If we are working with a RAW file, then see if a TRL file 
	   needs to be overwritten after the generic conversion comments.  */
	if (strstr(input, isuffix[0]) != NULL) {
	    /* Test whether the output file already exists */
	    exist = TrlExists(trl_out);            
	    if (exist == EXISTS_YES) {
		/* The output file exists, so we want to add to them 
		** the new trailer comments.  */
		    SetTrlOverwriteMode (NO);	
	    }
	}
   
    /* Sets up temp trailer file for output and copies input
     ** trailer file into it.  */
    InitTrlFile (trl_in, trl_out);
    
    return(status);
}