sep
sep copied to clipboard
`maskthresh` is not used?
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?