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