IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 4, 2021, 5:56:45 PM (5 years ago)
Author:
eugene
Message:

merge changes from trunk (glint model tweaks)

Location:
branches/eam_branches/ipp-dev-20210817/psastro
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-dev-20210817/psastro

  • branches/eam_branches/ipp-dev-20210817/psastro/src/psastroLoadGlints.c

    r41705 r41889  
    5252    double GLINT_LENGTH_POS_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_POS_SLOPE");
    5353    if (!status) {
    54         psLogMsg ("psastro", PS_LOG_INFO, "Assuming old-style glint masking, given the recipe keywords");
     54        psLogMsg ("psastro", PS_LOG_INFO, "Assuming old-style glint masking");
    5555        glintCheck = 1;
    5656    }
     
    150150
    151151            //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) {
     152            if(!glintCheck) {
    153153                if ((!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM")) && abs(star->FP->y) < GLINT_LENGTH_POS_CUT ){
    154154                  glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->y));
     
    246246                        pmChip *chip = fpa->chips->data[nChip];
    247247                        if (!chip) {continue;}
     248                        const char *chipName = psMetadataLookupStr(NULL,chip->concepts, "CHIP.NAME");
     249                        int X = chipName[2] - '0';
    248250
    249251                        if (!psastroFindChipInXrange (fpa, nChip, x_glint->data.F32[glint_point], y_glint->data.F32[glint_point])) {
     
    255257                        psastroFindChipYedges (&yFPAs, &yFPAe, fpa, nChip);
    256258
     259                        //For ease of reference, we adopt a frame in which coords with 0 are always lower in the relevant axis
    257260                        if (yFPAs > yFPAe) PS_SWAP (yFPAs, yFPAe);
    258261                        if (yFPA0 > yFPA1) {
     
    265268                        if (yFPA1 < yFPAs) {continue;}
    266269
    267 
    268270                        //find the y-coord positions for this chip
    269271                        double ycFPA0, ycFPA1;
     
    272274
    273275                        //now calculate the proper x-coord positions given the angle, for this chip
    274                         double xcFPA0, xcFPA1, angle;
     276                        double xcFPA0 = 0.0, xcFPA1 = 0.0;
     277                        double angle = 0.0, chip_angle = 0.0, glint_length = 0.0;
    275278                        angle = atan2(xFPA1 - xFPA0,yFPA1 - yFPA0);
    276279                        xcFPA0 = xFPA0 + (ycFPA0-yFPA0)*tan(angle);
    277                         xcFPA1 = xFPA0 + (ycFPA1-yFPA0)*tan(angle);
    278                        
    279 
    280                         double xChip0, yChip0, xChip1, yChip1, chip_angle, glint_length, xChip2,yChip2;
    281                         psastroFPAtoChip (&xChip0, &yChip0, fpa, nChip, xcFPA0, ycFPA0);
    282                         psastroFPAtoChip (&xChip1, &yChip1, fpa, nChip, xcFPA1, ycFPA1);
    283                         psastroFPAtoChip (&xChip2, &yChip2, fpa, nChip, star->FP->x,star->FP->y);
    284 
    285                         chip_angle = atan2(yChip1 - yChip0, xChip1 - xChip0);
    286                         glint_length = sqrt(pow(yChip1 - yChip0,2) + pow(xChip1 - xChip0,2));
     280                        xcFPA1 = xFPA0 + (ycFPA1-yFPA0)*tan(angle);     
     281
     282                        //use this to calculate the actual glint length as it wll be on this chip
     283                        glint_length = sqrt(pow(ycFPA1 - ycFPA0,2) + pow(xcFPA1 - xcFPA0,2));
     284
     285                        //also get the proper orientation of the glint angle, and determine the starting position on this chip. Remember that half of the focal plane is flipped
     286                        double xChip0, yChip0;
     287                        if (!strcasecmp(glintType, "TOP")) {
     288                          if(X<=3){
     289                            chip_angle = PM_RAD_DEG * (-90. - glintAngle/PM_RAD_DEG);
     290                          } else {
     291                            chip_angle = PM_RAD_DEG * (90. - glintAngle/PM_RAD_DEG);
     292                          }
     293                          psastroFPAtoChip (&xChip0, &yChip0, fpa, nChip, xcFPA1, ycFPA1);
     294                        }
     295                        if (!strcasecmp(glintType, "BOTTOM")) {
     296                          if(X<=3){
     297                            chip_angle = PM_RAD_DEG * (glintAngle/PM_RAD_DEG +90.);
     298                          } else {
     299                            chip_angle = PM_RAD_DEG * (glintAngle/PM_RAD_DEG -90.);
     300                          }
     301                          psastroFPAtoChip (&xChip0, &yChip0, fpa, nChip, xcFPA0, ycFPA0);
     302                        }
    287303
    288304                        // select the 0th readout of the 0th cell for this chip
     
    403419                        psastroFindChipXedges (&xFPAs, &xFPAe, fpa, nChip);
    404420
     421                        //For ease of reference, we adopt a frame in which coords with 0 are always lower in the relevant axis
    405422                        if (xFPAs > xFPAe) PS_SWAP (xFPAs, xFPAe);
    406423                        if (xFPA0 > xFPA1) {
     
    419436
    420437                        //now calculate the proper x-coord positions given the angle, for this chip
    421                         double ycFPA0, ycFPA1, angle;
     438                        double ycFPA0 = 0.0, ycFPA1 = 0.0;
     439                        double glint_length = 0.0, angle = 0.0, chip_angle = 0.0;
    422440                        angle = atan2(xFPA1 - xFPA0,yFPA1 - yFPA0);
    423441                        ycFPA0 = yFPA0 + (xcFPA0-xFPA0)/tan(angle);
    424442                        ycFPA1 = yFPA0 + (xcFPA1-xFPA0)/tan(angle);
    425443
    426                         double xChip0, yChip0, xChip1, yChip1, chip_angle, glint_length,xChip2,yChip2;
    427                         psastroFPAtoChip (&xChip0, &yChip0, fpa, nChip, xcFPA0, ycFPA0);
    428                         psastroFPAtoChip (&xChip1, &yChip1, fpa, nChip, xcFPA1, ycFPA1);
    429                         psastroFPAtoChip (&xChip2, &yChip2, fpa, nChip, star->FP->x,star->FP->y);
    430 
    431                         chip_angle = atan2(yChip1 - yChip0, xChip1 - xChip0);
    432                         glint_length = sqrt(pow(yChip1 - yChip0,2) + pow(xChip1 - xChip0,2));
     444                        //use this to calculate the actual glint length as it wll be on this chip
     445                        glint_length = sqrt(pow(ycFPA1 - ycFPA0,2) + pow(xcFPA1 - xcFPA0,2));
     446
     447                        //also get the proper orientation of the glint angle, and determine the starting position on this chip. Remember that half of the focal plane is flipped
     448                        double xChip0, yChip0;
     449                        if (!strcasecmp(glintType, "LEFT")) {
     450                          chip_angle = PM_RAD_DEG * (180. - glintAngle/PM_RAD_DEG);
     451                          psastroFPAtoChip (&xChip0, &yChip0, fpa, nChip, xcFPA0, ycFPA0);
     452                        }
     453                        if (!strcasecmp(glintType, "RIGHT")) {
     454                          chip_angle = PM_RAD_DEG * (glintAngle/PM_RAD_DEG +180.);
     455                          psastroFPAtoChip (&xChip0, &yChip0, fpa, nChip, xcFPA1, ycFPA1);
     456                        }
    433457
    434458                        // select the 0th readout of the 0th cell for this chip
Note: See TracChangeset for help on using the changeset viewer.