Skip to content

Commit

Permalink
Set default cuts and auto-scale image
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Jul 28, 2021
1 parent 6afe400 commit 54fe7ee
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions astrowidgets/bqplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, image_data=None,
axis_x = Axis(scale=scale_x, visible=False)
axis_y = Axis(scale=scale_y, orientation='vertical', visible=False)
scales_image = {'x': scale_x, 'y': scale_y,
'image': ColorScale(max=1.114, min=2902,
'image': ColorScale(max=1, min=0,
scheme='Greys')}

self._scatter_marks = {}
Expand Down Expand Up @@ -385,9 +385,9 @@ def _interval_and_stretch(self):

return stretched

def _send_data(self):
def _send_data(self, reset_view=True):
self._astro_im.set_data(self._interval_and_stretch(),
reset_view=False)
reset_view=reset_view)

def _get_interval(self):
if self._interval is None:
Expand Down Expand Up @@ -452,6 +452,8 @@ def _observe_cuts(self, change):
self._interval = apviz.ManualInterval(*cuts)
else:
self._interval = cuts
if self._data is not None:
self._send_data()

@trait.observe('zoom_level')
def _update_zoom_level(self, change):
Expand Down Expand Up @@ -481,11 +483,10 @@ def _update_viewer_zoom_scroll(self, change):
raise NotImplementedError('😭 sorry, cannot do that yet')
self._astro_im.set_scroll_zoom(change['new'])


# The methods, grouped loosely by purpose

# Methods for loading data
def load_fits(self, file_name_or_HDU):
def load_fits(self, file_name_or_HDU, reset_view=True):
if isinstance(file_name_or_HDU, str):
ccd = CCDData.read(file_name_or_HDU)
elif isinstance(file_name_or_HDU,
Expand All @@ -504,16 +505,20 @@ def load_fits(self, file_name_or_HDU):
self._ccd = ccd
self._data = ccd.data
self._wcs = ccd.wcs
self._send_data()
self._send_data(reset_view=reset_view)

def load_array(self, array):
def load_array(self, array, reset_view=True):
self._data = array
self._send_data()
self._send_data(reset_view=reset_view)

def load_nddata(self, data):
def load_nddata(self, data, reset_view=True):
self._ccd = data
self._data = self._ccd.data
self._send_data()
self._wcs = data.wcs
if self._wcs is None:
self._wcs = WCS(self._ccd.meta)

self._send_data(reset_view=reset_view)

# Saving contents of the view and accessing the view
def save(self, filename):
Expand Down

0 comments on commit 54fe7ee

Please sign in to comment.