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); }
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); }
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); }
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; }
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); }
static int ReadCCDTab (TblInfo *tabinfo, int row, TblRow *tabrow) { extern int status; c_tbegtt (tabinfo->tp, tabinfo->cp_amp, row, tabrow->ccdamp, ACS_CBUF-1); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_ccdchip, row, &tabrow->ccdchip); if (c_iraferr()) return (status = TABLE_ERROR); if (tabinfo->intgain == 1){ c_tbegti (tabinfo->tp, tabinfo->cp_ccdgain, row, &tabrow->ccdgaini); } else { c_tbegtr (tabinfo->tp, tabinfo->cp_ccdgain, row, &tabrow->ccdgainf); } if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_bin1, row, &tabrow->bin[0]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_bin2, row, &tabrow->bin[1]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_ccdoffset[0], row, &tabrow->ccdoffset[0]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_ccdoffset[1], row, &tabrow->ccdoffset[1]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_ccdoffset[2], row, &tabrow->ccdoffset[2]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_ccdoffset[3], row, &tabrow->ccdoffset[3]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_bias[0], row, &tabrow->bias[0]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_bias[1], row, &tabrow->bias[1]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_bias[2], row, &tabrow->bias[2]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_bias[3], row, &tabrow->bias[3]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_atodgain[0], row, &tabrow->atodgain[0]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_atodgain[1], row, &tabrow->atodgain[1]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_atodgain[2], row, &tabrow->atodgain[2]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_atodgain[3], row, &tabrow->atodgain[3]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_readnoise[0], row, &tabrow->readnoise[0]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_readnoise[1], row, &tabrow->readnoise[1]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_readnoise[2], row, &tabrow->readnoise[2]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_readnoise[3], row, &tabrow->readnoise[3]); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_ampx, row, &tabrow->ampx); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegti (tabinfo->tp, tabinfo->cp_ampy, row, &tabrow->ampy); if (c_iraferr()) return (status = TABLE_ERROR); c_tbegtr (tabinfo->tp, tabinfo->cp_saturate, row, &tabrow->saturate); if (c_iraferr()) return (status = TABLE_ERROR); return (status); }
/* 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); }
void c_tbegtt (const IRAFPointer tp, const IRAFPointer cp, int row, char *buffer, int maxch) { /* Read a string value from a table column. arguments: IRAFPointer tp i: table descriptor IRAFPointer cp i: column descriptor int row i: row number (one indexed) char *buffer o: value read from table int maxch i: maximum length of the string (not incl NULL) */ TableDescr *tbl_descr; ColumnDescr *col_descr; int anynul=0; long firstelem=1, nelem=1; char *value; int len; int status = 0; tbl_descr = (TableDescr *)tp; col_descr = (ColumnDescr *)cp; if (col_descr->datatype < 0) { if (col_descr->width >= maxch) len = col_descr->width; else len = maxch; } else { len = SZ_FITS_STR; } value = (char *)calloc (len+1, sizeof(char)); if (col_descr->datatype == IRAF_BOOL) { Bool b_value; c_tbegtb (tp, cp, row, &b_value); if (b_value == True) strcpy (value, "yes"); else strcpy (value, "no"); } else if (col_descr->datatype == IRAF_DOUBLE) { double d_value; c_tbegtd (tp, cp, row, &d_value); if (d_value == IRAF_INDEFD) strcpy (value, "INDEF"); else sprintf (value, "%.16g", d_value); } else if (col_descr->datatype == IRAF_REAL) { float r_value; c_tbegtr (tp, cp, row, &r_value); if (r_value >= 0.99999 * IRAF_INDEFR && r_value <= 1.00001 * IRAF_INDEFR) { strcpy (value, "INDEF"); } else { sprintf (value, "%.7g", r_value); } } else if (col_descr->datatype == IRAF_INT) { int i_value; c_tbegti (tp, cp, row, &i_value); if (i_value == IRAF_INDEFI) strcpy (value, "INDEF"); else sprintf (value, "%d", i_value); } else if (col_descr->datatype == IRAF_SHORT) { short si_value; c_tbegts (tp, cp, row, &si_value); if (si_value == IRAF_INDEFS) strcpy (value, "INDEF"); else sprintf (value, "%hd", si_value); } else { /* fits_read_col_str = ffgcvs */ fits_read_col_str (tbl_descr->fptr, col_descr->colnum, (long)row, firstelem, nelem, "INDEF", &value, &anynul, &status); if (status != 0) setError (status, "c_tbegtt: error reading element"); } copyString (buffer, value, maxch); free (value); }