Esempio n. 1
0
int GetDisp4 (StisInfo4 *sts, DispRelation *disp, char *ref_aper) {

/* arguments:
StisInfo4 *sts       i: calibration switches and info
DispRelation *disp   o: dispersion relation
char *ref_aper       o: name of aperture used to measure dispersion relation
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* loop index */
	int best_row;		/* read info from this row */
	double a2diff;		/* difference between A2CENTER and middle */
	double min_a2diff;	/* min value of a2diff */

	/* Open the dispersion coefficients table. */
	if ((status = OpenDSPTab (sts->disptab.name, &tabinfo)))
	    return (status);

	best_row = -1;			/* initial values */
	min_a2diff = 2. * MIDDLE_LINE;

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

	    if ((status = ReadDSPTab (&tabinfo, row, &tabrow)))
		return (status);

	    /* Check for a match with opt_elem and cenwave. */

	    if (SameString (tabrow.opt_elem, sts->opt_elem) &&
		SameInt (tabrow.cenwave, sts->cenwave)) {

		a2diff = fabs (tabrow.a2center - MIDDLE_LINE);
		if (a2diff < min_a2diff) {
		    min_a2diff = a2diff;
		    best_row = row;
		}
	    }
	}

	if (best_row < 1) {
	    printf ("Matching row not found in DISPTAB %s:\n",
				sts->disptab.name);
	    printf ("    OPT_ELEM %s, CENWAVE %d\n",
			sts->opt_elem, sts->cenwave);
	    return (TABLE_ERROR);
	}

	/* Read data from the most appropriate row. */
	if ((status = ReadDSPArray (&tabinfo, best_row, disp, ref_aper)))
	    return (status);

	/* Get pedigree & descrip from this row. */
	if ((status = RowPedigree (&sts->disptab, best_row,
                tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip)))
	    return (status);
	if (sts->disptab.goodPedigree == DUMMY_PEDIGREE) {
	    printf ("Warning  DUMMY pedigree in row %d of %s.\n",
		best_row, sts->disptab.name);
	}

	if ((status = CloseDSPTab (&tabinfo)))
	    return (status);

	return (0);
}
Esempio n. 2
0
int GetDisp (StisInfo7 *sts, DispRelation **disp) {

/* arguments:
StisInfo7 *sts       i: calibration switches and info
DispRelation **disp  o: size and coordinate info for output
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* loop index */
	int CheckDisp (DispRelation **);
	void FreeDisp (DispRelation **);

	/* Open the dispersion coefficients table. */
	if ((status = OpenDSPTab (sts->disptab.name, &tabinfo)))
	    return (status);

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

	    if ((status = ReadDSPTab (&tabinfo, row, &tabrow)))
		return (status);

	    /* Check for a match with opt_elem and cenwave. */

	    if (SameString (tabrow.opt_elem, sts->opt_elem) &&
		SameInt (tabrow.cenwave, sts->cenwave)) {

		/* Get pedigree & descrip from the row. */
		if ((status = RowPedigree (&sts->disptab, row,
                        tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip)))
		    return (status);
		if (sts->disptab.goodPedigree == DUMMY_PEDIGREE) {
		    printf ("Warning  DUMMY pedigree in row %d of %s.\n",
			row, sts->disptab.name);
		    sts->x2dcorr_o = DUMMY;
		    CloseDSPTab (&tabinfo);
		    return (0);
		}

		/* Read data from this row. */
		if ((status = ReadDSPArray (&tabinfo, row, disp)))
		    return (status);
	    }
	}

	/* Get for duplicate a2center or non-duplicate ref_aper. */
	if ((status = CheckDisp (disp))) {
	    FreeDisp (disp);
	    if (status < 0) {
		printf ("Warning  Matching row not found in DISPTAB %s; \\\n",
				sts->disptab.name);
		printf ("Warning  OPT_ELEM %s, CENWAVE %d\n",
			sts->opt_elem, sts->cenwave);
		sts->x2dcorr_o = OMIT;
	    } else {
		return (status);
	    }
	}

	if ((status = CloseDSPTab (&tabinfo)))
	    return (status);

	return (0);
}