IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27218


Ignore:
Timestamp:
Mar 5, 2010, 6:09:32 PM (16 years ago)
Author:
Paul Price
Message:

Fix setting of zero points and scaling of images. All images are now scaled to a target zero point (default 25 in all filters). Tested, and seems to work well!

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippconfig/gpc1/Makefile.am

    r26677 r27218  
    1818        ppImage.config \
    1919        ppMerge.config \
     20        ppStack.config \
    2021        psphot.config \
    2122        psastro.config \
  • trunk/ippconfig/gpc1/camera.config

    r26902 r27218  
    119119        PSWARP          STR     gpc1/pswarp.config
    120120        REJECTIONS      STR     gpc1/rejections.config       # rejection recipe
     121        PPSTACK         STR     gpc1/ppStack.config
    121122END
    122123
  • trunk/ippconfig/recipes/ppStack.config

    r27105 r27218  
    6262        y       F32     0.0
    6363END
     64ZP.TARGET       METADATA                # Target zero point by filter
     65        g       F32     25.0
     66        r       F32     25.0
     67        i       F32     25.0
     68        z       F32     25.0
     69        y       F32     25.0
     70END
    6471
    6572PSF.INSTANCES   S32     15              # Number of instances for PSF generation
  • trunk/ppStack/src/ppStackConvolve.c

    r27036 r27218  
    266266        UPDATE_CONCEPT(outCell, "CELL.EXPOSURE", options->sumExposure);
    267267        UPDATE_CONCEPT(outCell, "CELL.DARKTIME", NAN);
     268        UPDATE_CONCEPT(outFPA,  "FPA.ZP",        options->zp);
    268269
    269270        UPDATE_CONCEPT(unconvFPA,  "FPA.EXPOSURE",  options->sumExposure);
    270271        UPDATE_CONCEPT(unconvCell, "CELL.EXPOSURE", options->sumExposure);
    271272        UPDATE_CONCEPT(unconvCell, "CELL.DARKTIME", NAN);
     273        UPDATE_CONCEPT(unconvFPA,  "FPA.ZP",        options->zp);
    272274    }
    273275
  • trunk/ppStack/src/ppStackOptions.c

    r27158 r27218  
    5858    options->quality = 0;
    5959    options->psf = NULL;
     60    options->sumExposure = NAN;
     61    options->zp = NAN;
    6062    options->inputSeeing = NULL;
    6163    options->targetSeeing = NAN;
  • trunk/ppStack/src/ppStackOptions.h

    r27158 r27218  
    2323    float targetSeeing;                 // Target seeing FWHM
    2424    float sumExposure;                  // Sum of exposure times
     25    float zp;                           // Zero point for output
    2526    psVector *inputMask;                // Mask for inputs
    2627    psArray *sourceLists;               // Individual lists of sources for matching
  • trunk/ppStack/src/ppStackSources.c

    r27162 r27218  
    119119        return false;
    120120    }
     121    psMetadata *zpTargetMenu = psMetadataLookupMetadata(NULL, recipe, "ZP.TARGET"); // Target zero point terms
     122    if (!zpTargetMenu) {
     123        psError(PPSTACK_ERR_CONFIG, false, "Unable to find ZP.TARGET in recipe.");
     124        return false;
     125    }
    121126
    122127    int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs
    123128    psAssert(num == sourceLists->n, "Wrong number of source lists: %ld\n", sourceLists->n);
    124129
    125     psVector *zp = psVectorAlloc(num, PS_TYPE_F32); // Zero points for each image
     130    psVector *zp = psVectorAlloc(num, PS_TYPE_F32); // Relative zero points for each image
     131    psVector *zpExp = psVectorAlloc(num, PS_TYPE_F32); // Measured zero points for each image (maybe)
     132    int zpExpNum = 0;                                  // Number of measured zero points
    126133    const char *filter = NULL;          // Filter name
    127134    float airmassTerm = NAN;            // Airmass term
     135    float zpTarget = NAN;               // Target zero point
    128136    float sumExpTime = 0.0;             // Sum of the exposure time
    129137    int numGoodImages = 0;              // Number of good images
     
    160168        float airmass = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.AIRMASS"); // Airmass
    161169        const char *expFilter = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.FILTER"); // Filter name
     170        zpExp->data.F32[i] = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.ZP"); // Exposure zero point
     171        psLogMsg("ppStack", PS_LOG_INFO,
     172                 "Image %d: %.2f sec exposure in %s at airmass %.2f with zero point %.2f",
     173                 i, exptime, expFilter, airmass, zpExp->data.F32[i]);
    162174        if (!isfinite(exptime) || exptime == 0 || !isfinite(airmass) || airmass == 0 ||
    163175            !expFilter || strlen(expFilter) == 0) {
     
    168180            return false;
    169181        }
     182        if (isfinite(zpExp->data.F32[i])) {
     183            zpExp->data.F32[i] += 2.5 * log10(exptime);
     184            zpExpNum++;
     185        }
    170186
    171187        if (!filter) {
    172188            filter = expFilter;
    173             airmassTerm = psMetadataLookupF32(NULL, airmassZP, filter);
    174             if (!isfinite(airmassTerm)) {
     189            bool mdok;
     190            airmassTerm = psMetadataLookupF32(&mdok, airmassZP, filter);
     191            if (!mdok || !isfinite(airmassTerm)) {
    175192                psError(PPSTACK_ERR_CONFIG, false,
    176193                        "Unable to find airmass term (ZP.AIRMASS) for filter %s", filter);
     
    178195                return false;
    179196            }
     197            zpTarget = psMetadataLookupF32(&mdok, zpTargetMenu, filter);
     198            if (!mdok || !isfinite(zpTarget)) {
     199                psError(PPSTACK_ERR_CONFIG, false,
     200                        "Unable to find target zero point (ZP.TARGET) for filter %s", filter);
     201                psFree(zp);
     202                return false;
     203            }
    180204        } else if (strcmp(filter, expFilter) != 0) {
    181205            psError(PPSTACK_ERR_CONFIG, false, "Filters don't match: %s vs %s", filter, expFilter);
     
    184208        }
    185209
    186         zp->data.F32[i] = airmassTerm * airmass - 2.5 * log10(exptime);
     210        zp->data.F32[i] = airmassTerm * airmass + 2.5 * log10(exptime);
    187211        sumExpTime += exptime;
     212
    188213    }
    189214
     
    193218        psLogMsg("ppStack", PS_LOG_WARN, "No images with sources to measure transparency.");
    194219        options->quality = PPSTACK_ERR_REJECTED;
     220        psFree(zp);
     221        psFree(zpExp);
    195222        return true;
    196223    }
     
    205232        options->sources = psMemIncrRefCounter(sources);
    206233        psLogMsg("ppStack", PS_LOG_WARN, "Single image with sources --- no need to match transparency.");
     234        psFree(zp);
     235        psFree(zpExp);
    207236        return true;
     237    }
     238
     239    if (zpExpNum == numGoodImages) {
     240        for (int i = 0; i < num; i++) {
     241            zp->data.F32[i] = zpExp->data.F32[i];
     242        }
    208243    }
    209244
     
    244279                }
    245280                psArray *sources = sourceLists->data[i]; // Sources of interest
    246                 float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i];
     281                float magCorr = zp->data.F32[i] + trans->data.F32[i] - 2.5*log10(sumExpTime);
     282                if (zpExpNum == numGoodImages) {
     283                    // Using measured zero points, so attempt to set target zero point
     284                    magCorr -= zpTarget;
     285                }
    247286                options->norm->data.F32[i] = magCorr;
    248                 psLogMsg("ppStack", PS_LOG_INFO, "Applying magnitude correction to image %d: %f\n",
    249                          i, magCorr);
     287                psLogMsg("ppStack", PS_LOG_INFO,
     288                         "Applying scale correction to image %d: %f mag (%f)\n",
     289                         i, magCorr, trans->data.F32[i]);
    250290
    251291                for (int j = 0; j < sources->n; j++) {
     
    258298            }
    259299        }
     300
     301        if (zpExpNum == numGoodImages) {
     302            // Producing image with target zero point
     303            options->zp = zpTarget;
     304        } else {
     305            options->zp = NAN;
     306        }
     307
    260308
    261309#ifdef TESTING
Note: See TracChangeset for help on using the changeset viewer.