示例#1
0
int ImgHistory (RefImage *ref, Hdr *phdr) {

/* arguments:
RefImage *ref     i: info about reference image
Hdr *phdr         io: header to receive history records
*/

	char history[STIS_LINE];

	strcpy (history, "  reference image ");
	strcat (history, ref->name);
	addHistoryKw (phdr, history);
	if (hstio_err())
	    return (HEADER_PROBLEM);

	if (ref->pedigree[0] != '\0') {
	    strcpy (history, "    ");
	    strcat (history, ref->pedigree);
	    addHistoryKw (phdr, history);
	    if (hstio_err())
		return (HEADER_PROBLEM);
	}

	if (ref->descrip[0] != '\0') {
	    strcpy (history, "    ");
	    strcat (history, ref->descrip);
	    addHistoryKw (phdr, history);
	    if (hstio_err())
		return (HEADER_PROBLEM);
	}

	return (0);
}
示例#2
0
文件: acshist.c 项目: pllim/hstcal
int UpdateSwitch (char *calSwitch, int flag, Hdr *phdr, int *logit) {

  /* arguments:
   char *calSwitch   i: name of calibration switch
   int flag          i: value of calibration switch
   Hdr *phdr         o: primary header
   int *logit        o: true if we should log reference file names
   */

	extern int status;

	char *history;
	int PutKeyStr (Hdr *, char *, char *, char *);

	if ((history = (char *) calloc (CHAR_LINE_LENGTH+1, sizeof (char))) == NULL)
    return (status = OUT_OF_MEMORY);

	strcpy (history, calSwitch);

	*logit = 0;
	if (flag == PERFORM) {
    if (PutKeyStr (phdr, calSwitch, "COMPLETE", ""))
      return (status);
    strcat (history, " complete ...");
    addHistoryKw (phdr, history);
    if (hstio_err())
      return (status = HEADER_PROBLEM);
    *logit = 1;
	} else if (flag == DUMMY) {
    if (PutKeyStr (phdr, calSwitch, "SKIPPED", ""))
      return (status);
    strcat (history, " skipped due to dummy reference file ...");
    addHistoryKw (phdr,history);
    if (hstio_err())
      return (status = HEADER_PROBLEM);
    *logit = 1;
	} else if (flag == IGNORED) {
    if (PutKeyStr (phdr, calSwitch, "SKIPPED", ""))
      return (status);
    strcat (history, " not performed ...");  /* for some other reason */
    addHistoryKw (phdr,history);
    if (hstio_err())
      return (status = HEADER_PROBLEM);
    *logit = 1;
	}

	free (history);

	return (status);
}
示例#3
0
文件: acssum.c 项目: jhunkeler/hstcal
static int PutSumHdrInfo (SingleGroup *out, double sumexptime, double expend, int nimages, int nimsets) {

/* arguments:
SingleGroup *out  i: current imset
double *exptime   i: accumulated exposure time
double *expend    i: last exposure end time read from input file
int nimages       i: the number of imsets that were combined
*/

    extern int status;
    int PutKeyDbl (Hdr *, char *, double, char *);
    int PutKeyInt (Hdr *, char *, int, char *);
    int PutKeyStr (Hdr *, char *, char *, char *);

    /* Set the switch to indicate that rptcorr has been done. */
    if (PutKeyStr (out->globalhdr, "RPTCORR", "COMPLETE",
            "add individual repeat observations"))
        return (status);

    /* Write history records. */

    addHistoryKw (out->globalhdr, "RPTCORR complete");
    if (hstio_err())
        return (status = HEADER_PROBLEM);

    addHistoryKw (out->globalhdr, "Statistics computed after rptcorr.");
    if (hstio_err())
        return (status = HEADER_PROBLEM);

    /* Update NEXTEND in primary header, to indicate only one imset. */
    if (PutKeyInt (out->globalhdr, "NEXTEND", EXT_PER_GROUP * nimsets,
            "number of extensions"))
        return (status);

    /* Update NCOMBINE in primary header, to tell how many imsets were
       combined into this one output imset.
    */
    if (PutKeyInt (out->globalhdr, "NCOMBINE", nimages,
            "number of imsets combined"))
        return (status);

    /* Update exposure time info in SCI extension header. */
    if (PutKeyDbl (out->globalhdr, "EXPTIME", sumexptime, "exposure time"))
        return (status);
    if (PutKeyDbl (out->globalhdr, "EXPEND", expend, "exposure end time"))
        return (status);

    return (status);
}
示例#4
0
文件: acshist.c 项目: pllim/hstcal
int noiseHistory (Hdr *phdr) {

	extern int status;

	addHistoryKw (phdr, "Uncertainty array initialized.");
	if (hstio_err())
    return (status = HEADER_PROBLEM);

	return (status);
}
示例#5
0
int TabHistory (RefTab *ref, Hdr *phdr) {

/* arguments:
RefImage *ref     i: info about reference image
Hdr *phdr         io: header to receive history records
*/

	extern int status;

	char history[ACS_LINE];

	strcpy (history, "  reference table ");
	strcat (history, ref->name);
	addHistoryKw (phdr, history);
	if (hstio_err())
	    return (status = HEADER_PROBLEM);

	if (ref->pedigree[0] != '\0') {
	    strcpy (history, "    ");
	    strcat (history, ref->pedigree);
	    addHistoryKw (phdr, history);
	    if (hstio_err())
		return (status = HEADER_PROBLEM);
	}

	if (ref->descrip[0] != '\0') {		/* descrip from the header */
	    strcpy (history, "    ");
	    strcat (history, ref->descrip);
	    addHistoryKw (phdr, history);
	    if (hstio_err())
		return (status = HEADER_PROBLEM);
	}

	if (ref->descrip2[0] != '\0') {		/* descrip from the row */
	    strcpy (history, "    ");
	    strcat (history, ref->descrip2);
	    addHistoryKw (phdr, history);
	    if (hstio_err())
		return (status = HEADER_PROBLEM);
	}

	return (status);
}
示例#6
0
文件: acshist.c 项目: pllim/hstcal
int CCDHistory (ACSInfo *acs, Hdr *phdr) {

	extern int status;
	int TabHistory (RefTab *, Hdr *);

	addHistoryKw (phdr, "CCD parameters table: ");
	if (TabHistory (&acs->ccdpar, phdr))
    return (status);

	return (status);
}
示例#7
0
文件: acshist.c 项目: pllim/hstcal
int dqiHistory (ACSInfo *acs, Hdr *phdr) {

	extern int status;
	int logit;			/* true if we should log file name */
	int flag;
	int OmitStep (int);
	int TabHistory (RefTab *, Hdr *);
	int UpdateSwitch (char *, int, Hdr *, int *);

	if (OmitStep (acs->dqicorr))
    return (status);

	if (acs->bpix.exists == EXISTS_YES) {
    if (acs->bpix.goodPedigree == GOOD_PEDIGREE)
      flag = PERFORM;
    else if (acs->bpix.goodPedigree == DUMMY_PEDIGREE)
      flag = DUMMY;
    else
      flag = IGNORED;
	} else {
    flag = PERFORM;
	}

	if (UpdateSwitch ("DQICORR", flag, phdr, &logit))
    return (status);

	if (logit) {
    if (acs->detector != MAMA_DETECTOR) {
      addHistoryKw (phdr, "  values checked for saturation");
    }

    if (acs->bpix.exists == EXISTS_YES) {
      addHistoryKw (phdr, "  DQ array initialized ...");
      if (TabHistory (&acs->bpix, phdr))
        return (status);
    }
	}

	return (status);
}
示例#8
0
int blevHistory (WF3Info *wf3, Hdr *phdr, int done, int driftcorr) {

	extern int status;
	int OmitStep (int);
	int PutKeyStr (Hdr *, char *, char *, char *);
	int TabHistory (RefTab *, Hdr *);

	if (OmitStep (wf3->blevcorr))
	    return (status);

	if (PutKeyStr (phdr, "BLEVCORR", "COMPLETE", ""))
	    return (status);
	if (done) {
	    addHistoryKw (phdr,
	"BLEVCORR complete; bias level from overscan was subtracted.");
	} else {
	    addHistoryKw (phdr,
	"BLEVCORR complete, but default bias level was subtracted.");
	}
	if (hstio_err())
	    return (status = HEADER_PROBLEM);

	if (driftcorr) {
	    addHistoryKw (phdr,
	"BLEVCORR includes correction for drift along lines.");
	} else {
	    addHistoryKw (phdr,
	"BLEVCORR does not include correction for drift along lines.");
	}

	addHistoryKw (phdr, "  Overscan region table: ");
	if (TabHistory (&wf3->oscn, phdr))
	    return (status);

	if (hstio_err())
	    return (status = HEADER_PROBLEM);

	return (status);
}
示例#9
0
int cteHistory (WF3Info *wf3, Hdr *phdr) {
	extern int status;
	int logit;			/* true if we should log file name */
	int OmitStep (int);
	int TabHistory (RefTab *, Hdr *);
	int UpdateSwitch (char *, int, Hdr *, int *);

	if (OmitStep (wf3->pctecorr))
	    return (status);

	if (UpdateSwitch ("PCTECORR", wf3->pctecorr, phdr, &logit))
	    return (status);

	addHistoryKw (phdr, "CTE parameters table: ");
	if (TabHistory (&wf3->pctetab, phdr))
	    return (status);

	return (status);
}
示例#10
0
int History7 (StisInfo7 *sts, Hdr *phdr) {

/* arguments:
StisInfo7 *sts   i: calibration switches and info
Hdr *phdr        io: header to receive history records
*/

	int status;

	int logit;		/* true if we log history info */

	logit = 0;
	if (sts->obstype == SPECTROSCOPIC_TYPE) {
	    if (sts->x2dcorr == PERFORM) {
		Put_KeyS (phdr, "X2DCORR", "COMPLETE", "");
		Put_KeyS (phdr, "DISPCORR", "COMPLETE", "");
		addHistoryKw (phdr, "X2DCORR complete ...");
		logit = 1;
	    } else if (sts->x2dcorr == DUMMY) {
		Put_KeyS (phdr, "X2DCORR", "SKIPPED", "");
		addHistoryKw (phdr,
			"X2DCORR skipped due to dummy reference file ...");
		logit = 1;
	    }
	} else {
	    if (sts->x2dcorr == PERFORM) {
		Put_KeyS (phdr, "GEOCORR", "COMPLETE", "");
		addHistoryKw (phdr, "GEOCORR complete ...");
		logit = 1;
	    } else if (sts->x2dcorr == DUMMY) {
		Put_KeyS (phdr, "GEOCORR", "SKIPPED", "");
		addHistoryKw (phdr,
			"GEOCORR skipped due to dummy reference file ...");
		logit = 1;
	    }
	}
	if (logit) {
	    if (hstio_err())
		return (HEADER_PROBLEM);
	    if ((status = TabHistory (&sts->distntab, phdr)))
		return (status);
	    if (sts->obstype == SPECTROSCOPIC_TYPE) {
		if ((status = TabHistory (&sts->apdestab, phdr)))
		    return (status);
		if ((status = TabHistory (&sts->disptab, phdr)))
		    return (status);
		if ((status = TabHistory (&sts->inangtab, phdr)))
		    return (status);
		if ((status = TabHistory (&sts->sptrctab, phdr)))
		    return (status);
		if (sts->wx2dcorr == COMPLETE) {
		    addHistoryKw (phdr,
			"spectral trace was applied earlier, by wx2d");
		}
	    }
	}

	logit = 0;
	if (sts->sgeocorr == PERFORM) {
	    Put_KeyS (phdr, "SGEOCORR", "COMPLETE", "");
	    addHistoryKw (phdr, "SGEOCORR complete ...");
	    logit = 1;
	} else if (sts->sgeocorr == DUMMY) {
	    Put_KeyS (phdr, "SGEOCORR", "SKIPPED", "");
	    addHistoryKw (phdr,
			"SGEOCORR skipped due to dummy reference file ...");
	    logit = 1;
	}
	if (logit) {
	    if (hstio_err())
		return (HEADER_PROBLEM);
	    if ((status = ImgHistory (&sts->sdstfile, phdr)))
		return (status);
	}

	if (sts->heliocorr == PERFORM) {
	    Put_KeyS (phdr, "HELCORR", "COMPLETE", "");
	    addHistoryKw (phdr, "HELCORR complete");
	    if (hstio_err())
		return (HEADER_PROBLEM);
	}

	logit = 0;
	if (sts->fluxcorr == PERFORM) {
	    Put_KeyS (phdr, "FLUXCORR", "COMPLETE", "");
	    addHistoryKw (phdr, "FLUXCORR complete ...");
	    logit = 1;
	} else if (sts->fluxcorr == DUMMY) {
	    Put_KeyS (phdr, "FLUXCORR", "SKIPPED", "");
	    addHistoryKw (phdr,
			"FLUXCORR skipped due to dummy reference file ...");
	    logit = 1;
	}
	if (logit) {
	    if (hstio_err())
		return (HEADER_PROBLEM);
	    if ((status = TabHistory (&sts->phottab, phdr)))
		return (status);
	    if ((status = TabHistory (&sts->apertab, phdr)))
		return (status);

	    /* pctcorr is not independent; it's associated with fluxcorr. */
	    if (sts->pctcorr == PERFORM) {
		if ((status = TabHistory (&sts->pctab, phdr)))
		    return (status);
	    } else {
		addHistoryKw (phdr,
		"  Note:  PCTAB correction was not included in DIFF2PT");
		if (hstio_err())
		    return (HEADER_PROBLEM);
	    }

	    /* tdscorr is not independent; it's associated with fluxcorr. */
	    if (sts->tdscorr == PERFORM) {
		if ((status = TabHistory (&sts->tdstab, phdr)))
		    return (status);
	    } else {
		addHistoryKw (phdr,
		"  Note:  TDSTAB correction was not included in fluxcorr");
		if (hstio_err())
		    return (HEADER_PROBLEM);
	    }
	}

	if (sts->statcorr == PERFORM) {
	    addHistoryKw (phdr, "Statistics computed");
	    if (hstio_err())
		return (HEADER_PROBLEM);
	}

	return (0);
}
示例#11
0
/* remove stripes from post-SM4 full frame WFC data using information in
 * the prescan regions. chip2 is amps C & D, chip1 is amps A & B. */
int doDestripe(ACSInfo *acs, SingleGroup *chip2, SingleGroup *chip1) {
  extern int status;

  /* iteration variables */
  int i, j, k;

  /* amp array size variables */
  int arr_rows, arr_cols;

  /* array of arrays for each amp's data in order of AMPSORDER */
  double * ampdata[NAMPS];

  /* arrays of bias column means and standard deviation */
  double bias_col_means[NBIAS_COLS];
  double bias_col_stds[NBIAS_COLS];

  /* array of arrays designating whether a row is usable or not. 0: bad, 1:good */
  char * good_rows[NAMPS];

  /* array of number of good rows for each amp */
  int num_good_rows[NAMPS];
  
  /* number of rows ultimately worked on and fixed */
  int rows_fixed;
  int rows_skipped;
  
  /* character array for holding history messages */
  char history[ACS_LINE];

  /* bias pixel mean, standard deviation, and number of good pixels */
  double bias_mean, bias_std;
  int good_bias_pix;

  /* holder of bias means from each amp, saved here so I can put the
   * MEANBLEV keyword in the science extension headers */
  double bias_mean_arr[NAMPS];
  
  int PutKeyFlt(Hdr *, char *, float, char *);
  int blevHistory(ACSInfo *, Hdr *, int, int);
  int MkName (char *, char *, char *, char *, char *, int);

  /* figure out the size of individual amp arrays
   * should be 2068 rows by 2072 columns */
  arr_rows = chip2->sci.data.ny;
  arr_cols = chip2->sci.data.nx/2;

  /* allocate space for the amp arrays */
  for (i = 0; i < NAMPS; i++) {
    ampdata[i] = malloc(arr_rows * arr_cols * sizeof(double));
    good_rows[i] = malloc(arr_rows * sizeof(char));
  }

  /* copy data from SingleGroup structs to amp arrays */
  for (i = 0; i < NAMPS; i++) {
    if (i < 2) {
      make_amp_array(arr_rows, arr_cols, chip1, i, ampdata[i]);
    } else {
      make_amp_array(arr_rows, arr_cols, chip2, i, ampdata[i]);
    }
  }

  /* subtract each column's mean as computed after removing the mean of each
   * bias row, ignoring bias rows near saturated pixels, and doing
   * sigma rejection of outlying bias pixels. */
  for (i = 0; i < NAMPS; i++) {
    if (bias_col_mean_std(arr_rows, arr_cols, ampdata[i],
                          bias_col_means, bias_col_stds)) {
      return status;
    }
    if (sub_bias_col_means(arr_rows, arr_cols, NBIAS_COLS, bias_col_means,
                           ampdata[i])) {
      return status;
    }
  }

  /* for each amp figure out which rows to use and how many good rows there are */
  for (i = 0; i < NAMPS; i++) {
    find_good_rows(arr_rows, arr_cols, ampdata[i], good_rows[i], &num_good_rows[i]);
  }

  /* for each amp, figure out the mean of the good bias pixels with "sigma"
   * clipping, then subtract that mean from all that amp's data. */
  for (i = 0; i < NAMPS; i++) {
    if (calc_bias_mean_std(arr_rows, arr_cols, ampdata[i], good_rows[i],
                           &bias_mean, &bias_std, &good_bias_pix)) {
      return status;
    }

    /* subtract the mean from all the pixels in the image. */
    for (j = 0; j < arr_rows; j++) {
      for (k = 0; k < arr_cols; k++) {
        ampdata[i][arr_cols*j + k] -= bias_mean;
      }
    }

    /* report bias level subtracted to user */
    sprintf(MsgText, "     bias level of %.6g electrons was subtracted for AMP %c.",
            bias_mean, AMPSORDER[i]);
    trlmessage(MsgText);

    acs->blev[i] += bias_mean;
    bias_mean_arr[i] = bias_mean;
  }

  /* add MEANBLEV keyword to science extension headers */
  if (PutKeyFlt (&chip1->sci.hdr, "MEANBLEV", (bias_mean_arr[0] + bias_mean_arr[1])/2.,
                 "mean of bias levels subtracted in electrons")) {
    return (status);
  }
  if (PutKeyFlt (&chip2->sci.hdr, "MEANBLEV", (bias_mean_arr[2] + bias_mean_arr[3])/2.,
                 "mean of bias levels subtracted in electrons")) {
    return (status);
  }

  /* remove stripes */
  if (remove_stripes(arr_rows, arr_cols, good_rows, ampdata, &rows_fixed, &rows_skipped)) {
    return status;
  }
  
  /* add history keywords about rows fixed and rows skipped */
  sprintf(history, "DESTRIPE: number of rows fixed per amp: %i", rows_fixed);
  addHistoryKw(chip2->globalhdr, history);
  if (hstio_err()) {
    return (status = HEADER_PROBLEM);
  }
  
  sprintf(history, "DESTRIPE: number of rows skipped per amp: %i", rows_skipped);
  addHistoryKw(chip2->globalhdr, history);
  if (hstio_err()) {
    return (status = HEADER_PROBLEM);
  }

  /* copy modified data back to SingleGroup structs */
  for (i = 0; i < NAMPS; i++) {
    if (i < 2) {
      unmake_amp_array(arr_rows, arr_cols, chip1, i, ampdata[i]);
    } else {
      unmake_amp_array(arr_rows, arr_cols, chip2, i, ampdata[i]);
    }
  }

  /* free allocated arrays */
  for (i = 0; i < NAMPS; i++) {
    free(ampdata[i]);
    free(good_rows[i]);
  }

  return status;
}