Changeset 41367 for trunk/psModules
- Timestamp:
- May 27, 2020, 2:21:31 PM (6 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 3 edited
-
pmSourceIO.h (modified) (1 diff)
-
pmSourceIO_Ghosts.c (modified) (5 diffs)
-
pmSourceIO_Glints.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceIO.h
r41348 r41367 91 91 bool pmSourceIO_ReadMatchedRefs (psFits *fits, pmFPA *fpa, const pmConfig *config); 92 92 93 bool psastroZeroPointFromRecipeGlint (float *zeropt, float *exptime, float *ghostMaxMag, double *glintMaxMag, pmFPA *fpa, psMetadata *recipe); 93 94 bool pmSourceIO_WriteGlints (psFits *fits, pmFPA *fpa, pmConfig *config); 94 95 bool pmSourceIO_WriteGhosts (psFits *fits, pmFPA *fpa, pmConfig *config); -
trunk/psModules/src/objects/pmSourceIO_Ghosts.c
r41348 r41367 135 135 pmFPAview *view = pmFPAviewAlloc (0); 136 136 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 138 146 GET_2D_POLY ("GHOST.CENTER.X", centerX); 139 147 GET_2D_POLY ("GHOST.CENTER.Y", centerY); … … 143 151 GET_1D_POLY ("GHOST.INNER.MAJOR", innerMajor); 144 152 GET_1D_POLY ("GHOST.INNER.MINOR", innerMinor); 153 145 154 146 155 // select the input astrometry data (also carries the refstars) … … 153 162 154 163 // 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)) { 156 165 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 157 166 goto escape; … … 201 210 double theta0 = atan2(ref->FP->y,ref->FP->x); 202 211 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 } 210 227 211 228 ghost->inner.major = psPolynomial1DEval (innerMajor, rSrc); … … 503 520 return true; 504 521 } 522 523 -
trunk/psModules/src/objects/pmSourceIO_Glints.c
r41349 r41367 78 78 if (!REFSTAR_MASK_GLINTS) return true; 79 79 80 // select the limiting magnitude80 // select relevant keywords 81 81 double GLINT_MAX_MAG = psMetadataLookupF32 (&status, recipe, "GLINT_MAX_MAG"); 82 82 double GLINT_LENGTH_MAG_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_MAG_SLOPE"); 83 83 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; 84 88 double GLINT_LENGTH_POS_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_LENGTH_POS_SLOPE"); 89 if (!status) { glintCheck = 1; } 85 90 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"); 86 92 double GLINT_ANGLE_POS_SLOPE = psMetadataLookupF32 (&status, recipe, "GLINT_ANGLE_POS_SLOPE"); 87 93 double GLINT_ANGLE_POS_REF = psMetadataLookupF32 (&status, recipe, "GLINT_ANGLE_POS_REF"); 88 double glintWidth = psMetadataLookupF32 (&status, recipe, "GLINT_WIDTH"); 94 89 95 bool GLINT_OUTPUT = psMetadataLookupBool(&status, recipe, "PSASTRO.SAVE.GLINTS"); 90 96 if (!GLINT_OUTPUT) return true; … … 111 117 // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime) 112 118 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)) { 114 120 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 115 121 return false; … … 167 173 } 168 174 175 double glintLength = GLINT_LENGTH_MAG_SLOPE*(GLINT_LENGTH_MAG_ZERO - star->Mag); 169 176 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 pixels180 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 } 186 193 } 187 194 … … 230 237 } 231 238 232 233 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, float *ghostMaxMag, pmFPA *fpa, psMetadata *recipe) { 239 bool psastroZeroPointFromRecipeGlint (float *zeropt, float *exptime, float *ghostMaxMag, double *glintMaxMag, pmFPA *fpa, psMetadata *recipe) { 234 240 235 241 bool status; … … 279 285 psLogMsg ("psastro", PS_LOG_INFO, "found GHOST_MAX_MAG %f",*ghostMaxMag); 280 286 } 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 281 296 //MEH what zpt is set to 282 297 psLogMsg ("psastro", PS_LOG_INFO, "found ZEROPT %f",*zeropt);
Note:
See TracChangeset
for help on using the changeset viewer.
