IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 27, 2020, 2:21:31 PM (6 years ago)
Author:
tdeboer
Message:

gpc1 dynamic masks set up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroLoadGlints.c

    r41348 r41367  
    2626    bool status;
    2727    float zeropt, exptime;
     28    psVector *x_glint = psVectorAlloc(2,PS_TYPE_F32);
     29    psVector *y_glint = psVectorAlloc(2,PS_TYPE_F32);
    2830
    2931    psLogMsg ("psastro", PS_LOG_INFO, "determine glint positions");
     
    3941    if (!REFSTAR_MASK_GLINTS) return true;
    4042
    41     // select the limiting magnitude
     43    // select relevant keywords
    4244    double GLINT_MAX_MAG = psMetadataLookupF32 (&status, recipe, "GLINT_MAX_MAG");
    4345    double GLINT_LENGTH_MAG_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_MAG_SLOPE");
    4446    double GLINT_LENGTH_MAG_ZERO = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_MAG_ZERO");
     47    double glintWidth = psMetadataLookupF32 (&status, recipe, "GLINT_WIDTH");
     48    double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE");
     49
     50    //we will use one of the new keywords to differentiate between an old and new style glint treatment
     51    float glintCheck = 0;
    4552    double GLINT_LENGTH_POS_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_POS_SLOPE");
     53    if (!status) {
     54        psLogMsg ("psastro", PS_LOG_INFO, "Assuming old-style glint masking, given the recipe keywords");
     55        glintCheck = 1;
     56    }
    4657    double GLINT_LENGTH_POS_REF = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_POS_REF");
     58    double GLINT_LENGTH_POS_CUT = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_POS_CUT");
     59    double GLINT_LENGTH_MIN_FPA = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_MIN_FPA");
     60    if (!status) GLINT_LENGTH_MIN_FPA=1000.;
    4761    double GLINT_ANGLE_POS_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_ANGLE_POS_SLOPE");
    4862    double GLINT_ANGLE_POS_REF = psMetadataLookupF32 (&status, recipe, "GLINT_ANGLE_POS_REF");
    49     double glintWidth = psMetadataLookupF32 (&status, recipe, "GLINT_WIDTH");
    50     double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE");
     63
    5164
    5265    // select the set of glint regions (GLINT.REGION is a MULTI of METADATA items)
     
    7083
    7184    // really error-out here?  or just skip?
    72     if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) {
     85    if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, &GLINT_MAX_MAG, fpa, recipe)) {
    7386        psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
    7487        return false;
     
    7992    float MagOffset = zeropt + 2.5*log10(exptime);
    8093    GLINT_MAX_MAG += MagOffset;
    81     GLINT_LENGTH_MAG_ZERO += MagOffset;
     94    //GLINT_LENGTH_MAG_ZERO += MagOffset;
    8295
    8396    // select the raw objects for this readout (loaded in psastroExtract.c)
     
    91104    psastroChipBounds (fpa);
    92105
    93 
    94106    // find the possible glint stars, and convert the position to FPA coordinates.
    95107    // search for stars within the glint regions
     
    97109
    98110        pmAstromObj *star = glintStars->data[i];
    99         if (star->Mag > GLINT_MAX_MAG) continue; // XXX should not be needed...
     111        if (star->Mag > GLINT_MAX_MAG) continue;
    100112
    101113        // project glint star to the focal-plane
    102114        psProject (star->TP, star->sky, fpa->toSky);
    103115        psPlaneTransformApply (star->FP, fpa->fromTPA, star->TP);
    104         fprintf (stderr, "glint: %7.2f @ %8.1f, %8.1f (%f %f) %8.1f %8.1f\n", star->Mag, star->FP->x, star->FP->y, star->sky->r * PS_DEG_RAD, star->sky->d * PS_DEG_RAD, star->TP->x,star->TP->y);
     116        //fprintf (stderr, "glint: %7.2f @ %8.1f, %8.1f (%f %f) %8.1f %8.1f\n", star->Mag, star->FP->x, star->FP->y, star->sky->r * PS_DEG_RAD, star->sky->d * PS_DEG_RAD, star->TP->x,star->TP->y);
    105117
    106118        // find the GLINT.REGION this star lands in (if any)
     
    132144            }
    133145
    134             double glintLength = GLINT_LENGTH_MAG_SLOPE*(GLINT_LENGTH_MAG_ZERO - star->Mag);
     146            //double glintLength = GLINT_LENGTH_MAG_SLOPE*(GLINT_LENGTH_MAG_ZERO - star->Mag);
     147            //glint length should depend on the brightness on image, i.e. in instrumental mag. The same instrumental mag in different filters should likely give the same glint length.
     148            double glintLength = GLINT_LENGTH_MAG_SLOPE*(GLINT_LENGTH_MAG_ZERO - (star->Mag-MagOffset));
    135149            double glintAngle = 0;
    136150
    137             //Besides brightness, the length of the glints also depends on the position of the star compared to the focal plane. But, seemingly only for stars closer than 30k pixels     
    138             if ((!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM")) && abs(star->FP->y) < 30000 ){
    139               glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->y));
    140 
    141             }
    142             if ((!strcasecmp(glintType, "LEFT") || !strcasecmp(glintType, "RIGHT")) && abs(star->FP->x) < 30000 ) {
    143               glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->x));
    144             }
    145             //also compute the angle of the glint, which depends on position parallel to the FPX
    146             if (!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM") ){
    147               glintAngle = PM_RAD_DEG * (GLINT_ANGLE_POS_SLOPE*((GLINT_ANGLE_POS_REF - star->FP->x)/1000.));
    148 
    149             }
    150             if (!strcasecmp(glintType, "LEFT") || !strcasecmp(glintType, "RIGHT") ) {
    151               glintAngle = PM_RAD_DEG * (GLINT_ANGLE_POS_SLOPE*((GLINT_ANGLE_POS_REF - star->FP->y)/1000.));
     151            //Besides brightness, the length of the glints also depends on the position of the star compared to the focal plane. But, seemingly only for stars closer than about 30k pixels
     152            if(glintCheck) {
     153                if ((!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM")) && abs(star->FP->y) < GLINT_LENGTH_POS_CUT ){
     154                  glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->y));
     155                }
     156                if ((!strcasecmp(glintType, "LEFT") || !strcasecmp(glintType, "RIGHT")) && abs(star->FP->x) < GLINT_LENGTH_POS_CUT ) {
     157                  glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->x));
     158                }
     159                //also compute the angle of the glint, which depends on position parallel to the FPX
     160                if (!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM") ){
     161                  glintAngle = PM_RAD_DEG * (GLINT_ANGLE_POS_SLOPE*((GLINT_ANGLE_POS_REF - star->FP->x)/1000.));
     162                }
     163                if (!strcasecmp(glintType, "LEFT") || !strcasecmp(glintType, "RIGHT") ) {
     164                  glintAngle = PM_RAD_DEG * (GLINT_ANGLE_POS_SLOPE*((GLINT_ANGLE_POS_REF - star->FP->y)/1000.));
     165                }
    152166            }
    153167
     
    157171            if (!strcasecmp(glintType, "LEFT")   && ((star->FP->x + glintLength) < -20000.))  continue;
    158172            if (!strcasecmp(glintType, "RIGHT")  && ((star->FP->x - glintLength) > 20000.))  continue;
    159 
    160             psVector *x_glint = psVectorAlloc(2,PS_TYPE_F32);
    161             psVector *y_glint = psVectorAlloc(2,PS_TYPE_F32);
    162173
    163174            if (!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM")) {
     
    220231                    yFPA1 = yFPA0 + glintLength*cos(glintAngle);
    221232                }
     233
     234                if(glintLength < GLINT_LENGTH_MIN_FPA) continue;
    222235
    223236                x_glint->data.F32[0] = xFPA0;
     
    294307                          psFree (glints);
    295308                        }
    296                        
    297                         fprintf (stderr, "glint %s : %d %f,%f to %f,%f (%f %f %f)\n", glintType, nChip, xChip0, yChip0, xChip1, yChip1, glint_length, glintWidth, chip_angle);
    298                         psVector *glint = psVectorAlloc(5,PS_TYPE_F32);
     309                                                psVector *glint = psVectorAlloc(5,PS_TYPE_F32);
    299310                        glint->data.F32[0] = xChip0;
    300311                        glint->data.F32[1] = yChip0;
     
    369380                    yFPA1 = yFPA0 + glintLength*sin(glintAngle*-1.);
    370381                }
     382
     383                if(glintLength < GLINT_LENGTH_MIN_FPA) continue;
    371384
    372385                x_glint->data.F32[0] = xFPA0;
     
    441454                        }
    442455                       
    443                         fprintf (stderr, "glint %s : %d %f,%f to %f,%f (%f %f %f)\n", glintType, nChip, xChip0, yChip0, xChip1, yChip1, glint_length, glintWidth, chip_angle);
    444 
    445456                        psVector *glint = psVectorAlloc(5,PS_TYPE_F32);
    446457                        glint->data.F32[0] = xChip0;
Note: See TracChangeset for help on using the changeset viewer.