IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26793


Ignore:
Timestamp:
Feb 5, 2010, 3:11:11 PM (16 years ago)
Author:
eugene
Message:

bug fixes to psphot APIs

Location:
branches/eam_branches/20091201
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ppImage/src/ppImageBurntoolMask.c

    r26765 r26793  
    33#endif
    44
    5 #define PPIMAGE_BURNTOOL_DEBUG 1
     5#define PPIMAGE_BURNTOOL_DEBUG 0
    66
    77#include "ppImage.h"
     
    2323    return(false);
    2424  }
    25   long Nrows = psFitsTableSize(fits); 
     25  long Nrows = psFitsTableSize(fits);
    2626
    2727  long row = 0;
     
    3333  psImage *image = mask->mask;
    3434
    35  
     35
    3636  /* Set the maskValue from the recipes. */
    3737  psImageMaskType maskValue = options->burntoolMask;
    38 #ifdef PPIMAGE_BURNTOOL_DEBUG
     38#if PPIMAGE_BURNTOOL_DEBUG
    3939  psLogMsg("ppImageBurntoolMask", 4, "Status: %ld %d\n",Nrows,maskValue);
    4040#endif
     
    4848    if (psMetadataLookupS32(&status,rowMD,"cell") == burntool_cell) {
    4949      if (((options->burntoolTrails & 0x01)&&(psMetadataLookupS32(&status,rowMD,"func") == 4))||
    50           (((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1))||
    51            ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)))) {
    52         /*       If the fit fails, burntool reports zero here.  This
    53                 signifies that it expected to see a trail (else why
    54                 fit) but did not find it when it attempted to
    55                 correct. */
    56 #ifdef PPIMAGE_BURNTOOL_DEBUG
    57         psLogMsg ("ppImageBurntoolMask", 4, "Masking! %d (%d %d %d) %d %d",
    58                   psMetadataLookupS32(&status,rowMD,"cell"),
    59                   ((options->burntoolTrails & 0x0001)&&(psMetadataLookupS32(&status,rowMD,"nfit") == 0)),
    60                   ((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1)),
    61                   ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)),
    62                   options->burntoolTrails,
    63                   maskValue
    64                   );
     50          (((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1))||
     51           ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)))) {
     52        /*       If the fit fails, burntool reports zero here.  This
     53                signifies that it expected to see a trail (else why
     54                fit) but did not find it when it attempted to
     55                correct. */
     56#if PPIMAGE_BURNTOOL_DEBUG
     57        psLogMsg ("ppImageBurntoolMask", 4, "Masking! %d (%d %d %d) %d %d",
     58                  psMetadataLookupS32(&status,rowMD,"cell"),
     59                  ((options->burntoolTrails & 0x0001)&&(psMetadataLookupS32(&status,rowMD,"nfit") == 0)),
     60                  ((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1)),
     61                  ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)),
     62                  options->burntoolTrails,
     63                  maskValue
     64                  );
    6565#endif
    66         for (int i = psMetadataLookupS32(&status,rowMD,"sxfit");
    67              i <= psMetadataLookupS32(&status,rowMD,"exfit");
    68              i++) {
     66        for (int i = psMetadataLookupS32(&status,rowMD,"sxfit");
     67             i <= psMetadataLookupS32(&status,rowMD,"exfit");
     68             i++) {
    6969
    70           if (psMetadataLookupS32(&status,rowMD,"up") == 0) {
    71             for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) {
    72 #ifdef PPIMAGE_BURNTOOL_DEBUG
    73               psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
    74                        i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
     70          if (psMetadataLookupS32(&status,rowMD,"up") == 0) {
     71            for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) {
     72#if PPIMAGE_BURNTOOL_DEBUG
     73              psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
     74                       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
    7575#endif
    76               image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
    77             }
    78           }
    79           else {
    80             for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) {
    81 #ifdef PPIMAGE_BURNTOOL_DEBUG
    82               psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
    83                        i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
     76              image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     77            }
     78          }
     79          else {
     80            for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) {
     81#if PPIMAGE_BURNTOOL_DEBUG
     82              psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
     83                       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
    8484#endif
    85               image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
    86             }
    87           }
    88         }
     85              image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     86            }
     87          }
     88        }
    8989
    9090      }
     
    9595  return(status);
    9696}
    97            
    98 
    99 
    100    
  • branches/eam_branches/20091201/psphot/src/psphotLoadPSF.c

    r26788 r26793  
    1717    // find the currently selected readout
    1818    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    19     psAssert (file, "missing file?");
     19    if (file == NULL) {
     20        psLogMsg ("psphot", 3, "no psf supplied for this chip");
     21        return true;
     22    }
    2023
    2124    // find the currently selected chip
     
    3538
    3639    if (!psphotPSFstats (readout, psf)) {
    37         psAbort("cannot measure PSF shape terms");
     40        psAbort("cannot measure PSF shape terms");
    3841    }
    3942
     
    4245    // save PSF on readout->analysis
    4346    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot psf model", psf)) {
    44         psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
     47        psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
    4548        return false;
    4649    }
     
    6063    for (int i = 0; i < num; i++) {
    6164
    62         // Generate the mask and weight images, including the user-defined analysis region of interest
    63         if (!psphotLoadPSFReadout (config, view, "PSPHOT.PSF.LOAD", i)) {
     65        // Generate the mask and weight images, including the user-defined analysis region of interest
     66        if (!psphotLoadPSFReadout (config, view, "PSPHOT.PSF.LOAD", i)) {
    6467            psError (PSPHOT_ERR_CONFIG, false, "failed to load PSF model for PSPHOT.PSF.LOAD entry %d", i);
    65             return false;
    66         }
     68            return false;
     69        }
    6770    }
    6871    return true;
  • branches/eam_branches/20091201/psphot/src/psphotMergeSources.c

    r26788 r26793  
    1515    // loop over the available readouts
    1616    for (int i = 0; i < num; i++) {
    17         if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) {
     17        if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) {
    1818            psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i);
    19             return false;
    20         }
     19            return false;
     20        }
    2121    }
    2222    return true;
     
    4343    // XXX TEST:
    4444    if (detections->allSources) {
    45         psphotMaskCosmicRayFootprintCheck(detections->allSources);
     45        psphotMaskCosmicRayFootprintCheck(detections->allSources);
    4646    }
    4747    if (detections->newSources) {
    48         psphotMaskCosmicRayFootprintCheck(detections->newSources);
     48        psphotMaskCosmicRayFootprintCheck(detections->newSources);
    4949    }
    5050
    5151    if (!detections->allSources) {
    52         detections->allSources = psArrayAllocEmpty(newSources->n);
     52        detections->allSources = psArrayAllocEmpty(newSources->n);
    5353    }
    5454    psArray *allSources = detections->allSources;
     
    8787    psAssert (detections, "missing detections?");
    8888
    89     // XXX allSources of newSources?
     89    // XXX allSources or newSources?
    9090    psArray *sources = detections->allSources;
    9191    psAssert (sources, "missing sources?");
     
    9696        if (!readoutCMF) goto loadTXT;
    9797
    98         extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS");
    99         if (extCMF) {
    100             for (int i = 0; i < extCMF->allSources->n; i++) {
    101                 pmSource *source = extCMF->allSources->data[i];
    102                 source->mode |= PM_SOURCE_MODE_EXTERNAL;
     98        extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS");
     99        if (extCMF) {
     100            for (int i = 0; i < extCMF->allSources->n; i++) {
     101                pmSource *source = extCMF->allSources->data[i];
     102                source->mode |= PM_SOURCE_MODE_EXTERNAL;
    103103
    104104                // the supplied peak flux needs to be re-normalized
     
    106106                source->peak->value = 1.0;
    107107
    108                 // drop the loaded source modelPSF
    109                 psFree (source->modelPSF);
    110                 source->modelPSF = NULL;
    111 
    112                 psArrayAdd (detections->allSources, 100, source);
    113             }
    114         }
     108                // drop the loaded source modelPSF
     109                psFree (source->modelPSF);
     110                source->modelPSF = NULL;
     111
     112                psArrayAdd (detections->allSources, 100, source);
     113            }
     114        }
    115115    }
    116116
     
    128128                source->mode |= PM_SOURCE_MODE_EXTERNAL;
    129129
    130                 // drop the loaded source modelPSF
    131                 psFree (source->modelPSF);
    132                 source->modelPSF = NULL;
    133 
    134                 psArrayAdd (detections->allSources, 100, source);
    135             }
    136         }
     130                // drop the loaded source modelPSF
     131                psFree (source->modelPSF);
     132                source->modelPSF = NULL;
     133
     134                psArrayAdd (detections->allSources, 100, source);
     135            }
     136        }
    137137    }
    138138
     
    168168    if (!detections) {
    169169        psLogMsg ("psphot", 3, "no psf sources for this readout");
    170         return NULL;
     170        return NULL;
    171171    }
    172172
     
    174174    if (!sources) {
    175175        psLogMsg ("psphot", 3, "no psf sources for this readout");
    176         return NULL;
     176        return NULL;
    177177    }
    178178
     
    212212
    213213// generate the detection structure for the supplied array of sources
    214 // XXX this currently assumes there is a single input file 
     214// XXX this currently assumes there is a single input file
    215215bool psphotDetectionsFromSources (pmConfig *config, const pmFPAview *view, psArray *sources) {
    216216
     
    274274    // save detections on the readout->analysis
    275275    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detectinos", detections)) {
    276         psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
    277         return false;
     276        psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     277        return false;
    278278    }
    279279    psFree (detections);
     
    343343
    344344    if (sources->n) {
    345         // the user wants to make the psf from these stars; define them as psf stars:
    346         for (int i = 0; i < sources->n; i++) {
    347             pmSource *source = sources->data[i];
    348             source->mode |= PM_SOURCE_MODE_PSFSTAR;
    349         }
    350         // force psphotChoosePSF to use all loaded sources
    351         psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF_MAX_NSTARS", PS_META_REPLACE, "max number of sources for PSF model", sources->n);
    352 
    353         // measure stats of externally specified sources
    354         if (!psphotSourceStatsUpdate (sources, config, readout)) {
    355             psError(PSPHOT_ERR_CONFIG, false, "failure to measure stats of existing sources");
    356             return false;
    357         }
     345        // the user wants to make the psf from these stars; define them as psf stars:
     346        for (int i = 0; i < sources->n; i++) {
     347            pmSource *source = sources->data[i];
     348            source->mode |= PM_SOURCE_MODE_PSFSTAR;
     349        }
     350        // force psphotChoosePSF to use all loaded sources
     351        psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF_MAX_NSTARS", PS_META_REPLACE, "max number of sources for PSF model", sources->n);
     352
     353        // measure stats of externally specified sources
     354        if (!psphotSourceStatsUpdate (sources, config, readout)) {
     355            psError(PSPHOT_ERR_CONFIG, false, "failure to measure stats of existing sources");
     356            return false;
     357        }
    358358    } else {
    359359
    360         // find the detections (by peak and/or footprint) in the image.
    361         if (!psphotFindDetections (config, view, true)) {
    362             psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image");
    363             return psphotReadoutCleanup (config, view);
    364         }
    365 
    366         // construct sources and measure basic stats
    367         psphotSourceStats (config, view, true);
    368 
    369         // find blended neighbors of very saturated stars
    370         psphotDeblendSatstars (config, view);
    371 
    372         // mark blended peaks PS_SOURCE_BLEND
    373         if (!psphotBasicDeblend (config, view)) {
    374             psLogMsg ("psphot", 3, "failed on deblend analysis");
    375             return psphotReadoutCleanup (config, view);
    376         }
    377 
    378         // classify sources based on moments, brightness
    379         if (!psphotRoughClass (config, view)) {
    380             psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    381             return psphotReadoutCleanup (config, view);
    382         }
    383     }
    384 
    385     return true;
    386 }
     360        // find the detections (by peak and/or footprint) in the image.
     361        if (!psphotFindDetections (config, view, true)) {
     362            psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image");
     363            return psphotReadoutCleanup (config, view);
     364        }
     365
     366        // construct sources and measure basic stats
     367        psphotSourceStats (config, view, true);
     368
     369        // find blended neighbors of very saturated stars
     370        psphotDeblendSatstars (config, view);
     371
     372        // mark blended peaks PS_SOURCE_BLEND
     373        if (!psphotBasicDeblend (config, view)) {
     374            psLogMsg ("psphot", 3, "failed on deblend analysis");
     375            return psphotReadoutCleanup (config, view);
     376        }
     377
     378        // classify sources based on moments, brightness
     379        if (!psphotRoughClass (config, view)) {
     380            psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
     381            return psphotReadoutCleanup (config, view);
     382        }
     383    }
     384
     385    return true;
     386}
  • branches/eam_branches/20091201/psphot/src/psphotReadout.c

    r26788 r26793  
    5656        return psphotReadoutCleanup (config, view);
    5757    }
    58        
     58
    5959    // find the detections (by peak and/or footprint) in the image.
    6060    if (!psphotFindDetections (config, view, true)) { // pass 1
    61         // this only happens if we had an error in psphotFindDetections
     61        // this only happens if we had an error in psphotFindDetections
    6262        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    6363        return psphotReadoutCleanup (config, view);
     
    104104    // this step is skipped
    105105    if (!psphotChoosePSF (config, view)) { // pass 1
    106         psLogMsg ("psphot", 3, "failure to construct a psf model");
    107         return psphotReadoutCleanup (config, view);
     106        psLogMsg ("psphot", 3, "failure to construct a psf model");
     107        return psphotReadoutCleanup (config, view);
    108108    }
    109109    if (!strcasecmp (breakPt, "PSFMODEL")) {
     
    113113    // include externally-supplied sources
    114114    // XXX fix this in the new multi-input context
    115     psphotLoadExtSources (config, view); // pass 1
     115    // psphotLoadExtSources (config, view); // pass 1
    116116
    117117    // construct an initial model for each object, set the radius to fitRadius, set circular
     
    121121    // merge the newly selected sources into the existing list
    122122    // NOTE: merge OLD and NEW
    123     psphotMergeSources (config, view); 
     123    psphotMergeSources (config, view);
    124124
    125125    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
Note: See TracChangeset for help on using the changeset viewer.