IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10185


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

Location:
trunk/psphot/src
Files:
5 edited

Legend:

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

    r9515 r10185  
    2828    }
    2929
     30    // XXX for test checking of the config system
     31    // psphotDumpConfig (config);
     32
    3033    // call psphot for each readout
    3134    if (!psphotImageLoop (config)) {
  • trunk/psphot/src/psphot.h

    r10139 r10185  
    4444bool            psphotReplaceUnfit (psArray *sources);
    4545bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    46 bool            psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf, const pmConfig *config);
     46bool            psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf, pmReadout *background);
    4747bool            psphotSkyReplace (pmConfig *config, pmFPAview *view);
    4848bool            psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources);
     
    6969bool            psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    7070int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
     71bool psphotDumpConfig (pmConfig *config);
     72pmReadout *psphotSelectBackground (pmConfig *config, pmFPAview *view);
    7173
    7274// PSF / DBL / EXT evaluation functions
  • 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    }   
  • trunk/psphot/src/psphotOutput.c

    r10096 r10185  
    11# include "psphot.h"
     2
     3pmReadout *psphotSelectBackground (pmConfig *config, pmFPAview *view) {
     4
     5    bool status;
     6    pmReadout *background;   
     7
     8    pmFPAfile *file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKMDL");
     9    if (!file) return NULL;
     10    if (file->mode == PM_FPA_MODE_INTERNAL) {
     11        background = file->readout;
     12    } else {
     13        background = pmFPAviewThisReadout (view, file->fpa);
     14    }
     15    return background;
     16}
     17
     18bool psphotDumpConfig (pmConfig *config) {
     19
     20  psMetadataConfigWrite (config->site, "site.md");
     21  psMetadataConfigWrite (config->camera, "camera.md");
     22  psMetadataConfigWrite (config->recipes, "recipes.md");
     23  psMetadataConfigWrite (config->arguments, "arguments.md");
     24  psMetadataConfigWrite (config->files, "files.md");
     25  return true;
     26}
    227
    328int psphotSaveImage (psMetadata *header, psImage *image, char *filename) {
  • trunk/psphot/src/psphotReadout.c

    r10138 r10185  
    3232    // generate a background model (median, smoothed image)
    3333    psphotImageMedian (config, view);
     34
     35    pmReadout *background = psphotSelectBackground (config, view);
    3436
    3537    // find the peaks in the image
     
    111113
    112114    // calculate source magnitudes
    113     psphotMagnitudes(sources, recipe, psf, config);
     115    psphotMagnitudes(sources, recipe, psf, background);
    114116
    115117    // replace background in residual image
Note: See TracChangeset for help on using the changeset viewer.