Changeset 41290
- Timestamp:
- Feb 25, 2020, 9:55:36 AM (6 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 3 edited
-
psastro.h (modified) (1 diff)
-
psastroLoadGhosts.c (modified) (16 diffs)
-
psastroLoadGlints.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastro.h
r40490 r41290 60 60 psastroGhost *psastroGhostAlloc (void); 61 61 bool psastroLoadGhosts (pmConfig *config); 62 bool psastroLoadGhostsHSC (pmConfig *config);63 62 64 63 bool psastroDataSave (pmConfig *config, psMetadata *stats); -
trunk/psastro/src/psastroLoadGhosts.c
r40552 r41290 13 13 # include "psastroInternal.h" 14 14 15 // These are only used locally: 16 bool psastroLoadGhostsGPC (pmConfig *config, psMetadata *recipe, psMetadata *ghostModel, char *ghostFile); 17 bool psastroLoadGhostsHSC (pmConfig *config, psMetadata *recipe, psMetadata *ghostModel, char *ghostFile); 18 15 19 # define GET_2D_POLY(NAME,OUT) \ 16 20 md = psMetadataLookupMetadata (&status, ghostModel, NAME); \ … … 41 45 */ 42 46 43 44 45 47 bool psastroLoadGhosts (pmConfig *config) { 48 49 bool status; 50 51 psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions"); 52 53 // select the current recipe 54 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE); 55 if (!recipe) { 56 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe"); 57 return false; 58 } 59 60 // do we want to mask ghosts? 61 bool REFSTAR_MASK_GHOST = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_GHOST"); 62 if (!REFSTAR_MASK_GHOST) return true; 63 64 // choose ghost model file 65 char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL"); 66 if (!strcasecmp(ghostFile, "NONE")) return true; 67 68 // load ghost model metadata structure 69 psMetadata *ghostModel = NULL; 70 if (!pmConfigFileRead (&ghostModel, ghostFile, "GHOST MODEL")) { 71 psError(PSASTRO_ERR_CONFIG, true, "Trouble loading ghost model"); 72 return false; 73 } 74 75 // test for items which are used by either the GPC or HSC ghost models: 76 psMetadataItem *item = NULL; 77 78 // test for required HSC ghost model elements 79 item = psMetadataLookup(ghostModel, "GHOST.MODEL.HSC"); 80 if (item) { 81 status = psastroLoadGhostsHSC (config, recipe, ghostModel, ghostFile); 82 if (!status) goto escape; 83 } 84 85 // test for required GPC ghost model elements 86 item = psMetadataLookup(ghostModel, "GHOST.CENTER.X"); 87 if (item) { 88 status = psastroLoadGhostsGPC (config, recipe, ghostModel, ghostFile); 89 if (!status) goto escape; 90 } 91 92 escape: 93 psFree (ghostModel); 94 return status; 95 } 96 97 bool psastroLoadGhostsGPC (pmConfig *config, psMetadata *recipe, psMetadata *ghostModel, char *ghostFile) { 46 98 47 99 bool status; … … 57 109 psPolynomial1D *innerMajor = NULL; 58 110 psPolynomial1D *innerMinor = NULL; 59 psMetadata *ghostModel = NULL;60 61 psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions");62 63 // XXX this needs to be camera-dependent64 if (0) {65 psWarning("Doing the hard coded switch to HSC ghosts still.");66 return (psastroLoadGhostsHSC(config));67 }68 69 psWarning("hard coded switch to GPC ghosts.");70 71 // select the current recipe72 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);73 if (!recipe) {74 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");75 return false;76 }77 78 bool REFSTAR_MASK_GHOST = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_GHOST");79 if (!REFSTAR_MASK_GHOST) return true;80 81 82 char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL");83 if (!strcasecmp(ghostFile, "NONE")) return true;84 85 if (!pmConfigFileRead (&ghostModel, ghostFile, "GHOST MODEL")) {86 psError(PSASTRO_ERR_CONFIG, true, "Trouble loading ghost model");87 return false;88 }89 111 90 112 pmFPAview *view = pmFPAviewAlloc (0); 91 92 GET_2D_POLY ("GHOST.CENTER.X", centerX);93 GET_2D_POLY ("GHOST.CENTER.Y", centerY);94 95 GET_1D_POLY ("GHOST.OUTER.MAJOR", outerMajor);96 GET_1D_POLY ("GHOST.OUTER.MINOR", outerMinor);97 GET_1D_POLY ("GHOST.INNER.MAJOR", innerMajor);98 GET_1D_POLY ("GHOST.INNER.MINOR", innerMinor);99 113 100 114 // select the input astrometry data (also carries the refstars) … … 106 120 pmFPA *fpa = astrom->fpa; 107 121 108 // really error-out here? or just skip? 122 GET_2D_POLY ("GHOST.CENTER.X", centerX); 123 GET_2D_POLY ("GHOST.CENTER.Y", centerY); 124 125 GET_1D_POLY ("GHOST.OUTER.MAJOR", outerMajor); 126 GET_1D_POLY ("GHOST.OUTER.MINOR", outerMinor); 127 GET_1D_POLY ("GHOST.INNER.MAJOR", innerMajor); 128 GET_1D_POLY ("GHOST.INNER.MINOR", innerMinor); 129 130 // raise an error if the config is broken 109 131 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) { 110 ps LogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");132 psError(PSASTRO_ERR_CONFIG, true, "failed to load zeropt data from recipe"); 111 133 goto escape; 112 134 } … … 253 275 psFree (outerMajor); 254 276 psFree (outerMinor); 255 psFree (ghostModel);256 277 psFree (view); 257 278 return true; … … 264 285 psFree (outerMajor); 265 286 psFree (outerMinor); 266 psFree (ghostModel);267 287 psFree (view); 268 288 return false; 269 289 } 270 271 272 290 273 bool psastroLoadGhostsHSC (pmConfig *config) { 291 // This function adds the ghost mask elements to the ghostReadout->analysis structures. 292 // We return false and raise an error on a config problem. 293 bool psastroLoadGhostsHSC (pmConfig *config, psMetadata *recipe, psMetadata *ghostModel, char *ghostFile) { 294 274 295 bool status; 275 296 pmChip *chip = NULL; … … 277 298 pmReadout *readout = NULL; 278 299 float zeropt, exptime, MAX_MAG; 279 psMetadata *ghostModel = NULL;280 300 psVector *C_terms = NULL; 281 301 psVector *R_terms = NULL; 282 302 float glintPixelScale = 0.0; 283 303 284 psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions");285 286 // select the current recipe287 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);288 if (!recipe) {289 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");290 return false;291 }292 293 bool REFSTAR_MASK_GHOST = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_GHOST");294 if (!REFSTAR_MASK_GHOST) return true;295 296 // Load model from file297 char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL");298 if (!strcasecmp(ghostFile, "NONE")) return true;299 psLogMsg("psastro", PS_LOG_INFO, "ghost file %s",ghostFile);300 if (!pmConfigFileRead (&ghostModel, ghostFile, "GHOST MODEL")) {301 psError(PSASTRO_ERR_CONFIG, true, "Trouble loading ghost model");302 return false;303 }304 305 304 // Allocate FPA and refstars 306 305 pmFPAview *view = pmFPAviewAlloc (0); 306 307 307 // select the input astrometry data (also carries the refstars) 308 308 pmFPAfile *astrom = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); … … 314 314 315 315 char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID"); 316 316 317 psMetadataItem *item = psMetadataLookup(ghostModel, "GHOST.MODEL.HSC"); 317 318 if (!item) { 318 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC data missing");319 return false;319 psError(PSASTRO_ERR_CONFIG, true, "GHOST.MODEL.HSC data missing"); 320 goto escape; 320 321 } 321 322 if (item->type != PS_DATA_METADATA_MULTI) { 322 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC not multi");323 return false;323 psError(PSASTRO_ERR_CONFIG, true, "GHOST.MODEL.HSC not multi"); 324 goto escape; 324 325 } 325 326 … … 328 329 while ((refItem = psListGetAndIncrement(iter))) { 329 330 if (refItem->type != PS_DATA_METADATA) { 330 psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC entry not metadata");331 return false;331 psError(PSASTRO_ERR_CONFIG, true, "GHOST.MODEL.HSC entry not metadata"); 332 goto escape; 332 333 } 333 334 char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER"); 334 335 if (!status) { 335 // psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER");336 336 continue; 337 337 } … … 343 343 } 344 344 345 // really error-out here? or just skip?345 // if a ghost model is not defined for a filter, skip HSC ghost model for that filter (no error) 346 346 if (!R_terms) { 347 347 psLogMsg ("psastro", PS_LOG_INFO, "failed to find HSC ghost model for filter %s", filter); 348 goto escape;349 } 350 351 // really error-out here? or just skip?348 goto giveup; 349 } 350 351 // if a filter is defined, but the recipe elements are missing, the config is broken. 352 352 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) { 353 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");354 goto escape;353 psError(PSASTRO_ERR_CONFIG, true, "failed to load zeropt data from recipe"); 354 goto escape; 355 355 } 356 356 … … 430 430 431 431 if (ghostChip) { 432 psLogMsg("psastro",PS_LOG_INFO, 433 // psTrace("psastro.ghost",5, 432 psLogMsg("psastro", PS_LOG_INFO, 434 433 " 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)", 435 434 i,refstars->n, … … 441 440 ghost->inner.major,ghost->inner.minor,ghost->inner.theta, 442 441 ghost->outer.major,ghost->outer.minor,ghost->outer.theta); 443 } 444 else {445 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)",442 } else { 443 psTrace("psastro.ghost", 5, 444 " in ghost: %d/%ld: ref: (%f,%f) ghost: (%f,%f) or (%f,%f,%s) inner: (%f,%f,%f) outer: (%f,%f,%f)", 446 445 i,refstars->n, 447 446 ref->FP->x,ref->FP->y, … … 451 450 ghost->outer.major,ghost->outer.minor,ghost->outer.theta); 452 451 } 453 454 455 452 456 453 if (!ghostChip) goto skip; … … 475 472 psFree (ghosts); 476 473 } 477 478 474 psArrayAdd (ghosts, 100, ghost); 479 475 480 476 skip: 481 482 477 psFree (ghost); 483 478 } … … 488 483 psastroExtractFreeChipBounds(); 489 484 485 giveup: 490 486 psFree (C_terms); 491 487 psFree (R_terms); 492 // psFree (ghostModel);493 488 psFree (view); 494 489 return true; … … 497 492 psFree (C_terms); 498 493 psFree (R_terms); 499 // psFree (ghostModel);500 494 psFree (view); 501 495 return false; -
trunk/psastro/src/psastroLoadGlints.c
r40552 r41290 364 364 if (star_radius_deg < 0.8831) { 365 365 outer_edge_angle = 0.0; 366 } 367 else if (star_radius_deg < 0.9368) { 366 } else if (star_radius_deg < 0.9368) { 368 367 outer_edge_angle = 46.2985 * sqrt(star_radius_deg - 0.8831); 369 } 370 else { 368 } else { 371 369 outer_edge_angle = -2.67 + 14.3 * star_radius_deg; 372 370 } 373 371 if (star_radius_deg < 0.964) { 374 372 inner_edge_angle = -243.866 * pow(star_radius_deg - 0.932,2) + 2.4636; 375 } 376 else { 373 } else { 377 374 inner_edge_angle = 66.2061 * sqrt(star_radius_deg - 0.9635); 378 375 } … … 383 380 // These define the ends of a single arc in arc-centric coordinates 384 381 double x1 = C - R * cos(inner_edge_angle); 385 double y1 = R * sin(inner_edge_angle);382 double y1 = R * sin(inner_edge_angle); 386 383 double x2 = C - R * cos(outer_edge_angle); 387 double y2 = R * sin(outer_edge_angle);384 double y2 = R * sin(outer_edge_angle); 388 385 389 386 // Create the endpoints for the pair of arcs in device coordinates (in millimeters) … … 414 411 x2s,y2s,x2e,y2e); 415 412 416 413 // NOTE: the calculations below appear to expect (x1s, y1s) in millimeters, as mentioned above. 414 // They are then scaled to camera pixel units using 0.015 millimeters / pixel, and then to 415 // TPA units using 13.5 pixels / pixel. I do not know where the (12.78, 57.75) mm offsets 416 // come from (displacement of reference chip?) 417 417 418 tp->x = 13.5 * (y1s / 0.015 + 12.78); 418 419 tp->y = 13.5 * (x1s / -0.015 + 57.74); … … 420 421 x_start->data.F32[0] = fp->x; 421 422 y_start->data.F32[0] = fp->y; 422 // x_start->data.F32[0] = tp->x;423 // y_start->data.F32[0] = tp->y;424 423 425 424 tp->x = 13.5 * (y1e / 0.015 + 12.78); … … 428 427 x_end->data.F32[0] = fp->x; 429 428 y_end->data.F32[0] = fp->y; 430 // x_end->data.F32[0] = tp->x;431 // y_end->data.F32[0] = tp->y;432 429 433 430 x_start->data.F32[1] = x_end->data.F32[0]; … … 441 438 x_start->data.F32[2] = fp->x; 442 439 y_start->data.F32[2] = fp->y; 443 // x_start->data.F32[2] = tp->x;444 // y_start->data.F32[2] = tp->y;445 440 446 441 tp->x = 13.5 * (y2e / 0.015 + 12.78); … … 449 444 x_end->data.F32[2] = fp->x; 450 445 y_end->data.F32[2] = fp->y; 451 // x_end->data.F32[2] = tp->x;452 // y_end->data.F32[2] = tp->y;453 446 454 447 x_start->data.F32[3] = x_end->data.F32[2];
Note:
See TracChangeset
for help on using the changeset viewer.
