Changeset 42090
- Timestamp:
- Feb 28, 2022, 2:45:39 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryObjects.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryObjects.c
r41892 r42090 41 41 float psVectorSystematicError (psVector *residuals, psVector *errors, float clipFraction); 42 42 float pmAstrom2DSystematics (psVector *xPos, psVector *yPos, psVector *value); 43 float pmAstromSubsetSystematics (psVector *value); 43 44 44 45 #define PM_ASTROMETRYOBJECTS_DEBUG 1 … … 433 434 434 435 // pre-filter the values to ensure no NANs, other invalid 435 if (xPos->n < VAL_COUNT*2*2) { 436 return NAN; 436 437 // if we do not have enough measurements (< 25), use pmAstromSubsetSystematics instead (OK to 9 values) 438 if (xPos->n < MIN_COUNT*2*2) { 439 float result = pmAstromSubsetSystematics (value); 440 return result; 437 441 } 438 442 … … 517 521 psFree (sample); 518 522 523 return result; 524 } 525 526 # define SUBSET_NSAMPLE 3 527 // last-ditch attempt to assess the systematic error in the data. Just split into 3 bins, 528 // calculate median in each, and calculate stdev of the subset. The minimum number of 529 // values needed to make this measurement in any sensible way : 3*3 = 6. 530 float pmAstromSubsetSystematics (psVector *value) { 531 532 // give up if too few stars: 533 if (value->n < 3*SUBSET_NSAMPLE) return NAN; 534 535 psVector *sample = psVectorAlloc (SUBSET_NSAMPLE, PS_TYPE_F32); 536 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 537 538 // note that this drops the last 1 or 2 values if value->n % 3 = 1 or 2 539 int nSubset = value->n / SUBSET_NSAMPLE; 540 psVector *subset = psVectorAlloc (nSubset, PS_TYPE_F32); 541 for (int iter = 0; iter < SUBSET_NSAMPLE; iter++) { 542 for (int i = 0; i < nSubset; i++) { 543 subset->data.F32[i] = value->data.F32[i + nSubset*iter]; 544 } 545 546 // psVectorStats resets stats so we can call this repeatedly 547 psVectorStats (stats, subset, NULL, NULL, 0); 548 if (isfinite(stats->sampleMedian)) { 549 sample->data.F32[iter] = stats->sampleMedian; 550 } 551 } 552 553 stats->options = PS_STAT_SAMPLE_STDEV; 554 psVectorStats (stats, sample, NULL, NULL, 0); 555 float result = stats->sampleStdev; 556 557 if (!isfinite(stats->sampleStdev)) { 558 fprintf (stderr, "*** bad solution (2) ***\n"); 559 } 560 561 psFree (stats); 562 psFree (sample); 563 psFree (subset); 564 519 565 return result; 520 566 }
Note:
See TracChangeset
for help on using the changeset viewer.
