astropy / astropy/specutils

Create a mask from regions

Open
#552 1 comment 0 reactions 0 assignees View on GitHub
feature
Dominant language
Python
Stars
204
Forks
134
Avg merge
12h 55m
Merged PRs (30d)
1

Description

I'm not finding in the documentation any function to create a mask from a set of regions. Seems like we should have that, and maybe the inverse as well.

Something like this...

```
def mask_from_regions(spectrum,regions):
mask = np.zeros(spectrum.spectral_axis.shape,dtype=np.bool)
for r in regions:
submask = (spectrum.spectral_axis>r.lower) & (spectrum.spectral_axis<=r.upper)
mask = mask | submask
spectrum.mask = mask
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the documentation and existing spectrum masking APIs for a suitable entry point for mask_from_regions. Compare the requested region-bound behavior with current mask handling, and clarify whether the inverse operation is required. Done means the supported region-to-mask behavior is documented and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.