Exemplo n.º 1
0
static int ReadAtoDArray (TblInfo *tabinfo, int row, TblArray *tabarray) {

	extern int status;
	int nret;		/* number of elements actually read */

	/* Find out how many elements there are in the ATOD array,
	   and allocate space for the array to be read from the table.
	*/
	c_tbegti (tabinfo->tp, tabinfo->cp_nelem, row, &tabarray->nelem);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	tabarray->atod = (float *) malloc (tabarray->nelem * sizeof(float));
	if (tabarray->atod == NULL)
	    return (status = OUT_OF_MEMORY);

	nret = c_tbagtr (tabinfo->tp, tabinfo->cp_atod, row,
			tabarray->atod, 1, tabarray->nelem);
	if ( (status = c_iraferr()) )
	    return (status = TABLE_ERROR);

	if (nret < tabarray->nelem) {
	    sprintf (MsgText,
		     "CORRECTION array in row %d of ATODTAB is too short.",
		     row);
	    trlerror (MsgText);
	    free (tabarray->atod);
	    return (status = TABLE_ERROR);
	}

	return (status);
}
Exemplo n.º 2
0
static int ReadLinTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	extern int status;

	c_tbegtt (tabinfo->tp, tabinfo->cp_det, row,
			tabrow->detector, ACS_CBUF-1);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	c_tbegtd (tabinfo->tp, tabinfo->cp_global, row, &tabrow->global_limit);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	c_tbegtd (tabinfo->tp, tabinfo->cp_local, row, &tabrow->local_limit);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	c_tbegtd (tabinfo->tp, tabinfo->cp_tau, row, &tabrow->tau);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	c_tbegtr (tabinfo->tp, tabinfo->cp_expand, row, &tabrow->expand);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	return (status);
}
Exemplo n.º 3
0
static int ReadProfileArray (TblInfo *tabinfo, int row, ProfileArray **profa,
                             double *subscale) {
	int status;

	int npts1, npts2;
	ProfileArray *newp;
	int NewProfile (ProfileArray **, ProfileArray *);

	if ((newp = (ProfileArray *) malloc (sizeof (ProfileArray))) == NULL) {
	    printf ("ERROR    Can't allocate memory.\n");
	    return (OUT_OF_MEMORY);
	}
	newp->next = NULL;

	/* Get profile scalar data. */
	c_tbegti (tabinfo->tp, tabinfo->cp_npts,     row, &newp->npts);
	c_tbegti (tabinfo->tp, tabinfo->cp_nptsoff,  row, &newp->nptsoff);
	c_tbegtd (tabinfo->tp, tabinfo->cp_subscale, row, subscale);
	c_tbegtd (tabinfo->tp, tabinfo->cp_minw,     row, &newp->minw);
	c_tbegtd (tabinfo->tp, tabinfo->cp_maxw,     row, &newp->maxw);
	c_tbegti (tabinfo->tp, tabinfo->cp_minp,     row, &newp->minp);
	c_tbegti (tabinfo->tp, tabinfo->cp_maxp,     row, &newp->maxp);
	c_tbegtr (tabinfo->tp, tabinfo->cp_sn,       row, &newp->sn);

	/* Alloc array memory. */
	newp->profoff = (double *) malloc (newp->nptsoff * sizeof (double));
	newp->prof    = (double *) malloc (newp->npts * sizeof (double));
	if (newp->profoff == NULL || newp->prof == NULL) {
	    printf ("ERROR    Can't allocate memory.\n");
	    return (OUT_OF_MEMORY);
	}

	/* Get profile array data. */
	npts1 = c_tbagtd (tabinfo->tp, tabinfo->cp_profoff, row,
			 newp->profoff, 1, newp->nptsoff);
	if (c_iraferr())
	    return (TABLE_ERROR);
	npts2 = c_tbagtd (tabinfo->tp, tabinfo->cp_prof, row,
			 newp->prof, 1, newp->npts);
	if (c_iraferr())
	    return (TABLE_ERROR);

	if (npts1 != newp->nptsoff) {
	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Inconsistent array info in OPROFTAB\n");
	    return (TABLE_ERROR);
	}

	/* Insert newp into the profile list. */
	if ((status = NewProfile (profa, newp)))
	    return (status);

	free (newp->profoff);
	free (newp->prof);
	free (newp);

	return (0);
}
Exemplo n.º 4
0
static int ReadDSPArray (TblInfo *tabinfo, int row,
		DispRelation *disp, char *ref_aper) {

	int ncoeff;		/* number of coefficients read from table */
	int i;

	for (i = 0;  i < MAX_DISP_COEFF;  i++)
	    disp->coeff[i] = 0.;

	/* Get name of aperture used to measure dispersion relation. */
	c_tbegtt (tabinfo->tp, tabinfo->cp_ref_aper, row, ref_aper, STIS_CBUF);

	/* Number of coefficients in dispersion relation. */
	c_tbegti (tabinfo->tp, tabinfo->cp_ncoeff, row, &disp->ncoeff);
	if (disp->ncoeff > MAX_DISP_COEFF) {
	    printf ("Too many dispersion coefficients %d in DISPTAB.\n",
		disp->ncoeff);
	    return (TABLE_ERROR);
	}

	/* Get the coefficients themselves. */
	ncoeff = c_tbagtd (tabinfo->tp, tabinfo->cp_coeff, row,
			disp->coeff, 1, disp->ncoeff);
	if (c_iraferr())
	    return (TABLE_ERROR);

	if (ncoeff < disp->ncoeff) {
	    c_tbtclo (tabinfo->tp);
	    printf ("Not all coefficients were read from DISPTAB.\n");
	    return (TABLE_ERROR);
	}

	/* Get the a4corr info. */
	if (tabinfo->cp_a4corr == 0) {
	    disp->mref = 0;
	    disp->yref = 0.;
	    disp->a4corr = 0.;
	} else {
	    double yref;

	    c_tbegti (tabinfo->tp, tabinfo->cp_mref, row, &disp->mref);
	    if (c_iraferr())
		return (TABLE_ERROR);

	    c_tbegtd (tabinfo->tp, tabinfo->cp_yref, row, &yref);
	    if (c_iraferr())
		return (TABLE_ERROR);
	    /* convert to zero-indexing */
	    disp->yref = yref - 1.;

	    c_tbegtd (tabinfo->tp, tabinfo->cp_a4corr, row, &disp->a4corr);
	    if (c_iraferr())
		return (TABLE_ERROR);
	}

	return (0);
}
Exemplo n.º 5
0
static int ReadDSPTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	c_tbegtt (tabinfo->tp, tabinfo->cp_opt_elem, row,
			tabrow->opt_elem, STIS_CBUF);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegti (tabinfo->tp, tabinfo->cp_cenwave, row, &tabrow->cenwave);
	if (c_iraferr())
	    return (TABLE_ERROR);

	return (0);
}
Exemplo n.º 6
0
static int ReadCCDTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	c_tbegtt (tabinfo->tp, tabinfo->cp_amp, row,
			tabrow->ccdamp, STIS_CBUF);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegti (tabinfo->tp, tabinfo->cp_ccdgain, row, &tabrow->ccdgain);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegti (tabinfo->tp, tabinfo->cp_ccdoffset, row, &tabrow->ccdoffset);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegti (tabinfo->tp, tabinfo->cp_bin1, row, &tabrow->bin[0]);
	if (c_iraferr())
	    return (TABLE_ERROR);
	c_tbegti (tabinfo->tp, tabinfo->cp_bin2, row, &tabrow->bin[1]);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegtr (tabinfo->tp, tabinfo->cp_atodgain, row, &tabrow->atodgain);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegtr (tabinfo->tp, tabinfo->cp_bias, row, &tabrow->ccdbias);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegtr (tabinfo->tp, tabinfo->cp_readnoise, row, &tabrow->readnoise);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegtr (tabinfo->tp, tabinfo->cp_saturate, row, &tabrow->saturate);
	if (c_iraferr())
	    return (TABLE_ERROR);

	if (tabinfo->cp_blev_clip == 0) {
	    tabrow->blev_clip = DEFAULT_BLEV_CLIP;
	} else {
	    c_tbegtr (tabinfo->tp, tabinfo->cp_blev_clip, row,
			&tabrow->blev_clip);
	    if (c_iraferr())
		return (TABLE_ERROR);
	}

	return (0);
}
Exemplo n.º 7
0
static int ReadIntensArray (StisInfo6 *sts, TblInfo *tabinfo, int row,
                            IntensArray *inta, int sporder) {

	int status;
	int nwave, nintens;	/* number of elements actually read */

	/* Find out how many elements there are in the intensity arrays,
	   and allocate space for the arrays to be read from the table.
	*/
	c_tbegti (tabinfo->tp, tabinfo->cp_nelem, row, &inta->nelem);
	if (c_iraferr())
	    return (TABLE_ERROR);

	/* Allocate memory. */
	inta->wave   = (double *) calloc (inta->nelem, sizeof(double));
	inta->intens = (double *) calloc (inta->nelem, sizeof(double));
	if (inta->wave == NULL || inta->intens == NULL) {
	    CloseIntensTab (tabinfo);
	    return (OUT_OF_MEMORY);
	}
	inta->allocated = 1;

	nwave = c_tbagtd (tabinfo->tp, tabinfo->cp_wave, row,
                          inta->wave, 1, inta->nelem);
	if (c_iraferr())
	    return (TABLE_ERROR);

	nintens = c_tbagtd (tabinfo->tp, tabinfo->cp_intens, row,
                            inta->intens, 1, inta->nelem);
	if (c_iraferr())
	    return (TABLE_ERROR);

	/* Go get data to transform flux into net counts. */
	if (sts->fflux) {
	    status = FluxToNet (sts, inta, sporder);
	    if (status != STIS_OK)
	        return (status);
	}

	if (nwave < inta->nelem || nintens < inta->nelem) {
	    c_tbtclo (tabinfo->tp);
	    free (inta->wave);
	    free (inta->intens);
	    printf ("ERROR    Not all coefficients were read from OSPECTAB\n");
	    return (TABLE_ERROR);
	}

	return (0);
}
Exemplo n.º 8
0
static int ReadSDistArray (TblInfo *tabinfo, int row, CoordInfo **coords) {

	int status;

	CoordInfo *newrec;
	int NewCoord6 (CoordInfo **, CoordInfo *);

	if ((newrec = malloc (sizeof (CoordInfo))) == NULL) {
	    printf ("ERROR    (GetSDC) can't allocate memory.\n");
	    return (OUT_OF_MEMORY);
	}
	newrec->next = NULL;

	/* Get size info and coordinate parameters. */
	c_tbegti (tabinfo->tp, tabinfo->cp_sporder, row, &newrec->sporder);
	c_tbegtd (tabinfo->tp, tabinfo->cp_a2center, row, &newrec->a2center);
	c_tbegtd (tabinfo->tp, tabinfo->cp_cdelt2, row, &newrec->cdelt2);
	c_tbegti (tabinfo->tp, tabinfo->cp_npix, row, &newrec->npix);
	if (c_iraferr())
	    return (TABLE_ERROR);

	/* Insert in the coords list. */
	if ((status = NewCoord6 (coords, newrec)))
	    return (status);

	free (newrec);

	return (0);
}
Exemplo n.º 9
0
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);
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
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);
}
Exemplo n.º 12
0
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);
}
Exemplo n.º 13
0
static int CheckPedigree (TblInfo *tabinfo, int row, int *pedigree) {

	char *str_pedigree;

	if (tabinfo->cp_pedigree > 0) {

	    if ((str_pedigree = (char *) calloc (STIS_LINE+1,
                                         sizeof(char))) == NULL) {
		printf ("ERROR    Out of memory.\n");
		return (OUT_OF_MEMORY);
	    }
	    c_tbegtt (tabinfo->tp, tabinfo->cp_pedigree, row,
			str_pedigree, STIS_LINE);
	    if (c_iraferr())
		return (TABLE_ERROR);

	    if (strncmp (str_pedigree, "DUMMY", 5) == 0)
		*pedigree = DUMMY_PEDIGREE;
	    else
		*pedigree = GOOD_PEDIGREE;
	    free (str_pedigree);

	} else {

	    *pedigree = GOOD_PEDIGREE;
	}

	return (0);
}
Exemplo n.º 14
0
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);
}
Exemplo n.º 15
0
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);
}
Exemplo n.º 16
0
static int CloseTdcTab (TblInfo *tabinfo) {

	c_tbtclo (tabinfo->tp);
	if (c_iraferr())
	    return TABLE_ERROR;

	return 0;
}
Exemplo n.º 17
0
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);
}
Exemplo n.º 18
0
static int ReadProfileTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	c_tbegti (tabinfo->tp, tabinfo->cp_sporder, row, &tabrow->sporder);
	if (c_iraferr())
	    return (TABLE_ERROR);

	return (0);
}
Exemplo n.º 19
0
static int CloseProfileTab (TblInfo *tabinfo) {

	c_tbtclo (tabinfo->tp);
	if (c_iraferr())
	    return (TABLE_ERROR);

	return (0);
}
Exemplo n.º 20
0
static int ReadIACArray (TblInfo *tabinfo, int row, InangInfo *iac) {

	int ncoeff1, ncoeff2;	/* number of coefficients read from table */
	char *tname;		/* for possible error message */

	c_tbegti (tabinfo->tp, tabinfo->cp_ncoeff1, row, &ncoeff1);
	c_tbegti (tabinfo->tp, tabinfo->cp_ncoeff2, row, &ncoeff2);
	iac->ncoeff1 = ncoeff1;
	iac->ncoeff2 = ncoeff2;

	if (ncoeff1 > 0) {
	    if ((iac->coeff1 = (double *) malloc (iac->ncoeff1 *
                                                  sizeof(double))) == NULL)
		return (OUT_OF_MEMORY);
	    /* replace ncoeff1 with actual number of elements read */
	    ncoeff1 = c_tbagtd (tabinfo->tp, tabinfo->cp_coeff1, row,
			iac->coeff1, 1, iac->ncoeff1);
	    if (c_iraferr())
		return (TABLE_ERROR);
	}
	if (ncoeff2 > 0) {
	    if ((iac->coeff2 = (double *) malloc (iac->ncoeff2 *
                                                  sizeof(double))) == NULL)
		return (OUT_OF_MEMORY);
	    ncoeff2 = c_tbagtd (tabinfo->tp, tabinfo->cp_coeff2, row,
			iac->coeff2, 1, iac->ncoeff2);
	    if (c_iraferr())
		return (TABLE_ERROR);
	}
	iac->allocated = 1;

	if (ncoeff1 < iac->ncoeff1 || ncoeff2 < iac->ncoeff2) {
	    if ((tname = (char *) calloc (STIS_LINE+1, sizeof (char))) == NULL)
		return (OUT_OF_MEMORY);
	    c_tbtnam (tabinfo->tp, tname, STIS_LINE);
	    c_tbtclo (tabinfo->tp);
	    printf (
	"ERROR    Not all coefficients were read from %s\n", tname);
	    free (tname);
	    return (TABLE_ERROR);
	}

	return (0);
}
Exemplo n.º 21
0
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);
}
Exemplo n.º 22
0
static int ReadApTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	c_tbegtt (tabinfo->tp, tabinfo->cp_aperture, row,
			tabrow->aperture, STIS_CBUF);
	c_tbegtd (tabinfo->tp, tabinfo->cp_offset, row, &tabrow->offset);
	if (c_iraferr())
	    return (TABLE_ERROR);

	return (0);
}
Exemplo n.º 23
0
static int CloseCCDTab (TblInfo *tabinfo) {

	extern int status;

	c_tbtclo (tabinfo->tp);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	return (status);
}
Exemplo n.º 24
0
static int ReadTraceArray (TblInfo *tabinfo, int row, StisInfo6* sts, SpTrace **trace) {

	int status;

	int nelem;		/* number of elements read from table */
	double mjd;             /* MJD */
	double degperyr;        /* rate of trace rotation */

	SpTrace *newd;
	int NewTrace6 (SpTrace **, SpTrace *);

	if ((newd = (SpTrace *) malloc (sizeof (SpTrace))) == NULL) {
	    printf ("ERROR    Can't allocate memory.\n");
	    return (OUT_OF_MEMORY);
	}
	newd->next = NULL;

	/* Get spectrum trace and other info. */
	c_tbegtd (tabinfo->tp, tabinfo->cp_a1center, row, &newd->a1center);
	c_tbegtd (tabinfo->tp, tabinfo->cp_a2center, row, &newd->a2center);

	c_tbegti (tabinfo->tp, tabinfo->cp_nelem, row, &newd->nelem);
	if (newd->nelem > MAX_SP_TRACE) {
	    printf ("ERROR    Spectrum trace in SPTRCTAB is too large.\n");
	    return (TABLE_ERROR);
	}
	nelem = c_tbagtd (tabinfo->tp, tabinfo->cp_a2displ, row,
			newd->a2displ, 1, newd->nelem);
	if (c_iraferr())
	    return (TABLE_ERROR);

	if (tabinfo->cp_mjd != 0) {
	    c_tbegtd (tabinfo->tp, tabinfo->cp_mjd, row, &mjd);
	    c_tbegtd (tabinfo->tp, tabinfo->cp_degperyr, row, &degperyr);
	    sts->trace_rotation = rotatetrace(sts->expstart, mjd, degperyr, newd->a2displ, nelem);
	}

	/* Convert a1center and a2center to zero-indexed. */
	newd->a1center--;
	newd->a2center--;

	if (nelem < newd->nelem) {
	    c_tbtclo (tabinfo->tp);
	    printf ("ERROR    Not all elements were read from SPTRCTAB\n");
	    return (TABLE_ERROR);
	}

	/* Insert newd into the SpTrace list. */
	if ((status = NewTrace6 (trace, newd)))
	    return (status);

	free (newd);

	return (0);
}
Exemplo n.º 25
0
int GetTdcCorr(StisInfo1 *sts, double mean_dark, double *factor) {

/* arguments:
StisInfo1 *sts          i: calibration switches, etc
double mean_dark        i: average of good pixels of dark reference image
double *factor          o: NUV correction factor for dark image
*/
	int status;
	int tbl_type;		/* original or post-SM4 */

	IRAFPointer tp;			/* pointer to table descriptor */
	/* column descriptors */
	IRAFPointer cp_1, cp_2, cp_3, cp_4;

	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;
	}

	/* Look for some of the columns we expect in each format TDC table. */
	c_tbcfnd1(tp, "DATE0", &cp_1);
	c_tbcfnd1(tp, "TEMP0", &cp_2);
	c_tbcfnd1(tp, "A1", &cp_3);
	c_tbcfnd1(tp, "D1", &cp_4);
	if (cp_1 != 0 && cp_2 != 0 && cp_3 != 0 && cp_4 != 0) {
	    /* columns were found */
	    tbl_type = POST_SM4_TDC_FORMAT;
	} else {
	    c_tbcfnd1(tp, "MJD", &cp_1);
	    c_tbcfnd1(tp, "SCALE", &cp_2);
	    c_tbcfnd1(tp, "NORM", &cp_3);
	    c_tbcfnd1(tp, "T_MIN", &cp_4);
	    if (cp_1 != 0 && cp_2 != 0 && cp_3 != 0 && cp_4 != 0) {
		tbl_type = ORIG_TDC_FORMAT;
	    } else {
		tbl_type = UNDEFINED_TDC_FORMAT;
	    }
	}

	c_tbtclo(tp);

	if (tbl_type == POST_SM4_TDC_FORMAT) {
	    status = postSM4TdcCorr(sts, mean_dark, factor);
	} else if (tbl_type == ORIG_TDC_FORMAT) {
	    status = origTdcCorr(sts, factor);
	} else {
	    printf("ERROR    TDCTAB `%s' is not a recognized format.\n",
		sts->tdctab.name);
	    return OPEN_FAILED;
	}

	return status;
}
Exemplo n.º 26
0
static int ReadPhotTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	c_tbegtt (tabinfo->tp, tabinfo->cp_opt_elem, row,
			tabrow->opt_elem, STIS_CBUF);
	if (c_iraferr())
	    return (TABLE_ERROR);

	if (tabinfo->cp_cenwave != 0) {
	    c_tbegti (tabinfo->tp, tabinfo->cp_cenwave, row, &tabrow->cenwave);
	    if (c_iraferr())
		return (TABLE_ERROR);
	    c_tbegti (tabinfo->tp, tabinfo->cp_sporder, row, &tabrow->sporder);
	    if (c_iraferr())
		return (TABLE_ERROR);
	} else {
	    tabrow->cenwave = 0;
	    tabrow->sporder = 0;
	}

	return (0);
}
Exemplo n.º 27
0
static int ReadAtoDTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	c_tbegtt (tabinfo->tp, tabinfo->cp_amp, row,
			tabrow->ccdamp, STIS_CBUF);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegti (tabinfo->tp, tabinfo->cp_gain, row, &tabrow->ccdgain);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegtt (tabinfo->tp, tabinfo->cp_key, row,
			tabrow->ref_key, STIS_CBUF);
	if (c_iraferr())
	    return (TABLE_ERROR);

	c_tbegtd (tabinfo->tp, tabinfo->cp_keyval, row, &tabrow->ref_key_value);
	if (c_iraferr())
	    return (TABLE_ERROR);

	return (0);
}
Exemplo n.º 28
0
static int ReadAtoDTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	extern int status;

	c_tbegtt (tabinfo->tp, tabinfo->cp_amp, row,
			tabrow->ccdamp, SZ_CBUF);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	c_tbegtr (tabinfo->tp, tabinfo->cp_gain, row, &tabrow->ccdgain);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	c_tbegtt (tabinfo->tp, tabinfo->cp_key, row,
			tabrow->ref_key, SZ_CBUF);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	c_tbegtd (tabinfo->tp, tabinfo->cp_keyval, row, &tabrow->ref_key_value);
	if (c_iraferr())
	    return (status = TABLE_ERROR);

	return (status);
}
Exemplo n.º 29
0
static int ReadTdcTab (TblInfo *tabinfo, int row, TblRow *tabrow) {

	c_tbegtd (tabinfo->tp, tabinfo->cp_mjd, row, &tabrow->mjd);
	if (c_iraferr())
	    return TABLE_ERROR;

	c_tbegtd (tabinfo->tp, tabinfo->cp_scale, row, &tabrow->scale);
	if (c_iraferr())
	    return TABLE_ERROR;

	c_tbegtd (tabinfo->tp, tabinfo->cp_norm, row, &tabrow->norm);
	if (c_iraferr())
	    return TABLE_ERROR;

	c_tbegtr (tabinfo->tp, tabinfo->cp_tmin, row, &tabrow->tmin);
	if (c_iraferr())
	    return TABLE_ERROR;

	c_tbegtr (tabinfo->tp, tabinfo->cp_thermcst, row, &tabrow->thermcst);
	if (c_iraferr())
	    return TABLE_ERROR;

	return 0;
}
Exemplo n.º 30
0
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);
}