Changeset 41367 for trunk/psastro
- Timestamp:
- May 27, 2020, 2:21:31 PM (6 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 11 edited
-
psastro.h (modified) (1 diff)
-
psastroChooseGlintStars.c (modified) (1 diff)
-
psastroConvert.c (modified) (1 diff)
-
psastroExtractGhosts.c (modified) (1 diff)
-
psastroExtractStars.c (modified) (1 diff)
-
psastroLoadCrosstalk.c (modified) (1 diff)
-
psastroLoadGhosts.c (modified) (5 diffs)
-
psastroLoadGlints.c (modified) (12 diffs)
-
psastroMaskUpdates.Mosaic.c (modified) (1 diff)
-
psastroMaskUpdates.c (modified) (2 diffs)
-
psastroZeroPoint.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastro.h
r41290 r41367 156 156 psVector *psastroZeroPointReadoutAccum(psVector *dMag, pmReadout *readout, float exptime, float refminMag, float refmaxMag); 157 157 bool psastroZeroPointAnalysis (psMetadata *header, psVector *dMag, float zeropt, psMetadata *recipe); 158 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, float *ghostMaxMag, pmFPA *fpa, psMetadata *recipe);158 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, float *ghostMaxMag, double *glintMaxMag, pmFPA *fpa, psMetadata *recipe); 159 159 bool psastroZeroPointRefMagLimitFromRecipe (float *refminMag, float *refmaxMag, pmFPA *fpa, psMetadata *recipe); 160 160 -
trunk/psastro/src/psastroChooseGlintStars.c
r24645 r41367 37 37 38 38 // really error-out here? or just skip? 39 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) {39 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, NULL, fpa, recipe)) { 40 40 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 41 41 return false; -
trunk/psastro/src/psastroConvert.c
r39926 r41367 65 65 66 66 // really error-out here? or just skip? 67 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) {67 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, NULL, fpa, recipe)) { 68 68 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 69 69 zeropt = 0.0; -
trunk/psastro/src/psastroExtractGhosts.c
r24648 r41367 53 53 54 54 // really error-out here? or just skip? 55 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) {55 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, NULL, fpa, recipe)) { 56 56 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 57 57 return false; -
trunk/psastro/src/psastroExtractStars.c
r24648 r41367 65 65 66 66 // really error-out here? or just skip? 67 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) {67 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, NULL, fpa, recipe)) { 68 68 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 69 69 return false; -
trunk/psastro/src/psastroLoadCrosstalk.c
r36837 r41367 94 94 95 95 // really error-out here? or just skip? 96 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) {96 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, NULL, fpa, recipe)) { 97 97 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 98 98 goto escape; -
trunk/psastro/src/psastroLoadGhosts.c
r41348 r41367 113 113 pmFPAview *view = pmFPAviewAlloc (0); 114 114 115 GET_1D_POLY ("GHOST.MIRROR.RAD", mirrorRad); 115 //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 116 float mirCheck = 0; 117 md = psMetadataLookupMetadata (&status, ghostModel, "GHOST.MIRROR.RAD"); 118 if (!md) { psLogMsg ("psastro", PS_LOG_INFO, "No ghost mirror_rad polynomial found. Assuming old-style ghost masking"); } 119 if (md) { 120 GET_1D_POLY ("GHOST.MIRROR.RAD", mirrorRad); 121 mirCheck = 1; 122 } 123 116 124 GET_2D_POLY ("GHOST.CENTER.X", centerX); 117 125 GET_2D_POLY ("GHOST.CENTER.Y", centerY); … … 131 139 132 140 // raise an error if the config is broken 133 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) {141 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, NULL, fpa, recipe)) { 134 142 psError(PSASTRO_ERR_CONFIG, true, "failed to load zeropt data from recipe"); 135 143 goto escape; … … 179 187 ghost->srcFP->y = ref->FP->y; 180 188 181 //TdB: first mirror the reference star positions (around the 0,0 pixel) using the radial offset coefficients and the ghost/star angle182 189 double rSrc = hypot (ref->FP->x, ref->FP->y); 183 190 double theta0 = atan2(ref->FP->y,ref->FP->x); 184 191 185 double ghost_offset_rad = psPolynomial1DEval (mirrorRad, rSrc); 186 double ghost_x_fpa_mirror = ref->FP->x + ((ref->FP->x*-1.)/abs(ref->FP->x)*abs(cos(theta0)*ghost_offset_rad)); 187 double ghost_y_fpa_mirror = ref->FP->y + ((ref->FP->y*-1.)/abs(ref->FP->y)*abs(sin(theta0)*ghost_offset_rad)); 188 189 // Now use the mirrored position together with the 2D ghost center fitting to get the actual ghost position in FPA coords 190 ghost->FP->x = ghost_x_fpa_mirror + psPolynomial2DEval(centerX, ghost_x_fpa_mirror, ghost_y_fpa_mirror); 191 ghost->FP->y = ghost_y_fpa_mirror + psPolynomial2DEval(centerY, ghost_x_fpa_mirror, ghost_y_fpa_mirror); 192 if(mirCheck) { 193 //TdB: first mirror the reference star positions (around the 0,0 pixel) using the radial offset coefficients and the ghost/star angle 194 double ghost_offset_rad = psPolynomial1DEval (mirrorRad, rSrc); 195 double ghost_x_fpa_mirror = ref->FP->x + ((ref->FP->x*-1.)/abs(ref->FP->x)*abs(cos(theta0)*ghost_offset_rad)); 196 double ghost_y_fpa_mirror = ref->FP->y + ((ref->FP->y*-1.)/abs(ref->FP->y)*abs(sin(theta0)*ghost_offset_rad)); 197 198 // Now use the mirrored position together with the 2D ghost center fitting to get the actual ghost position in FPA coords 199 ghost->FP->x = ghost_x_fpa_mirror + psPolynomial2DEval(centerX, ghost_x_fpa_mirror, ghost_y_fpa_mirror); 200 ghost->FP->y = ghost_y_fpa_mirror + psPolynomial2DEval(centerY, ghost_x_fpa_mirror, ghost_y_fpa_mirror); 201 } 202 if(!mirCheck) { 203 //Use the old-style ghost position determination 204 ghost->FP->x = -ref->FP->x + psPolynomial2DEval(centerX, -ref->FP->x, -ref->FP->y); 205 ghost->FP->y = -ref->FP->y + psPolynomial2DEval(centerY, -ref->FP->x, -ref->FP->y); 206 } 192 207 193 208 ghost->inner.major = psPolynomial1DEval (innerMajor, rSrc); … … 210 225 ghostChip = psastroFindChip (&ghost->chip->x, &ghost->chip->y, fpa, ghost->FP->x, ghost->FP->y); 211 226 // fprintf (stderr, "-> model chip position: %f, %f\n", ghost->chip->x, ghost->chip->y); 227 212 228 213 229 if (ghostChip) { … … 356 372 357 373 // if a filter is defined, but the recipe elements are missing, the config is broken. 358 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) {374 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, NULL, fpa, recipe)) { 359 375 psError(PSASTRO_ERR_CONFIG, true, "failed to load zeropt data from recipe"); 360 376 goto escape; -
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; -
trunk/psastro/src/psastroMaskUpdates.Mosaic.c
r21183 r41367 56 56 57 57 // really error-out here? or just skip? 58 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, fpa, recipe)) {58 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, NULL, fpa, recipe)) { 59 59 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 60 60 return false; -
trunk/psastro/src/psastroMaskUpdates.c
r41348 r41367 184 184 185 185 // really error-out here? or just skip? 186 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &GHOST_MAX_MAG, fpa, recipe)) {186 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &GHOST_MAX_MAG, NULL, fpa, recipe)) { 187 187 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 188 188 return false; … … 443 443 //psLogMsg ("psastro", 3, "glint: %f %f %f %f\n", glint->x0, glint->y0, glint->x1, glint->y1); 444 444 //psastroMaskRectangle (readoutMask->mask, glintMaskValue, glint->x0, glint->y0, glint->x1, glint->y1); 445 446 psLogMsg ("psastro", 3, "glint: %d %f %f %f %f %f\n",i, glint->data.F32[0], glint->data.F32[1],glint->data.F32[2], glint->data.F32[3], glint->data.F32[4]);447 445 psastroMaskBox (readoutMask->mask, glintMaskValue, glint->data.F32[0], glint->data.F32[1], 448 446 glint->data.F32[2], glint->data.F32[3], glint->data.F32[4]); -
trunk/psastro/src/psastroZeroPoint.c
r37552 r41367 55 55 56 56 // really error-out here? or just skip? 57 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) {57 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, NULL, fpa, recipe)) { 58 58 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 59 59 return false; … … 480 480 return false; } 481 481 482 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, float *ghostMaxMag, pmFPA *fpa, psMetadata *recipe) {482 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, float *ghostMaxMag, double *glintMaxMag, pmFPA *fpa, psMetadata *recipe) { 483 483 484 484 bool status; … … 527 527 //MEH null is a pain.. so only log if set 528 528 psLogMsg ("psastro", PS_LOG_INFO, "found GHOST_MAX_MAG %f",*ghostMaxMag); 529 } 530 if (glintMaxMag) { 531 float MaxMag = psMetadataLookupF32 (&status, refItem->data.md, "GLINT_MAX_MAG"); 532 if (status) { 533 *glintMaxMag = MaxMag ; 534 //MEH null is a pain.. so only log if set 535 psLogMsg ("psastro", PS_LOG_INFO, "found GLINT_MAX_MAG %f",*glintMaxMag); 536 } 529 537 } 530 538 //MEH what zpt is set to
Note:
See TracChangeset
for help on using the changeset viewer.
