IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33626


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

Location:
trunk/magic/censorObjects/src
Files:
5 edited

Legend:

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

    r26331 r33626  
    4646    }
    4747
    48     // load the raw detection data (using PSPHOT.SOURCES filerule)
    49     // select subset of stars for astrometry
    50     if (!censorLoop (config)) {
    51         psErrorStackPrint(stderr, "error loading input data\n");
    52         psFree(config);
    53         exit(PS_EXIT_DATA_ERROR);
     48    bool status;
     49    bool checkInputOnly = psMetadataLookupBool(&status, config->arguments,
     50        "CHECK.INPUT.ONLY");
     51
     52    if (!checkInputOnly) {
     53        // load the raw detection data (using PSPHOT.SOURCES filerule)
     54        // select subset of stars for astrometry
     55        if (!censorLoop (config)) {
     56            psErrorStackPrint(stderr, "error loading input data\n");
     57            psFree(config);
     58            exit(PS_EXIT_DATA_ERROR);
     59        }
     60
     61        psLogMsg("censor", 3, "complete censor run: %f sec\n", psTimerMark ("complete"));
     62    } else {
     63        if (!checkInputLoop (config)) {
     64            psErrorStackPrint(stderr, "error loading input data\n");
     65            psFree(config);
     66            exit(PS_EXIT_DATA_ERROR);
     67        }
     68        psLogMsg("censor", 3, "complete check input run: %f sec\n", psTimerMark ("complete"));
    5469    }
    55 
    56     psLogMsg("censor", 3, "complete censor run: %f sec\n", psTimerMark ("complete"));
    5770
    5871    censorCleanup(config);
  • trunk/magic/censorObjects/src/censor.h

    r24714 r33626  
    3131bool censorParseCamera (pmConfig *config);
    3232bool censorLoop (pmConfig *config);
     33bool checkInputLoop (pmConfig *config);
    3334bool censorReadout (pmReadout *readout, pmConfig *config, const pmFPAview *view, bool badMaskFile);
    3435void censorCleanup (pmConfig *config);
  • trunk/magic/censorObjects/src/censorArguments.c

    r24695 r33626  
    3232    }
    3333
     34    status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
     35    if (!status) {
     36        psError(CENSOR_ERR_ARGUMENTS, true, "Missing -file (input) or -list (input)");
     37        psErrorStackPrint(stderr, "exit");
     38        return NULL;
     39    }
     40
     41    if ((N = psArgumentGet (argc, argv, "-checkinputonly"))) {
     42        psArgumentRemove (N, &argc, argv);
     43        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "CHECK.INPUT.ONLY", PS_META_REPLACE, "do not censor just check input sources", true);
     44        return config;
     45    }
     46       
    3447    // define the input mask
    3548    status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT.MASK", "-mask", "-masklist");
     
    4255    }
    4356
    44     status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
    45     if (!status) {
    46         psError(CENSOR_ERR_ARGUMENTS, true, "Missing -file (input) or -list (input)");
    47         psErrorStackPrint(stderr, "exit");
    48         return NULL;
    49     }
    5057
    5158    if (argc != 2) {
  • 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}
  • trunk/magic/censorObjects/src/censorParseCamera.c

    r24692 r33626  
    2323        return false;
    2424    }
     25
     26    bool checkInputOnly = psMetadataLookupBool(&status, config->arguments, "CHECK.INPUT.ONLY");
     27    if (checkInputOnly) {
     28        // nothing else to do
     29        return true;
     30    }
     31
    2532
    2633    pmFPAfile *output = pmFPAfileDefineOutput (config, input->fpa, "CENSOR.OUTPUT");
Note: See TracChangeset for help on using the changeset viewer.