Changeset 36837
- Timestamp:
- Jun 8, 2014, 9:27:56 AM (12 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 9 edited
-
psastro.h (modified) (2 diffs)
-
psastroArguments.c (modified) (2 diffs)
-
psastroCleanup.c (modified) (1 diff)
-
psastroConvert.c (modified) (7 diffs)
-
psastroDataLoad.c (modified) (2 diffs)
-
psastroDefineFiles.c (modified) (1 diff)
-
psastroLoadCrosstalk.c (modified) (3 diffs)
-
psastroOneChipFit.c (modified) (6 diffs)
-
psastroOneChipGrid.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastro.h
r35715 r36837 66 66 bool psastroAnalysis (pmConfig *config, psMetadata *stats); 67 67 68 bool psastroConvertFPA (pmFPA *fpa, psMetadata *recipe); 69 bool psastroConvertReadout (pmReadout *readout, psMetadata *recipe); 68 bool psastroConvertFPA (pmConfig *config, pmFPA *fpa, psMetadata *recipe); 69 bool psastroConvertReadout (pmConfig *config, pmFPAview *view, pmReadout *readout, psMetadata *recipe); 70 bool psastroCorrectKH (pmConfig *config, pmFPAview *view, pmReadout *readout, psMetadata *recipe, psArray *inStars); 71 70 72 psArray *pmSourceToAstromObj (psArray *sources); 71 73 bool psastroAstromGuess (int *nStars, pmConfig *config); … … 90 92 psArray *psastroRemoveClumpsIterate (psArray *input, int scale, int nIter); 91 93 bool psastroRemoveClumpsRawstars (pmConfig *config); 94 95 bool psastroChipFailureHeader (psMetadata *updates); 92 96 93 97 -
trunk/psastro/src/psastroArguments.c
r35715 r36837 60 60 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.USE.MODEL", PS_META_REPLACE, "", true); 61 61 } 62 // define the reference astrometry file 62 // define the reference astrometry file (add a container ASTROM.MODEL to config->arguments if -astrommodel (file) is found) 63 63 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "ASTROM.MODEL", "-astrommodel", "-astrommodellist"); 64 65 // define the koppenhoefer correction file (add a container KH.CORRECT to config->arguments if -kh-correct (file) is found) 66 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "KH.CORRECT", "-kh-correct", NULL); 64 67 65 68 // define the reference astrometry file … … 108 111 } 109 112 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.SKIP.ASTRO", PS_META_REPLACE, "", true); 113 114 // SKIP.ASTRO and USE.MODEL are fundamentally incompatible 115 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.USE.MODEL", PS_META_REPLACE, "", false); 110 116 } 111 117 -
trunk/psastro/src/psastroCleanup.c
r23242 r36837 17 17 psFree (config); 18 18 pmVisualClose (); 19 pmVisualCleanup (); 19 20 20 21 psTimerStop (); -
trunk/psastro/src/psastroConvert.c
r31661 r36837 16 16 static psArray *chooseStars(psArray *inStars, char *listName, psArray *sources, psVector *index, int nMax, float iMagMin, float iMagMax, pmSourceMode skip); 17 17 18 bool psastroConvertFPA (pm FPA *fpa, psMetadata *recipe) {18 bool psastroConvertFPA (pmConfig *config, pmFPA *fpa, psMetadata *recipe) { 19 19 20 20 pmChip *chip; … … 35 35 if (! readout->data_exists) { continue; } 36 36 37 psastroConvertReadout (readout, recipe); 37 if (!psastroConvertReadout (config, view, readout, recipe)) { 38 psError(PSASTRO_ERR_CONFIG, true, "problem converting readout\n"); 39 return false; 40 } 38 41 } 39 42 } … … 44 47 45 48 // pass/apply the WCS information? 46 bool psastroConvertReadout (pm Readout *readout, psMetadata *recipe) {49 bool psastroConvertReadout (pmConfig *config, pmFPAview *view, pmReadout *readout, psMetadata *recipe) { 47 50 48 51 bool status; … … 57 60 // convert the pmSource objects into pmAstromObj objects (drop !STAR and SATSTAR?) 58 61 psArray *inStars = pmSourceToAstromObj (sources); 62 63 // apply Koppenhoefer correction if needed 64 if (!psastroCorrectKH (config, view, readout, recipe, inStars)){ 65 psError(PSASTRO_ERR_CONFIG, true, "failed to correct Koppenhoefer Effect\n"); 66 return false; 67 } 59 68 60 69 // sort in ascending magnitude order … … 183 192 psF32 *dPAR = model->dparams->data.F32; 184 193 194 // Note from EAM: I measured the KH correction from the nightly science database 195 // The KH effect was active until 2011/05/11 when the camera voltages were modified 196 // Between 2011/09/06 and 2013/04/30, there was a bug in pmPSF_ModelToAxes with the 197 // result that the reported values were too large by a factor of sqrt(2). Fortunately, 198 // this did not affect the data in the nightly science DVO used to measure the 199 // effect (all affected data was processed BEFORE the bug was introduced), and it 200 // does not affect any of the PV2 or PV3 data processed AFTER the bug was fixed. 201 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, model->type); 202 185 203 pmAstromObj *obj = pmAstromObjAlloc (); 186 204 … … 192 210 obj->Mag = source->psfMag; 193 211 obj->dMag = source->psfMagErr; 212 obj->SBinst = source->psfMag + 5.0*log10(axes.major); 194 213 195 214 // XXX do we have the information giving the readout and cell offset? … … 221 240 } 222 241 242 static float pltScale[] = { 243 +0.0, 244 -0.255347177386, 245 -0.255585625172, 246 -0.255733260512, 247 -0.255747352242, 248 -0.255611001253, 249 -0.255311933756, 250 +0.0, 251 +0.0, 252 +0.0, 253 -0.255296201766, 254 -0.255688636720, 255 -0.256161080003, 256 -0.256464074850, 257 -0.256324860930, 258 -0.256147363186, 259 -0.255734743476, 260 -0.255422729909, 261 +0.0, 262 +0.0, 263 -0.255508323163, 264 -0.256142899513, 265 -0.255493895173, 266 -0.256997376740, 267 -0.256935591102, 268 -0.256644588679, 269 -0.256123321533, 270 -0.255515242517, 271 +0.0, 272 +0.0, 273 -0.255633033872, 274 -0.256356916189, 275 -0.256929253668, 276 -0.257250442505, 277 -0.257260403216, 278 -0.256962024927, 279 -0.256387320280, 280 -0.255681164920, 281 +0.0, 282 +0.0, 283 -0.255671992302, 284 -0.256371312678, 285 -0.256936249495, 286 -0.257237892330, 287 -0.257248004675, 288 -0.256911942035, 289 -0.256365648448, 290 -0.255632205397, 291 +0.0, 292 +0.0, 293 -0.255455072403, 294 -0.256080205411, 295 -0.256570428520, 296 -0.256908982217, 297 -0.256899240971, 298 -0.256607972383, 299 -0.256107793808, 300 -0.255482232273, 301 +0.0, 302 +0.0, 303 -0.255237901688, 304 -0.255669494152, 305 -0.256101093233, 306 -0.256372770309, 307 -0.256373448133, 308 -0.256118197262, 309 -0.255689391643, 310 -0.255279636681, 311 +0.0, 312 +0.0, 313 +0.0, 314 -0.255286350489, 315 -0.255517200172, 316 -0.255689459741, 317 -0.255668706447, 318 -0.255539349556, 319 -0.255363308907, 320 }; 321 322 bool psastroCorrectKH (pmConfig *config, pmFPAview *view, pmReadout *readout, psMetadata *recipe, psArray *inStars) { 323 324 bool status; 325 326 psAssert (readout, "missing readout"); 327 psAssert (readout->parent, "missing cell"); 328 psAssert (readout->parent->parent, "missing chip"); 329 330 // should we stay or should we go? 331 bool apply = psMetadataLookupBool (&status, recipe, "KH.CORRECT.APPLY.EXP"); 332 if (!apply) return true; 333 334 // get the chip ID from the chip name: 335 pmChip *chip = readout->parent->parent; 336 char *chipName = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 337 338 psAssert (strlen(chipName) == 4, "error in chip name"); 339 psAssert (chipName[0] == 'X', "error in chip name"); 340 psAssert (chipName[1] == 'Y', "error in chip name"); 341 342 int chipID = atoi (&chipName[2]); 343 344 // XXX hardwired list of chips to correct 345 // some notes: 346 // XY24 surpisingly does not need correction 347 // XY27 has poor astrometry with a weird correction for all mags 348 // XY36 surpisingly does not need correction 349 // XY67 has poor astrometry with a weird correction for all mags 350 351 // correct this chip? (raise an error for unexpected chipID values) 352 switch (chipID) { 353 case 1: // do not correct 354 case 2: // do not correct 355 case 3: // do not correct 356 case 10: // do not correct 357 case 11: // do not correct 358 case 12: // do not correct 359 case 13: // do not correct 360 case 20: // do not correct 361 case 21: // do not correct 362 case 22: // do not correct 363 case 23: // do not correct 364 case 24: // do not correct 365 case 27: // do not correct 366 case 30: // do not correct 367 case 31: // do not correct 368 case 32: // do not correct 369 case 33: // do not correct 370 case 36: // do not correct 371 case 44: // do not correct 372 case 45: // do not correct 373 case 46: // do not correct 374 case 47: // do not correct 375 case 54: // do not correct 376 case 55: // do not correct 377 case 56: // do not correct 378 case 57: // do not correct 379 case 64: // do not correct 380 case 65: // do not correct 381 case 66: // do not correct 382 case 67: // do not correct 383 case 74: // do not correct 384 case 75: // do not correct 385 case 76: // do not correct 386 return true; 387 case 4: // correct 388 case 5: // correct 389 case 6: // correct 390 case 14: // correct 391 case 15: // correct 392 case 16: // correct 393 case 17: // correct 394 case 25: // correct 395 case 26: // correct 396 case 34: // correct 397 case 35: // correct 398 case 37: // correct 399 case 40: // correct 400 case 41: // correct 401 case 42: // correct 402 case 43: // correct 403 case 50: // correct 404 case 51: // correct 405 case 52: // correct 406 case 53: // correct 407 case 60: // correct 408 case 61: // correct 409 case 62: // correct 410 case 63: // correct 411 case 71: // correct 412 case 72: // correct 413 case 73: // correct 414 break; 415 default: 416 psAbort ("chipID is invalid"); 417 } 418 419 // grab the KH correction file 420 pmFPAfile *KHfile = psMetadataLookupPtr (NULL, config->files, "PSASTRO.KH.CORRECT"); 421 if (!KHfile) { 422 psError(PM_ERR_CONFIG, false, "KH correction file not found"); 423 return false; 424 } 425 426 // grab the corresponding chip 427 pmChip *KHchip = pmFPAviewThisChip (view, KHfile->fpa); 428 psAssert (KHchip, "found KH file, but not chip?"); 429 430 // grab the correction spline 431 KHcorrectData *spline = psMetadataLookupPtr (&status, KHchip->analysis, "KH.CORRECT"); 432 if (!spline) { 433 psError(PM_ERR_CONFIG, false, "KH correction not found"); 434 return false; 435 } 436 437 // the hard-wired array of plate-scales per chip above come from 438 // a single smf. in there, a negative plate scale means parity is flipped 439 // on the sky. 440 float myPltScale = fabs(pltScale[chipID]); 441 442 // apply the correction to the detections 443 for (int i = 0; i < inStars->n; i++) { 444 pmAstromObj *obj = inStars->data[i]; 445 446 float Xraw = obj->pix->x; 447 float SBinst = obj->SBinst; 448 449 float dX = KHcorrectApply (spline, SBinst); 450 451 float Xfix = Xraw + dX / myPltScale; 452 453 // note that we carry around pix, cell, chip but the real analysis only operates on chip 454 // if in the future we add transformations between chip->cell->pix, then we will need to 455 // make these consistent as well. 456 obj->pix->x = Xfix; 457 obj->cell->x = Xfix; 458 obj->chip->x = Xfix; 459 } 460 461 return true; 462 463 } 464 -
trunk/psastro/src/psastroDataLoad.c
r21409 r36837 53 53 pmFPAfileActivate (config->files, true, "PSASTRO.INPUT"); 54 54 55 // if we request KH Correction, activate that file as well 56 bool applyKH = psMetadataLookupBool (NULL, recipe, "KH.CORRECT.APPLY.EXP"); 57 if (applyKH) { 58 pmFPAfileActivate (config->files, true, "PSASTRO.KH.CORRECT"); 59 } 60 55 61 pmFPAview *view = pmFPAviewAlloc (0); 56 62 … … 73 79 if (!readout->data_exists) { continue; } 74 80 75 if (!psastroConvertReadout ( readout, recipe)) ESCAPE;81 if (!psastroConvertReadout (config, view, readout, recipe)) ESCAPE; 76 82 77 83 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; -
trunk/psastro/src/psastroDefineFiles.c
r36441 r36837 43 43 if (!psastroDefineFile (config, input->fpa, "PSASTRO.MODEL", "ASTROM.MODEL", PM_FPA_FILE_ASTROM_MODEL, PM_DETREND_TYPE_ASTROM)) { 44 44 psError (PS_ERR_IO, false, "Can't find an astrometry model file"); 45 return NULL; 46 } 47 } 45 return false; 46 } 47 } 48 49 bool KHapply = psMetadataLookupBool (&status, recipe, "KH.CORRECT.APPLY"); 50 if (KHapply) { 51 // Get the time from FPA.TIME 52 psTime *time = psMetadataLookupPtr(NULL, input->fpa->concepts, "FPA.TIME"); 53 if (time->sec == 0 && time->nsec == 0) { 54 psError (PM_ERR_CONFIG, false, "KH.CORRECT.APPLY requested, but date/time of exposure not found"); 55 return false; 56 } 57 // what is the appropriate date range for the correction 58 char *KHendDate = psMetadataLookupStr (&status, recipe, "KH.CORRECT.ENDDATE"); 59 if (!KHendDate) { 60 psError (PM_ERR_CONFIG, false, "KH.CORRECT.APPLY requested, but KH.CORRECT.ENDDATE not in recipe"); 61 return false; 62 } 63 psTime *endtime = psTimeFromString (KHendDate, PS_TIME_TAI); 64 if (!endtime) { 65 psError (PM_ERR_CONFIG, false, "KH.CORRECT.APPLY requested, KH.CORRECT.ENDDATE has an invalid date/time"); 66 return false; 67 } 68 if (psTimeDelta (endtime, time) < 0) { 69 KHapply = false; 70 psLogMsg ("psastro", PS_LOG_INFO, "Koppenhoefer correction requested, but exposure after end date, correction skipped"); 71 } else { 72 psLogMsg ("psastro", PS_LOG_INFO, "Koppenhoefer correction requested, exposure in valid date range, correction may be applied"); 73 } 74 psFree (endtime); 75 } 76 if (KHapply) { 77 if (!psastroDefineFile (config, input->fpa, "PSASTRO.KH.CORRECT", "KH.CORRECT", PM_FPA_FILE_KH_CORRECT, PM_DETREND_TYPE_KH_CORRECT)) { 78 psError (PS_ERR_IO, false, "Can't find a Koppenhoefer Correction file"); 79 return NULL; 80 } 81 } 82 // the bool above in the recipe says "apply generally for this camera". here we are asserting that 83 // we can and should apply for this exposure XXX change the name? 84 psMetadataAddBool (recipe, PS_LIST_TAIL, "KH.CORRECT.APPLY.EXP", PS_META_REPLACE, "", KHapply); 48 85 49 86 // this step is optional -
trunk/psastro/src/psastroLoadCrosstalk.c
r36789 r36837 175 175 176 176 float x_t_chip,y_t_chip; 177 // int faint_ct = 0; 177 // int faint_ct = 0; NOTE: not currently used 178 178 pmCellCoordsForChip(&x_cell,&y_cell,CTsourceCell,ref->chip->x,ref->chip->y); 179 179 … … 229 229 Xt = 3; 230 230 Ut = 2; 231 // faint_ct = 1; 231 // faint_ct = 1; NOTE: not currently used 232 232 } 233 233 } … … 251 251 Xt = 4; 252 252 Ut = 2; 253 // faint_ct = 1; 253 // faint_ct = 1; NOTE: not currently used 254 254 } 255 255 } -
trunk/psastro/src/psastroOneChipFit.c
r27639 r36837 62 62 if (match == NULL) { 63 63 psLogMsg ("psastro", 3, "failed to find radius-matched sources\n"); 64 psastroChipFailureHeader (updates); 64 65 return false; 65 66 } … … 69 70 if (!unique) { 70 71 psLogMsg ("psastro", 3, "failed to generate a uniq set of matched sources\n"); 72 psastroChipFailureHeader (updates); 71 73 return false; 72 74 } … … 99 101 psLogMsg ("psastro", 3, "insufficient stars or invalid order: %ld stars", match->n); 100 102 psFree (match); 103 psastroChipFailureHeader (updates); 101 104 return false; 102 105 } … … 126 129 psFree (match); 127 130 psFree (fitStats); 131 psastroChipFailureHeader (updates); 128 132 return false; 129 133 } … … 185 189 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", astNstar); 186 190 } else { 187 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", 0.0); 188 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", 0); 191 psastroChipFailureHeader (updates); 189 192 } 190 193 psMetadataAddF32 (updates, PS_LIST_TAIL, "EQUINOX", PS_META_REPLACE, "equinox of ref catalog", 2000.0); // XXX this is bogus: should be defined based on equinox of refstars … … 222 225 } 223 226 227 bool psastroChipFailureHeader (psMetadata *updates) { 228 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", 0.0); 229 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", 0); 230 return true; 231 } 232 233 234 224 235 // psastroWriteStars ("raw.1.dat", rawstars); 225 236 // psastroWriteStars ("ref.1.dat", refstars); -
trunk/psastro/src/psastroOneChipGrid.c
r31161 r36837 57 57 psFree (rawGridStars); 58 58 psFree (refGridStars); 59 psastroChipFailureHeader (updates); 59 60 return false; 60 61 } … … 68 69 psFree (rawGridStars); 69 70 psFree (refGridStars); 71 psastroChipFailureHeader (updates); 70 72 return false; 71 73 }
Note:
See TracChangeset
for help on using the changeset viewer.
