Commit 16eed05
committed
Restrict "tweaked moments" for "free shape"
1) Consider this the equivalent of commit f3b10b1. That commit tightened the condition for applying "tweaked moments" for forced beams: apply "tweaked moments" only when the rounded barycenter position is part of the island. The current commit tightens the conditions for "tweaked moments" for a "free shape" in the same way in the sense that a maximum pixel value and corresponding position can no longer be used as "basevalue" and "basepos", i.e. can no longer be used as the base point for a "tweaked moments" extrapolation.
2) Fixed a serious bug that occurs for "ill-formed" or large islands: "posx.size==posy.size!=no_pixels" is the source of error. Since we have indices "[0][0]" in the line "i = np.nonzero(mask)[0][0]" this will often still end up right, but we have encountered cases from a collection of 60 GRB images described here: #180 (comment) where a run "pyse GRB201006A/*.fits --vectorized --back-size-x 50 --back-size-y 50" will reveal serious problems, i.e. unrealistic peak brightnesses. This can occur on one machine, while not causing any problems on another machine with exactly the same code. This comes from the way the "np.empty" fills values in these lines in the "extract" module: https://github.com/transientskp/pyse/blob/591717fd72decbb7fc991bf2232be595c3f2b6f3/sourcefinder/extract.py#L2229
"xpositions = np.empty((num_islands, max_pixels), dtype=np.int32)"
and https://github.com/transientskp/pyse/blob/591717fd72decbb7fc991bf2232be595c3f2b6f3/sourcefinder/extract.py#L2230
"ypositions = np.empty((num_islands, max_pixels), dtype=np.int32)"
What is called "xpositions" and "ypositions" in the "extract" module is propagated to "posx" and "posy" in "fitting.moments_enhanced", respectively. The problem can occur for any island smaller than the largest island, i.e. for "no_pixels < max_pixels" from this line https://github.com/transientskp/pyse/blob/591717fd72decbb7fc991bf2232be595c3f2b6f3/sourcefinder/measure.py#L498
"
mask = (posx == rounded_barycenter[0]) & (posy == rounded_barycenter[1])
"
which generally causes "mask.size>no_pixels", i.e. "mask" generally becomes (much) larger than the island. This should nnever occur.
3) After the fix from 1) we end up with a maximum ratio "peak/maxi" of 1.62 from the 60 images described above, see this comment: #182 (comment). That is why
"upp_bound = 2.0 * basevalue" seems appropriate, in the sense that this bound will never be reached. This implies that we could replace that line by "upp_bound = np.inf", but that seems a bit risky at this stage; we have not explored enough pathological cases yet.
4) The comment about the meaning of the "maxi" input to "measure.moments_enhanced" should be clearer now.1 parent 591717f commit 16eed05
1 file changed
Lines changed: 9 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
372 | | - | |
373 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
374 | 375 | | |
375 | 376 | | |
376 | 377 | | |
| |||
464 | 465 | | |
465 | 466 | | |
466 | 467 | | |
| 468 | + | |
| 469 | + | |
467 | 470 | | |
468 | 471 | | |
469 | 472 | | |
| |||
504 | 507 | | |
505 | 508 | | |
506 | 509 | | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
| 510 | + | |
514 | 511 | | |
515 | 512 | | |
516 | 513 | | |
| |||
595 | 592 | | |
596 | 593 | | |
597 | 594 | | |
598 | | - | |
| 595 | + | |
599 | 596 | | |
600 | 597 | | |
601 | 598 | | |
| |||
620 | 617 | | |
621 | 618 | | |
622 | 619 | | |
623 | | - | |
| 620 | + | |
624 | 621 | | |
625 | | - | |
| 622 | + | |
626 | 623 | | |
627 | 624 | | |
628 | 625 | | |
| |||
0 commit comments