Skip to content

Commit

Permalink
Merge pull request spacetelescope#2660 from pllim/bye-bye-space-invad…
Browse files Browse the repository at this point in the history
…ers-more-sadface

DOC: Hide boolean mask support in load_regions
  • Loading branch information
pllim authored Jan 16, 2024
2 parents 8456914 + ed77c97 commit eeeeaf8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
7 changes: 3 additions & 4 deletions jdaviz/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ def load_regions(self, regions, max_num_regions=None, refdata_label=None,
* Astropy ``regions`` object
* ``photutils`` apertures (limited support until ``photutils``
fully supports ``regions``)
* Numpy boolean array (shape must match data, dtype should be ``np.bool_``)
max_num_regions : int or `None`
Maximum number of regions to load, starting from top of the list.
Expand All @@ -707,7 +706,7 @@ def load_regions(self, regions, max_num_regions=None, refdata_label=None,
Label of data to use for sky-to-pixel conversion for a region, or
mask creation. Data must already be loaded into Jdaviz.
If `None`, defaults to the reference data in the default viewer.
Choice of this data is particularly important when sky or masked
Choice of this data is particularly important when sky
region is involved.
return_bad_regions : bool
Expand All @@ -716,8 +715,7 @@ def load_regions(self, regions, max_num_regions=None, refdata_label=None,
kwargs : dict
Extra keywords to be passed into the region's ``to_mask`` method.
**This is ignored if the region can be made interactive or
if a Numpy array is given.**
**This is ignored if the region can be made interactive.**
Returns
-------
Expand Down Expand Up @@ -808,6 +806,7 @@ def load_regions(self, regions, max_num_regions=None, refdata_label=None,
bad_regions.append((region, f'Failed to load: {repr(e)}'))
continue

# Boolean mask as input is supported but not advertised.
elif (isinstance(region, np.ndarray) and region.shape == data.shape
and region.dtype == np.bool_):
im = region
Expand Down
18 changes: 2 additions & 16 deletions notebooks/ImvizDitheredExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -339,21 +339,7 @@
"my_reg = CirclePixelRegion(center=PixCoord(x=600, y=200), radius=20)\n",
"my_reg_sky = CircleSkyRegion(c, Angle(2, u.arcsec))\n",
"\n",
"# Numpy mask\n",
"idx = (np.array([350, 350, 350, 350, 350, 350, 351, 351, 351, 351, 352, 352, 352,\n",
" 352, 352, 352, 352, 352, 352, 352, 353, 353, 353, 353, 353, 353,\n",
" 353, 353, 353, 353, 353, 353, 354, 354, 354, 354, 354, 354, 354,\n",
" 354, 355, 355, 355, 355, 355, 355, 355, 355, 356, 356, 356, 356,\n",
" 356, 356, 356, 357, 357, 358, 358]),\n",
" np.array([353, 354, 355, 356, 357, 358, 350, 352, 359, 361, 350, 352, 353,\n",
" 354, 355, 356, 357, 358, 359, 361, 350, 351, 352, 353, 354, 355,\n",
" 356, 357, 358, 359, 360, 361, 351, 352, 354, 355, 356, 357, 359,\n",
" 360, 352, 353, 354, 355, 356, 357, 358, 359, 352, 353, 354, 355,\n",
" 356, 357, 358, 353, 358, 352, 359]))\n",
"my_mask = np.zeros(data.shape, dtype=np.bool_)\n",
"my_mask[idx] = True\n",
"\n",
"my_regions = [my_aper, my_aper_sky, my_reg, my_reg_sky, my_mask]\n",
"my_regions = [my_aper, my_aper_sky, my_reg, my_reg_sky]\n",
"imviz.load_regions(my_regions)"
]
},
Expand Down Expand Up @@ -697,7 +683,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.12.0"
}
},
"nbformat": 4,
Expand Down

0 comments on commit eeeeaf8

Please sign in to comment.