Esempio n. 1
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);
}
Esempio n. 2
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);
}
Esempio n. 3
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);
}
Esempio n. 4
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);
}
Esempio n. 5
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);
}
Esempio n. 6
0
static int ReadDSPArray (TblInfo *tabinfo, int row, DispRelation **disp) {

	int status;

	int ncoeff;		/* number of coefficients read from table */
	DispRelation *newrec;
	int NewDisp (DispRelation **, DispRelation *);

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

	/* Get dispersion coefficients and other info. */
	c_tbegtd (tabinfo->tp, tabinfo->cp_a2center, row, &newrec->a2center);
	c_tbegtt (tabinfo->tp, tabinfo->cp_ref_aper, row, newrec->ref_aper,
		STIS_CBUF);
	c_tbegti (tabinfo->tp, tabinfo->cp_ncoeff, row, &newrec->ncoeff);
	if (newrec->ncoeff > MAX_DISP_COEFF) {
	    printf (
	"ERROR    Too many dispersion coefficients %d in DISPTAB.\n",
		newrec->ncoeff);
	    return (TABLE_ERROR);
	}
	ncoeff = c_tbagtd (tabinfo->tp, tabinfo->cp_coeff, row,
			newrec->coeff, 1, newrec->ncoeff);
	if (c_iraferr())
	    return (TABLE_ERROR);

	/* Convert a2center to zero-indexed. */
	newrec->a2center--;

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

	/* Insert newrec into the disp list. */
	if ((status = NewDisp (disp, newrec)))
	    return (status);

	free (newrec);

	return (0);
}
Esempio n. 7
0
static int ReadPhotData (TblInfo *tabinfo, int row, PhotInfo *phot) {

	int nwl, nthru;		/* number of elements actually read */

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

	phot->wl = (double *) malloc (phot->nelem * sizeof(double));
	phot->thru = (double *) malloc (phot->nelem * sizeof(double));
	if (phot->wl == NULL || phot->thru == NULL)
	    return (OUT_OF_MEMORY);

	nwl = c_tbagtd (tabinfo->tp, tabinfo->cp_wl, row,
			phot->wl, 1, phot->nelem);
	if (c_iraferr())
	    return (TABLE_ERROR);

	nthru = c_tbagtd (tabinfo->tp, tabinfo->cp_thru, row,
			phot->thru, 1, phot->nelem);
	if (c_iraferr())
	    return (TABLE_ERROR);

	if (nwl < phot->nelem || nthru < phot->nelem) {
	    c_tbtclo (tabinfo->tp);
	    free (phot->wl);
	    free (phot->thru);
	    printf ("ERROR    Not all elements were read from PHOTTAB.\n");
	    return (TABLE_ERROR);
	}

	phot->allocated = 1;			/* set flag */

	if (phot->blazecorr == PERFORM) {

	    c_tbegti (tabinfo->tp, tabinfo->cp_mref, row, &phot->mref);
	    c_tbegtd (tabinfo->tp, tabinfo->cp_wref, row, &phot->wref);
	    c_tbegtd (tabinfo->tp, tabinfo->cp_yref, row, &phot->yref);
	    c_tbegtd (tabinfo->tp, tabinfo->cp_mjd,  row, &phot->mjd);
	    c_tbegtd (tabinfo->tp, tabinfo->cp_mx,   row, &phot->mx);
	    c_tbegtd (tabinfo->tp, tabinfo->cp_my,   row, &phot->my);
	    c_tbegtd (tabinfo->tp, tabinfo->cp_mt,   row, &phot->mt);
	    if (tabinfo->cp_m0 == 0)
		phot->m0 = 0.;
	    else
		c_tbegtd (tabinfo->tp, tabinfo->cp_m0, row, &phot->m0);

	    if (c_iraferr()) {
	        free (phot->wl);
	        free (phot->thru);
	        free (phot->error);
	        return (TABLE_ERROR);
	    }

	    /* Reference data is 1-indexed ! */
	    phot->yref -= 1.0;
	}

	return (0);
}
Esempio n. 8
0
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);
}
Esempio n. 9
0
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);
}
Esempio n. 10
0
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);
}