IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21109


Ignore:
Timestamp:
Jan 12, 2009, 4:19:18 PM (17 years ago)
Author:
Paul Price
Message:

Generate a proper background model using psphot, instead of a really braindead model that causes bad photometry. Compiles, but not tested yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_20090108/ppStack/src/ppStackMatch.c

    r21106 r21109  
    66#include <pslib.h>
    77#include <psmodules.h>
     8#include <psphot.h>
    89
    910#include "ppStack.h"
     
    119120}
    120121
     122// Add background into the fake image
     123// Based on ppSubBackground()
     124static psImage *stackBackgroundModel(pmReadout *ro, // Readout for which to generate background model
     125                                     const pmConfig *config // Configuration
     126    )
     127{
     128    psAssert(ro && ro->image, "Need readout image");
     129    psAssert(config, "Need configuration");
     130
     131    psImage *image = ro->image;         // Image of interest
     132    int numCols = image->numCols, numRows = image->numRows; // Size of image
     133
     134    psMetadata *ppStackRecipe = psMetadataLookupPtr(NULL, config->recipes, PPSTACK_RECIPE);
     135    psAssert(ppStackRecipe, "Need PPSTACK recipe");
     136    psMetadata *psphotRecipe = psMetadataLookupPtr(NULL, config->recipes, PSPHOT_RECIPE);
     137    psAssert(psphotRecipe, "Need PSPHOT recipe");
     138
     139    psString maskBadStr = psMetadataLookupStr(NULL, ppStackRecipe, "MASK.BAD");// Name of bits to mask for bad
     140    psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     141
     142    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     143    psMetadataAddU8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad);
     144
     145    psImage *binned = psphotBackgroundModel(ro, config); // Binned background model
     146    psImageBinning *binning = psMetadataLookupPtr(NULL, psphotRecipe,
     147                                                  "PSPHOT.BACKGROUND.BINNING"); // Binning for model
     148    psAssert(binning, "Need binning parameters");
     149    psImage *unbinned = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Unbinned background model
     150    if (!psImageUnbin(unbinned, binned, binning)) {
     151        psError(PS_ERR_UNKNOWN, false, "Unable to unbin background model");
     152        psFree(unbinned);
     153        return NULL;
     154    }
     155
     156    // XXX should these really be here?? (probably not...)
     157    // pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
     158    // pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
     159
     160     return unbinned;
     161}
     162
     163
     164
     165
     166#if 0
    121167#define BG_SIZE 64                      // Large box half-size in which to measure background
    122168
     
    174220    return bgImage;
    175221}
     222#endif
     223
    176224
    177225bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, float *chi2, float *weighting,
     
    372420            }
    373421
    374 
    375 #if 0
    376422            // Add the background into the target image
    377             psImage *bgImage = stackBackgroundModel(readout, maskVal, stampSources, footprint); // Image of background
     423            psImage *bgImage = stackBackgroundModel(readout, config); // Image of background
    378424            psBinaryOp(fake->image, fake->image, "+", bgImage);
    379425            psFree(bgImage);
    380 #endif
    381 
    382426
    383427#ifdef TESTING
Note: See TracChangeset for help on using the changeset viewer.