IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 7, 2009, 4:08:25 PM (17 years ago)
Author:
Paul Price
Message:

Merging trunk (r25026) to get up-to-date on old branch.

Location:
branches/pap
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/psastro

    • Property svn:mergeinfo deleted
  • branches/pap/psastro/src/psastroMaskUpdates.c

    r23844 r25027  
    2828    pmCell *cell = NULL;
    2929    pmReadout *readout = NULL;
    30     float zeropt, exptime;
     30    float zeropt, exptime, GHOST_MAX_MAG;
    3131
    3232    psImageMaskType ghostMaskValue = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
     33    psImageMaskType glintMaskValue = pmConfigMaskGet("GHOST", config); // Mask value for glint pixels (overload ghost)
    3334    psImageMaskType spikeMaskValue = pmConfigMaskGet("SPIKE", config); // Mask value for ghost pixels
    3435    psImageMaskType starMaskValue  = pmConfigMaskGet("STARCORE", config); // Mask value for ghost pixels
     
    5354    }
    5455    bool COUNT_GHOSTS = psMetadataLookupF32 (&status, recipe, "REFSTAR_COUNT_GHOSTS");
    55     double GHOST_MAX_MAG = psMetadataLookupF32 (&status, recipe, "GHOST_MAX_MAG");
    5656    int nGhosts = 0;
     57
     58    // convert star positions to glint positions and add to the fpa->analysis data
     59    if (!psastroLoadGlints (config)) {
     60        psError(PSASTRO_ERR_CONFIG, false, "Error loading glints");
     61        return false;
     62    }
    5763
    5864    psLogMsg ("psastro", PS_LOG_INFO, "generating a bright-star mask");
     
    7985
    8086    // really error-out here?  or just skip?
    81     if (!psastroZeroPointFromRecipe (&zeropt, &exptime, fpa, recipe)) {
     87    if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &GHOST_MAX_MAG, fpa, recipe)) {
    8288        psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
    8389        return false;
     
    221227                    }
    222228
     229                    // This masking option was needed for persistent charge trails in GPC1; it
     230                    // has since been replaced with 'burntool', which is applied upon readout
     231                    // by the camera software, and therefore is aware of the image sequence.
    223232                    if (REFSTAR_MASK_BLEED) {
    224 
    225233                        // convert x,y chip coordinates to cells in maskChip
    226234                        pmCell *refCell = pmCellInChip (refChip, ref->chip->x, ref->chip->y);
     
    245253                }
    246254
    247                 // select the raw objects for this readout (loaded in psastroExtract.c)
     255                // select the ghost object for this readout (loaded in psastroExtractGhosts.c).
     256                // These differ from the reference stars since the star position is not
     257                // contained by the readout; instead, the ghost position is predicted based on
     258                // the ghost model, and the ghost positions associated with a given readout are
     259                // supplied here.
    248260                psArray *ghosts = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.GHOSTS");
    249                 if (ghosts == NULL) { continue; }
    250 
    251                 // identify the bright stars of interest
    252                 for (int i = 0; i < ghosts->n; i++) {
    253                     psastroGhost *ghost = ghosts->data[i];
    254                     // XXX bright vs faint ghost bits? (OR with SUSPECT)
    255                     psastroMaskEllipticalAnnulus (readoutMask->mask, ghostMaskValue, ghost->chip->x, ghost->chip->y, ghost->inner, ghost->outer);
    256                 }
    257 
    258                 // select the raw objects for this readout, flag is they fall in a mask
    259                 psArray *rawstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.RAWSTARS");
    260                 if (rawstars == NULL) return false;
     261                if (ghosts) {
     262                    // mask the ghosts on this readout
     263                    for (int i = 0; i < ghosts->n; i++) {
     264                        psastroGhost *ghost = ghosts->data[i];
     265                        // XXX bright vs faint ghost bits? (OR with SUSPECT)
     266                        psastroMaskEllipticalAnnulus (readoutMask->mask, ghostMaskValue, ghost->chip->x, ghost->chip->y, ghost->inner, ghost->outer);
     267                    }
     268                }
     269
     270                // Select the glint mask regions for this readout (loaded in
     271                // psastroExtractGlints.c).  These glint regions are defined as rectangular
     272                // boxes and are generated for each chip based on the position of the bright
     273                // stars beyond the edge of the focal plane.  This masking is currently very
     274                // GPC1-specific
     275                psArray *glints = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.GLINTS");
     276                if (glints) {
     277                    // mask the glints on this readout
     278                    for (int i = 0; i < glints->n; i++) {
     279                        psRegion *glint = glints->data[i];
     280                        psastroMaskRectangle (readoutMask->mask, glintMaskValue, glint->x0, glint->y0, glint->x1, glint->y1);
     281                    }
     282                }
     283
     284                // this probably should move into a function of its own:
     285                {
     286                    // select the raw objects for this readout, flag is they fall in a mask
     287                    psArray *inSources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     288                    if (inSources == NULL) continue;
    261289               
    262                 // XXX finish this:
    263                 for (int i = 0; i < rawstars->n; i++) {
    264                     pmAstromObj *raw = rawstars->data[i];
    265                     psImageMaskType value = readoutMask->mask->data.PS_TYPE_IMAGE_MASK_DATA[(int)(raw->chip->x)][(int)(raw->chip->y)];
    266                     if (value) continue;
     290                    // create a replacement output array:
     291                    // psArray *outSources = psAllocArrayEmpty(100);
     292
     293                    // XXX finish this: raise a bit for stars that land on certain types of masks;
     294                    // others (eg, bright star core) should be ignored.
     295                    for (int i = 0; i < inSources->n; i++) {
     296                        pmSource *source = inSources->data[i];
     297
     298                        int xChip = source->peak->x;
     299                        int yChip = source->peak->y;
     300
     301                        bool onChip = true;
     302                        onChip &= (xChip >= 0);
     303                        onChip &= (xChip < readoutMask->mask->numCols);
     304                        onChip &= (yChip >= 0);
     305                        onChip &= (yChip < readoutMask->mask->numRows);
     306                        if (!onChip) {
     307                            // if the source is off the edge of the chip, raise a different bit?
     308                            source->mode |= PM_SOURCE_MODE_OFF_CHIP;
     309                            continue;
     310                        }
     311
     312                        psImageMaskType value = readoutMask->mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip];
     313                        if (value & ghostMaskValue) {
     314                            source->mode |= PM_SOURCE_MODE_ON_GHOST;
     315                        }
     316                        // XXX note that for now, glint and ghost are identical
     317                        pmSourceMode PM_SOURCE_MODE_ON_GLINT = PM_SOURCE_MODE_ON_GHOST;
     318                        if (value & glintMaskValue) {
     319                            source->mode |= PM_SOURCE_MODE_ON_GLINT;
     320                        }
     321                        if (value & spikeMaskValue) {
     322                            source->mode |= PM_SOURCE_MODE_ON_SPIKE;
     323                        }
     324                    }
    267325                }
    268326            }
Note: See TracChangeset for help on using the changeset viewer.