IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36855


Ignore:
Timestamp:
Jun 12, 2014, 11:52:06 PM (12 years ago)
Author:
mhuber
Message:

adding BSCALEOFFSET option hack to apply -0.5*bscale offset to each input warp, default is -0.0 offset

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippconfig/gpc1/ppStack.config

    r36773 r36855  
    160160    STACK.TYPE              STR   DEEP_STACK  ## needed?
    161161    PSF.INPUT.CLIP.SIMPLE   BOOL  True
    162     PSF.INPUT.MAX           F32   6.0   # never really want >6 pixels in refstack, even on edges
     162    PSF.INPUT.MAX           F32   7.0   # center/edge can vary 1-2 pix, prefer <6 pix but needs to be <7 pix for edges
    163163    PSF.INPUT.CLIP.NSIGMA   F32   1.0   # sample typically on rising side of distribution (set even smaller?)
    164164    PSF.INPUT.THRESH        F32   NAN
     
    168168    PSF.TARGET.AS.MAX       BOOL  TRUE      # Set the target PSF FWHM as the maximum of accepted input FWHM values.
    169169    PSF.TARGET.AS.MAX.EPSILON F32 0.1       # Amount to set the target PSF FWHM larger than the maximum input. Target = eps + max(input)
     170    THRESHOLD.MASK  F32     0.1             # Threshold for mask deconvolution (0..1)
     171    COMBINE.ITER    F32     0.5             # Number of rejection iterations per input
     172    COMBINE.REJ     F32     3.0             # Rejection threshold in combination (sigma)
     173    COMBINE.SYS     F32     0.1             # Relative systematic error in combination
     174    COMBINE.DISCARD F32     0.2             # Discard fraction for Olympic weighted mean
     175    IMAGE.REJ       F32     0.1             # Rejected pixel fraction threshold for rejecting entire image
     176    NMINPIX         S32     4               # Minimum input per pixel
     177    MASK.VAL        STR     SUSPECT,MASK.VALUE,CONV.BAD,GHOST # Mask value of input bad pixels
     178    MASK.BLANKBORDER S32    20              # Mask blank border in final stack output
     179    BSCALEOFFSET    BOOL    TRUE            # HACK for removing bscale offset from input warps because of compression (0.5*BSCALE)
    170180END
    171181
     
    193203    MASK.VAL        STR     SUSPECT,MASK.VALUE,CONV.BAD,GHOST # Mask value of input bad pixels
    194204    MASK.BLANKBORDER S32    20              # Mask blank border in final stack output
     205    BSCALEOFFSET    BOOL    TRUE            # HACK for removing bscale offset from input warps because of compression (0.5*BSCALE)
    195206END
    196207
  • trunk/ippconfig/recipes/ppStack.config

    r36773 r36855  
    3434TARGET.MINMAG   F32     3.0             # Minimum magnitude difference to tolerate in stamp
    3535NMINPIX         S32     1               # Minimum input per pixel
     36BSCALEOFFSET    BOOL    FALSE           # HACK for removing offset from input warps because of compression (0.5*BSCALE)
    3637
    3738BACKGROUND.MODEL    BOOL   FALSE        # Construct a stacked version of the warp stage background
  • trunk/ppStack/src/ppStack.h

    r34849 r36855  
    108108                         const psVector *addVariance, // Additional variance for rejection
    109109                         bool safety,                 // Enable safety switch?
    110                          const psVector *norm         // Normalisations to apply
     110                         const psVector *norm,         // Normalisations to apply
     111                         const psVector *bscaleApplyOffset  // hack for offset based on bscale
    111112    );
    112113
  • trunk/ppStack/src/ppStackCombineFinal.c

    r36717 r36855  
    4444
    4545bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options,
    46                          pmConfig *config, bool safe, bool normalise, bool grow)
     46                         pmConfig *config, bool safe, bool normalise, bool grow, bool bscaleoffset)
    4747{
    4848    psAssert(stack, "Require stack");
     
    107107        PS_ARRAY_ADD_SCALAR(job->args, safe, PS_TYPE_U8);
    108108        PS_ARRAY_ADD_SCALAR(job->args, normalise, PS_TYPE_U8);
     109        PS_ARRAY_ADD_SCALAR(job->args, bscaleoffset, PS_TYPE_U8);
    109110        if (!psThreadJobAddPending(job)) {
    110111            psFree(reject);
  • trunk/ppStack/src/ppStackLoop.c

    r36365 r36855  
    120120    psTrace("ppStack", 2, "Final stack of convolved images....\n");
    121121    if (options->convolve) {
    122       if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true)) {
     122      if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true, false)) {
    123123        psError(psErrorCodeLast(), false, "Unable to perform final combination.");
    124124        psFree(stack);
     
    128128    else {
    129129      // Since we haven't convolved, I believe we do need to normalize here.
    130       if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, true, true)) {
     130      //MEH -- see below for comment on ppStackCombineFinal and bscaleOffset
     131      if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, true, true, true)) {
    131132        psError(psErrorCodeLast(), false, "Unable to perform final combination.");
    132133        psFree(stack);
     
    207208        // generate the unconvolved stack. NOTE: this one must be normalized since the inputs have not been
    208209        psTrace("ppStack", 2, "Stack of unconvolved images....\n");
    209         if (!ppStackCombineFinal(stack, options->origCovars, options, config, false, true, false)) {
     210        //MEH -- terrible hack for bscale offset to input warps -- treat like normalization
     211        // -- if BSCALEOFFSET TRUE, 0.5*bscale for offset values, otherwise value 0.0
     212        // -- bscaleOffset set when files read in and applied in CombineFinal (if arg true, only valid for unconv case)
     213        if (!ppStackCombineFinal(stack, options->origCovars, options, config, false, true, false, true)) {
    210214            psError(psErrorCodeLast(), false, "Unable to perform unconvolved combination.");
    211215            psFree(stack);
  • trunk/ppStack/src/ppStackLoop.h

    r34800 r36855  
    6565    bool safe,                          // Allow safe combination?
    6666    bool norm,                          // Normalise images?
    67     bool grow                           // Grow rejection masks?
     67    bool grow,                           // Grow rejection masks?
     68    bool bscaleoffset                   // Apply bscale offset?
    6869    );
    6970
  • trunk/ppStack/src/ppStackOptions.c

    r35167 r36855  
    1919    psFree(options->inputMask);
    2020    psFree(options->sourceLists);
     21    psFree(options->bscaleOffset);
    2122    psFree(options->norm);
    2223    psFree(options->sources);
     
    6566    options->inputMask = NULL;
    6667    options->sourceLists = NULL;
     68    options->bscaleOffset = NULL;
    6769    options->norm = NULL;
    6870    options->sources = NULL;
  • trunk/ppStack/src/ppStackOptions.h

    r35167 r36855  
    3535    float clippedMean;                  // clipped mean of input fwhm
    3636    float clippedStdev;                 // clipped stdev of input fwhm
     37    psVector *bscaleOffset;             // hack offset of bzero using 0.5*bscale if option, 0.0 if not
    3738    // Convolve
    3839    psArray *cells;                     // Cells for convolved images --- a handle for reading again
  • trunk/ppStack/src/ppStackPrepare.c

    r35931 r36855  
    148148    }
    149149
     150    //MEH -- bscale offset hack for warps
     151    options->bscaleOffset = psVectorAlloc(options->num, PS_TYPE_F32);
     152    psVectorInit(options->bscaleOffset, 0.0);
     153    bool setbscaleoffset = psMetadataLookupBool(NULL,recipe, "BSCALEOFFSET");
     154
    150155    psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope
    151156    int numCols = 0, numRows = 0;   // Size of image
     
    162167        }
    163168        options->sumExposure += options->exposures->data.F32[i];
     169
     170        //MEH -- hdu get redefn again below if conv (lots of this happening..)
     171        if (setbscaleoffset) {
     172            pmHDU *hdu = pmHDUFromCell(cell);
     173            assert(hdu && hdu->header);
     174            float bscale = psMetadataLookupF32(NULL, hdu->header, "BSCALE");
     175            options->bscaleOffset->data.F32[i] = 0.5*bscale;
     176        }
     177        psLogMsg("ppStack", PS_LOG_INFO, "bscaleOffset: %d %f", i,options->bscaleOffset->data.F32[i]);
    164178
    165179        // Get list of PSFs, to determine target PSF
  • trunk/ppStack/src/ppStackReadout.c

    r36710 r36855  
    3434    bool safety = PS_SCALAR_VALUE(args->data[4], U8);    // Safety switch on?
    3535    bool normalise = PS_SCALAR_VALUE(args->data[5], U8); // Normalise images?
     36    bool bscaleoffset = PS_SCALAR_VALUE(args->data[6], U8); // Apply bscale offset?
    3637
    3738    psVector *mask = options->inputMask; // Mask for inputs
     
    4041    psVector *addVariance = options->matchChi2; // Additional variance when rejecting
    4142    psVector *norm = normalise ? options->norm : NULL; // Normalisations to apply to images
     43    psVector *bscaleApplyOffset = bscaleoffset ? options->bscaleOffset : NULL; // BSCALE offset to apply to images
    4244
    4345    bool status = ppStackReadoutFinal(config, options->outRO, options->expRO, thread->readouts, mask, reject,
    44                                       weightings, exposures, addVariance, safety, norm); // Status of operation
     46                                      weightings, exposures, addVariance, safety, norm, bscaleApplyOffset); // Status of operation
    4547
    4648    thread->busy = false;
     
    201203                         const psVector *mask, const psArray *rejected, const psVector *weightings,
    202204                         const psVector *exposures, const psVector *addVariance, bool safety,
    203                          const psVector *norm)
     205                         const psVector *norm, const psVector *bscaleApplyOffset)
    204206{
    205207    assert(config);
     
    271273        stack->data[i] = data;
    272274
     275        //MEH -- apply bscale offset before norm   
     276        if (bscaleApplyOffset) {
     277            psLogMsg("ppStack", PS_LOG_INFO, "bscaleApplyOffset: %d %f", i, bscaleApplyOffset->data.F32[i]);
     278            psBinaryOp(ro->image, ro->image, "-", psScalarAlloc(bscaleApplyOffset->data.F32[i], PS_TYPE_F32));
     279        }
     280
    273281        if (norm) {
    274282            float normalise = powf(10.0, -0.4 * norm->data.F32[i]); // Normalisation
  • trunk/ppStack/src/ppStackThread.c

    r34800 r36855  
    277277
    278278    {
    279         psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 6);
     279        psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 7);
    280280        task->function = &ppStackReadoutFinalThread;
    281281        psThreadTaskAdd(task);
Note: See TracChangeset for help on using the changeset viewer.