Changeset 41367 for trunk/psastro/src/psastroLoadGlints.c
- Timestamp:
- May 27, 2020, 2:21:31 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroLoadGlints.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroLoadGlints.c
r41348 r41367 26 26 bool status; 27 27 float zeropt, exptime; 28 psVector *x_glint = psVectorAlloc(2,PS_TYPE_F32); 29 psVector *y_glint = psVectorAlloc(2,PS_TYPE_F32); 28 30 29 31 psLogMsg ("psastro", PS_LOG_INFO, "determine glint positions"); … … 39 41 if (!REFSTAR_MASK_GLINTS) return true; 40 42 41 // select the limiting magnitude43 // select relevant keywords 42 44 double GLINT_MAX_MAG = psMetadataLookupF32 (&status, recipe, "GLINT_MAX_MAG"); 43 45 double GLINT_LENGTH_MAG_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_MAG_SLOPE"); 44 46 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; 45 52 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 } 46 57 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.; 47 61 double GLINT_ANGLE_POS_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_ANGLE_POS_SLOPE"); 48 62 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 51 64 52 65 // select the set of glint regions (GLINT.REGION is a MULTI of METADATA items) … … 70 83 71 84 // 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)) { 73 86 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 74 87 return false; … … 79 92 float MagOffset = zeropt + 2.5*log10(exptime); 80 93 GLINT_MAX_MAG += MagOffset; 81 GLINT_LENGTH_MAG_ZERO += MagOffset;94 //GLINT_LENGTH_MAG_ZERO += MagOffset; 82 95 83 96 // select the raw objects for this readout (loaded in psastroExtract.c) … … 91 104 psastroChipBounds (fpa); 92 105 93 94 106 // find the possible glint stars, and convert the position to FPA coordinates. 95 107 // search for stars within the glint regions … … 97 109 98 110 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; 100 112 101 113 // project glint star to the focal-plane 102 114 psProject (star->TP, star->sky, fpa->toSky); 103 115 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); 105 117 106 118 // find the GLINT.REGION this star lands in (if any) … … 132 144 } 133 145 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)); 135 149 double glintAngle = 0; 136 150 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 pixels138 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 FPX146 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 } 152 166 } 153 167 … … 157 171 if (!strcasecmp(glintType, "LEFT") && ((star->FP->x + glintLength) < -20000.)) continue; 158 172 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);162 173 163 174 if (!strcasecmp(glintType, "TOP") || !strcasecmp(glintType, "BOTTOM")) { … … 220 231 yFPA1 = yFPA0 + glintLength*cos(glintAngle); 221 232 } 233 234 if(glintLength < GLINT_LENGTH_MIN_FPA) continue; 222 235 223 236 x_glint->data.F32[0] = xFPA0; … … 294 307 psFree (glints); 295 308 } 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); 299 310 glint->data.F32[0] = xChip0; 300 311 glint->data.F32[1] = yChip0; … … 369 380 yFPA1 = yFPA0 + glintLength*sin(glintAngle*-1.); 370 381 } 382 383 if(glintLength < GLINT_LENGTH_MIN_FPA) continue; 371 384 372 385 x_glint->data.F32[0] = xFPA0; … … 441 454 } 442 455 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 445 456 psVector *glint = psVectorAlloc(5,PS_TYPE_F32); 446 457 glint->data.F32[0] = xChip0;
Note:
See TracChangeset
for help on using the changeset viewer.
