Changeset 40199
- Timestamp:
- Oct 30, 2017, 2:34:03 PM (9 years ago)
- Location:
- branches/czw_branch/20170908
- Files:
-
- 5 edited
-
ippconfig/hsc/Makefile.am (modified) (1 diff)
-
ippconfig/hsc/ghost.model.mdc (modified) (3 diffs)
-
ippconfig/hsc/psastro.config (modified) (2 diffs)
-
psastro/src/psastro.h (modified) (1 diff)
-
psastro/src/psastroLoadGhosts.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20170908/ippconfig/hsc/Makefile.am
r40179 r40199 8 8 format_mef.config \ 9 9 format_cmf.config \ 10 ghost.model.mdc \ 10 11 ppImage.config \ 11 12 ppMerge.config \ -
branches/czw_branch/20170908/ippconfig/hsc/ghost.model.mdc
r40179 r40199 1 2 1 3 # The R_TERMS polynomials have been converted from um units to mm units to be consistent with C_TERMS polynomials. 2 4 3 5 GHOST.MODEL.HSC MULTI 4 GHOST.MODEL.HSC METADATA6 GHOST.MODEL.HSC METADATA 5 7 FILTER STR g 6 8 @C_TERMS F32 3.86129097e-04 -4.56480396e+02 5.94514717e+02 -8.20984903e+03 4.35455723e+04 -1.19834803e+05 1.60789252e+05 -8.66581086e+04 # a comment 7 9 @R_TERMS F32 2.80257250e+00 -1.14163334e+01 6.25378363e+02 -6.59305008e+03 3.21678893e+04 -7.68658356e+04 8.71449290e+04 -3.66203193e+04 # a comment 8 LIMIT F32 12.09 10 SCALE F32 3.49794238e-06 10 11 # WRONG ORDER 11 12 # @C_TERMS F32 -8.66581086e+04 1.60789252e+05 -1.19834803e+05 4.35455723e+04 -8.20984903e+03 5.94514717e+02 -4.56480396e+02 3.86129097e-04 12 13 # @R_TERMS F32 -3.66203193e+04 8.71449290e+04 -7.68658356e+04 3.21678893e+04 -6.59305008e+03 6.25378363e+02 -1.14163334e+01 2.80257250e+00 13 END14 GHOST.MODEL.HSC METADATA14 END 15 GHOST.MODEL.HSC METADATA 15 16 FILTER STR r 16 17 @C_TERMS F32 1.10217740e-03 -4.13994264e+02 -1.08162329e+02 -1.75333116e+02 -1.44358813e+03 7.03878935e+03 -1.55470840e+04 1.05167578e+04 # a comment 17 18 @R_TERMS F32 7.84632263e+00 -1.34007061e-02 9.57272709e+01 -9.45421731e+02 5.64254906e+03 -1.97396910e+04 3.55382290e+04 -2.46004825e+04 # a comment 18 LIMIT F32 11.519 19 SCALE F32 3.49794238e-06 20 20 # @C_TERMS for original r 8.14947896e+03 -1.24163720e+04 5.41143508e+03 -1.02024286e+03 -2.39667209e+02 -1.00805716e+02 -4.16757016e+02 -1.48799186e-03 … … 23 23 # @C_TERMS F32 1.05167578e+04 -1.55470840e+04 7.03878935e+03 -1.44358813e+03 -1.75333116e+02 -1.08162329e+02 -4.13994264e+02 1.10217740e-03 24 24 # @R_TERMS F32 -2.46004825e+04 3.55382290e+04 -1.97396910e+04 5.64254906e+03 -9.45421731e+02 9.57272709e+01 -1.34007061e-02 7.84632263e+00 25 END26 GHOST.MODEL.HSC METADATA25 END 26 GHOST.MODEL.HSC METADATA 27 27 FILTER STR i 28 28 @C_TERMS F32 -3.95203567e-03 -4.55641159e+02 5.73358984e+02 -8.75512267e+03 5.43205903e+04 -1.74052246e+05 2.70933733e+05 -1.66554502e+05 # a comment 29 29 @R_TERMS F32 2.24351724e+00 -1.59383063e+01 8.56547254e+02 -1.09461298e+04 6.86646484e+04 -2.19342516e+05 3.46712176e+05 -2.15706075e+05 # a comment 30 LIMIT F32 11.031 30 SCALE F32 3.49794238e-06 32 31 # @C_TERMS for original i 7.09135701e+03 -1.08899009e+04 4.53311864e+03 -7.45070274e+02 -2.86196488e+02 -9.58537252e+01 -4.15997892e+02 -2.10038501e-03 … … 35 34 # @C_TERMS F32 -1.66554502e+05 2.70933733e+05 -1.74052246e+05 5.43205903e+04 -8.75512267e+03 5.73358984e+02 -4.55641159e+02 -3.95203567e-03 36 35 # @R_TERMS F32 -2.15706075e+05 3.46712176e+05 -2.19342516e+05 6.86646484e+04 -1.09461298e+04 8.56547254e+02 -1.59383063e+01 2.24351724e+00 37 END38 GHOST.MODEL.HSC METADATA36 END 37 GHOST.MODEL.HSC METADATA 39 38 FILTER STR z 40 39 @C_TERMS F32 -1.79546522e-03 -4.13201008e+02 -1.08898155e+02 -1.51535018e+02 -1.51139264e+03 6.94362981e+03 -1.47396976e+04 9.59579373e+03 # a comment 41 40 @R_TERMS F32 7.39449641e+00 7.28959803e-01 1.06569049e+02 -1.18036333e+03 7.42160510e+03 -2.62797780e+04 4.70124953e+04 -3.23514338e+04 # a comment 42 LIMIT F32 11.043 41 SCALE F32 3.49794238e-06 44 42 # WRONG ORDER 45 43 # @C_TERMS F32 9.59579373e+03 -1.47396976e+04 6.94362981e+03 -1.51139264e+03 -1.51535018e+02 -1.08898155e+02 -4.13201008e+02 -1.79546522e-03 46 44 # @R_TERMS F32 -3.23514338e+04 4.70124953e+04 -2.62797780e+04 7.42160510e+03 -1.18036333e+03 1.06569049e+02 7.28959803e-01 7.39449641e+00 47 END48 GHOST.MODEL.HSC METADATA45 END 46 GHOST.MODEL.HSC METADATA 49 47 FILTER STR y 50 48 @C_TERMS F32 -2.04774887e-03 -4.50571358e+02 3.73884700e+02 -6.38727141e+03 4.28067607e+04 -1.47306815e+05 2.42465240e+05 -1.56137979e+05 # a comment 51 49 @R_TERMS F32 2.04967838e+00 -8.92675213e+00 6.03954493e+02 -7.97354793e+03 5.32635002e+04 -1.79071587e+05 2.94475198e+05 -1.88924528e+05 # a comment 52 LIMIT F32 11.053 50 SCALE F32 3.49794238e-06 54 51 # WRONG ORDER 55 52 # @C_TERMS F32 -1.56137979e+05 2.42465240e+05 -1.47306815e+05 4.28067607e+04 -6.38727141e+03 3.73884700e+02 -4.50571358e+02 -2.04774887e-03 56 53 # @R_TERMS F32 -1.88924528e+05 2.94475198e+05 -1.79071587e+05 5.32635002e+04 -7.97354793e+03 6.03954493e+02 -8.92675213e+00 2.04967838e+00 57 END58 GHOST.MODEL.HSC METADATA54 END 55 GHOST.MODEL.HSC METADATA 59 56 FILTER STR NB816 60 57 @C_TERMS F32 -3.52735759e-03 -4.54174618e+02 5.11013724e+02 -8.05597593e+03 5.11417991e+04 -1.67422366e+05 2.65225596e+05 -1.65501517e+05 # a comment 61 58 @R_TERMS F32 2.17954931e+00 -1.39611991e+01 7.88077371e+02 -1.01750660e+04 6.49121728e+04 -2.10323885e+05 3.36261570e+05 -2.11111649e+05 # a comment 62 LIMIT F32 11.063 59 SCALE F32 3.49794238e-06 64 60 # WRONG ORDER 65 61 # @C_TERMS F32 -1.65501517e+05 2.65225596e+05 -1.67422366e+05 5.11417991e+04 -8.05597593e+03 5.11013724e+02 -4.54174618e+02 -3.52735759e-03 66 62 # @R_TERMS F32 -2.11111649e+05 3.36261570e+05 -2.10323885e+05 6.49121728e+04 -1.01750660e+04 7.88077371e+02 -1.39611991e+01 2.17954931e+00 67 END68 GHOST.MODEL.HSC METADATA63 END 64 GHOST.MODEL.HSC METADATA 69 65 FILTER STR NB921 70 66 @C_TERMS F32 -2.99761113e-03 -4.52301392e+02 4.49346634e+02 -7.38661211e+03 4.83455130e+04 -1.62550708e+05 2.63017929e+05 -1.66995347e+05 # a comment 71 67 @R_TERMS F32 2.11290612e+00 -1.15228777e+01 7.02729746e+02 -9.20923423e+03 6.01493518e+04 -1.98625679e+05 3.22255104e+05 -2.04640222e+05 # a comment 72 LIMIT F32 11.073 68 SCALE F32 3.49794238e-06 74 69 # WRONG ORDER 75 70 # @C_TERMS F32 -1.66995347e+05 2.63017929e+05 -1.62550708e+05 4.83455130e+04 -7.38661211e+03 4.49346634e+02 -4.52301392e+02 -2.99761113e-03 76 71 # @R_TERMS F32 -2.04640222e+05 3.22255104e+05 -1.98625679e+05 6.01493518e+04 -9.20923423e+03 7.02729746e+02 -1.15228777e+01 2.11290612e+00 77 END78 72 END 73 -
branches/czw_branch/20170908/ippconfig/hsc/psastro.config
r40179 r40199 13 13 PHOTCODE.DATA METADATA 14 14 FILTER STR g 15 ZEROPT F32 26.75 15 # ZEROPT F32 26.75 16 ZEROPT F32 26.70 16 17 PHOTCODE STR g 17 GHOST_MAX_MAG F32 - 16.518 GHOST_MAX_MAG F32 -22.0 18 19 END 19 20 PHOTCODE.DATA METADATA 20 21 FILTER STR r 21 ZEROPT F32 27.1 22 # ZEROPT F32 27.1 23 ZEROPT F32 27.05 22 24 PHOTCODE STR r 23 GHOST_MAX_MAG F32 -2 0.025 GHOST_MAX_MAG F32 -22.5 24 26 END 25 27 PHOTCODE.DATA METADATA 26 28 FILTER STR i 27 ZEROPT F32 27.0 29 # ZEROPT F32 27.0 30 ZEROPT F32 26.8 28 31 PHOTCODE STR i 29 GHOST_MAX_MAG F32 -2 5.032 GHOST_MAX_MAG F32 -23.0 30 33 END 31 34 PHOTCODE.DATA METADATA 32 35 FILTER STR z 33 ZEROPT F32 26.2 36 # ZEROPT F32 26.2 37 ZEROPT F32 26.0 34 38 PHOTCODE STR z 35 GHOST_MAX_MAG F32 -2 5.039 GHOST_MAX_MAG F32 -23.0 36 40 END 37 41 PHOTCODE.DATA METADATA 38 42 FILTER STR y 39 ZEROPT F32 25.1 43 # ZEROPT F32 25.1 44 ZEROPT F32 25.55 40 45 PHOTCODE STR y 41 GHOST_MAX_MAG F32 -2 5.046 GHOST_MAX_MAG F32 -23.0 42 47 END 43 48 PHOTCODE.DATA METADATA 44 49 FILTER STR NB816 45 ZEROPT F32 26.0 50 # ZEROPT F32 26.0 51 ZEROPT F32 23.75 46 52 PHOTCODE STR i 47 GHOST_MAX_MAG F32 -2 5.053 GHOST_MAX_MAG F32 -23.0 48 54 END 49 55 PHOTCODE.DATA METADATA 50 56 FILTER STR NB921 51 ZEROPT F32 25.4 57 # ZEROPT F32 25.4 58 ZEROPT F32 23.95 52 59 PHOTCODE STR z 53 GHOST_MAX_MAG F32 -2 5.060 GHOST_MAX_MAG F32 -23.0 54 61 END 55 62 … … 148 155 REFSTAR_MASK_BLEED_MAG_SLOPE_Y F32 0.425 149 156 150 REFSTAR_MASK_GLINTS BOOL TRUE 157 REFSTAR_COUNT_GHOSTS BOOL TRUE 158 #REFSTAR_MASK_GHOST BOOL TRUE 159 REFSTAR_MASK_GHOST BOOL FALSE 160 GHOST_MODEL STR hsc/ghost.model.mdc 161 162 163 #REFSTAR_MASK_GLINTS BOOL TRUE 164 REFSTAR_MASK_GLINTS BOOL FALSE 151 165 GLINT_MAX_MAG F32 -19 152 166 GLINT_LENGTH_MAG_SLOPE F32 0.0 -
branches/czw_branch/20170908/psastro/src/psastro.h
r39926 r40199 60 60 psastroGhost *psastroGhostAlloc (void); 61 61 bool psastroLoadGhosts (pmConfig *config); 62 bool psastroLoadGhostsHSC (pmConfig *config); 62 63 63 64 bool psastroDataSave (pmConfig *config, psMetadata *stats); -
branches/czw_branch/20170908/psastro/src/psastroLoadGhosts.c
r40181 r40199 61 61 psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions"); 62 62 63 if (1) { 64 psWarning("Doing the hard coded switch to HSC ghosts still."); 65 return (psastroLoadGhostsHSC(config)); 66 } 67 63 68 // select the current recipe 64 69 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE); … … 71 76 if (!REFSTAR_MASK_GHOST) return true; 72 77 78 73 79 char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL"); 74 80 if (!strcasecmp(ghostFile, "NONE")) return true; … … 264 270 bool psastroLoadGhostsHSC (pmConfig *config) { 265 271 bool status; 266 pmChip *chip = NULL; 267 pmCell *cell = NULL; 268 pmReadout *readout = NULL; 269 // float zeropt, exptime, MAX_MAG; 270 float MAX_MAG; 271 psMetadata *ghostModel = NULL; 272 psVector *C_terms; 273 psVector *R_terms; 274 float glintPixelScale; 272 pmChip *chip = NULL; 273 pmCell *cell = NULL; 274 pmReadout *readout = NULL; 275 float zeropt, exptime, MAX_MAG; 276 psMetadata *ghostModel = NULL; 277 psVector *C_terms; 278 psVector *R_terms; 279 float glintPixelScale; 280 281 psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions"); 282 283 // select the current recipe 284 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE); 285 if (!recipe) { 286 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe"); 287 return false; 288 } 289 290 bool REFSTAR_MASK_GHOST = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_GHOST"); 291 if (!REFSTAR_MASK_GHOST) return true; 292 293 // Load model from file 294 char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL"); 295 if (!strcasecmp(ghostFile, "NONE")) return true; 296 psLogMsg("psastro", PS_LOG_INFO, "ghost file %s",ghostFile); 297 if (!pmConfigFileRead (&ghostModel, ghostFile, "GHOST MODEL")) { 298 psError(PSASTRO_ERR_CONFIG, true, "Trouble loading ghost model"); 299 return false; 300 } 301 302 // Allocate FPA and refstars 303 pmFPAview *view = pmFPAviewAlloc (0); 304 // select the input astrometry data (also carries the refstars) 305 pmFPAfile *astrom = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 306 if (!astrom) { 307 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data"); 308 goto escape; 309 } 310 pmFPA *fpa = astrom->fpa; 311 312 char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID"); 313 psMetadataItem *item = psMetadataLookup(ghostModel, "GHOST.MODEL.HSC"); 314 if (!item) { 315 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC data missing"); 316 return false; 317 } 318 if (item->type != PS_DATA_METADATA_MULTI) { 319 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC not multi"); 320 return false; 321 } 322 323 psListIterator *iter = psListIteratorAlloc(item->data.list,PS_LIST_HEAD, false); 324 psMetadataItem *refItem = NULL; 325 while ((refItem = psListGetAndIncrement(iter))) { 326 if (refItem->type != PS_DATA_METADATA) { 327 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC entry not metadata"); 328 return false; 329 } 330 char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER"); 331 if (!status) { 332 // psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER"); 333 continue; 334 } 335 if (strcmp(refFilter, filter)) continue; 275 336 276 psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions"); 277 278 // select the current recipe 279 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE); 280 if (!recipe) { 281 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe"); 282 return false; 283 } 284 285 bool REFSTAR_MASK_GHOST = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_GHOST"); 286 if (!REFSTAR_MASK_GHOST) return true; 287 288 // Load model from file 289 char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL"); 290 if (!strcasecmp(ghostFile, "NONE")) return true; 291 292 if (!pmConfigFileRead (&ghostModel, ghostFile, "GHOST MODEL")) { 293 psError(PSASTRO_ERR_CONFIG, true, "Trouble loading ghost model"); 294 return false; 295 } 296 297 // Allocate FPA and refstars 298 pmFPAview *view = pmFPAviewAlloc (0); 299 // select the input astrometry data (also carries the refstars) 300 pmFPAfile *astrom = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 301 if (!astrom) { 302 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data"); 303 goto escape; 304 } 305 pmFPA *fpa = astrom->fpa; 306 307 char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID"); 308 psMetadataItem *item = psMetadataLookup(ghostModel, "GHOST.MODEL.HSC"); 309 if (!item) { 310 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC data missing"); 311 return false; 312 } 313 if (item->type != PS_DATA_METADATA_MULTI) { 314 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC not multi"); 315 return false; 316 } 317 psListIterator *iter = psListIteratorAlloc(item->data.list,PS_LIST_HEAD, false); 318 psMetadataItem *refItem = NULL; 319 while ((refItem = psListGetAndIncrement(iter))) { 320 if (refItem->type != PS_DATA_METADATA) { 321 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC entry not metadata"); 322 return false; 337 C_terms = psMetadataLookupPtr(&status, refItem->data.md, "C_TERMS"); 338 R_terms = psMetadataLookupPtr(&status, refItem->data.md, "R_TERMS"); 339 glintPixelScale = psMetadataLookupF32(&status, refItem->data.md, "SCALE"); 340 } 341 342 // really error-out here? or just skip? 343 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) { 344 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 345 goto escape; 346 } 347 348 // recipe values are given in instrumental magnitudes 349 // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime) 350 float MagOffset = zeropt + 2.5*log10(exptime); 351 MAX_MAG += MagOffset; 352 353 // this loop selects the matched stars for all chips 354 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) { 355 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 356 if (!chip->process || !chip->file_exists) { continue; } 357 if (!chip->fromFPA) { continue; } 358 359 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 360 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 361 if (!cell->process || !cell->file_exists) { continue; } 362 363 // process each of the readouts 364 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 365 if (! readout->data_exists) { continue; } 366 367 // select the raw objects for this readout (loaded in psastroChooseRefstars.c) 368 // XXX : note that we place limits on the refstar sample in psastroChooseRefstars.c: 369 // 1) on chip and 2) < PSASTRO.MAX.NREF. magnitude limits and clump exclusion are only 370 psArray *refstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.REFSTARS"); 371 if (refstars == NULL) { continue; } 372 373 // identify the bright stars of interest 374 for (int i = 0; i < refstars->n; i++) { 375 pmAstromObj *ref = refstars->data[i]; 376 if (ref->Mag > MAX_MAG) continue; 377 378 psastroGhost *ghost = psastroGhostAlloc (); 379 380 double R_TPA = sqrt(pow(ref->TP->y,2) + pow(ref->TP->x,2)); 381 double theta0 = atan2(ref->TP->y,ref->TP->x); 382 double star_radius_deg = R_TPA * glintPixelScale; 383 384 // psTrace("psastro.ghost",5, 385 psLogMsg("psastro",PS_LOG_INFO, 386 "Begin ghost %d/%ld: MAX_MAG: %g; ref_mag: %g @ (%.10g,%.10g) TPA: (%f %f) R: %f %f %f", 387 i,refstars->n,MAX_MAG,ref->Mag,ref->sky->r * 180 / M_PI,ref->sky->d * 180.0 / M_PI,ref->TP->x,ref->TP->y, 388 R_TPA,star_radius_deg,theta0); 389 390 if (star_radius_deg > 0.5) { continue; } 391 392 // Calculate expected position. 393 double C = C_terms->data.F32[0] + C_terms->data.F32[1] * star_radius_deg + C_terms->data.F32[2] * pow(star_radius_deg,2) + 394 C_terms->data.F32[3] * pow(star_radius_deg,3) + C_terms->data.F32[4] * pow(star_radius_deg,4) + 395 C_terms->data.F32[5] * pow(star_radius_deg,5) + C_terms->data.F32[6] * pow(star_radius_deg,6) + 396 C_terms->data.F32[7] * pow(star_radius_deg,7); 397 double R = R_terms->data.F32[0] + R_terms->data.F32[1] * star_radius_deg + R_terms->data.F32[2] * pow(star_radius_deg,2) + 398 R_terms->data.F32[3] * pow(star_radius_deg,3) + R_terms->data.F32[4] * pow(star_radius_deg,4) + 399 R_terms->data.F32[5] * pow(star_radius_deg,5) + R_terms->data.F32[6] * pow(star_radius_deg,6) + 400 R_terms->data.F32[7] * pow(star_radius_deg,7); 401 R = R / 0.015; 402 403 psPlane *fp = psPlaneAlloc(); 404 psPlane *tp = psPlaneAlloc(); 405 406 tp->x = 13.5 * (C * cos(theta0) / 0.015 + 12.78); 407 tp->y = 13.5 * (C * sin(theta0) / 0.015 + 57.74); 408 psPlaneTransformApply(fp,fpa->fromTPA, tp); 409 410 ghost->srcFP->x = ref->FP->x; 411 ghost->srcFP->y = ref->FP->y; 412 ghost->FP->x = fp->x; 413 ghost->FP->y = fp->y; 414 415 ghost->inner.major = 0.0; 416 ghost->inner.minor = 0.0; 417 ghost->outer.major = R; 418 ghost->outer.minor = R; 419 420 pmChip *ghostChip = psastroFindChip (&ghost->chip->x, &ghost->chip->y, fpa, ghost->FP->x, ghost->FP->y); 421 422 if (ghostChip) { 423 psLogMsg("psastro",PS_LOG_INFO, 424 // psTrace("psastro.ghost",5, 425 " in ghost: %d/%ld: ref: (%f,%f) or (%s) ghost: (%f,%f) or (%f,%f,%s) %f inner: (%f,%f,%f) outer: (%f,%f,%f)", 426 i,refstars->n, 427 ref->FP->x,ref->FP->y, 428 psMetadataLookupStr(NULL,chip->concepts,"CHIP.NAME"), 429 ghost->FP->x,ghost->FP->y, 430 ghost->chip->x,ghost->chip->y,psMetadataLookupStr(NULL,ghostChip->concepts,"CHIP.NAME"), 431 C, 432 ghost->inner.major,ghost->inner.minor,ghost->inner.theta, 433 ghost->outer.major,ghost->outer.minor,ghost->outer.theta); 434 } 435 else { 436 psTrace("psastro.ghost",5," in ghost: %d/%ld: ref: (%f,%f) ghost: (%f,%f) or (%f,%f,%s) inner: (%f,%f,%f) outer: (%f,%f,%f)", 437 i,refstars->n, 438 ref->FP->x,ref->FP->y, 439 ghost->FP->x,ghost->FP->y, 440 ghost->chip->x,ghost->chip->y,"NONE", 441 ghost->inner.major,ghost->inner.minor,ghost->inner.theta, 442 ghost->outer.major,ghost->outer.minor,ghost->outer.theta); 443 } 444 445 446 447 if (!ghostChip) goto skip; 448 if (!ghostChip->cells) goto skip; 449 if (!ghostChip->cells->n) goto skip; 450 451 452 pmCell *ghostCell = ghostChip->cells->data[0]; 453 if (!ghostCell) goto skip; 454 if (!ghostCell->readouts) goto skip; 455 if (!ghostCell->readouts->n) goto skip; 456 pmReadout *ghostReadout = ghostCell->readouts->data[0]; 457 if (!ghostReadout) goto skip; 458 459 psArray *ghosts = psMetadataLookupPtr (&status, ghostReadout->analysis, "PSASTRO.GHOSTS"); 460 if (ghosts == NULL) { 461 ghosts = psArrayAllocEmpty (100); 462 if (!psMetadataAdd (ghostReadout->analysis, PS_LIST_TAIL, "PSASTRO.GHOSTS", PS_DATA_ARRAY, "astrometry matches", ghosts)) { 463 psError(PSASTRO_ERR_CONFIG, false, "failure to add ghosts to readout"); 464 goto escape; 465 } 466 psFree (ghosts); 467 } 468 469 psArrayAdd (ghosts, 100, ghost); 470 471 skip: 472 473 psFree (ghost); 474 } 323 475 } 324 char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER"); 325 if (!status) { 326 // psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER"); 327 continue; 328 } 329 if (strcmp(refFilter, filter)) continue; 330 331 C_terms = psMetadataLookupPtr(&status, refItem->data.md, "C_TERMS"); 332 R_terms = psMetadataLookupPtr(&status, refItem->data.md, "R_TERMS"); 333 MAX_MAG = psMetadataLookupF32(&status, refItem->data.md, "LIMIT"); 334 glintPixelScale = psMetadataLookupF32(&status, refItem->data.md, "SCALE"); 335 } 336 337 // really error-out here? or just skip? 338 // if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) { 339 // psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 340 // goto escape; 341 // } 342 343 // recipe values are given in instrumental magnitudes 344 // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime) 345 // float MagOffset = zeropt + 2.5*log10(exptime); 346 // MAX_MAG += MagOffset; 347 348 // this loop selects the matched stars for all chips 349 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) { 350 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 351 if (!chip->process || !chip->file_exists) { continue; } 352 if (!chip->fromFPA) { continue; } 353 354 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 355 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 356 if (!cell->process || !cell->file_exists) { continue; } 357 358 // process each of the readouts 359 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 360 if (! readout->data_exists) { continue; } 361 362 // select the raw objects for this readout (loaded in psastroChooseRefstars.c) 363 // XXX : note that we place limits on the refstar sample in psastroChooseRefstars.c: 364 // 1) on chip and 2) < PSASTRO.MAX.NREF. magnitude limits and clump exclusion are only 365 psArray *refstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.REFSTARS"); 366 if (refstars == NULL) { continue; } 367 368 // identify the bright stars of interest 369 for (int i = 0; i < refstars->n; i++) { 370 pmAstromObj *ref = refstars->data[i]; 371 psTrace("psastro.ghost",5,"Begin ghost %d/%ld: MAX_MAG: %g; ref_mag: %g @ (%.10g,%.10g) TPA: (%f %f)", 372 i,refstars->n,MAX_MAG,ref->Mag,ref->sky->r * 180 / M_PI,ref->sky->d * 180.0 / M_PI,ref->TP->x,ref->TP->y); 373 if (ref->Mag > MAX_MAG) continue; 374 375 psastroGhost *ghost = psastroGhostAlloc (); 376 377 double R_TPA = sqrt(pow(ref->TP->y,2) + pow(ref->TP->x,2)); 378 double theta0 = atan2(ref->TP->y,ref->TP->x); 379 double star_radius_deg = R_TPA * glintPixelScale; 380 if (star_radius_deg > 0.5) { continue; } 381 382 // Calculate expected position. 383 double C = C_terms->data.F32[0] + C_terms->data.F32[1] * star_radius_deg + C_terms->data.F32[2] * pow(star_radius_deg,2) + 384 C_terms->data.F32[3] * pow(star_radius_deg,3) + C_terms->data.F32[4] * pow(star_radius_deg,4) + 385 C_terms->data.F32[5] * pow(star_radius_deg,5) + C_terms->data.F32[6] * pow(star_radius_deg,6) + 386 C_terms->data.F32[7] * pow(star_radius_deg,7); 387 double R = R_terms->data.F32[0] + R_terms->data.F32[1] * star_radius_deg + R_terms->data.F32[2] * pow(star_radius_deg,2) + 388 R_terms->data.F32[3] * pow(star_radius_deg,3) + R_terms->data.F32[4] * pow(star_radius_deg,4) + 389 R_terms->data.F32[5] * pow(star_radius_deg,5) + R_terms->data.F32[6] * pow(star_radius_deg,6) + 390 R_terms->data.F32[7] * pow(star_radius_deg,7); 391 R = 13.5 * (R / 0.015); // Convert to TPA units. 392 393 psPlane *fp = psPlaneAlloc(); 394 psPlane *tp = psPlaneAlloc(); 395 396 tp->x = 13.5 * (C * cos(theta0) / 0.015 + 12.78); 397 tp->y = 13.5 * (C * sin(theta0) / 0.015 + 57.74); 398 psPlaneTransformApply(fp,fpa->fromTPA, tp); 399 400 ghost->srcFP->x = ref->FP->x; 401 ghost->srcFP->y = ref->FP->y; 402 ghost->FP->x = fp->x; 403 ghost->FP->y = fp->y; 404 405 ghost->inner.major = 0.0; 406 ghost->inner.minor = 0.0; 407 ghost->outer.major = R; 408 ghost->outer.minor = R; 409 410 pmChip *ghostChip = psastroFindChip (&ghost->chip->x, &ghost->chip->y, fpa, ghost->FP->x, ghost->FP->y); 411 412 413 414 if (ghostChip) { 415 psTrace("psastro.ghost",5," in ghost: %d/%ld: ref: (%f,%f) or (%s) ghost: (%f,%f) or (%f,%f,%s) %f inner: (%f,%f,%f) outer: (%f,%f,%f)", 416 i,refstars->n, 417 ref->FP->x,ref->FP->y, 418 psMetadataLookupStr(NULL,chip->concepts,"CHIP.NAME"), 419 ghost->FP->x,ghost->FP->y, 420 ghost->chip->x,ghost->chip->y,psMetadataLookupStr(NULL,ghostChip->concepts,"CHIP.NAME"), 421 C, 422 ghost->inner.major,ghost->inner.minor,ghost->inner.theta, 423 ghost->outer.major,ghost->outer.minor,ghost->outer.theta); 424 /* psWarning(" GHOST_DATA: %d/%ld: ref: (%f,%f) or (%f,%f,%s) ghost: (%f,%f) or (%f,%f,%s) %f inner: (%f,%f,%f) outer: (%f,%f,%f)", */ 425 /* i,refstars->n, */ 426 /* ref->FP->x,ref->FP->y, */ 427 /* ref_chip_x,ref_chip_y,psMetadataLookupStr(NULL,chip->concepts,"CHIP.NAME"), */ 428 /* ghost->FP->x,ghost->FP->y, */ 429 /* ghost->chip->x,ghost->chip->y,psMetadataLookupStr(NULL,ghostChip->concepts,"CHIP.NAME"), */ 430 /* rSrc, */ 431 /* ghost->inner.major,ghost->inner.minor,ghost->inner.theta, */ 432 /* ghost->outer.major,ghost->outer.minor,ghost->outer.theta); */ 433 } 434 else { 435 psTrace("psastro.ghost",5," in ghost: %d/%ld: ref: (%f,%f) ghost: (%f,%f) or (%f,%f,%s) inner: (%f,%f,%f) outer: (%f,%f,%f)", 436 i,refstars->n, 437 ref->FP->x,ref->FP->y, 438 ghost->FP->x,ghost->FP->y, 439 ghost->chip->x,ghost->chip->y,"NONE", 440 ghost->inner.major,ghost->inner.minor,ghost->inner.theta, 441 ghost->outer.major,ghost->outer.minor,ghost->outer.theta); 442 } 443 444 445 446 if (!ghostChip) goto skip; 447 if (!ghostChip->cells) goto skip; 448 if (!ghostChip->cells->n) goto skip; 449 450 451 pmCell *ghostCell = ghostChip->cells->data[0]; 452 if (!ghostCell) goto skip; 453 if (!ghostCell->readouts) goto skip; 454 if (!ghostCell->readouts->n) goto skip; 455 pmReadout *ghostReadout = ghostCell->readouts->data[0]; 456 if (!ghostReadout) goto skip; 457 458 psArray *ghosts = psMetadataLookupPtr (&status, ghostReadout->analysis, "PSASTRO.GHOSTS"); 459 if (ghosts == NULL) { 460 ghosts = psArrayAllocEmpty (100); 461 if (!psMetadataAdd (ghostReadout->analysis, PS_LIST_TAIL, "PSASTRO.GHOSTS", PS_DATA_ARRAY, "astrometry matches", ghosts)) { 462 psError(PSASTRO_ERR_CONFIG, false, "failure to add ghosts to readout"); 463 goto escape; 464 } 465 psFree (ghosts); 466 } 467 468 psArrayAdd (ghosts, 100, ghost); 469 470 skip: 471 472 psFree (ghost); 473 } 474 } 475 } 476 } 477 478 psastroExtractFreeChipBounds(); 479 480 psFree (C_terms); 481 psFree (R_terms); 482 psFree (ghostModel); 483 psFree (view); 484 return true; 485 486 escape: 487 psFree (C_terms); 488 psFree (R_terms); 489 psFree (ghostModel); 490 psFree (view); 491 return false; 476 } 477 } 478 479 psastroExtractFreeChipBounds(); 480 481 psFree (C_terms); 482 psFree (R_terms); 483 // psFree (ghostModel); 484 psFree (view); 485 return true; 486 487 escape: 488 psFree (C_terms); 489 psFree (R_terms); 490 // psFree (ghostModel); 491 psFree (view); 492 return false; 492 493 }
Note:
See TracChangeset
for help on using the changeset viewer.
