IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19914


Ignore:
Timestamp:
Oct 6, 2008, 3:15:02 AM (18 years ago)
Author:
eugene
Message:

psf clump is now measured on subregions, and stored in associated metadatas in the recipe

File:
1 edited

Legend:

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

    r16820 r19914  
    11# include "psphotInternal.h"
    22
    3 # define CHECK_STATUS(S,MSG) { \
    4   if (!status) { \
    5     psError(PSPHOT_ERR_CONFIG, false, "missing PSF Clump entry: %s\n", MSG); \
    6     return false; \
    7   } }
     3# define CHECK_STATUS(S,MSG) {                                          \
     4        if (!status) {                                                  \
     5            psError(PSPHOT_ERR_CONFIG, false, "missing PSF Clump entry: %s\n", MSG); \
     6            return false;                                               \
     7        } }
     8
     9bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *recipe, const bool havePSF);
    810
    911// 2006.02.02 : no leaks
    10 bool psphotRoughClass (psArray *sources, psMetadata *recipe, const bool havePSF) {
     12bool psphotRoughClass (pmReadout *readout, psArray *sources, psMetadata *recipe, const bool havePSF) {
    1113
    1214    bool status;
    13     static pmPSFClump psfClump;
    1415
    1516    psTimerStart ("psphot");
    1617
    17     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    18     psMaskType maskSat = psMetadataLookupU8(&status, recipe, "MASK.SAT"); // Mask value for bad pixels
    19     assert (maskSat);
     18    // we make this measurement on a NxM grid of regions across the readout
     19    int NX  = psMetadataLookupS32 (&status, recipe, "PSF_CLUMP_NX");  CHECK_STATUS (status, "PSF_CLUMP_NX");
     20    int NY  = psMetadataLookupS32 (&status, recipe, "PSF_CLUMP_NY");  CHECK_STATUS (status, "PSF_CLUMP_NY");
     21    int dX  = readout->image->numCols / NX;
     22    int dY  = readout->image->numRows / NY;
    2023
    21     if (!havePSF) {
    22         // determine the PSF parameters from the source moment values
    23         psfClump = pmSourcePSFClump (sources, recipe);
    24         psMetadataAddF32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.X",  PS_META_REPLACE, "psf clump center", psfClump.X);
    25         psMetadataAddF32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.Y",  PS_META_REPLACE, "psf clump center", psfClump.Y);
    26         psMetadataAddF32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX);
    27         psMetadataAddF32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY);
    28     } else {
    29         // pull FWHM_X,Y from the recipe, use to define psfClump.X,Y
    30         psfClump.X  = psMetadataLookupF32 (&status, recipe, "PSF.CLUMP.X");  CHECK_STATUS (status, "PSF.CLUMP.X");
    31         psfClump.Y  = psMetadataLookupF32 (&status, recipe, "PSF.CLUMP.Y");  CHECK_STATUS (status, "PSF.CLUMP.Y");
    32         psfClump.dX = psMetadataLookupF32 (&status, recipe, "PSF.CLUMP.DX");  CHECK_STATUS (status, "PSF.CLUMP.DX");
    33         psfClump.dY = psMetadataLookupF32 (&status, recipe, "PSF.CLUMP.DY");  CHECK_STATUS (status, "PSF.CLUMP.DY");
     24    int nRegion = 0;
     25    for (int ix = 0; ix < NX; ix ++) {
     26        for (int iy = 0; iy < NY; iy ++) {
     27
     28            psRegion region = psRegionSet (ix*dX, (ix + 1)*dX, iy*dY, (iy + 1)*dY);
     29            if (!psphotRoughClassRegion (nRegion, &region, sources, recipe, havePSF)) {
     30                psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classification for region %d (%f - %f : %f - %f)\n",
     31                         nRegion, region.x0, region.x1, region.y0, region.y1);
     32                return false;
     33            }
     34           
     35            nRegion ++;
     36        }
    3437    }
    35 
    36     if (psfClump.X < 0) {
    37         psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourcePSFClump");
    38         return false;
    39     }
    40     if (!psfClump.X || !psfClump.Y) {
    41         psError(PSPHOT_ERR_DATA, true, "Failed to find a valid PSF clump");
    42         return false;
    43     }
    44     psLogMsg ("psphot", 3, "psf clump  X,  Y: %f, %f\n", psfClump.X, psfClump.Y);
    45     psLogMsg ("psphot", 3, "psf clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);
    46 
    47     // group into STAR, COSMIC, EXTENDED, SATURATED, etc.
    48     if (!pmSourceRoughClass (sources, recipe, psfClump, maskSat)) {
    49         psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourceRoughClass");
    50         return false;
    51     }
     38    psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS",  PS_META_REPLACE, "psf clump regions", nRegion);
    5239
    5340    // optional printout of source moments only
     
    5643    psLogMsg ("psphot.roughclass", PS_LOG_INFO, "rough classification: %f sec\n", psTimerMark ("psphot"));
    5744
     45    psphotVisualPlotMoments (recipe, sources);
     46    psphotVisualShowRoughClass (sources);
     47    psphotVisualShowFlags (sources);
     48
    5849    return true;
    5950}
    6051
     52bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *recipe, const bool havePSF) {
     53
     54    bool status;
     55    char regionName[64];
     56    pmPSFClump psfClump;
     57
     58    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     59    psMaskType maskSat = psMetadataLookupU8(&status, recipe, "MASK.SAT"); // Mask value for bad pixels
     60    assert (maskSat);
     61
     62    snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", nRegion);
     63    psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);
     64    if (!regionMD) {
     65        regionMD = psMetadataAlloc();
     66        psMetadataAddMetadata (recipe, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD);
     67        psFree (regionMD);
     68    }
     69
     70    if (!havePSF) {
     71        // determine the PSF parameters from the source moment values
     72        psfClump = pmSourcePSFClump (region, sources, recipe);
     73        psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X",  PS_META_REPLACE, "psf clump center", psfClump.X);
     74        psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y",  PS_META_REPLACE, "psf clump center", psfClump.Y);
     75        psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX);
     76        psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY);
     77    } else {
     78        // pull FWHM_X,Y from the recipe, use to define psfClump.X,Y
     79        psfClump.X  = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X");   CHECK_STATUS (status, "PSF.CLUMP.X");
     80        psfClump.Y  = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y");   CHECK_STATUS (status, "PSF.CLUMP.Y");
     81        psfClump.dX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX");  CHECK_STATUS (status, "PSF.CLUMP.DX");
     82        psfClump.dY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY");  CHECK_STATUS (status, "PSF.CLUMP.DY");
     83    }
     84
     85    if (psfClump.X < 0) {
     86        psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourcePSFClump");
     87        return false;
     88    }
     89    if (!psfClump.X || !psfClump.Y) {
     90        psError(PSPHOT_ERR_DATA, true, "Failed to find a valid PSF clump");
     91        return false;
     92    }
     93    psLogMsg ("psphot", 3, "psf clump  X,  Y: %f, %f\n", psfClump.X, psfClump.Y);
     94    psLogMsg ("psphot", 3, "psf clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);
     95
     96    // group into STAR, COSMIC, EXTENDED, SATURATED, etc.
     97    if (!pmSourceRoughClass (region, sources, recipe, psfClump, maskSat)) {
     98        psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourceRoughClass");
     99        return false;
     100    }
     101
     102    return true;
     103}
Note: See TracChangeset for help on using the changeset viewer.