IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18476


Ignore:
Timestamp:
Jul 11, 2008, 10:01:25 AM (18 years ago)
Author:
Paul Price
Message:

Fail if there's only a single chip and it failed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroChipAstrom.c

    r17108 r18476  
    1111    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE);
    1212    if (!recipe) {
    13         psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");
    14         return false;
     13        psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");
     14        return false;
    1515    }
    1616
     
    1818    pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
    1919    if (!input) {
    20         psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");
    21         return false;
     20        psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");
     21        return false;
    2222    }
    2323
     
    2525    pmFPA *fpa = input->fpa;
    2626
     27    int numGoodChips = 0;               // Number of chips for which astrometry succeeds
     28
    2729    while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {
    2830        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    2931        if (!chip->process || !chip->file_exists) { continue; }
    30        
    31         while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
     32
     33        int numGoodCells = 0;           // Number of cells for which astrometry succeeds
     34        while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
    3235            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    3336            if (!cell->process || !cell->file_exists) { continue; }
    34             if (!chip->fromFPA) { continue; }
     37            if (!chip->fromFPA) { continue; }
    3538
    36             // process each of the readouts
    37             while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
    38                 if (! readout->data_exists) { continue; }
     39            // process each of the readouts
     40            int numGoodRO = 0;          // Number of readouts for which astrometry succeeds
     41            while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
     42                if (! readout->data_exists) { continue; }
    3943
    40                 // select the raw objects for this readout
    41                 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
    42                 if (rawstars == NULL) { continue; }
     44                // select the raw objects for this readout
     45                psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
     46                if (rawstars == NULL) { continue; }
    4347
    44                 // select the raw objects for this readout
    45                 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");
    46                 if (refstars == NULL) { continue; }
     48                // select the raw objects for this readout
     49                psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");
     50                if (refstars == NULL) { continue; }
    4751
    48                 // the absolute minimum number of stars is 4 (for order = 1)
    49                 if ((rawstars->n < 4) || (refstars->n < 4)) {
    50                     readout->data_exists = false;
    51                     psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)",
    52                               rawstars->n, refstars->n);
    53                     continue;
    54                 }
     52                // the absolute minimum number of stars is 4 (for order = 1)
     53                if ((rawstars->n < 4) || (refstars->n < 4)) {
     54                    readout->data_exists = false;
     55                    psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)",
     56                              rawstars->n, refstars->n);
     57                    continue;
     58                }
    5559
    56                 // save WCS and analysis metadata in update header
    57                 psMetadata *updates = psMetadataAlloc();
     60                // save WCS and analysis metadata in update header
     61                psMetadata *updates = psMetadataAlloc();
    5862
    59                 // XXX update the header with info to reflect the failure
    60                 if (!psastroOneChipGrid (fpa, chip, refstars, rawstars, recipe, updates)) {
    61                     readout->data_exists = false;
    62                     psLogMsg ("psastro", 3, "failed to find a solution\n");
    63                     psFree (updates);
    64                     continue;
    65                 }
    66                 // XXX update the header with info to reflect the failure
    67                 if (!psastroOneChipFit (fpa, chip, refstars, rawstars, recipe, updates)) {
    68                     readout->data_exists = false;
    69                     psLogMsg ("psastro", 3, "failed to find a solution\n");
    70                     psFree (updates);
    71                     continue;
    72                 }
     63                // XXX update the header with info to reflect the failure
     64                if (!psastroOneChipGrid (fpa, chip, refstars, rawstars, recipe, updates)) {
     65                    readout->data_exists = false;
     66                    psLogMsg ("psastro", 3, "failed to find a solution\n");
     67                    psFree (updates);
     68                    continue;
     69                }
     70                // XXX update the header with info to reflect the failure
     71                if (!psastroOneChipFit (fpa, chip, refstars, rawstars, recipe, updates)) {
     72                    readout->data_exists = false;
     73                    psLogMsg ("psastro", 3, "failed to find a solution\n");
     74                    psFree (updates);
     75                    continue;
     76                }
    7377
    74                 // write the elapsed time here; this will be updated in psastroMosaicAstrometry, if called
    75                 psMetadataAddF32 (updates, PS_LIST_TAIL, "DT_ASTR", PS_META_REPLACE, "elapsed psastro time", psTimerMark ("psastroAnalysis"));
     78                numGoodRO++;
    7679
    77                 pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL);
    78                 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_DATA_METADATA, "psastro header stats", updates);
    79                 psFree (updates);
     80                // write the elapsed time here; this will be updated in psastroMosaicAstrometry, if called
     81                psMetadataAddF32 (updates, PS_LIST_TAIL, "DT_ASTR", PS_META_REPLACE, "elapsed psastro time", psTimerMark ("psastroAnalysis"));
    8082
    81                 if (psTraceGetLevel("psastro.dump") > 0) {
     83                pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL);
     84                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_DATA_METADATA, "psastro header stats", updates);
     85                psFree (updates);
    8286
    83                     char *filename = NULL;
    84                     char *chipname = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     87                if (psTraceGetLevel("psastro.dump") > 0) {
    8588
    86                     psStringAppend (&filename, "rawstars.ch.%s.dat", chipname);
    87                     psastroDumpStars (rawstars, filename);
    88                     psFree (filename);
    89                     filename = NULL;
     89                    char *filename = NULL;
     90                    char *chipname = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
    9091
    91                     psStringAppend (&filename, "refstars.ch.%s.dat", chipname);
    92                     psastroDumpStars (refstars, filename);
    93                     psFree (filename);
    94                     filename = NULL;
    95                 }
    96             }
    97         }
     92                    psStringAppend (&filename, "rawstars.ch.%s.dat", chipname);
     93                    psastroDumpStars (rawstars, filename);
     94                    psFree (filename);
     95                    filename = NULL;
     96
     97                    psStringAppend (&filename, "refstars.ch.%s.dat", chipname);
     98                    psastroDumpStars (refstars, filename);
     99                    psFree (filename);
     100                    filename = NULL;
     101                }
     102            }
     103            if (numGoodRO > 0) {
     104                numGoodCell++;
     105            }
     106        }
     107        if (numGoodCell > 0) {
     108            numGoodChip++;
     109        }
     110    }
     111
     112    if (fpa->chips->n == 1 && numGoodChip == 0) {
     113        psError(PSASTRO_ERR_UNKNOWN, false, "Failed to fit single chip.");
     114        return false;
    98115    }
    99116
     
    102119# if (0)
    103120    if (!psastroFixChipsTest (config, recipe)) {
    104         psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");
    105         return false;
     121        psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");
     122        return false;
    106123    }
    107124# endif
    108125
    109126    if (!psastroFixChips (config, recipe)) {
    110         psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");
    111         return false;
     127        psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");
     128        return false;
    112129    }
    113130
Note: See TracChangeset for help on using the changeset viewer.