IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 30, 2012, 2:11:49 PM (14 years ago)
Author:
bills
Message:

add new option to censorObjects where it simply reads the input smf file.
If it failes we can assume that the file is corrupt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/censorObjects/src/censorLoop.c

    r25081 r33626  
    155155    return true;
    156156}
     157
     158/**
     159 * \brief this loop loads the data from the input smf file(s) and mask(s).  call censorReadout
     160 * to perform the actual rejection.
     161 */
     162bool checkInputLoop (pmConfig *config) {
     163    pmChip *chip;
     164    pmCell *cell;
     165    pmReadout *readout;
     166
     167    psTimerStart ("checksources");
     168
     169    // select the input data sources
     170    pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "CENSOR.INPUT");
     171    if (!input) {
     172        psError(CENSOR_ERR_CONFIG, true, "Can't find input data!\n");
     173        return false;
     174    }
     175
     176    pmFPAview *view = pmFPAviewAlloc (0);
     177
     178    // files associated with the science image
     179    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     180
     181    // check PHU header to see if we are using mosaic-level or per-chip astrometry
     182    bool bilevelAstrometry = false;
     183    pmHDU *phu = pmFPAviewThisPHU (view, input->fpa);
     184    if (phu) {
     185      char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
     186      if (ctype) bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
     187    }
     188    if (bilevelAstrometry) {
     189      pmAstromReadBilevelMosaic (input->fpa, phu->header);
     190    }
     191
     192    while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
     193        psTrace ("checksources", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     194        if (!chip->process || !chip->file_exists) { continue; }
     195       
     196        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     197
     198        // read WCS data from the corresponding header
     199
     200        pmHDU *hdu = pmFPAviewThisHDU (view, input->fpa);
     201       
     202        if (bilevelAstrometry) {
     203          if (!pmAstromReadBilevelChip (chip, hdu->header)) {
     204            psWarning("Could not get WCS information from header for chip %d, skipping", view->chip);
     205            continue;
     206          }
     207        } else {
     208          if (!pmAstromReadWCS(input->fpa, chip, hdu->header, 1.0)) {
     209            psWarning( "Unable to read WCS astrometry from chip %d, skipping", view->chip);
     210            continue;
     211          }
     212        }
     213
     214        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
     215            psTrace ("checksources", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     216            if (!cell->process || !cell->file_exists) { continue; }
     217
     218            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     219
     220            // process each of the readouts
     221            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
     222
     223                if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     224                if (!readout->data_exists) { continue; }
     225               
     226                // select the raw objects for this readout, flag is they fall in a mask
     227                pmDetections *detections = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.DETECTIONS");
     228                if (detections == NULL) {
     229                    psError(CENSOR_ERR_CONFIG, true, "Can't find detections for this readout");
     230                    return false;
     231                }
     232                if (!detections->allSources) {
     233                    psError(CENSOR_ERR_CONFIG, true, "Can't find sources for this readout");
     234                    return false;
     235                }
     236
     237                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     238            }
     239            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     240        }
     241        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     242    }
     243    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     244
     245    psLogMsg ("checksources", 3, "checkInputLoop done : %f sec\n", psTimerMark ("checksources"));
     246
     247    psFree (view);
     248    return true;
     249}
Note: See TracChangeset for help on using the changeset viewer.