Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maskthresh is not used? #133

Open
ysBach opened this issue Nov 30, 2021 · 0 comments
Open

maskthresh is not used? #133

ysBach opened this issue Nov 30, 2021 · 0 comments

Comments

@ysBach
Copy link
Contributor

ysBach commented Nov 30, 2021

Make test data first:

import sep
import numpy as np
import pandas as pd

def extractor(data, mask=None, thresh=0., maskthresh=0.0):
    data = data.astype(float)
    if mask is not None:
        mask = mask.astype(float)
    obj, segm = sep.extract(data, thresh=thresh, mask=mask, maskthresh=maskthresh, segmentation_map=True)
    return pd.DataFrame(obj), segm

data = np.array([[0, 10, 0], [10, 100, 10], [0, 10, 0]])
mask = np.array([[0, 1, 0], [1, 2, 1], [0, 1, 0]])

(1) If no mask is provided, maskthresh has no effect, as expected:

extractor(data, maskthresh=0.0)
extractor(data, maskthresh=1.0)
extractor(data, maskthresh=2.0)
# ALL IDENTICAL:
# (   thresh  npix  tnpix  xmin  xmax  ymin  ymax    x    y        x2        y2  \
#  0     0.0     9      5     0     2     0     2  1.0  1.0  0.519231  0.519231   
# ...
# array([[1, 1, 1],
#        [1, 1, 1],
#        [1, 1, 1]], dtype=int32))

(2) If mask is provided, the results are AGAIN identical:

extractor(data, mask, maskthresh=0.0)
extractor(data, mask, maskthresh=2.0)
extractor(data, mask, maskthresh=10.0)
# ALL IDENTICAL:
# (   thresh  npix  tnpix  xmin  xmax  ymin  ymax    x         y   x2        y2  \
#  0     0.0     6      1     0     2     0     1  1.0  0.333333  0.5  0.222222   
# ...
#  array([[1, 1, 1],
#         [1, 1, 1],
#         [0, 0, 0]], dtype=int32))

FYI, the docstring says

   maskthresh : float, optional
        Mask threshold. This is the inclusive upper limit on the mask value in
        order for the corresponding pixel to be unmasked. For boolean arrays,
        `False` and `True` are interpreted as 0 and 1, respectively. Thus,
        given a threshold of zero, True corresponds to masked and `False`
        corresponds to unmasked.

So I expected extractor(data, mask, maskthresh=10.0) should be identical to extractor(data, mask=None). Am I misunderstanding something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant