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