IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 24, 2006, 11:06:14 AM (20 years ago)
Author:
eugene
Message:

fixed code to measure local background for sources: added new function psphotSelectBackground, new args for psphotMagnitudes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotMagnitudes.c

    r10138 r10185  
    44                      psMetadata *recipe,
    55                      pmPSF *psf,
    6                       const pmConfig *config)
     6                      pmReadout *background)
    77{
    88    bool status = false;
     
    1313    pmSourceMagnitudesInit (recipe);
    1414
     15    // XXX require (assert) that we have a background model, or
     16    // allow it to be missing, setting local sky to 0.0?
     17
    1518    // Get enough information to return sky level
    16     assert (config != NULL);
    17     const psImage *background = NULL;
    18     int DX = 0, DY = 0, dx = 0, dy = 0; // unpacked with PSPHOT.BACKMDL
    19     {
    20         const pmFPAfile *backgroundFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL");
    21         if (backgroundFile != NULL) {
    22             assert (backgroundFile->readout != NULL);
    23             background = backgroundFile->readout->image;
    24 
    25             assert(backgroundFile->readout->analysis != NULL);
    26             DX = psMetadataLookupS32(&status, backgroundFile->readout->analysis, "XBIN");
    27             assert (status == true);
    28             DY = psMetadataLookupS32(&status, backgroundFile->readout->analysis, "YBIN");
    29             assert (status == true);
    30             dx = psMetadataLookupS32(&status, backgroundFile->readout->analysis, "x0");
    31             assert (status == true);
    32             dy = psMetadataLookupS32(&status, backgroundFile->readout->analysis, "y0");
    33             assert (status == true);
    34         }
    35     }
     19    assert(background != NULL);
     20    assert(background->analysis != NULL);
     21    int DX = psMetadataLookupS32(&status, background->analysis, "XBIN");
     22    assert (status == true);
     23    int DY = psMetadataLookupS32(&status, background->analysis, "YBIN");
     24    assert (status == true);
     25    int dx = psMetadataLookupS32(&status, background->analysis, "x0");
     26    assert (status == true);
     27    int dy = psMetadataLookupS32(&status, background->analysis, "y0");
     28    assert (status == true);
    3629
    3730    bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH");
     
    4740        if (status) Nap ++;
    4841
    49         source->sky = 0;
    50 #if 0
    51         source->sky += source->moments->Sky;
    52 #endif
    53 
    54         if (background != NULL) {
    55             source->sky += psImageUnbinPixel(source->peak->x, source->peak->y, background, DX, DY, dx, dy);
    56             if (isnan(source->sky) && false) {
    57                 psError(PSPHOT_ERR_SKY, false, "Setting pmSource.sky");
    58                 psErrorStackPrint(NULL, " ");
    59                 psErrorClear();
    60             }
     42        source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, background->image, DX, DY, dx, dy);
     43        if (isnan(source->sky) && false) {
     44          psError(PSPHOT_ERR_SKY, false, "Setting pmSource.sky");
     45          psErrorStackPrint(NULL, " ");
     46          psErrorClear();
    6147        }
    6248    }   
Note: See TracChangeset for help on using the changeset viewer.