IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 27, 2018, 4:11:05 PM (8 years ago)
Author:
eugene
Message:

add options and elements for HSC ghosts and glints

Location:
trunk/psastro
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro

  • trunk/psastro/src/psastroMaskUpdates.c

    r33851 r40490  
    129129   
    130130    bool REFSTAR_MASK_BLEED                = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_BLEED");
    131 
     131    bool REFSTAR_MASK_BLEED_ORIENTATION_X  = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_BLEED_ORIENTATION_X");
     132    bool REFSTAR_MASK_BLEED_ORIENTATION_Y  = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_BLEED_ORIENTATION_Y");
     133
     134   
    132135    double REFSTAR_MASK_MAX_MAG            = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_MAX_MAG");
    133136    double REFSTAR_MASK_SATSTAR_MAG_SLOPE  = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_SATSTAR_MAG_SLOPE");
     
    143146    double REFSTAR_MASK_BLEED_MAG_SLOPE    = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_BLEED_MAG_SLOPE");
    144147
     148    double REFSTAR_MASK_BLEED_MAG_MAX_X    = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_BLEED_MAG_MAX_X");
     149    double REFSTAR_MASK_BLEED_MAG_SLOPE_X  = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_BLEED_MAG_SLOPE_X");
     150    double REFSTAR_MASK_BLEED_MAG_MAX_Y    = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_BLEED_MAG_MAX_Y");
     151    double REFSTAR_MASK_BLEED_MAG_SLOPE_Y  = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_BLEED_MAG_SLOPE_Y");
     152
    145153    double REFSTAR_MASK_CROSSTALK_MAG_MAX  = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_CROSSTALK_MAG_MAX");
    146154    double REFSTAR_MASK_CROSSTALK_MAG_SLOPE= psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_CROSSTALK_MAG_SLOPE");
     
    180188    }
    181189
     190    psTrace("psastro.masks",2,"Configuration loaded for masking.");
     191   
    182192    // recipe values are given in instrumental magnitudes
    183193    // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime)
     
    187197    REFSTAR_MASK_SATSPIKE_MAG_MAX += MagOffset;
    188198    REFSTAR_MASK_BLEED_MAG_MAX += MagOffset;
     199    REFSTAR_MASK_BLEED_MAG_MAX_X += MagOffset;
     200    REFSTAR_MASK_BLEED_MAG_MAX_Y += MagOffset;
     201   
    189202    GHOST_MAX_MAG += MagOffset;
    190203
     204    psTrace("psastro.masks",2,"Magnitudes: max_mag: %f satstar: %f satspike: %f bleed: %f ghost %f\n",
     205            REFSTAR_MASK_MAX_MAG,REFSTAR_MASK_SATSTAR_MAG_MAX,REFSTAR_MASK_SATSPIKE_MAG_MAX,REFSTAR_MASK_BLEED_MAG_MAX,GHOST_MAX_MAG);
     206   
    191207    // select the output mask image :: we mosaic to chip mosaic format
    192208    pmFPAfile *outMask = psMetadataLookupPtr (NULL, config->files, "PSASTRO.OUTPUT.MASK");
     
    287303                if (!refstars) continue;
    288304
     305                psTrace("psastro.masks",2,"In Readout loop.");
    289306                // we need to generate the following masks regions:
    290307                // 1) circle around the saturated stars (scaled by magnitude)
     
    301318                        }
    302319                    }
    303 
     320                    psTrace("psastro.masks",4,"In refstar loop: %d/%ld %f %f\n",
     321                            i,refstars->n,ref->Mag,REFSTAR_MASK_MAX_MAG);
    304322                    if (ref->Mag > REFSTAR_MASK_MAX_MAG) continue;
    305323
     
    334352
    335353                        // The length should also be a function of the image background level
    336 
     354                        psTrace("psastro.masks",4,"Masking: Radius: %f Theta: %f Length: %f Width: %f\n",
     355                                radius,Theta,spikeLength,spikeWidth);
     356                        psTrace("psastro.masks",4,"Also: %f %f %f %f\n",ref->chip->x,ref->chip->y,ROTANGLE,REFSTAR_MASK_SATSTAR_POS_ZERO);
    337357                        psastroMaskBox (readoutMask->mask, spikeMaskValue, ref->chip->x, ref->chip->y, spikeLength, spikeWidth, Theta);
    338358                    }
     
    349369                            float xCell = 0.0;
    350370                            float yCell = 0.0;
    351                             float xEnd = 0.0;
    352                             float yEnd = 0.0;
     371                            float xStart = 0.0;
     372                            float xEnd   = 0.0;
     373                            float yStart = 0.0;
     374                            float yEnd   = 0.0;
     375                            //                            float xEnd = 0.0;
     376                            //                            float yEnd = 0.0;
     377                            float width = 0.0;
     378                            float length = 0.0;
    353379                            // find coordinate of star on cell
    354380                            pmCellCoordsForChip (&xCell, &yCell, refCell, ref->chip->x, ref->chip->y);
    355381                            // find coordinate of end-point on chip
    356382
    357                             int ySize = psMetadataLookupS32(NULL, refCell->concepts, "CELL.YSIZE");
    358                             pmChipCoordsForCell (&xEnd, &yEnd, refCell, xCell, ySize);
    359 
    360                             float width = REFSTAR_MASK_BLEED_MAG_SLOPE*(REFSTAR_MASK_BLEED_MAG_MAX - ref->Mag);
    361                             psastroMaskRectangle (readoutMask->mask, spikeMaskValue, (int) ref->chip->x-0.5*width, (int) ref->chip->y, (int) ref->chip->x+0.5*width+1, yEnd);
     383                            if (REFSTAR_MASK_BLEED_ORIENTATION_X) {
     384                              length = pow(10,REFSTAR_MASK_BLEED_MAG_SLOPE_X*(REFSTAR_MASK_BLEED_MAG_MAX_X - ref->Mag));
     385                              width  = REFSTAR_MASK_BLEED_MAG_SLOPE  *(REFSTAR_MASK_BLEED_MAG_MAX - ref->Mag);
     386
     387                              pmChipCoordsForCell (&xStart, &yStart, refCell, xCell - length, yCell - 0.5 * width);
     388                              pmChipCoordsForCell (&xEnd, &yEnd,     refCell, xCell + length, yCell + 0.5 * width);
     389                              psastroMaskRectangle (readoutMask->mask, spikeMaskValue, (int) xStart, (int) yStart, (int) xEnd, (int) yEnd + 1);
     390                            }
     391                            if (REFSTAR_MASK_BLEED_ORIENTATION_Y) {
     392                              length = pow(10,REFSTAR_MASK_BLEED_MAG_SLOPE_Y*(REFSTAR_MASK_BLEED_MAG_MAX_Y - ref->Mag));
     393                              width  = REFSTAR_MASK_BLEED_MAG_SLOPE  *(REFSTAR_MASK_BLEED_MAG_MAX - ref->Mag);
     394
     395                              pmChipCoordsForCell (&xStart, &yStart, refCell, xCell - 0.5 * width, yCell - length);
     396                              pmChipCoordsForCell (&xEnd, &yEnd,     refCell, xCell + 0.5 * width, yCell + length);
     397                              psastroMaskRectangle (readoutMask->mask, spikeMaskValue, (int) xStart, (int) yStart, (int) xEnd + 1, (int) yEnd);
     398                            }
     399                           
    362400                        }
    363401                    }
     
    392430                    }
    393431                }
    394 
     432                // Because it's very GPC1-specific, handle alternate glint types here
     433                psArray *hsc_glints = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.GLINTS.HSC");
     434                if (hsc_glints) {
     435                  for (int i = 0; i < hsc_glints->n; i++) {
     436                    // Contains (start_x, start_y, length, width, theta)
     437                    psVector *glint = hsc_glints->data[i];
     438
     439                    psTrace("psastro.masks", 4, "Masking glint %d on chip %s with params (%f,%f,%f,%f,%f)\n",
     440                            i, psMetadataLookupStr(&status,readout->parent->parent->concepts,"CHIP.NAME"),
     441                            glint->data.F32[0], glint->data.F32[1],
     442                            glint->data.F32[2], glint->data.F32[3], glint->data.F32[4]);
     443
     444                    psastroMaskBox (readoutMask->mask, glintMaskValue, glint->data.F32[0], glint->data.F32[1],
     445                                    glint->data.F32[2], glint->data.F32[3], glint->data.F32[4]);
     446                  }
     447                }
     448               
    395449                // Select the crosstalk artifact regions for this readout, and mask a circular region
    396450                // corresponding to the source star
Note: See TracChangeset for help on using the changeset viewer.