IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41367 for trunk/psModules


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

gpc1 dynamic masks set up

Location:
trunk/psModules/src/objects
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourceIO.h

    r41348 r41367  
    9191bool pmSourceIO_ReadMatchedRefs (psFits *fits, pmFPA *fpa, const pmConfig *config);
    9292
     93bool psastroZeroPointFromRecipeGlint (float *zeropt, float *exptime, float *ghostMaxMag, double *glintMaxMag, pmFPA *fpa, psMetadata *recipe);
    9394bool pmSourceIO_WriteGlints (psFits *fits, pmFPA *fpa, pmConfig *config);
    9495bool pmSourceIO_WriteGhosts (psFits *fits, pmFPA *fpa, pmConfig *config);
  • trunk/psModules/src/objects/pmSourceIO_Ghosts.c

    r41348 r41367  
    135135    pmFPAview *view = pmFPAviewAlloc (0);
    136136
    137     GET_1D_POLY ("GHOST.MIRROR.RAD", mirrorRad);
     137    //We need to check whether we are dealing with an old style ghost_model, or a new style model. Check if the mirror_rad polynomial exists
     138    float mirCheck = 0;
     139    md = psMetadataLookupMetadata (&status, ghostModel, "GHOST.MIRROR.RAD");
     140    if (!md) { psLogMsg ("psastro", PS_LOG_INFO, "No ghost mirror_rad polynomial found. Assuming old-style ghost masking"); }
     141    if (md) {
     142        GET_1D_POLY ("GHOST.MIRROR.RAD", mirrorRad);
     143        mirCheck = 1;
     144    } 
     145
    138146    GET_2D_POLY ("GHOST.CENTER.X", centerX);
    139147    GET_2D_POLY ("GHOST.CENTER.Y", centerY);
     
    143151    GET_1D_POLY ("GHOST.INNER.MAJOR", innerMajor);
    144152    GET_1D_POLY ("GHOST.INNER.MINOR", innerMinor);
     153
    145154
    146155    // select the input astrometry data (also carries the refstars)
     
    153162
    154163    // really error-out here?  or just skip?
    155     if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa_ast, recipe)) {
     164    if (!psastroZeroPointFromRecipeGlint (&zeropt, &exptime, &MAX_MAG,NULL, fpa_ast, recipe)) {
    156165        psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
    157166        goto escape;
     
    201210                        double theta0 = atan2(ref->FP->y,ref->FP->x);
    202211
    203                         double ghost_offset_rad = psPolynomial1DEval (mirrorRad, rSrc);
    204                         double ghost_x_fpa_mirror = ref->FP->x + ((ref->FP->x*-1.)/abs(ref->FP->x)*abs(cos(theta0)*ghost_offset_rad));
    205                         double ghost_y_fpa_mirror = ref->FP->y + ((ref->FP->y*-1.)/abs(ref->FP->y)*abs(sin(theta0)*ghost_offset_rad));
    206 
    207                         // Now use the mirrored position together with the 2D ghost center fitting to get the actual ghost position in FPA coords
    208                         ghost->FP->x = ghost_x_fpa_mirror + psPolynomial2DEval(centerX, ghost_x_fpa_mirror, ghost_y_fpa_mirror);
    209                         ghost->FP->y = ghost_y_fpa_mirror + psPolynomial2DEval(centerY, ghost_x_fpa_mirror, ghost_y_fpa_mirror);
     212                        if(mirCheck) {
     213                            //TdB: first mirror the reference star positions (around the 0,0 pixel) using the radial offset coefficients and the ghost/star angle
     214                            double ghost_offset_rad = psPolynomial1DEval (mirrorRad, rSrc);
     215                            double ghost_x_fpa_mirror = ref->FP->x + ((ref->FP->x*-1.)/abs(ref->FP->x)*abs(cos(theta0)*ghost_offset_rad));
     216                            double ghost_y_fpa_mirror = ref->FP->y + ((ref->FP->y*-1.)/abs(ref->FP->y)*abs(sin(theta0)*ghost_offset_rad));
     217
     218                            // Now use the mirrored position together with the 2D ghost center fitting to get the actual ghost position in FPA coords
     219                            ghost->FP->x = ghost_x_fpa_mirror + psPolynomial2DEval(centerX, ghost_x_fpa_mirror, ghost_y_fpa_mirror);
     220                            ghost->FP->y = ghost_y_fpa_mirror + psPolynomial2DEval(centerY, ghost_x_fpa_mirror, ghost_y_fpa_mirror);
     221                        } 
     222                        if(!mirCheck) {
     223                            //Use the old-style ghost position determination
     224                            ghost->FP->x = -ref->FP->x + psPolynomial2DEval(centerX, -ref->FP->x, -ref->FP->y);
     225                            ghost->FP->y = -ref->FP->y + psPolynomial2DEval(centerY, -ref->FP->x, -ref->FP->y);
     226                        }
    210227
    211228                        ghost->inner.major = psPolynomial1DEval (innerMajor, rSrc);
     
    503520  return true;
    504521}
     522
     523
  • trunk/psModules/src/objects/pmSourceIO_Glints.c

    r41349 r41367  
    7878    if (!REFSTAR_MASK_GLINTS) return true;
    7979
    80     // select the limiting magnitude
     80    // select relevant keywords
    8181    double GLINT_MAX_MAG = psMetadataLookupF32 (&status, recipe, "GLINT_MAX_MAG");
    8282    double GLINT_LENGTH_MAG_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_MAG_SLOPE");
    8383    double GLINT_LENGTH_MAG_ZERO = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_MAG_ZERO");
     84    double glintWidth = psMetadataLookupF32 (&status, recipe, "GLINT_WIDTH");
     85
     86    //we will use one of the new keywords to differentiate between an old and new style glint treatment
     87    float glintCheck = 0;
    8488    double GLINT_LENGTH_POS_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_POS_SLOPE");
     89    if (!status) { glintCheck = 1; }
    8590    double GLINT_LENGTH_POS_REF = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_POS_REF");
     91    double GLINT_LENGTH_POS_CUT = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_POS_CUT");
    8692    double GLINT_ANGLE_POS_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_ANGLE_POS_SLOPE");
    8793    double GLINT_ANGLE_POS_REF = psMetadataLookupF32 (&status, recipe, "GLINT_ANGLE_POS_REF");
    88     double glintWidth = psMetadataLookupF32 (&status, recipe, "GLINT_WIDTH");
     94
    8995    bool GLINT_OUTPUT = psMetadataLookupBool(&status, recipe, "PSASTRO.SAVE.GLINTS");
    9096    if (!GLINT_OUTPUT) return true;
     
    111117    // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime)
    112118    pmFPA *fpa_ast = astrom->fpa;
    113     if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa_ast, recipe)) {
     119    if (!psastroZeroPointFromRecipeGlint (&zeropt, &exptime, NULL,&GLINT_MAX_MAG, fpa_ast, recipe)) {
    114120        psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
    115121        return false;
     
    167173                }
    168174
     175                double glintLength = GLINT_LENGTH_MAG_SLOPE*(GLINT_LENGTH_MAG_ZERO - star->Mag);
    169176                double glintAngle = 0;
    170                 //compute the angle of the glint, which depends on position parallel to the FPX
    171                 if (!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM") ){
    172                   glintAngle = PM_RAD_DEG * (GLINT_ANGLE_POS_SLOPE*((GLINT_ANGLE_POS_REF - star->FP->x)/1000.));
    173                 }
    174                 if (!strcasecmp(glintType, "LEFT") || !strcasecmp(glintType, "RIGHT") ) {
    175                   glintAngle = PM_RAD_DEG * (GLINT_ANGLE_POS_SLOPE*((GLINT_ANGLE_POS_REF - star->FP->y)/1000.));
    176                 }
    177 
    178                 double glintLength = GLINT_LENGTH_MAG_SLOPE*(GLINT_LENGTH_MAG_ZERO - star->Mag);
    179                 //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     
    180                 if ((!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM")) && abs(star->FP->y) < 30000 ){
    181                   glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->y));
    182 
    183                 }
    184                 if ((!strcasecmp(glintType, "LEFT") || !strcasecmp(glintType, "RIGHT")) && abs(star->FP->x) < 30000 ) {
    185                   glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->x));
     177
     178                //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
     179                if(glintCheck) {
     180                    if ((!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM")) && abs(star->FP->y) < GLINT_LENGTH_POS_CUT ){
     181                      glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->y));
     182                    }
     183                    if ((!strcasecmp(glintType, "LEFT") || !strcasecmp(glintType, "RIGHT")) && abs(star->FP->x) < GLINT_LENGTH_POS_CUT ) {
     184                      glintLength /= GLINT_LENGTH_POS_SLOPE*(GLINT_LENGTH_POS_REF - abs(star->FP->x));
     185                    }
     186                    //also compute the angle of the glint, which depends on position parallel to the FPX
     187                    if (!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM") ){
     188                      glintAngle = PM_RAD_DEG * (GLINT_ANGLE_POS_SLOPE*((GLINT_ANGLE_POS_REF - star->FP->x)/1000.));
     189                    }
     190                    if (!strcasecmp(glintType, "LEFT") || !strcasecmp(glintType, "RIGHT") ) {
     191                      glintAngle = PM_RAD_DEG * (GLINT_ANGLE_POS_SLOPE*((GLINT_ANGLE_POS_REF - star->FP->y)/1000.));
     192                    }
    186193                }
    187194
     
    230237}
    231238
    232 
    233 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, float *ghostMaxMag, pmFPA *fpa, psMetadata *recipe) {
     239bool psastroZeroPointFromRecipeGlint (float *zeropt, float *exptime, float *ghostMaxMag, double *glintMaxMag, pmFPA *fpa, psMetadata *recipe) {
    234240
    235241    bool status;
     
    279285            psLogMsg ("psastro", PS_LOG_INFO, "found GHOST_MAX_MAG %f",*ghostMaxMag);
    280286        }
     287        if (glintMaxMag) {
     288            float MaxMag = psMetadataLookupF32 (&status, refItem->data.md, "GLINT_MAX_MAG");
     289            if (status) {
     290                *glintMaxMag = MaxMag ;
     291                //MEH null is a pain.. so only log if set
     292                psLogMsg ("psastro", PS_LOG_INFO, "found GLINT_MAX_MAG %f",*glintMaxMag);
     293            }
     294        }
     295
    281296        //MEH what zpt is set to
    282297        psLogMsg ("psastro", PS_LOG_INFO, "found ZEROPT  %f",*zeropt);
Note: See TracChangeset for help on using the changeset viewer.