Skip to content

Commit

Permalink
Added a readable error when reproject module not installed
Browse files Browse the repository at this point in the history
- added a readable error message when trying to start the plugin without
  having the astropy reproject module installed
  • Loading branch information
ejeschke committed Feb 15, 2022
1 parent 78cd108 commit 4ac5aed
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions ginga/rv/plugins/Reproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
**Plugin Type: Local**
``Reproject`` is a local plugin, which means it is associated with a channel.
An instance can be opened for each channel.
An instance can be opened for each channel. You need to have the Astropy
'reproject' module installed to use this plugin.
**Usage**
Expand Down Expand Up @@ -43,7 +44,13 @@
import numpy as np
#np.set_printoptions(threshold=np.inf)
from astropy.io import fits
import reproject

have_reproject = False
try:
import reproject
have_reproject = True
except ImportError:
pass

from ginga import GingaPlugin, AstroImage
from ginga.misc import Future
Expand All @@ -52,15 +59,17 @@

__all__ = ['Reproject']


_choose = {'adaptive': dict(order=['nearest-neighbor', 'bilinear'],
method=reproject.reproject_adaptive),
'interp': dict(order=['nearest-neighbor', 'bilinear',
'biquadratic', 'bicubic'],
method=reproject.reproject_interp),
'exact': dict(order=['n/a'],
method=reproject.reproject_exact),
}
if have_reproject:
_choose = {'adaptive': dict(order=['nearest-neighbor', 'bilinear'],
method=reproject.reproject_adaptive),
'interp': dict(order=['nearest-neighbor', 'bilinear',
'biquadratic', 'bicubic'],
method=reproject.reproject_interp),
'exact': dict(order=['n/a'],
method=reproject.reproject_exact),
}
else:
_choose = {}


class Reproject(GingaPlugin.LocalPlugin):
Expand All @@ -83,12 +92,13 @@ def __init__(self, fv, fitsimage):
self._proj_type = 'interp'

def build_gui(self, container):
if not have_reproject:
raise Exception("Please install the 'reproject' module to use "
"this plugin")
vtop = Widgets.VBox()
vtop.set_border_width(4)

box, sw, orientation = Widgets.get_oriented_box(container)
# Uncomment to debug; passing parent logger generates too
# much noise in the main logger
zi = Viewers.CanvasView(logger=self.logger)
zi.set_desired_size(self._wd, self._ht)
zi.enable_autozoom('override')
Expand Down

0 comments on commit 4ac5aed

Please sign in to comment.