IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29552


Ignore:
Timestamp:
Oct 25, 2010, 3:22:33 PM (16 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20100823

Location:
trunk/ppStack/src
Files:
6 edited

Legend:

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

    r27319 r29552  
    124124        psLibFinalize();
    125125        pmVisualClose();
     126        pmVisualCleanup ();
    126127
    127128        exitValue = ppStackExitCode(exitValue);
  • trunk/ppStack/src/ppStackCombineFinal.c

    r28405 r29552  
    9393
    9494    // Sum covariance matrices
     95    // the array may be defined, but no covariances actually supplied.
     96    bool haveCovariances = false;
    9597    if (covariances) {
     98        for (int i = 0; i < covariances->n; i++) {
     99            haveCovariances |= (covariances->data[i] != NULL);
     100        }
     101    }
     102
     103    if (haveCovariances) {
    96104        outRO->covariance = psImageCovarianceAverageWeighted(covariances, options->weightings);
    97105    } else {
  • trunk/ppStack/src/ppStackLoop.c

    r28182 r29552  
    204204#if 1
    205205    // Unconvolved stack --- it's cheap to calculate, compared to everything else!
     206    // XXX unconvolved stack is currently using the convolved mask!  oops!
    206207    if (options->convolve) {
    207208        // Start threading
  • trunk/ppStack/src/ppStackMatch.c

    r28253 r29552  
    6868
    6969    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    70     psMetadataAddU8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad);
     70    psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad);
    7171
    7272    psImage *binned = psphotModelBackgroundReadoutNoFile(ro, config); // Binned background model
     
    153153    int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
    154154
    155     if (!pmReadoutMaskNonfinite(readout, maskVal)) {
     155    // Replaced pmReadoutMaskNonfinite with pmReadoutMaskInvalid (tests for already masked pixels)
     156    if (!pmReadoutMaskInvalid(readout, maskVal, maskBad)) {
    156157        psError(psErrorCodeLast(), false, "Unable to mask non-finite pixels in readout.");
    157158        return false;
     
    319320                }
    320321            } else {
     322                // we need to register the FWHM values for use downstream
     323                pmSubtractionSetFWHMs(options->inputSeeing->data.F32[index], options->targetSeeing);
     324
    321325                // Scale the input parameters
    322326                psVector *widthsCopy = psVectorCopy(NULL, widths, PS_TYPE_F32); // Copy of kernel widths
    323                 if (scale && !pmSubtractionParamsScale(&size, &footprint, widthsCopy,
    324                                                        options->inputSeeing->data.F32[index],
    325                                                        options->targetSeeing, scaleRef, scaleMin, scaleMax)) {
     327                if (scale && !pmSubtractionParamsScale(&size, &footprint, widthsCopy, scaleRef, scaleMin, scaleMax)) {
    326328                    psError(psErrorCodeLast(), false, "Unable to scale kernel parameters");
    327329                    psFree(fake);
  • trunk/ppStack/src/ppStackPSF.c

    r27004 r29552  
    1515{
    1616    bool mdok = false;
     17    pmPSF *psf = NULL;
    1718
    18 #ifndef TESTING
    1919    // Get the recipe values
    2020    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
    2121    psAssert(recipe, "We've thrown an error on this before.");
    2222
    23     int psfInstances = psMetadataLookupS32(NULL, recipe, "PSF.INSTANCES"); // Number of instances for PSF
    24     float psfRadius = psMetadataLookupF32(NULL, recipe, "PSF.RADIUS"); // Radius for PSF
    25     const char *psfModel = psMetadataLookupStr(NULL, recipe, "PSF.MODEL"); // Model for PSF
    26     int psfOrder = psMetadataLookupS32(NULL, recipe, "PSF.ORDER"); // Spatial order for PSF
    27 
    28     psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in
    29     if (!mdok || !maskValStr) {
    30         psError(PPSTACK_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe");
    31         return false;
    32     }
    33     psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
    34 
    35     for (int i = 0; i < psfs->n; i++) {
    36         if (inputMask->data.U8[i]) {
    37             psFree(psfs->data[i]);
    38             psfs->data[i] = NULL;
    39         }
     23    bool autosize = psMetadataLookupBool(&mdok, recipe, "PSF.AUTOSIZE"); // Spatial order for PSF
     24    if (!mdok) {
     25        // older config files which lack PSF.AUTOSIZE used TRUE as the default
     26        autosize = true;
    4027    }
    4128
    42     // Solve for the target PSF
    43     pmPSF *psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal);
    44     if (!psf) {
    45         psError(PPSTACK_ERR_PSF, false, "Unable to determine output PSF.");
    46         return NULL;
     29    char *psfModel = psMetadataLookupStr(NULL, recipe, "PSF.MODEL"); // Model for PSF
     30
     31    if (autosize) {
     32
     33        int psfInstances = psMetadataLookupS32(NULL, recipe, "PSF.INSTANCES"); // Number of instances for PSF
     34        float psfRadius = psMetadataLookupF32(NULL, recipe, "PSF.RADIUS"); // Radius for PSF
     35        int psfOrder = psMetadataLookupS32(NULL, recipe, "PSF.ORDER"); // Spatial order for PSF
     36
     37        psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in
     38        if (!mdok || !maskValStr) {
     39            psError(PPSTACK_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe");
     40            return NULL;
     41        }
     42        psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
     43
     44        for (int i = 0; i < psfs->n; i++) {
     45            if (inputMask->data.U8[i]) {
     46                psFree(psfs->data[i]);
     47                psfs->data[i] = NULL;
     48            }
     49        }
     50
     51        // Solve for the target PSF
     52        psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal);
     53        if (!psf) {
     54            psError(PPSTACK_ERR_PSF, false, "Unable to determine output PSF.");
     55            return NULL;
     56        }
     57    } else {
     58
     59        // Manually defined target PSF
     60        float psfFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.OUTPUT.FWHM"); // Radius for PSF
     61        if (!mdok) {
     62            psfFWHM = 4.0;
     63        }
     64
     65        float Mxx = M_SQRT2 * psfFWHM / 2.35;
     66
     67        psf = pmPSFBuildSimple(psfModel, Mxx, Mxx, 0.0, 0.0);
     68        if (!psf) {
     69            psError(PPSTACK_ERR_PSF, false, "Unable to build dummy PSF.");
     70            return NULL;
     71        }
    4772    }
    48 #else
    49     // Dummy PSF
    50     pmPSF *psf = pmPSFBuildSimple("PS_MODEL_PS1_V1", 4.0, 4.0, 0.0, 1.0);
    51     if (!psf) {
    52         psError(PPSTACK_ERR_PSF, false, "Unable to build dummy PSF.");
    53         return NULL;
    54     }
    55 #endif
    5673
    5774    return psf;
  • trunk/ppStack/src/ppStackReadout.c

    r27427 r29552  
    130130    int kernelSize = psMetadataLookupS32(NULL, ppsub, "KERNEL.SIZE"); // Kernel half-size
    131131
    132     psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in
    133     psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     132    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask for bad
     133    psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     134
    134135    psString maskSuspectStr = psMetadataLookupStr(NULL, recipe, "MASK.SUSPECT"); // Name of suspect mask bits
    135136    psImageMaskType maskSuspect = pmConfigMaskGet(maskSuspectStr, config); // Suspect bits
    136     psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    137     psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     137
     138    bool status = false;
     139    psImageMaskType maskBlank;
     140    psString maskBlankStr = psMetadataLookupStr(&status, recipe, "MASK.BLANK"); // Name of bits to set for empty pixels
     141    if (maskBlankStr) {
     142      maskBlank = pmConfigMaskGet(maskBlankStr, config); // Bits to mask for bad pixels
     143    } else {
     144      maskBlankStr = psMetadataLookupStr(&status, recipe, "MASK.BAD"); // Old name for MASK.BLANK
     145      if (maskBlankStr) {
     146        maskBlank = pmConfigMaskGet(maskBlankStr, config); // Bits to mask for bad pixels
     147      } else {
     148        maskBlank = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels
     149      }
     150    }
    138151
    139152    int num = readouts->n;              // Number of inputs
     
    157170    }
    158171
    159     if (!pmStackCombine(outRO, NULL, stack, maskVal | maskBad, maskSuspect, maskBad, kernelSize, iter,
     172    if (!pmStackCombine(outRO, NULL, stack, maskBad, maskSuspect, maskBlank, kernelSize, iter,
    160173                        combineRej, combineSys, combineDiscard, useVariance, safe, false)) {
    161174        psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection.");
     
    215228    bool safe = psMetadataLookupBool(&mdok, recipe, "SAFE"); // Be safe when combining small numbers of pixels
    216229
    217     psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in
    218     psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     230    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask for bad
     231    psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     232
    219233    psString maskSuspectStr = psMetadataLookupStr(NULL, recipe, "MASK.SUSPECT"); // Name of suspect mask bits
    220234    psImageMaskType maskSuspect = pmConfigMaskGet(maskSuspectStr, config); // Suspect bits
    221     psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    222     psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     235
     236    bool status = false;
     237    psImageMaskType maskBlank;
     238    psString maskBlankStr = psMetadataLookupStr(&status, recipe, "MASK.BLANK"); // Name of bits to set for empty pixels
     239    if (maskBlankStr) {
     240      maskBlank = pmConfigMaskGet(maskBlankStr, config); // Bits to mask for bad pixels
     241    } else {
     242      maskBlankStr = psMetadataLookupStr(&status, recipe, "MASK.BAD"); // Old name for MASK.BLANK
     243      if (maskBlankStr) {
     244        maskBlank = pmConfigMaskGet(maskBlankStr, config); // Bits to mask for bad pixels
     245      } else {
     246        maskBlank = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels
     247      }
     248    }
    223249
    224250    int num = readouts->n;              // Number of inputs
     
    257283    }
    258284
    259     if (!pmStackCombine(outRO, expRO, stack, maskVal | maskBad, maskSuspect, maskBad, 0, iter, combineRej,
     285    if (!pmStackCombine(outRO, expRO, stack, maskBad, maskSuspect, maskBlank, 0, iter, combineRej,
    260286                        combineSys, combineDiscard, useVariance, safe, rejected)) {
    261287        psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts.");
Note: See TracChangeset for help on using the changeset viewer.