コード例 #1
0
ファイル: getsdc6.c プロジェクト: jhunkeler/hstcal
static int OpenSDistTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    SDCTAB `%s' not found.\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */

	c_tbcfnd1 (tabinfo->tp, "OPT_ELEM", &tabinfo->cp_opt_elem);
	c_tbcfnd1 (tabinfo->tp, "CENWAVE", &tabinfo->cp_cenwave);

	c_tbcfnd1 (tabinfo->tp, "SPORDER", &tabinfo->cp_sporder);
	c_tbcfnd1 (tabinfo->tp, "A2CENTER", &tabinfo->cp_a2center);
	c_tbcfnd1 (tabinfo->tp, "CDELT2", &tabinfo->cp_cdelt2);
	c_tbcfnd1 (tabinfo->tp, "NPIX2", &tabinfo->cp_npix);

	if (tabinfo->cp_opt_elem == 0 || tabinfo->cp_cenwave == 0 ||
	    tabinfo->cp_sporder == 0  || tabinfo->cp_a2center == 0 ||
	    tabinfo->cp_cdelt2 == 0   || tabinfo->cp_npix == 0) {

	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Column not found in SDCTAB.\n");
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (0);
}
コード例 #2
0
ファイル: getangle4.c プロジェクト: brechmos-stsci/hstcal
static int OpenApTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("APDESTAB `%s' not found.\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "APERTURE", &tabinfo->cp_aperture);
	c_tbcfnd1 (tabinfo->tp, "OFFSET1", &tabinfo->cp_offset);
	if (tabinfo->cp_aperture == 0 || tabinfo->cp_offset == 0) {
	    printf ("Column not found in APDESTAB.\n");
	    c_tbtclo (tabinfo->tp);
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (0);
}
コード例 #3
0
ファイル: doatod.c プロジェクト: jhunkeler/hstcal
static int OpenAtoDTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    ATODTAB `%s' not found.\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "CCDAMP", &tabinfo->cp_amp);
	c_tbcfnd1 (tabinfo->tp, "CCDGAIN", &tabinfo->cp_gain);
	c_tbcfnd1 (tabinfo->tp, "REF_KEY", &tabinfo->cp_key);
	c_tbcfnd1 (tabinfo->tp, "REF_KEY_VALUE", &tabinfo->cp_keyval);
	c_tbcfnd1 (tabinfo->tp, "NELEM", &tabinfo->cp_nelem);
	c_tbcfnd1 (tabinfo->tp, "ATOD", &tabinfo->cp_atod);
	if (tabinfo->cp_amp == 0 ||
	    tabinfo->cp_gain == 0 ||
	    tabinfo->cp_key == 0 ||
	    tabinfo->cp_keyval == 0 ||
	    tabinfo->cp_nelem == 0 ||
	    tabinfo->cp_atod == 0) {
	    printf ("ERROR    Column not found in ATODTAB.\n");
	    c_tbtclo (tabinfo->tp);
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (0);
}
コード例 #4
0
ファイル: getlintab.c プロジェクト: jhunkeler/hstcal
static int OpenLinTab (char *tname, TblInfo *tabinfo) {

	extern int status;

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    sprintf (MsgText, "MLINTAB `%s' not found.", tname);
	    trlerror (MsgText);
		return (status = OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "DETECTOR", &tabinfo->cp_det);
	c_tbcfnd1 (tabinfo->tp, "GLOBAL_LIMIT", &tabinfo->cp_global);
	c_tbcfnd1 (tabinfo->tp, "LOCAL_LIMIT", &tabinfo->cp_local);
	c_tbcfnd1 (tabinfo->tp, "TAU", &tabinfo->cp_tau);
	c_tbcfnd1 (tabinfo->tp, "EXPAND", &tabinfo->cp_expand);
	if (tabinfo->cp_det == 0 ||
	    tabinfo->cp_global == 0 ||
	    tabinfo->cp_local == 0 ||
	    tabinfo->cp_tau == 0 ||
	    tabinfo->cp_expand == 0) {
	    trlerror ("Column not found in MLINTAB.");
	    c_tbtclo (tabinfo->tp);
	    return (status = COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (status);
}
コード例 #5
0
ファイル: getapoffset6.c プロジェクト: jhunkeler/hstcal
static int OpenApTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    APDESTAB `%s' not found\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "APERTURE", &tabinfo->cp_aperture);
	c_tbcfnd1 (tabinfo->tp, "OFFSET1", &tabinfo->cp_offset[0]);
	c_tbcfnd1 (tabinfo->tp, "OFFSET2", &tabinfo->cp_offset[1]);
	if (tabinfo->cp_aperture == 0 ||
	    tabinfo->cp_offset[0] == 0 || tabinfo->cp_offset[1] == 0) {
	    printf ("ERROR    Column not found in APDESTAB\n");
	    c_tbtclo (tabinfo->tp);
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree is not a required column. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);

	return (0);
}
コード例 #6
0
ファイル: gettdccorr.c プロジェクト: brechmos-stsci/hstcal
static int OpenTdcTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    TDCTAB `%s' not found.\n", tname);
	    return OPEN_FAILED;
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */

	c_tbcfnd1 (tabinfo->tp, "MJD", &tabinfo->cp_mjd);
	c_tbcfnd1 (tabinfo->tp, "SCALE", &tabinfo->cp_scale);
	c_tbcfnd1 (tabinfo->tp, "NORM", &tabinfo->cp_norm);
	c_tbcfnd1 (tabinfo->tp, "T_MIN", &tabinfo->cp_tmin);
	c_tbcfnd1 (tabinfo->tp, "THERMCST", &tabinfo->cp_thermcst);
	if (tabinfo->cp_mjd == 0 ||
	    tabinfo->cp_scale == 0 ||
	    tabinfo->cp_norm == 0 ||
	    tabinfo->cp_tmin == 0 ||
	    tabinfo->cp_thermcst == 0) {
	    printf ("ERROR    Column not found in TDCTAB.\n");
	    c_tbtclo (tabinfo->tp);
	    return COLUMN_NOT_FOUND;
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return 0;
}
コード例 #7
0
ファイル: getdisp4.c プロジェクト: brechmos-stsci/hstcal
static int OpenDSPTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("DISPTAB `%s' not found.\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */

	c_tbcfnd1 (tabinfo->tp, "OPT_ELEM", &tabinfo->cp_opt_elem);
	c_tbcfnd1 (tabinfo->tp, "CENWAVE", &tabinfo->cp_cenwave);
	c_tbcfnd1 (tabinfo->tp, "A2CENTER", &tabinfo->cp_a2center);

	c_tbcfnd1 (tabinfo->tp, "NCOEFF", &tabinfo->cp_ncoeff);
	c_tbcfnd1 (tabinfo->tp, "COEFF", &tabinfo->cp_coeff);
	c_tbcfnd1 (tabinfo->tp, "REF_APER", &tabinfo->cp_ref_aper);

	/* for the a4corr for echelle data */
	c_tbcfnd1 (tabinfo->tp, "MREF", &tabinfo->cp_mref);
	c_tbcfnd1 (tabinfo->tp, "YREF", &tabinfo->cp_yref);
	c_tbcfnd1 (tabinfo->tp, "A4CORR", &tabinfo->cp_a4corr);

	if (tabinfo->cp_opt_elem == 0 || tabinfo->cp_cenwave == 0 ||
	    tabinfo->cp_a2center == 0 ||
	    tabinfo->cp_ncoeff == 0   || tabinfo->cp_coeff == 0 ||
	    tabinfo->cp_ref_aper == 0) {

	    c_tbtclo (tabinfo->tp);
	    printf ("Column not found in DISPTAB.\n");
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	if (tabinfo->cp_mref == 0 || tabinfo->cp_yref == 0 ||
	    tabinfo->cp_a4corr == 0) {
	    printf ("Warning  A4CORR not found.\n");
	    tabinfo->cp_a4corr = 0;	/* so we can test on just one value */
	}

	return (0);
}
コード例 #8
0
ファイル: echscatread.c プロジェクト: brechmos-stsci/hstcal
static int GetXDisp (char *name, ScatterFunctions *scf) {

/* arguments
char *name;             i: name of CDSTAB reference file
ScatterFunctions *scf;  o: data structure with scattering functions
*/
        IRAFPointer tp;
        IRAFPointer cp_optelem, cp_nelem, cp_cdscat;
        char opt_elem[STIS_CBUF];
        int row, nrows, i;

        tp = c_tbtopn (name, IRAF_READ_ONLY, 0);
        if (c_iraferr()) {
            printf ("ERROR    CDSTAB `%s' not found\n", name);
            return (OPEN_FAILED);
        }
        nrows = c_tbpsta (tp, TBL_NROWS);
        c_tbcfnd1 (tp, "OPT_ELEM", &cp_optelem);
        c_tbcfnd1 (tp, "NELEM",    &cp_nelem);
        c_tbcfnd1 (tp, "CDSCAT",   &cp_cdscat);
        if (cp_optelem == 0 || cp_nelem == 0 || cp_cdscat == 0) {
            printf( "ERROR    Column not found in CDSTAB\n");
            c_tbtclo (tp);
            return (COLUMN_NOT_FOUND);
        }

        for (row = 1; row <= nrows ; row++) {
            c_tbegtt (tp, cp_optelem, row, opt_elem, STIS_CBUF-1);
            if (streq_ic (opt_elem, scf->opt_elem)) {
                c_tbegti (tp, cp_nelem, row, &(scf->nxdisp));
                scf->xdisp = (float *) calloc (scf->nxdisp, sizeof (float));
                if (scf->xdisp == NULL )
                    return (OUT_OF_MEMORY);
                i = c_tbagtr (tp, cp_cdscat, row, scf->xdisp, 1, scf->nxdisp);
                if (c_iraferr())
                    return (TABLE_ERROR);
                c_tbtclo (tp);
                return (STIS_OK);
            }
        }

        printf( "ERROR    Row with %s optical element not found in CDSTAB\n",
                 opt_elem);
        c_tbtclo (tp);
        return (ROW_NOT_FOUND);
}
コード例 #9
0
ファイル: dodqi.c プロジェクト: jhunkeler/hstcal
static int OpenBpixTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr())
	    return (OPEN_FAILED);

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "PIX1", &tabinfo->cp_xstart);
	c_tbcfnd1 (tabinfo->tp, "PIX2", &tabinfo->cp_ystart);
	c_tbcfnd1 (tabinfo->tp, "LENGTH", &tabinfo->cp_length);
	c_tbcfnd1 (tabinfo->tp, "AXIS", &tabinfo->cp_axis);
	c_tbcfnd1 (tabinfo->tp, "VALUE", &tabinfo->cp_flag);
	if (tabinfo->cp_xstart == 0 ||
	    tabinfo->cp_ystart == 0 ||
	    tabinfo->cp_length == 0 ||
	    tabinfo->cp_axis == 0 ||
	    tabinfo->cp_flag == 0) {
	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Column not found in BPIXTAB.\n");
	    return (COLUMN_NOT_FOUND);
	}

	/* This column is optional, for backward compatibility. */
	c_tbcfnd1 (tabinfo->tp, "OPT_ELEM", &tabinfo->cp_opt_elem);

	/* Find out how large a full-size data quality array should be. */
	tabinfo->axlen1 = c_tbhgti (tabinfo->tp, "SIZAXIS1");
	if (c_iraferr()) {
	    c_tbtclo (tabinfo->tp);
	    printf (
		"ERROR    Couldn't get SIZAXIS1 from BPIXTAB header.\n");
	    return (TABLE_ERROR);
	}
	tabinfo->axlen2 = c_tbhgti (tabinfo->tp, "SIZAXIS2");
	if (c_iraferr()) {
	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Couldn't get SIZAXIS2 from BPIXTAB header.\n");
	    return (TABLE_ERROR);
	}

	return (0);
}
コード例 #10
0
ファイル: getccdtab.c プロジェクト: jhunkeler/hstcal
static int OpenCCDTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    CCDTAB `%s' not found.\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "CCDAMP", &tabinfo->cp_amp);
	c_tbcfnd1 (tabinfo->tp, "CCDGAIN", &tabinfo->cp_ccdgain);
	c_tbcfnd1 (tabinfo->tp, "BINAXIS1", &tabinfo->cp_bin1);
	c_tbcfnd1 (tabinfo->tp, "BINAXIS2", &tabinfo->cp_bin2);
	c_tbcfnd1 (tabinfo->tp, "CCDOFFST", &tabinfo->cp_ccdoffset);
	c_tbcfnd1 (tabinfo->tp, "ATODGAIN", &tabinfo->cp_atodgain);
	c_tbcfnd1 (tabinfo->tp, "CCDBIAS", &tabinfo->cp_bias);
	c_tbcfnd1 (tabinfo->tp, "READNSE", &tabinfo->cp_readnoise);
	c_tbcfnd1 (tabinfo->tp, "SATURATE", &tabinfo->cp_saturate);
	c_tbcfnd1 (tabinfo->tp, "BLEV_CLIP", &tabinfo->cp_blev_clip);
	if (tabinfo->cp_amp == 0 ||
	    tabinfo->cp_ccdgain == 0 ||
	    tabinfo->cp_bin1 == 0 ||
	    tabinfo->cp_bin2 == 0 ||
	    tabinfo->cp_ccdoffset == 0 ||
	    tabinfo->cp_atodgain == 0 ||
	    tabinfo->cp_bias == 0 ||
	    tabinfo->cp_readnoise == 0 ||
	    tabinfo->cp_saturate == 0) {
	    printf ("ERROR    Column not found in CCDTAB.\n");
	    c_tbtclo (tabinfo->tp);
	    return (COLUMN_NOT_FOUND);
	}

	/* BLEV_CLIP is an optional column. */

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (0);
}
コード例 #11
0
ファイル: gettrace6.c プロジェクト: brechmos-stsci/hstcal
static int OpenTraceTab (char *tname, TblInfo *tabinfo) {

        clear_cvoserr();
	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    SPTRCTAB `%s' not found\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */

	c_tbcfnd1 (tabinfo->tp, "OPT_ELEM", &tabinfo->cp_opt_elem);
	c_tbcfnd1 (tabinfo->tp, "CENWAVE", &tabinfo->cp_cenwave);
	c_tbcfnd1 (tabinfo->tp, "SPORDER", &tabinfo->cp_sporder);

	c_tbcfnd1 (tabinfo->tp, "A1CENTER", &tabinfo->cp_a1center);
	c_tbcfnd1 (tabinfo->tp, "A2CENTER", &tabinfo->cp_a2center);
	c_tbcfnd1 (tabinfo->tp, "NELEM", &tabinfo->cp_nelem);
	c_tbcfnd1 (tabinfo->tp, "A2DISPL", &tabinfo->cp_a2displ);

	if (tabinfo->cp_opt_elem == 0 || tabinfo->cp_cenwave == 0 ||
	    tabinfo->cp_sporder == 0  ||
	    tabinfo->cp_a1center == 0  || tabinfo->cp_a2center == 0 ||
	    tabinfo->cp_nelem == 0   || tabinfo->cp_a2displ == 0) {

	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Column not found in SPTRCTAB\n");
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	/* mjd and degperyr are optional columns used for trace rotation. */
	c_tbcfnd1 (tabinfo->tp, "MJD", &tabinfo->cp_mjd);
	c_tbcfnd1 (tabinfo->tp, "DEGPERYR", &tabinfo->cp_degperyr);

	return (0);
}
コード例 #12
0
ファイル: getintens.c プロジェクト: jhunkeler/hstcal
static int OpenIntensTab (char *tname, TblInfo *tabinfo, double *exptime,
                          int fflux) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    OSPECTAB `%s' not found\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, SPORDER, &tabinfo->cp_sporder);
	c_tbcfnd1 (tabinfo->tp, NELEM, &tabinfo->cp_nelem);
	c_tbcfnd1 (tabinfo->tp, WAVELENGTH, &tabinfo->cp_wave);
	if (fflux)
	    c_tbcfnd1 (tabinfo->tp, "FLUX", &tabinfo->cp_intens);
	else
	    c_tbcfnd1 (tabinfo->tp, NET, &tabinfo->cp_intens);

	if (tabinfo->cp_sporder == 0 ||
            tabinfo->cp_nelem   == 0 ||
	    tabinfo->cp_wave    == 0 ||
	    tabinfo->cp_intens  == 0) {
	    printf ("ERROR    Column not found in OSPECTAB\n");
	    c_tbtclo (tabinfo->tp);
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	/* Get EXPTIME */
	*exptime = c_tbhgtd (tabinfo->tp, "EXPTIME");

	return (0);
}
コード例 #13
0
ファイル: getprofile.c プロジェクト: jhunkeler/hstcal
static int OpenProfileTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    OPROFTAB `%s' not found\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "SPORDER", &tabinfo->cp_sporder);
	c_tbcfnd1 (tabinfo->tp, "NPTS", &tabinfo->cp_npts);
	c_tbcfnd1 (tabinfo->tp, "NPTS_OFFSET", &tabinfo->cp_nptsoff);
	c_tbcfnd1 (tabinfo->tp, "SUB_FACTOR", &tabinfo->cp_subscale);
	c_tbcfnd1 (tabinfo->tp, "MIN_WAVE", &tabinfo->cp_minw);
	c_tbcfnd1 (tabinfo->tp, "MAX_WAVE", &tabinfo->cp_maxw);
	c_tbcfnd1 (tabinfo->tp, "MIN_PIX", &tabinfo->cp_minp);
	c_tbcfnd1 (tabinfo->tp, "MAX_PIX", &tabinfo->cp_maxp);
	c_tbcfnd1 (tabinfo->tp, "S_N", &tabinfo->cp_sn);
	c_tbcfnd1 (tabinfo->tp, "PROF_OFFSET", &tabinfo->cp_profoff);
	c_tbcfnd1 (tabinfo->tp, "PROF", &tabinfo->cp_prof);
	if (tabinfo->cp_sporder == 0 || tabinfo->cp_npts == 0 ||
	    tabinfo->cp_minw    == 0 || tabinfo->cp_maxw == 0 ||
	    tabinfo->cp_minp    == 0 || tabinfo->cp_maxp == 0 ||
	    tabinfo->cp_profoff == 0 || tabinfo->cp_prof == 0 ||
	    tabinfo->cp_sn      == 0 || tabinfo->cp_nptsoff == 0) {
	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Column not found in OPROFTAB\n");
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (0);
}
コード例 #14
0
ファイル: getinang6.c プロジェクト: jhunkeler/hstcal
static int OpenIACTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    Can't open `%s'\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */

	c_tbcfnd1 (tabinfo->tp, "OPT_ELEM", &tabinfo->cp_opt_elem);
	c_tbcfnd1 (tabinfo->tp, "CENWAVE", &tabinfo->cp_cenwave);
	c_tbcfnd1 (tabinfo->tp, "SPORDER", &tabinfo->cp_sporder);

	c_tbcfnd1 (tabinfo->tp, "NCOEFF1", &tabinfo->cp_ncoeff1);
	c_tbcfnd1 (tabinfo->tp, "COEFF1", &tabinfo->cp_coeff1);
	c_tbcfnd1 (tabinfo->tp, "NCOEFF2", &tabinfo->cp_ncoeff2);
	c_tbcfnd1 (tabinfo->tp, "COEFF2", &tabinfo->cp_coeff2);

	if (tabinfo->cp_opt_elem == 0 || tabinfo->cp_cenwave == 0 ||
	    tabinfo->cp_sporder == 0  ||
	    tabinfo->cp_ncoeff1 == 0   || tabinfo->cp_coeff1 == 0 ||
	    tabinfo->cp_ncoeff2 == 0   || tabinfo->cp_coeff2 == 0) {

	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Column not found in %s\n", tname);
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (0);
}
コード例 #15
0
ファイル: getdisp.c プロジェクト: jhunkeler/hstcal
static int OpenDSPTab (char *tname, TblInfo *tabinfo) {

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    DISPTAB `%s' not found.\n", tname);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */

	c_tbcfnd1 (tabinfo->tp, "OPT_ELEM", &tabinfo->cp_opt_elem);
	c_tbcfnd1 (tabinfo->tp, "CENWAVE", &tabinfo->cp_cenwave);

	c_tbcfnd1 (tabinfo->tp, "A2CENTER", &tabinfo->cp_a2center);
	c_tbcfnd1 (tabinfo->tp, "NCOEFF", &tabinfo->cp_ncoeff);
	c_tbcfnd1 (tabinfo->tp, "COEFF", &tabinfo->cp_coeff);
	c_tbcfnd1 (tabinfo->tp, "REF_APER", &tabinfo->cp_ref_aper);

	if (tabinfo->cp_opt_elem == 0 || tabinfo->cp_cenwave == 0 ||
	    tabinfo->cp_a2center == 0 ||
	    tabinfo->cp_ncoeff == 0   || tabinfo->cp_coeff == 0 ||
	    tabinfo->cp_ref_aper == 0) {

	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Column not found in DISPTAB.\n");
	    return (COLUMN_NOT_FOUND);
	}

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (0);
}
コード例 #16
0
ファイル: readpar.c プロジェクト: brechmos-stsci/hstcal
/*  rejpar_in -- Read parameters either from user input or table.

  Description:
  ------------
  Reads CL parameters and does necessary checkings
  
  Input parameters from crrej reference table:
  -------------------------------------------
  Col. Name     Parameter
  "skysub"      sky         Sky levels subtraction scheme
  "crsigmas"    sigmas      Rejection thresholds
  "crradius"    radius      Radius (in pixels) to propagate the cosmic ray
  "crthresh"    thresh      Propagation factor
  "initgues"    initgues    Scheme of computing initial-guess image
  "scalense"    scalense    multiplicative noise in percents
  "badinpdq"    badinpdq    Data quality pset
  "crmask"      mask        flag CR-rejected pixels in input files?

  Input parameters from input image primary header:
  ------------------------------------------------


  Date          Author          Description
  ----          ------          -----------
  24-Sep-1998   W.J. Hack       Initial ACS Version	
*/
int rejpar_in (clpar *par, int newpar[], int nimgs, float exptot, int *niter, float sigma[])
{
    extern int status;

    IRAFPointer     tp;
    IRAFPointer     colptr, colptr1;
    int             i, nrows, nmatch, row;
    int             crsplit_in, crsplit, maxcrsplit;
    float           exp_in, meanexp, mindiff, diff;
    char            maskstr[ACS_CBUF+1];

    void    PrRefInfo (char *, char *, char *, char *, char *);
    void    WhichError (int);

/* -------------------------------- begin ---------------------------------- */

    crsplit_in = nimgs;

    exp_in = exptot / (float) crsplit_in;
    par->meanexp = exp_in;

    /* if all parameters are specified by the user, no need to open the 
	    reference CRREJ table */
    if (newpar[0] < MAX_PAR) {

        tp = c_tbtopn (par->tbname, IRAF_READ_ONLY, 0);
            if (c_iraferr() != 0) {
                sprintf (MsgText,"CRREJTAB table '%s' does not exist", par->tbname);
                trlerror (MsgText);
                return (status = TABLE_ERROR);
            }
        nrows = c_tbpsta (tp, TBL_NROWS);

        /* read the columns CRSPLIT and MEANEXP */
        c_tbcfnd1 (tp, "crsplit", &colptr);
        if (colptr == 0) {
            trlerror ("column CRSPLIT does not exist in CRREJTAB");
            return (status = COLUMN_NOT_FOUND);
        }
        c_tbcfnd1 (tp, "meanexp", &colptr1);
        if (colptr1 == 0) {
            trlerror ("column MEANEXP does not exist in CRREJTAB\n");
            return (status = COLUMN_NOT_FOUND);
        }
        nmatch = 0;

        /* find the largest value in the CRSPLIT column */
        for (i = 1; i <= nrows; i++) {
            c_tbegti (tp, colptr, i, &crsplit);
            if (i == 1) maxcrsplit = crsplit;
            if (crsplit > maxcrsplit)
            maxcrsplit = crsplit;
        }
        if (crsplit_in >= maxcrsplit) crsplit_in = maxcrsplit;

        /* find the matching row in CRREJTAB to use */
        for (i = 1; i <= nrows; i++) {
            c_tbegti (tp, colptr, i, &crsplit);
            c_tbegtr (tp, colptr1, i, &meanexp);
            diff = meanexp - exp_in;
            if (crsplit_in == crsplit && diff >= 0.) {
                nmatch++;
                if (nmatch == 1) mindiff = diff;
                if (diff <= mindiff) {
                    row = i;
                    mindiff = diff;
                }
            }
        }
        if (nmatch == 0) {
            trlerror (" No matching CRSPLIT and MEANEXP in CRREJTAB");
            return (status = ROW_NOT_FOUND);
        }

        /* read the sigmas parameter */ 
        if (newpar[CRSIGMAS] == 0) {
            c_tbcfnd1 (tp, "crsigmas", &colptr);
            if (colptr == 0) {
                trlerror ("column CRSIGMAS does not exist in CRREJTAB");
                return (status = COLUMN_NOT_FOUND);
            }
            c_tbegtt (tp, colptr, row, par->sigmas, ACS_LINE);
        }

        /* read other parameters */
        if (newpar[SKYSUB] == 0) {
            c_tbcfnd1 (tp, "skysub", &colptr);
            if (colptr == 0) {
                trlerror ("column SKYSUB does not exist in CRREJTAB");
                return (status = COLUMN_NOT_FOUND);
            }
            c_tbegtt (tp, colptr, row, par->sky, ACS_FITS_REC);
        }

        /* CR propagation parameters */
        if (newpar[CRRADIUS] == 0) {
            c_tbcfnd1 (tp, "crradius", &colptr);
            if (colptr == 0) {
                trlerror ("column CRRADIUS does not exist in CRREJTAB");
                return (status = COLUMN_NOT_FOUND);
            }
            c_tbegtr (tp, colptr, row, &par->radius);
        }
        if (newpar[CRTHRESH] == 0) {
            c_tbcfnd1 (tp, "crthresh", &colptr);
            if (colptr == 0) {
                trlerror ("column CRTHRESH does not exist in CRREJTAB");
                return (status = COLUMN_NOT_FOUND);
            }
            c_tbegtr (tp, colptr, row, &par->thresh);
        }

            /* figure out how to do initial comparison image */
        if (newpar[INITGUES] == 0) {
            c_tbcfnd1 (tp, "initgues", &colptr);
            if (colptr == 0) {
                trlerror ("column INITGUES does not exist in CRREJTAB");
                return (status = COLUMN_NOT_FOUND);
            }
            c_tbegtt (tp, colptr, row, par->initgues, ACS_FITS_REC);
        }

        /* read the noise model */
        if (newpar[SCALENSE] == 0) {
            c_tbcfnd1 (tp, "scalense", &colptr);
            if (colptr == 0) {
                trlerror ("column SCALENSE does not exist in CRREJTAB");
                return (status = COLUMN_NOT_FOUND);
            }
            c_tbegtr (tp, colptr, row, &par->scalense);
        }

        if (newpar[BADINPDQ] == 0) {
            c_tbcfnd1 (tp, "badinpdq", &colptr);
            if (colptr == 0) {
                trlerror ("column BADINPDQ does not exist in CRREJTAB");
                return (status = COLUMN_NOT_FOUND);
            }
            c_tbegts (tp, colptr, row, &par->badinpdq);
        }

        if (newpar[CRMASK] == 0) {
            c_tbcfnd1 (tp, "crmask", &colptr);
            if (colptr == 0) {
                trlerror ("column CRMASK does not exist in CRREJTAB");
                return (status = COLUMN_NOT_FOUND);
            }
            c_tbegti (tp, colptr, row, &par->mask);
        }

        c_tbtclo (tp);
    }

    PrRefInfo ("crrejtab", par->tbname, "", "", "");
    
    /* parse the sigmas string into numbers */
    *niter = strtor (par->sigmas, sigma);
    if (status != ACS_OK) {
        WhichError (status);
        return (status);
    }
    
    if (*niter > MAX_ITER) {
        sprintf (MsgText,"No more than %d iterations permitted.", MAX_ITER);
        trlerror (MsgText);
        return (status = ERROR_RETURN);
    }
    if (*niter <= 0) {
        trlerror ("Number of iterations is ZERO.");
        return (status = ERROR_RETURN);
    }

    /* other fixed (for now) parameters */
    par->crval = (short) DATAREJECT;
    par->fillval = 0.;
    
    /* print out which parameter are used */
    if (par->verbose) {
        sprintf (MsgText,"\n number of images = %d", nimgs);
        trlmessage (MsgText);
        sprintf (MsgText," CRREJ ref table used: %s", par->tbname);
        trlmessage (MsgText);
        sprintf (MsgText," initial guess method: %s", par->initgues);
        trlmessage (MsgText);
        sprintf (MsgText," total exposure time = %0.1f", exptot);
        trlmessage (MsgText);
        sprintf (MsgText," sigmas used: %s", par->sigmas);
        trlmessage (MsgText);
        sprintf (MsgText," sky subtraction used: %s", par->sky);
        trlmessage (MsgText);
        sprintf (MsgText," rejection radius = %0.1f", par->radius);
        trlmessage (MsgText);
        sprintf (MsgText," propagation threshold = %0.1f", par->thresh);
        trlmessage (MsgText);
        sprintf (MsgText," scale noise = %0.1f%%", par->scalense);
        trlmessage (MsgText);
        sprintf (MsgText," input bad bits value = %d", par->badinpdq);
        trlmessage (MsgText);
        
        if (par->mask == 1) {
            strcpy (maskstr,"YES");
        } else {
            strcpy (maskstr, "NO");
        }
        sprintf (MsgText," reset crmask = %s\n", maskstr);
        trlmessage (MsgText);
    }
    return (status);
}
コード例 #17
0
ファイル: getabsphot.c プロジェクト: brechmos-stsci/hstcal
static int OpenPhotTab (StisInfo7 *sts, TblInfo *tabinfo, PhotInfo *phot,
			int *warn) {

	tabinfo->tp = c_tbtopn (sts->phottab.name, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("ERROR    PHOTTAB `%s' not found.\n", sts->phottab.name);
	    return (OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the mandatory columns. */
	c_tbcfnd1 (tabinfo->tp, "OPT_ELEM", &tabinfo->cp_opt_elem);
	c_tbcfnd1 (tabinfo->tp, "NELEM", &tabinfo->cp_nelem);
	c_tbcfnd1 (tabinfo->tp, "WAVELENGTH", &tabinfo->cp_wl);
	c_tbcfnd1 (tabinfo->tp, "THROUGHPUT", &tabinfo->cp_thru);
	if (tabinfo->cp_opt_elem == 0 ||
	    tabinfo->cp_nelem == 0 ||
	    tabinfo->cp_wl == 0 ||
	    tabinfo->cp_thru == 0) {
	    printf ("ERROR    Column not found in PHOTTAB.\n");
	    c_tbtclo (tabinfo->tp);
	    return (COLUMN_NOT_FOUND);
	}
	if (sts->obstype == SPECTROSCOPIC_TYPE) {
	    c_tbcfnd1 (tabinfo->tp, "CENWAVE", &tabinfo->cp_cenwave);
	    c_tbcfnd1 (tabinfo->tp, "SPORDER", &tabinfo->cp_sporder);
	    if (tabinfo->cp_cenwave == 0 || tabinfo->cp_sporder == 0) {
		printf (
	"ERROR    Column (CENWAVE or SPORDER) not found in PHOTTAB.\n");
		c_tbtclo (tabinfo->tp);
		return (COLUMN_NOT_FOUND);
	    }
	} else {
	    /* Flag the fact that we didn't try to find these columns. */
	    tabinfo->cp_cenwave = 0;
	    tabinfo->cp_sporder = 0;
	}

	/* Now look for the blaze shift columns. It's not an error if
	   they are not found.
	*/
	phot->blazecorr = OMIT;
	if (!(sts->first_order)) {
	    phot->blazecorr = PERFORM;
	    c_tbcfnd1 (tabinfo->tp, "REFORD",      &tabinfo->cp_mref);
	    c_tbcfnd1 (tabinfo->tp, "REFWAV",      &tabinfo->cp_wref);
	    c_tbcfnd1 (tabinfo->tp, "REFY",        &tabinfo->cp_yref);
	    c_tbcfnd1 (tabinfo->tp, "REFMJD",      &tabinfo->cp_mjd);
	    c_tbcfnd1 (tabinfo->tp, "BSHIFT_VS_X", &tabinfo->cp_mx);
	    c_tbcfnd1 (tabinfo->tp, "BSHIFT_VS_Y", &tabinfo->cp_my);
	    c_tbcfnd1 (tabinfo->tp, "BSHIFT_VS_T", &tabinfo->cp_mt);
	    /* bshift_offset is an optional column */
	    c_tbcfnd1 (tabinfo->tp, "BSHIFT_OFFSET", &tabinfo->cp_m0);
	    if (tabinfo->cp_mref == 0 ||
		tabinfo->cp_wref == 0 ||
		tabinfo->cp_yref == 0 ||
		tabinfo->cp_mjd  == 0 ||
		tabinfo->cp_mx   == 0 ||
		tabinfo->cp_my   == 0 ||
		tabinfo->cp_mt   == 0) {

		phot->blazecorr = OMIT;

		if (*warn)
		    printf ("Warning  PHOTTAB does not "
			    "contain blaze shift information.\n");
		*warn = 0;
	    }
        }

	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

	return (0);
}
コード例 #18
0
ファイル: echscatread.c プロジェクト: brechmos-stsci/hstcal
static int GetRefWave (Hdr *phdr, char *name, ScatterFunctions *scf) {

/* arguments
Hdr *phdr               i: primary header
char *name;             i: name of SRWTAB reference file
ScatterFunctions *scf;  o: data structure with reference wavelengths
*/
        IRAFPointer tp;
        IRAFPointer cp_optelem, cp_cenwave, cp_nrw, cp_hrwlist, cp_prwlist;
        char opt_elem[STIS_CBUF];
        int row, nrows, i, cenwave, status;
        double holdh[10], holdp[10];   /* holds a maximum of 10 wavelengths */

        /* This is necessary to avoid rui warnings from the debugger. */
        for (i = 0; i < 10; i++) {
            holdh[i] = 0.0;
            holdp[i] = 0.0;
        }
        for (i = 0; i <= NREFWAVE; i++) {
            scf->kernw[i] = 0.0;
            scf->psfw[i] = 0.0;
        }

        /* get reference CENWAVE. */

        if ((status = Get_KeyI (phdr, "CENWAVE", 0, 0, &cenwave)))
            return (status);

        tp = c_tbtopn (name, IRAF_READ_ONLY, 0);
        if (c_iraferr()) {
            printf ("ERROR    SRWTAB `%s' not found\n", name);
            return (OPEN_FAILED);
        }
        nrows = c_tbpsta (tp, TBL_NROWS);
        c_tbcfnd1 (tp, "OPT_ELEM",  &cp_optelem);
        c_tbcfnd1 (tp, "CENWAVE",   &cp_cenwave);
        c_tbcfnd1 (tp, "NRW",       &cp_nrw);
        c_tbcfnd1 (tp, "HALOWAVES", &cp_hrwlist);
        c_tbcfnd1 (tp, "PSFWAVES",  &cp_prwlist);
        if (cp_optelem == 0 || cp_cenwave == 0 ||
            cp_nrw     == 0 || cp_hrwlist == 0 || cp_prwlist == 0) {
            printf( "ERROR    Column not found in SRWTAB\n");
            c_tbtclo (tp);
            return (COLUMN_NOT_FOUND);
        }

        scf->nwave = 0;
        for (row = 1; row <= nrows ; row++) {

            c_tbegti (tp, cp_cenwave, row, &i);
            c_tbegtt (tp, cp_optelem, row, opt_elem, STIS_CBUF-1);
            if (c_iraferr())
                return (TABLE_ERROR);
            if ((i == cenwave) && (streq_ic (opt_elem, scf->opt_elem))) {

                c_tbegti (tp, cp_nrw, row, &(scf->nwave));
                if (c_iraferr())
                    return (TABLE_ERROR);
                i = c_tbagtd (tp, cp_hrwlist, row, holdh, 1, scf->nwave);
                if (c_iraferr())
                    return (TABLE_ERROR);
                i = c_tbagtd (tp, cp_prwlist, row, holdp, 1, scf->nwave);
                if (c_iraferr())
                    return (TABLE_ERROR);
                c_tbtclo (tp);

                scf->kernw[0] = holdh[0];
                scf->psfw[0]  = holdp[0];
                if (scf->nwave > 1) {
                    scf->kernw[1] = holdh[1];
                    scf->psfw[1]  = holdp[1];
                }
                if (scf->nwave > 2) {
                    scf->kernw[2] = holdh[2];
                    scf->psfw[2]  = holdp[2];
                }

                return (STIS_OK);
            }
        }

        printf( "ERROR    Row not found in SRWTAB\n");
        c_tbtclo (tp);
        return (ROW_NOT_FOUND);
}
コード例 #19
0
ファイル: echscatread.c プロジェクト: brechmos-stsci/hstcal
static int GetRipple (Hdr *phdr, char *name, ScatterFunctions *scf) {

/* arguments
Hdr *phdr               i: primary header
char *name;             i: name of RIPTAB  reference file
ScatterFunctions *scf;  o: data structure with ripple functions
*/
        IRAFPointer tp;
        IRAFPointer cp_optelem, cp_cenwave, cp_sporder, cp_wave,
                    cp_nelem, cp_ripple;
        char opt_elem[STIS_CBUF];
        int row, nrows, i, k, cenwave, status;

        /* get reference CENWAVE. */

        if ((status = Get_KeyI (phdr, "CENWAVE", 0, 0, &cenwave)))
            return (status);

        /* Open table and get column pointers. */

        tp = c_tbtopn (name, IRAF_READ_ONLY, 0);
        if (c_iraferr()) {
            printf ("ERROR    RIPTAB `%s' not found\n", name);
            return (OPEN_FAILED);
        }
        c_tbcfnd1 (tp, "OPT_ELEM",   &cp_optelem);
        c_tbcfnd1 (tp, "CENWAVE",    &cp_cenwave);
        c_tbcfnd1 (tp, "SPORDER",    &cp_sporder);
        c_tbcfnd1 (tp, "NELEM",      &cp_nelem);
        c_tbcfnd1 (tp, "WAVELENGTH", &cp_wave);
        c_tbcfnd1 (tp, "RIPPLE",     &cp_ripple);
        if (cp_cenwave == 0 || cp_sporder == 0 ||
            cp_wave    == 0 || cp_ripple  == 0 ||
            cp_nelem   == 0 || cp_optelem == 0) {
            printf( "ERROR    Column not found in RIPTAB\n");
            c_tbtclo (tp);
            return (COLUMN_NOT_FOUND);
        }

        /* Get # of matching rows. */

        nrows = c_tbpsta (tp, TBL_NROWS);
        scf->nrp = 0;
        for (row = 1; row <= nrows; row++) {
            c_tbegti (tp, cp_cenwave, row, &i);
            c_tbegtt (tp, cp_optelem, row, opt_elem, STIS_CBUF-1);
            if (c_iraferr())
                return (TABLE_ERROR);

            if ((i == cenwave) && (streq_ic (opt_elem, scf->opt_elem)))
                (scf->nrp)++;
        }
        if (scf->nrp == 0) {
            printf ("ERROR    No matching rows in RIPTAB `%s'\n", name);
            return (TABLE_ERROR);
        }

        /* Alloc memory. */

        scf->rpfunc = (RippleFunc *) calloc (scf->nrp, sizeof (RippleFunc));
        if (scf->rpfunc == NULL)
            return (OUT_OF_MEMORY);

        /* Ingest data from matching rows. */

        k = 0;
        for (row = 1; row <= nrows ; row++) {

            c_tbegti (tp, cp_cenwave, row, &i);
            c_tbegtt (tp, cp_optelem, row, opt_elem, STIS_CBUF-1);
            if (c_iraferr())
                return (TABLE_ERROR);

            if ((i == cenwave) && (streq_ic (opt_elem, scf->opt_elem))) {

                c_tbegti (tp, cp_sporder, row, &(scf->rpfunc[k].sporder));
                if (c_iraferr())
                    return (TABLE_ERROR);
                scf->rpfunc[k].nelem = c_tbcigi (cp_ripple,
                                                 TBL_COL_LENDATA);
                scf->rpfunc[k].wavelengths = (double *) calloc (
                                             scf->rpfunc[k].nelem,
                                             sizeof (double));
                if (scf->rpfunc[k].wavelengths == NULL)
                    return (OUT_OF_MEMORY);
                scf->rpfunc[k].values = (double *) calloc (
                                         scf->rpfunc[k].nelem,
                                         sizeof (double));
                if (scf->rpfunc[k].values == NULL)
                    return (OUT_OF_MEMORY);
                i = c_tbagtd (tp, cp_wave, row, scf->rpfunc[k].wavelengths,
                              1, scf->rpfunc[k].nelem);
                if (c_iraferr())
                    return (TABLE_ERROR);
                i = c_tbagtd (tp, cp_ripple, row, scf->rpfunc[k].values,
                              1, scf->rpfunc[k].nelem);
                if (c_iraferr())
                    return (TABLE_ERROR);

                k++;
            }
        }

        c_tbtclo (tp);

        return (STIS_OK);
}
コード例 #20
0
ファイル: gettdccorr.c プロジェクト: brechmos-stsci/hstcal
static int postSM4TdcCorr(StisInfo1 *sts, double mean_dark,
                          double *factor) {

/* arguments:
StisInfo1 *sts          i: calibration switches, etc
double mean_dark        i: mean of good pixels of dark reference image
                           (binned to 1024x1024 pixels in size)
double *factor          o: NUV correction factor for dark image
*/
        /*int status;*/

	IRAFPointer tp;			/* pointer to table descriptor */
	/* column descriptors */
	IRAFPointer cp_date0, cp_temp0,
		cp_a1, cp_d1, cp_a2, cp_d2, cp_ta, cp_tb, cp_tc;
	int nrows;			/* number of rows in table */
	/* values read from a table row */
	double date0;			/* reference date */
	double temp0;			/* reference temperature */
	double a1;
	double d1;
	double a2;
	double d2;
	double ta;
	double tb;
	double tc;
	int row;			/* loop index for row number */
	int read_this_row = -1;		/* number of row of table to read */
	double min_date0 = 0.;		/* min value of data0 */
	double best_date0 = 0.;		/* date0 in row to use */
	double d_date;			/* expstart - date0 */
	double d_temp;			/* temperature - temp0 */
	double count_rate;		/* computed count rate at EXPSTART */

	tp = c_tbtopn(sts->tdctab.name, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf("ERROR    Can't open TDCTAB `%s'.\n", sts->tdctab.name);
	    return OPEN_FAILED;
	}
	nrows = c_tbpsta(tp, TBL_NROWS);
	if (nrows < 1) {
	    printf("ERROR    TDCTAB %s is empty.\n", sts->tdctab.name);
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	/* Look for all of the columns we require. */
	c_tbcfnd1(tp, "DATE0", &cp_date0);
	c_tbcfnd1(tp, "TEMP0", &cp_temp0);
	c_tbcfnd1(tp, "A1", &cp_a1);
	c_tbcfnd1(tp, "D1", &cp_d1);
	c_tbcfnd1(tp, "A2", &cp_a2);
	c_tbcfnd1(tp, "D2", &cp_d2);
	c_tbcfnd1(tp, "TA", &cp_ta);
	c_tbcfnd1(tp, "TB", &cp_tb);
	c_tbcfnd1(tp, "TC", &cp_tc);
	if (cp_date0 == 0 || cp_temp0 == 0 ||
	    cp_a1 == 0 || cp_d1 == 0 ||
	    cp_a2 == 0 || cp_d2 == 0 ||
	    cp_ta == 0 || cp_tb == 0 || cp_tc == 0) {
	    printf("ERROR    Column not found in TDCTAB.\n");
	    c_tbtclo(tp);
	    return COLUMN_NOT_FOUND;
	}

	/* Find the minimum value in the DATE0 column. */
	for (row = 1;  row <= nrows;  row++) { /* row number is one-indexed */
	    c_tbegtd(tp, cp_date0, row, &date0);
	    if (c_iraferr()) {
		c_tbtclo(tp);
		return TABLE_ERROR;
	    }
	    if (row == 1)
		min_date0 = date0;
	    else if (date0 < min_date0)
		min_date0 = date0;
	}
	if (sts->expstart < min_date0) {
	    printf("ERROR    Exposure start time precedes earliest date "
	           "in TDCTAB.\n");
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	/* Select the row such that DATE0 is less than but closest to
	   the exposure start time.
	*/
	best_date0 = min_date0;			/* initial value */
	for (row = 1;  row <= nrows;  row++) {
	    c_tbegtd(tp, cp_date0, row, &date0);
	    if (c_iraferr()) {
		c_tbtclo(tp);
		return TABLE_ERROR;
	    }
	    if (date0 < sts->expstart && (row == 1 || date0 > best_date0)) {
		best_date0 = date0;
		read_this_row = row;
	    }
	}
	if (read_this_row < 1) {
	    c_tbtclo(tp);
	    printf("Warning:  No valid row found in TDCTAB %s\n",
	           sts->tdctab.name);
	    *factor = 1.;
	    return 0;
	}

	c_tbegtd(tp, cp_date0, read_this_row, &date0);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}
	d_date = sts->expstart - date0;

	c_tbegtd(tp, cp_temp0, read_this_row, &temp0);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}
	d_temp = sts->detector_temp - temp0;

	c_tbegtd(tp, cp_a1, read_this_row, &a1);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	c_tbegtd(tp, cp_d1, read_this_row, &d1);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	c_tbegtd(tp, cp_a2, read_this_row, &a2);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	c_tbegtd(tp, cp_d2, read_this_row, &d2);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	c_tbegtd(tp, cp_ta, read_this_row, &ta);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	c_tbegtd(tp, cp_tb, read_this_row, &tb);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	c_tbegtd(tp, cp_tc, read_this_row, &tc);
	if (c_iraferr()) {
	    c_tbtclo(tp);
	    return TABLE_ERROR;
	}

	c_tbtclo(tp);

	count_rate = a1 * exp(-d_date / d1) +
	             a2 * exp(-d_date / d2) +
	             ta + tb * d_temp +
	                  tc * d_temp * d_temp;

	if (count_rate > 100.) {
	    printf("Warning  TDC dark count rate = %.6g\n", count_rate);
	}
	*factor = count_rate / mean_dark;
	if (fabs(*factor) > 100. || fabs(*factor) < 0.01) {
	    printf("Warning  TDC correction factor = %.6g.\n", *factor);
	}

	return 0;
}
コード例 #21
0
ファイル: echscatread.c プロジェクト: brechmos-stsci/hstcal
static int GetHalo (char *name, ScatterFunctions *scf,
                    Image *halo1, Image *halo2, Image *halo3) {

/*
char *name;             i: name of HALOTAB reference file
ScatterFunctions *scf;  o: data structure with scattering functions
Image *halo1,2,3;       o: halo images, previously initialized
*/

        IRAFPointer tp;
        IRAFPointer cp_optelem, cp_refwave, cp_haldim, cp_halo;
        char opt_elem[STIS_CBUF];
        int row, nrows, i, status, k, haldim;
        double rw;

        int Alloc2DImage (Image *, int, int);

        tp = c_tbtopn (name, IRAF_READ_ONLY, 0);
        if (c_iraferr()) {
            printf ("ERROR    HALOTAB `%s' not found\n", name);
            return (OPEN_FAILED);
        }
        nrows = c_tbpsta (tp, TBL_NROWS);
        c_tbcfnd1 (tp, "OPT_ELEM", &cp_optelem);
        c_tbcfnd1 (tp, "HALOWAVE", &cp_refwave);
        c_tbcfnd1 (tp, "HALDIM",   &cp_haldim);
        c_tbcfnd1 (tp, "HALO",     &cp_halo);
        if (cp_optelem == 0 || cp_refwave == 0 ||
            cp_haldim  == 0 || cp_halo    == 0) {
            printf( "ERROR    Column not found in HALOTAB\n");
            c_tbtclo (tp);
            return (COLUMN_NOT_FOUND);
        }

        k = 0;
        for (row = 1; row <= nrows ; row++) {

            c_tbegtt (tp, cp_optelem, row, opt_elem, STIS_CBUF-1);
            c_tbegtd (tp, cp_refwave, row, &rw);
            if (c_iraferr())
                return (TABLE_ERROR);

            if ((rw == scf->kernw[k]) &&
                (streq_ic (opt_elem, scf->opt_elem))) {

                c_tbegti (tp, cp_haldim, row, &haldim);

                /* This awful code is a consequence of the
                   change in reference file format that took place
                   after the original code was completed.
                */
                switch (k) {
                case 0:
                    if ((status = Alloc2DImage (halo1, haldim, haldim)))
                        return (status);
                    i = c_tbagtr (tp, cp_halo, row, halo1->pix, 1, halo1->npix);
                    if (c_iraferr())
                        return (TABLE_ERROR);
                    break;
                case 1:
                    if ((status = Alloc2DImage (halo2, haldim, haldim)))
                        return (status);
                    i = c_tbagtr (tp, cp_halo, row, halo2->pix, 1, halo2->npix);
                    if (c_iraferr())
                        return (TABLE_ERROR);
                    break;
                case 2:
                    if ((status = Alloc2DImage (halo3, haldim, haldim)))
                        return (status);
                    i = c_tbagtr (tp, cp_halo, row, halo3->pix, 1, halo3->npix);
                    if (c_iraferr())
                        return (TABLE_ERROR);
                    break;
                default:
                    break;
                }

                k++;
            }
        }

        if (k == 0) {
            printf ("ERROR    No matching rows in HALOTAB `%s'\n", name);
            return (TABLE_ERROR);
        }

        c_tbtclo (tp);
        return (STIS_OK);
}
コード例 #22
0
ファイル: echscatread.c プロジェクト: brechmos-stsci/hstcal
static int GetPSF (char *name, Hdr *phdr, double xsize, double ysize,
                   ScatterFunctions *scf,
                   Image *psf1, Image *psf2, Image *psf3) {

/*
char *name;             i: name of TELTAB reference file
Hdr *phdr               i: primary header
double xsize, ysize;    i: aperture size in arcsec
ScatterFunctions *scf;  o: data structure with scattering functions
Image *psf1,2,3;        o: PSF images, previously initialized
*/
        IRAFPointer tp;
        IRAFPointer cp_refwave, cp_pscale, cp_psfdim, cp_telepsf;
        int row, nrows, psfdim;
        double rw, psfscale;
        Image ospsf;
        Image imtemp, psf;
        char keyword[STIS_CBUF];
        double xplate, yplate;
        double sbox, lbox;
        double rstart, rstop;
        double frac1, frac2;
        float fhold;
        double sum;
        int i, j, k, kk, ms, ml, ns, nl, s, l;
        int ns2, nl2, s1, s2, l1, l2;
        int istart, istop;
        int status;

        int Alloc1DImage (Image *, int);
        int Alloc2DImage (Image *, int, int);
        void InitImage (Image *);
        void FreeImage (Image *);

        /* Define plate scale. */

        if (streq_ic (scf->opt_elem, "E140M"))
            xplate = 0.036;
        else if (streq_ic (scf->opt_elem, "E140H"))
            xplate = 0.0466;
        else if (streq_ic (scf->opt_elem, "E230M"))
            xplate = 0.033;
        else if (streq_ic (scf->opt_elem, "E230H"))
            xplate = 0.0466;
        else {
            printf ("Non supported grating.\n");
            return (ERROR_RETURN);
        }
        yplate = 0.029;

        /* Truncate the aperture size if it extends beyond the borders
           of an image.
        */

        /* See if uniformly illuminated aperture was used. */

        if ((status = Get_KeyS (phdr, "SCLAMP", 0, "", keyword, STIS_CBUF)))
            return (status);
        if (!streq_ic (keyword, "NONE")) {
            ml = (int)floor (ysize / yplate);
            if (ml % 2) {
                status  = Alloc1DImage (psf1, ml+1);
                status |= Alloc1DImage (psf2, ml+1);
                status |= Alloc1DImage (psf3, ml+1);
                if (status)
                    return (status);
                for (i = 1; i < ml; i++) {
                    psf1->pix[i] = 1.0 / ml;
                    psf2->pix[i] = 1.0 / ml;
                    psf3->pix[i] = 1.0 / ml;
                }
                psf1->pix[0]  = 0.5 / ml;
                psf1->pix[ml] = 0.5 / ml;
                psf2->pix[0]  = 0.5 / ml;
                psf2->pix[ml] = 0.5 / ml;
                psf3->pix[0]  = 0.5 / ml;
                psf3->pix[ml] = 0.5 / ml;
            } else {
                status  = Alloc1DImage (psf1, ml);
                status |= Alloc1DImage (psf2, ml);
                status |= Alloc1DImage (psf3, ml);
                if (status)
                    return (status);
                for (i = 0; i < ml; i++) {
                    psf1->pix[i] = 1.0 / ml;
                    psf2->pix[i] = 1.0 / ml;
                    psf3->pix[i] = 1.0 / ml;
                }
            }
            return (STIS_OK);
        }

        /* Scan reference file and process each PSF. */

        tp = c_tbtopn (name, IRAF_READ_ONLY, 0);
        if (c_iraferr()) {
            printf ("ERROR    TELTAB `%s' not found\n", name);
            return (OPEN_FAILED);
        }
        nrows = c_tbpsta (tp, TBL_NROWS);
        c_tbcfnd1 (tp, "PSFWAVE", &cp_refwave);
        c_tbcfnd1 (tp, "PSCALE",  &cp_pscale);
        c_tbcfnd1 (tp, "PSFDIM",  &cp_psfdim);
        c_tbcfnd1 (tp, "TELEPSF", &cp_telepsf);
        if (cp_refwave == 0 || cp_psfdim  == 0 ||
            cp_pscale  == 0 || cp_telepsf == 0) {
            printf( "ERROR    Column not found in TELTAB\n");
            c_tbtclo (tp);
            return (COLUMN_NOT_FOUND);
        }

        kk = 0;
        for (row = 1; row <= nrows ; row++) {

            c_tbegtd (tp, cp_refwave, row, &rw);
            if (c_iraferr())
                return (TABLE_ERROR);

            /* Matching reference wavelenghts. */

            if (rw == scf->psfw[kk]) {

                /* Read PSF image and associated data. */

                c_tbegtd (tp, cp_pscale, row, &psfscale);
                c_tbegti (tp, cp_psfdim, row, &psfdim);

                InitImage (&imtemp);
                if ((status = Alloc2DImage (&imtemp, psfdim, psfdim)))
                    return (status);
                i = c_tbagtr (tp, cp_telepsf, row, imtemp.pix, 1,
                              imtemp.npix);
                if (c_iraferr())
                    return (TABLE_ERROR);

                /* Find peak. */

                ns = imtemp.nx;
                nl = imtemp.ny;
                fhold = -FLT_MAX;
                for (i = 0; i < ns; i++) {
                    for (j = 0; j < nl; j++) {
                        if (PIX (imtemp, i, j) > fhold) {
                            s = i;
                            l = j;
                            fhold = PIX (imtemp, i, j);
                        }
                    }
                }

                /* Determine portion of PSF that made it through aperture. */

                ns2 = ((int)NINT (xsize / psfscale)) / 2;
                nl2 = ((int)NINT (ysize / psfscale)) / 2;
                s1  = ((s - ns2) >= 0) ? (s - ns2) : 0;
                s2  = ((s + ns2) <= (ns - 1)) ? (s + ns2) : (ns - 1);
                l1  = ((l - nl2) >= 0) ? (l - nl2) : 0;
                l2  = ((l + nl2) <= (nl - 1)) ? (l + nl2) : (nl - 1);

                /* Extract sub-image. */

                InitImage (&ospsf);
                if ((status = Alloc2DImage (&ospsf, s2 - s1 + 1, l2 - l1 + 1)))
                    return (status);
                k = 0;
                /* location of braces looks like a typo, but harmless */
                for (j = l1; j <= l2; j++)
                    for (i = s1; i <= s2; i++) {
                        ospsf.pix[k++] = PIX (imtemp, i, j);
                }
                FreeImage (&imtemp);
                ns = ospsf.nx;
                nl = ospsf.ny;

                /* # of STIS pixels (ms*ml) illuminated by aperture. */

                /* modified on 2013 Nov 13 by PEH
                   xplate / psfscale and yplate / psfscale are the factors
                   by which the PSF in the _tel.fits file are oversampled.
                */
                ms = (NINT (ns / (xplate / psfscale))) / 2;
                ml = (NINT (nl / (yplate / psfscale))) / 2;
                ms = 2 * ms + 1;
                ml = 2 * ml + 1;

                /* Bin oversampled PSF to STIS pixel scale. */

                /* Bin columns. */

                if ((status = Alloc2DImage (&imtemp, ms, nl)))
                    return (status);
                sbox = ns / (double)ms;
                for (i = 0; i < ms; i++) {
                    rstart = i     * sbox;
                    rstop  = (i+1) * sbox;
                    istart = (int) floor (rstart);
                    istop  = (int) floor (rstop);
                    istop = (istop < ns) ? istop : ns-1;
                    frac1 = rstart - istart;
                    frac2 = 1.0 - (rstop - istop);
                    for (j = 0; j < nl; j++) {
                        for (k = istart+1; k < istop;
                            PIX (imtemp, i, j) += PIX (ospsf, k++, j));
                        PIX (imtemp, i, j) += PIX (ospsf, istart, j) *
                                              (1.0 - frac1);
                        PIX (imtemp, i, j) += PIX (ospsf, istop,  j) *
                                              (1.0 - frac2);
                    }
                }
                FreeImage (&ospsf);

                /* Bin rows. */

                InitImage (&psf);
                if ((status = Alloc2DImage (&psf, ms, ml)))
                    return (status);
                lbox = nl / (double)ml;
                for (j = 0; j < ml; j++) {
                    rstart = j     * lbox;
                    rstop  = (j+1) * lbox;
                    istart = (int) floor (rstart);
                    istop  = (int) floor (rstop);
                    istop = (istop < nl) ? istop : nl-1;
                    frac1 = rstart - istart;
                    frac2 = 1.0 - (rstop - istop);
                    for (i = 0; i < ms; i++) {
                        for (k = istart+1; k < istop;
                             PIX (psf, i, j) += PIX (imtemp, i, k++));
                        PIX (psf, i, j) += PIX (imtemp, i, istart) *
                                            (1.0 - frac1);
                        PIX (psf, i, j) += PIX (imtemp, i, istop) *
                                            (1.0 - frac2);
                    }
                }
                FreeImage (&imtemp);

                /* Normalize PSF to unit area. */

                sum = 0.0;
                for (i = 0; i < psf.npix; sum += psf.pix[i++]);
                for (i = 0; i < psf.npix; psf.pix[i++] /= sum);

                /* This awful code is a consequence of the
                   change in reference file format that took place
                   after the original code was completed.
                */
                switch (kk) {
                case 0:
                    if ((status = Alloc2DImage (psf1, psf.nx, psf.ny)))
                        return (status);
                    for (i= 0 ; i < psf1->npix; i++)
                        psf1->pix[i] = psf.pix[i];
                    break;
                case 1:
                    if ((status = Alloc2DImage (psf2, psf.nx, psf.ny)))
                        return (status);
                    for (i= 0 ; i < psf2->npix; i++)
                        psf2->pix[i] = psf.pix[i];
                    break;
                case 2:
                    if ((status = Alloc2DImage (psf3, psf.nx, psf.ny)))
                        return (status);
                    for (i= 0 ; i < psf3->npix; i++)
                        psf3->pix[i] = psf.pix[i];
                    break;
                default:
                    break;
                }

                FreeImage (&psf);
                kk++;
            }
        }

        if (kk == 0) {
            printf ("ERROR    No matching rows in TELTAB `%s'\n", name);
            return (TABLE_ERROR);
        }

        c_tbtclo (tp);
        return (STIS_OK);
}
コード例 #23
0
ファイル: wf3table.c プロジェクト: brechmos-stsci/hstcal
int GetAsnTable (AsnInfo *asn) {

    /* Arguments:
     **	asn		o: Association info structure
     */
    extern int status;

    /* Local variables */
    int i;				/* loop index */
    int nrows;			/* number of rows in ASNTAB */
    int col, row;			/* loop indexes */
    IRAFPointer tp;			/* ASNTAB table pointer */
    IRAFPointer colptr[NCOLS];	/* ASNTAB column pointers */
    int numsp;			/* number of sub-products in asn */
    int	posid;			/* id of sub-product */
    RowInfo *exp;		/* Internal structure for table information */
    int *spmems, *expmem;	/* number of EXP for each sub-product */
    int poslen;		/* Length of memtype string minus POSID */
    int prodid;		/* id of product 	*/
    int expid;
    int defid;		/* default position id for exposures */
    int procprod;
    int maxspmems;		/* max number of sub-product members */
    char *word;
    Bool proddth;
    char spname_ext[SZ_CBUF+1];	/* Extension for sub-product */
    char spname_ext_cte[SZ_CBUF+1];	/* Extension for sub-product */
    char memtype[SZ_COLNAME+1];
    char memsubtype[SZ_COLNAME+1];

    /* ASNTAB column names */
    char colname[NCOLS][SZ_COLNAME+1] = {
        "MEMNAME",
        "MEMTYPE",
        "MEMPRSNT"
    };

    /* Function definitions */
    void freeAsnInfo (AsnInfo *);
    int  allocAsnInfo (AsnInfo *, int, int *);
    void trlopenerr (char *);
    void trlwarn (char *);
    char *lowcase (char *, char *);
    int  MkName (char *, char *, char *, char *, char *, int);
    void initRowInfo (RowInfo *);
    int  streq_ic (char *, char *);  /* strings equal? (case insensitive) */

    if (asn->debug) {
        sprintf (MsgText, "GetAsnTable: ASN_TABLE is %s",asn->asn_table);
        trlmessage (MsgText); 
    }

    /* Open the ASN table */
    tp = c_tbtopn (asn->asn_table, IRAF_READ_ONLY, 0);
    if (c_iraferr()) {
        trlopenerr (asn->asn_table);
        return (status = TABLE_ERROR);
    }

    /* Get pointers to columns in ASNTAB */
    for (col=0; col < NCOLS; col++) {
        c_tbcfnd1 (tp, colname[col], &(colptr[col]));
        if (c_iraferr() || colptr[col] == 0) {
            sprintf (MsgText, "Can't find column %s in %s", colname[col],
                    asn->asn_table);
            trlerror (MsgText);
            c_tbtclo (tp);
            return (status = COLUMN_NOT_FOUND);
        }
    }

    /* Find out how many rows are in ASNTAB */
    nrows = 0;
    nrows = c_tbpsta (tp, TBL_NROWS);
    if (nrows <= 0) {
        sprintf (MsgText, "Invalid number of rows in %s", asn->asn_table);
        trlerror (MsgText);
        c_tbtclo (tp);
        return (status = TABLE_ERROR);
    }

    /* Initialize total number of members based on number of
     ** rows in table */
    asn->numasn = nrows;
    poslen = 0;

    /* Allocate space for internal variables */
    exp = NULL;
    exp = (RowInfo *)calloc(nrows, sizeof(RowInfo));
    for (row = 0; row < nrows; row++)
        initRowInfo (&(exp[row]));

    /* Read each row of ASNTAB into a local structure */
    for (row = 0; row < nrows; row++) {

        /* Get the MEMBER NAME in this row */
        c_tbegtt (tp, colptr[0], row+1, exp[row].memname, SZ_CBUF);
        if (c_iraferr()) {
            sprintf (MsgText, "Can't read %s in row %d in %s", colname[0],
                    row+1, asn->asn_table);
            trlerror (MsgText);
            c_tbtclo (tp);
            free (exp);
            return (status = ELEMENT_NOT_FOUND);
        }

        /* Convert to lowercase for use as a file name */
        for (i = 0; i < strlen(exp[row].memname); i++)
            exp[row].memname[i] = tolower(exp[row].memname[i]);

        /* Get the TYPE in this row */
        c_tbegtt (tp, colptr[1], row+1, exp[row].mtype, SZ_CBUF);
        if (c_iraferr()) {
            sprintf (MsgText, "Can't read %s in row %d in %s", colname[1],
                    row+1, asn->asn_table);
            trlerror (MsgText);
            c_tbtclo (tp);
            free (exp);
            return (status = ELEMENT_NOT_FOUND);
        }

        /* Convert to lowercase for use later in routine.
         ** Also, if a value of MEMTYPE contains a UNDERLINE, then 
         ** record conversion to DASH in trailer file and warn
         ** user to correct the value. */
        lowcase (exp[row].type, exp[row].mtype);
        for (i = 0; i < strlen(exp[row].type); i++) {
            if (exp[row].type[i] == UNDERLINE_CHAR) {       
                exp[row].type[i] = DASH_CHAR;
                sprintf(MsgText, "MEMTYPE %s in row %d was INVALID and needs to be corrected.",
                        exp[row].mtype, row+1);
                trlwarn(MsgText);
            }
        }

        /* Get the STATUS in this row */
        c_tbegtb (tp, colptr[2], row+1, &(exp[row].prsnt));
        if (c_iraferr()) {
            sprintf (MsgText, "Can't read %s in row %d in %s", colname[2],
                    row+1, asn->asn_table);
            trlerror (MsgText);
            c_tbtclo (tp);
            free (exp);
            return (status = ELEMENT_NOT_FOUND);
        }
        if (asn->debug) {
            sprintf (MsgText, "GetAsnTable: Read in row %d from ASN table",
                    row);
            trlmessage (MsgText);
        }
    }

    /*  
     ** Determine whether CRCORR or RPTOBS processing will be required
     ** by searching for MEMTYPE of EXP_CR* or EXP_RPT*, respectively.
     ** Once it is determined, go on to next step...
     */
    for (row = 0; row < nrows; row++) {

        /* Check to see if we need to do CR-SPLIT combination ... */
        if (strstr (exp[row].type, "-cr") != NULL) {
            asn->crcorr = PERFORM;
            asn->rptcorr = OMIT;
            poslen = CRLEN;
            break;

            /* ... or REPEAT-OBS combination ... 	*/
        } else if (strstr (exp[row].type, "-rp") != NULL) { 
            asn->rptcorr = PERFORM;
            asn->crcorr = OMIT;
            poslen = RPTLEN;
            break;

            /* ... or neither at all	*/
        } else {
            asn->rptcorr = OMIT;
            asn->crcorr = OMIT;
            poslen = DTHLEN;
        }	
    }

    /* Default to always perform DRIZCORR step */
    asn->dthcorr = PERFORM;

    if (asn->debug) {
        sprintf (MsgText, "GetAsnTable: CRCORR = %d, RPTCORR = %d",
                asn->crcorr,asn->rptcorr);
        trlmessage (MsgText);
    }

    /* Sort through the list figuring out which are input vs. output
     ** files, and see if any input files are missing. */
    /* Initialize local variables */
    numsp   = 0;
    posid   = 0;
    prodid  = 0;
    proddth = False;
    defid   = 1;

    /* Find out how many products/sub-products are in the association
     ** and determine the posid for each member. */	
    for (row = 0; row < nrows; row++) {
        memtype[0] = '\0';
        memsubtype[0] = '\0';

        /* As long as this is not the final product,
         ** count number of members in each product/sub-product...*/
        if (strstr(exp[row].type,"prod-dth") != NULL) {
            exp[row].posid = 0;	
            posid = 0;	

            /* If we have a dither product listed, we want to eventually
             ** perform dither combining step... */	
            prodid++;
            proddth = True;

            /* We always want to produce a product, but if
             ** not set to PERFORM, then create an empty product... */
            if (asn->dthcorr == OMIT) 
                asn->dthcorr = DUMMY;

        } else {

            strcpy(memtype,exp[row].type);	
            /* Let's start by breaking up the MEMTYPE string */
            word = strtok(memtype,"-");
            strcpy(memsubtype,word);
            /* The end of this second part of MEMTYPE has the POSID */
            word = strtok(NULL,"\n");

            /* If the last character of the memtype is a number or letter, 
             ** convert to an integer value...  */
            if (streq_ic(word,"crj") || streq_ic(word,"rpt") || streq_ic(word,"crc") ) {
                posid = 1;
            } else {
                if (exp[row].prsnt || streq_ic(memsubtype,"prod")) {

                    if (isalnum(word[poslen])) {
                        /* Interpret the POSID from the second part
                         ** of MEMTYPE */
                        posid=(int)strtol(&word[poslen],(char **)NULL,10);
                    } else {
                        /* Otherwise, assume it is a different pointing
                         ** and assign an incremented position ID. After
                         ** all, it is NOT a CR-SPLIT or RPT-OBS exposure.*/
                        posid = defid;
                        defid++;
                    }
                }
            }

            /* Keep track of how many sub-products there are based on
             ** POSID from MEMTYPE values */

            if (posid > numsp) {
                if ((exp[row].prsnt && (strstr(memtype,"exp") != NULL)) ||
                        strstr(memtype,"prod") != NULL) {
                    numsp++;
                }
            }

            exp[row].posid = posid;		
        }

        if (asn->debug) {
            sprintf (MsgText, "GetAsnTable: Posid = %d for row %d",posid,
                    row);
            trlmessage (MsgText);
        }	

        /* If the member is missing, give a warning */
        /* This implies that MEMPRSNT must be set to YES for EXP_*
         ** This is not fatal for WF3.  Simply decrement tmembers. */
        if (!exp[row].prsnt && strncmp(exp[row].type, "prod-",5) != 0) {
            sprintf (MsgText, "Member \"%s\" is not present",
                    exp[row].memname);
            trlwarn (MsgText);		 
            asn->numasn--;
            /* Now flag row as being absent so it doesn't get passed
             ** along for further processing... */
            exp[row].posid = MEMABSENT;
        }
    }

    if (asn->debug) {
        sprintf (MsgText, "GetAsnTable: NUMSP = %d, PRODID = %d",numsp,
                prodid);
        trlmessage (MsgText);
    }

    /* Check for existence of enough data to process */
    if (asn->numasn < 1) {
        trlerror ("No data available for given assoc. table");
        freeAsnInfo (asn);
        return (status = ERROR_RETURN);
    }

    /* Record the number of products found in association */
    if (proddth) {
        asn->numprod = prodid;
    } else {
        /* If there are no PROD-DTH entries in ASN table, set
         ** numprod to 1 */
        asn->numprod = prodid + 1;
    }

    /* Determine what elements should be processed based on
     ** initial input, either FULL or PARTIAL processing.  */
    procprod = 0;
    if (asn->process != FULL) {
        for (row=0; row < nrows; row++){
            /* Look for entry with same name as input */
            if (streq_ic(exp[row].memname, asn->rootname)) {
                /* We only want to process this product	*/
                procprod = exp[row].posid;
                numsp = 1;
            }	
        }
    }

    /* Allocate space to count number of exposures per sub-product
     ** with spmems[0] being reserved for final output product
     ** since POSID starts indexing at 1. */
    spmems = (int *)calloc(numsp+1,sizeof(int));
    expmem = (int *)calloc(numsp+1,sizeof(int));

    /* Initialize arrays */
    for (i=0; i <= numsp; i++) {
        spmems[i] = 0;
        expmem[i] = 0;
    }

    /* For each sub-product,
     ** identify each EXP that belongs to that posid and 
     ** is present to be processed. */
    for (row=0; row < nrows; row++) {
        if (strstr(exp[row].type, "exp-") && exp[row].posid > MEMABSENT) {

            if ((asn->process != FULL && exp[row].posid == procprod) ||
                    asn->process == FULL) {

                spmems[exp[row].posid]++;
                /* Exposure IDs will start at 1 to be consistent 
                 ** with POSID numbering. Initialize here, count later. */
                expmem[exp[row].posid] = 1;
            }
        }
    }

    /* Allocate slots for all members in ASN info structure */
    if (allocAsnInfo (asn, numsp, spmems)) {
        return (status = TABLE_ERROR);
    }

    asn->product[prodid].prodid = prodid;

    /* Reset prodid for filling ASN table */
    prodid = 0;

    /* Copy summary information about ASN relationships to ASN structure. */
    maxspmems = 0;
    asn->numsp = numsp;
    for (i=0; i <= numsp; i++) {
        asn->spmems[i] = spmems[i];
        if (spmems[i] > maxspmems)
            maxspmems = spmems[i];
    }

    /* If there aren't any sub-products with more than 1 member, then
     ** omit crcorr/rptcorr processing */
    if ((maxspmems < 2) && asn->crcorr == PERFORM) {
        sprintf (MsgText,
                "No sub-product with more than 1 member; CRCORR will be skipped");
        trlwarn (MsgText);
        asn->crcorr = DUMMY;
    } else if ((maxspmems < 2) && asn->rptcorr == PERFORM) {
        sprintf (MsgText,
                "No sub-product with more than 1 member; RPTCORR will be skipped");
        trlwarn (MsgText);
        asn->rptcorr = DUMMY;
    }

    /* Copy information read-in into ASN structure now... */
    for (row = 0; row < nrows; row++) {
        if (exp[row].posid != MEMABSENT) {
            if ((asn->process != FULL && exp[row].posid == procprod) ||
                    asn->process == FULL) {	  
                posid = exp[row].posid;

                /* Is this row the final product entry? */
                if (strstr(exp[row].type, "prod-dth") != NULL) {
                    strcpy (asn->product[prodid].name, exp[row].memname);
                    strcpy (asn->product[prodid].mtype, exp[row].type);
                    asn->product[prodid].prsnt = exp[row].prsnt;
                    asn->product[prodid].numsp = numsp;
                    asn->product[prodid].asnrow = row+1;

                    /* Create full file name for this image */
                    if (MkName (exp[row].memname, "_raw", "_drz", "",
                                asn->product[prodid].prodname, SZ_LINE)){
                        strcpy(asn->product[prodid].prodname,
                                exp[row].memname);
                        strcat (asn->product[prodid].prodname,
                                "_drz.fits");
                    }
                    
                    /* Create full file name for this CTE image */
                    if (MkName (exp[row].memname, "_rac_tmp", "_drc", "",
                                asn->product[prodid].prodname_cte, SZ_LINE)){
                        strcpy(asn->product[prodid].prodname_cte,
                                exp[row].memname);
                        strcat (asn->product[prodid].prodname_cte,
                                "_drc.fits");
                    }
                    

                    /* Or, is this row an input exposure? */
                } else if (strstr(exp[row].type, "exp-") != NULL) {

                    if (exp[row].posid > MEMABSENT) {

                        /* Internal counter for which exposure we want for
                         ** a position */
                        expid = expmem[posid];
                        strcpy(asn->product[prodid].subprod[posid].exp[expid].name,
                                exp[row].memname);		
                        strcpy(asn->product[prodid].subprod[posid].exp[expid].mtype,
                                exp[row].type);
                        asn->product[prodid].subprod[posid].exp[expid].prsnt =
                            exp[row].prsnt;
                        asn->product[prodid].subprod[posid].exp[expid].asnrow=
                            row+1;

                        /* Create full file name for this image */
                        if (MkName (exp[row].memname, "_raw", "_raw", "",
                                    asn->product[prodid].subprod[posid].exp[expid].expname,
                                    SZ_LINE)) {

                            strcpy(asn->product[prodid].subprod[posid].exp[expid].expname,
                                    exp[row].memname);
                            strcat(asn->product[prodid].subprod[posid].exp[expid].expname,
                                    "_raw.fits");
                        }

                        /* Fill-in sub-product information for EXP-DTH
                         ** exposures which don't create sub-products */
                        if (strstr(exp[row].type, "exp-dth") != NULL) {
                            if (!MkName (exp[row].memname, "_raw", "_flt", "",
                                        asn->product[prodid].subprod[posid].spname,
                                        SZ_LINE) ) {

                                strcpy(asn->product[prodid].subprod[posid].name,
                                        exp[row].memname);
                                strcpy(asn->product[prodid].subprod[posid].mtype,
                                        exp[row].type);
                                asn->product[prodid].subprod[posid].posid =
                                    exp[row].posid;
                            }
                        }

                        /* Increment that counter for next exposure's id
                         ** for this posid */
                        expmem[posid]++;
                    }

                    /* If neither, it must be a sub-product */
                } else {

                    if (spmems[posid] > 0) {

                        strcpy(asn->product[prodid].subprod[posid].name,
                                exp[row].memname);
                        strcpy(asn->product[prodid].subprod[posid].mtype,
                                exp[row].type);
                        asn->product[prodid].subprod[posid].prsnt =
                            exp[row].prsnt;
                        asn->product[prodid].subprod[posid].asnrow = row+1;


                        /* Create full file name for this image for 
                         ** DTHCORR input */
                        spname_ext[0] = '\0';
                        spname_ext_cte[0] = '\0';
                        if (asn->crcorr || asn->rptcorr) {
                            strcpy (spname_ext, "_crj");
                            strcpy (spname_ext_cte,"_crc");
                        } else {
                            strcpy (spname_ext, "_sfl");
                            strcpy (spname_ext_cte, "_sfl");
                        }

                        if (MkName (exp[row].memname, "_raw", spname_ext, "",
                                    asn->product[prodid].subprod[posid].spname,
                                    SZ_LINE)) {

                            strcpy(asn->product[prodid].subprod[posid].spname,
                                    exp[row].memname);
                            strcat(asn->product[prodid].subprod[posid].spname,
                                    spname_ext);		
                            strcat(asn->product[prodid].subprod[posid].spname,
                                    ".fits");		
                                    
                        }
                        if (MkName (exp[row].memname, "_raw", spname_ext_cte, "",
                                    asn->product[prodid].subprod[posid].spname_cte,
                                    SZ_LINE)) {

                            strcpy(asn->product[prodid].subprod[posid].spname_cte,
                                    exp[row].memname);
                            strcat(asn->product[prodid].subprod[posid].spname_cte,
                                    spname_ext_cte);		
                            strcat(asn->product[prodid].subprod[posid].spname_cte,
                                    ".fits");		
                                    
                        }

                        asn->product[prodid].subprod[posid].numexp =
                            spmems[posid];
                        asn->product[prodid].subprod[posid].posid = posid;

                    }
                }
            }
        } /* Process only those exposures where MEMPRSNT == YES */
    }

    /* Close the ASN table.  We are done reading it in. */
    c_tbtclo (tp);



    /* Clean up memory usage as well. */
    free (spmems);
    free (expmem);
    free (exp);

    if (asn->debug) {
        trlmessage ("GetAsnTable: Info from ASN read into memory.");
    }

    /* Successful return */
    return (status);
}
コード例 #24
0
ファイル: getgrpinfo4.c プロジェクト: brechmos-stsci/hstcal
static void GetSDC (StisInfo4 *sts) {

	IRAFPointer tp;
	IRAFPointer cp_opt_elem;
	IRAFPointer cp_a2center, cp_cdelt2;
	IRAFPointer cp_pedigree, cp_descrip;
	char opt_elem[STIS_CBUF+1];		/* grating or prism name */
	int nrows, row;
	int foundit;

	/* default values */
	sts->crpix[1] = PRISM_CRPIX2 - 1.;	/* zero indexed */
	sts->cdelt[1] = PRISM_CDELT2;		/* degrees per pixel */
	sts->crpix[0] = 0.;		/* the rest are not used */
	sts->cdelt[0] = 0.;
	sts->crval[0] = 0.;
	sts->crval[1] = 0.;

	tp = c_tbtopn (sts->sdctab.name, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("Warning  SDCTAB `%s' not found; default values used.\n",
		sts->sdctab.name);
	    clear_cvoserr();
	    return;
	}
	nrows = c_tbpsta (tp, TBL_NROWS);

	c_tbcfnd1 (tp, "OPT_ELEM", &cp_opt_elem);
	c_tbcfnd1 (tp, "A2CENTER", &cp_a2center);
	c_tbcfnd1 (tp, "CDELT2", &cp_cdelt2);
	if (cp_opt_elem == 0 || cp_a2center == 0 || cp_cdelt2 == 0) {
	    printf ("Warning  Column(s) not found in SDCTAB; defaults used.\n");
	    c_tbtclo (tp);
	    return;
	}
	c_tbcfnd1 (tp, "PEDIGREE", &cp_pedigree);
	c_tbcfnd1 (tp, "DESCRIP", &cp_descrip);

	foundit = 0;
	for (row = 1;  row <= nrows;  row++) {

	    c_tbegtt (tp, cp_opt_elem, row, opt_elem, STIS_CBUF);
	    if (c_iraferr()) {
		strcpy (opt_elem, "dummy");
		clear_cvoserr();
	    }

	    if (SameString (opt_elem, sts->opt_elem)) {

		foundit = 1;
		c_tbegtd (tp, cp_a2center, row, &sts->crpix[1]);
		c_tbegtd (tp, cp_cdelt2, row, &sts->cdelt[1]);
		sts->crpix[1] -= 1.;		/* zero indexed */
		sts->cdelt[1] /= 3600.;		/* degrees per pixel */

		RowPedigree (&sts->sdctab, row, tp, cp_pedigree, cp_descrip);

		break;
	    }
	}

	c_tbtclo (tp);

	if (!foundit)
	    printf ("Warning  PRISM not found in SDCTAB; defaults used.\n");
}
コード例 #25
0
ファイル: getccdtab.c プロジェクト: jhunkeler/hstcal
static int OpenCCDTab (char *tname, TblInfo *tabinfo) {

	extern int status;

    int colnum, datatype, lendata, lenfmt;
	char *colname;
    char *colunits;
    char *colfmt;

	int nocol[NUMCOLS];
	int i, j, missing;
	
	char *colnames[NUMCOLS] ={"CCDAMP", "CCDCHIP", "CCDGAIN", "BINAXIS1",
    "BINAXIS2", "CCDOFSTA", "CCDOFSTB", "CCDOFSTC", "CCDOFSTD","CCDBIASA", 
    "CCDBIASB","CCDBIASC","CCDBIASD","ATODGNA", "ATODGNB", "ATODGNC", "ATODGND", "READNSEA", "READNSEB", 
    "READNSEC", "READNSED", "AMPX", "AMPY", "SATURATE"};

	int PrintMissingCols (int, int, int *, char **, char *, IRAFPointer);

	for (j = 0; j < NUMCOLS; j++)
		nocol[j] = NO;


	if ((colname = calloc (SZ_COLNAME+1, sizeof(char))) == NULL) {
	    trlerror ("Out of memory.\n");
	    return (OUT_OF_MEMORY);
	}
	if ((colunits = calloc (ACS_CBUF+1, sizeof(char))) == NULL) {
	    trlerror ("Out of memory.\n");
	    return (OUT_OF_MEMORY);
	}
	if ((colfmt = calloc (ACS_CBUF+1, sizeof(char))) == NULL) {
	    trlerror ("Out of memory.\n");
	    return (OUT_OF_MEMORY);
	}


	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    sprintf (MsgText, "CCDTAB `%s' not found.", tname);
	    trlerror (MsgText);
		return (status = OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "CCDAMP", &tabinfo->cp_amp);
	c_tbcfnd1 (tabinfo->tp, "CCDCHIP", &tabinfo->cp_ccdchip);
	c_tbcfnd1 (tabinfo->tp, "CCDGAIN", &tabinfo->cp_ccdgain);
	c_tbcfnd1 (tabinfo->tp, "BINAXIS1", &tabinfo->cp_bin1);
	c_tbcfnd1 (tabinfo->tp, "BINAXIS2", &tabinfo->cp_bin2);
	c_tbcfnd1 (tabinfo->tp, "CCDOFSTA", &tabinfo->cp_ccdoffset[0]);
	c_tbcfnd1 (tabinfo->tp, "CCDOFSTB", &tabinfo->cp_ccdoffset[1]);
	c_tbcfnd1 (tabinfo->tp, "CCDOFSTC", &tabinfo->cp_ccdoffset[2]);
	c_tbcfnd1 (tabinfo->tp, "CCDOFSTD", &tabinfo->cp_ccdoffset[3]);
	c_tbcfnd1 (tabinfo->tp, "CCDBIASA", &tabinfo->cp_bias[0]);
	c_tbcfnd1 (tabinfo->tp, "CCDBIASB", &tabinfo->cp_bias[1]);
	c_tbcfnd1 (tabinfo->tp, "CCDBIASC", &tabinfo->cp_bias[2]);
	c_tbcfnd1 (tabinfo->tp, "CCDBIASD", &tabinfo->cp_bias[3]);
	c_tbcfnd1 (tabinfo->tp, "ATODGNA", &tabinfo->cp_atodgain[0]);
	c_tbcfnd1 (tabinfo->tp, "ATODGNB", &tabinfo->cp_atodgain[1]);
	c_tbcfnd1 (tabinfo->tp, "ATODGNC", &tabinfo->cp_atodgain[2]);
	c_tbcfnd1 (tabinfo->tp, "ATODGND", &tabinfo->cp_atodgain[3]);
	c_tbcfnd1 (tabinfo->tp, "READNSEA", &tabinfo->cp_readnoise[0]);
	c_tbcfnd1 (tabinfo->tp, "READNSEB", &tabinfo->cp_readnoise[1]);
	c_tbcfnd1 (tabinfo->tp, "READNSEC", &tabinfo->cp_readnoise[2]);
	c_tbcfnd1 (tabinfo->tp, "READNSED", &tabinfo->cp_readnoise[3]);
	c_tbcfnd1 (tabinfo->tp, "AMPX", &tabinfo->cp_ampx);
	c_tbcfnd1 (tabinfo->tp, "AMPY", &tabinfo->cp_ampy);
	c_tbcfnd1 (tabinfo->tp, "SATURATE", &tabinfo->cp_saturate);
	
	/* Initialize counters here... */
	missing = 0;
	i=0;
		
    /* Increment i for every column, mark only missing columns in
        nocol as YES.  WJH 27 July 1999
    */
	if (tabinfo->cp_amp == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_ccdchip == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_ccdgain == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_bin1 == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_bin2 == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_ccdoffset[0] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_ccdoffset[1] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_ccdoffset[2] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_ccdoffset[3] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_bias[0] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_bias[1] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_bias[2] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_bias[3] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_atodgain[0] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_atodgain[1] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_atodgain[2] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_atodgain[3] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_readnoise[0] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_readnoise[1] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_readnoise[2] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_readnoise[3] == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_ampx == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_ampy == 0 ) { missing++; nocol[i] = YES;} i++;
	if (tabinfo->cp_saturate == 0) { missing++; nocol[i] = YES;} i++;
	
	if (PrintMissingCols (missing, NUMCOLS, nocol, colnames, "CCDTAB", tabinfo->tp) )
		return(status);
		
	/* Pedigree and descrip are optional columns. */
	c_tbcfnd1 (tabinfo->tp, "PEDIGREE", &tabinfo->cp_pedigree);
	c_tbcfnd1 (tabinfo->tp, "DESCRIP", &tabinfo->cp_descrip);

    /* get info on ccdgain column to determine whether we 
       have int or float values to read in.
    */    
    c_tbcinf(tabinfo->cp_ccdgain, &colnum, colname, colunits, colfmt, &datatype, &lendata, &lenfmt);
    if (datatype == IRAF_INT){
        tabinfo->intgain = 1;
    } else {
        tabinfo->intgain = 0;
    }
    free(colname);
    free(colunits);
    free(colfmt);

	return (status);
}
コード例 #26
0
ファイル: findover.c プロジェクト: brechmos-stsci/hstcal
static int OpenOverTab (char *tname, TblInfo *tabinfo) {

	extern int status;
	
	int nocol[NUMCOLS];
	int i, j, missing;
	
	char *colnames[NUMCOLS] ={"CCDAMP","CCDCHIP","BINX","BINY","NX","NY","TRIMX1",	"TRIMX2", "TRIMY1", "TRIMY2", "VX1", "VX2", "VY1", "VY2", "BIASSECTA1", "BIASSECTA2", "BIASSECTB1", "BIASSECTB2"};

	int PrintMissingCols (int, int, int *, char **, char *, IRAFPointer);

	tabinfo->tp = c_tbtopn (tname, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    sprintf (MsgText, "OSCNTAB `%s' not found.", tname);
	    trlerror (MsgText);
		return (status = OPEN_FAILED);
	}

	tabinfo->nrows = c_tbpsta (tabinfo->tp, TBL_NROWS);

	for (j = 0; j < NUMCOLS; j++)
		nocol[j] = NO;
	
	/* Find the columns. */
	c_tbcfnd1 (tabinfo->tp, "CCDAMP", &tabinfo->cp_amp);
	c_tbcfnd1 (tabinfo->tp, "CCDCHIP", &tabinfo->cp_chip);
	c_tbcfnd1 (tabinfo->tp, "BINX", &tabinfo->cp_binx);
	c_tbcfnd1 (tabinfo->tp, "BINY", &tabinfo->cp_biny);	
	c_tbcfnd1 (tabinfo->tp, "NX", &tabinfo->cp_nx);
	c_tbcfnd1 (tabinfo->tp, "NY", &tabinfo->cp_ny);	
	c_tbcfnd1 (tabinfo->tp, "TRIMX1", &tabinfo->cp_trimx1);
	c_tbcfnd1 (tabinfo->tp, "TRIMX2", &tabinfo->cp_trimx2);
	c_tbcfnd1 (tabinfo->tp, "TRIMY1", &tabinfo->cp_trimy1);
	c_tbcfnd1 (tabinfo->tp, "TRIMY2", &tabinfo->cp_trimy2);	
	c_tbcfnd1 (tabinfo->tp, "VX1", &tabinfo->cp_vx1);
	c_tbcfnd1 (tabinfo->tp, "VX2", &tabinfo->cp_vx2);
	c_tbcfnd1 (tabinfo->tp, "VY1", &tabinfo->cp_vy1);	
	c_tbcfnd1 (tabinfo->tp, "VY2", &tabinfo->cp_vy2);
	c_tbcfnd1 (tabinfo->tp, "BIASSECTA1", &tabinfo->cp_biassecta1);
	c_tbcfnd1 (tabinfo->tp, "BIASSECTA2", &tabinfo->cp_biassecta2);
	c_tbcfnd1 (tabinfo->tp, "BIASSECTB1", &tabinfo->cp_biassectb1);
	c_tbcfnd1 (tabinfo->tp, "BIASSECTB2", &tabinfo->cp_biassectb2);

	/* Initialize counters here... */
	missing = 0;
	i=0;
	/* Check which columns are missing */
	if (tabinfo->cp_amp == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_chip == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_binx == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_biny == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_nx == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_ny == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_vx1 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_vx2 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_vy1 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_vy2 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_trimx1 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_trimx2 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_trimy1 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_trimy2 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_biassecta1 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_biassecta2 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_biassectb1 == 0 ) { missing++; nocol[i] = YES; i++;}
	if (tabinfo->cp_biassectb2 == 0 ){ missing++; nocol[i] = YES; i++;}

	if (PrintMissingCols (missing, NUMCOLS, nocol, colnames, "OSCNTAB", tabinfo->tp) )
		return(status);

	return (status);
}
コード例 #27
0
ファイル: echscatread.c プロジェクト: brechmos-stsci/hstcal
static int GetScatter (char *name, ScatterFunctions *scf) {

/* arguments
char *name;             i: name of ECHSCTAB reference file
ScatterFunctions *scf;  o: data structure with scattering functions
*/
        IRAFPointer tp;
        IRAFPointer cp_optelem, cp_sporder, cp_nelem, cp_scat;
        char opt_elem[STIS_CBUF];
        int row, nrows, i;

        tp = c_tbtopn (name, IRAF_READ_ONLY, 0);
        if (c_iraferr()) {
            printf ("ERROR    ECHSCTAB `%s' not found\n", name);
            return (OPEN_FAILED);
        }
        nrows = c_tbpsta (tp, TBL_NROWS);
        c_tbcfnd1 (tp, "OPT_ELEM", &cp_optelem);
        c_tbcfnd1 (tp, "NELEM",    &cp_nelem);
        c_tbcfnd1 (tp, "SPORDER",  &cp_sporder);
        c_tbcfnd1 (tp, "ECHSCAT",  &cp_scat);
        if (cp_optelem == 0 || cp_nelem == 0 ||
            cp_sporder == 0 || cp_scat  == 0) {
            printf( "ERROR    Column not found in ECHSCTAB\n");
            c_tbtclo (tp);
            return (COLUMN_NOT_FOUND);
        }

        /* This creates some small amount of unused memory but the
           cost is negligible.
        */
        scf->scfunc = (ScFunc *) calloc (nrows , sizeof (ScFunc));
        scf->nsc = 0;

        for (row = 1; row <= nrows ; row++) {

            c_tbegtt (tp, cp_optelem, row, opt_elem, STIS_CBUF-1);

            if (streq_ic (opt_elem, scf->opt_elem)) {

                c_tbegti (tp, cp_sporder, row,
                          &(scf->scfunc[(scf->nsc)].sporder));
                if (c_iraferr())
                    return (TABLE_ERROR);
                c_tbegti (tp, cp_nelem, row, &(scf->scfunc[(scf->nsc)].nelem));
                if (c_iraferr())
                    return (TABLE_ERROR);
                scf->scfunc[(scf->nsc)].values = (double *) calloc (
                                                 scf->scfunc[(scf->nsc)].nelem,
                                                 sizeof (double));
                i = c_tbagtd (tp, cp_scat, row,
                                           scf->scfunc[(scf->nsc)].values, 1,
                                           scf->scfunc[(scf->nsc)].nelem);
                if (c_iraferr())
                    return (TABLE_ERROR);

                (scf->nsc)++;
            }
        }

        c_tbtclo (tp);

        if (scf->nsc == 0) {
            printf( "ERROR    Row not found in ECHSCTAB\n");
            return (ROW_NOT_FOUND);
        }

        return (STIS_OK);
}