class TestStandaloneImageViewer(object): def setup_method(self, method): im = np.random.random((3, 3)) self.w = StandaloneImageViewer(im) def test_set_cmap(self): cm_mode = self.w.toolbar.tools['image:colormap'] act = cm_mode.menu_actions()[1] act.trigger() assert self.w._composite.layers['image']['color'] is act.cmap def test_double_set_image(self): assert len(self.w._axes.images) == 1 self.w.set_image(np.zeros((3, 3))) assert len(self.w._axes.images) == 1
class TestStandaloneImageViewer(object): def setup_method(self, method): im = np.random.random((3, 3)) self.w = StandaloneImageViewer(im) def teardown_method(self, method): self.w.close() def test_set_cmap(self): cm_mode = self.w.toolbar.tools['image:colormap'] act = cm_mode.menu_actions()[1] act.trigger() assert self.w._composite.layers['image']['color'] is act.cmap def test_double_set_image(self): assert len(self.w._axes.images) == 1 self.w.set_image(np.zeros((3, 3))) assert len(self.w._axes.images) == 1
def preview(self): success = self.verify_input() if not success: self.statusBar().showMessage("Please fill in all fields") return t = self.make_catalog_table() if t is None: raise Exception("Spectra files were not found.") fb = list(t['id']) if len(fb) == 0: return row = pick_item(t, fb, title='Preview', label='Pick a target:') if row is None: return # Make cutouts using info in catalog. self.statusBar().showMessage("Making cutouts") output_path = os.path.join(self.save_path, self.output_dir_format) fits_cutouts, success_counter, success_table = go_make_cutouts( QTable(row), self.img_path, "cutouts", output_file_format=self.output_file_format, output_dir_format=output_path, clobber=True, apply_rotation=True, report=self.report) hdu = fits_cutouts[0] self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(1) self.progress_bar.reset() QApplication.processEvents() if hdu is None: raise Exception("Could not make cutout. Object " "may be out of the image's range.") if self.session is not None: iv = StandaloneImageViewer(hdu.data, parent=self.session.application) iv.setWindowFlags(iv.windowFlags() | Qt.Tool) iv.show() else: import matplotlib.pyplot as plt plt.imshow(hdu.data) plt.show()
def preview(self): success = self.verify_input() if not success: self.statusBar().showMessage("Please fill in all fields") return fb, target_names = self.get_file_base() if len(fb) == 0: return fn = pick_item(fb, [os.path.basename(i) for i in fb], title='Preview', label='Pick a target:') if fb is None: return programName = os.path.basename(fn).split("_")[0] t, skipped = self.make_catalog_table([fn], target_names, programName) if t is None: raise Exception("Input spectra file has bad WCS and/or header.") #Make cutouts using info in catalog. self.statusBar().showMessage("Making cutouts") fits_cutouts, success_counter, success_table = go_make_cutouts( t, self.img_path, programName, output_file_format=self.output_file_format, output_dir_format=self.output_dir_format, clobber=True, apply_rotation=True, ispreview=True, report=self.report) hdu = fits_cutouts[0] self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(1) self.progress_bar.reset() QApplication.processEvents() if hdu is None: raise Exception("Could not make cutout. " "Object may be out of the image's range.") if self.session is not None: iv = StandaloneImageViewer(hdu.data, parent=self.session.application) iv.setWindowFlags(iv.windowFlags() | Qt.Tool) iv.show() else: import matplotlib.pyplot as plt plt.imshow(hdu.data) plt.show()
def preview(self): success = self.verify_input() if not success: self.statusBar().showMessage("Please fill in all fields") return t = self.make_catalog_table() index = pick_item(range(len(t)), t["id"].tolist(), title='Preview', label='Pick a target:') if index is None: return t = QTable(t[index]) programName, file_extension = os.path.splitext(self.img_path) programName = os.path.basename(programName) #Make cutouts using info in catalog. self.statusBar().showMessage("Making cutouts") fits_cutouts, success_counter, success_table = go_make_cutouts( t, self.img_path, programName, output_file_format=self.output_file_format, output_dir_format=self.output_dir_format, clobber=True, apply_rotation=True, ispreview=True, report=self.report) hdu = fits_cutouts[0] self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(1) self.progress_bar.reset() QApplication.processEvents() if hdu is None: raise Exception("Could not make cutout. " "Object may be out of the image's range.") if self.session is not None: iv = StandaloneImageViewer(hdu.data) iv.setWindowFlags(iv.windowFlags() | Qt.Tool) iv.show() else: import matplotlib.pyplot as plt plt.imshow(hdu.data) plt.show()
def preview(self): success = self.verify_input() if not success: self.statusBar().showMessage("Please fill in all fields") return t = self.make_catalog_table() index = pick_item(range(len(t)) , t["id"].tolist(), title='Preview', label='Pick a target:') if index is None: return t = QTable(t[index]) programName, file_extension = os.path.splitext(self.img_path) programName = os.path.basename(programName) #Make cutouts using info in catalog. self.statusBar().showMessage("Making cutouts") fits_cutouts, success_counter, success_table = go_make_cutouts( t, self.img_path, programName, output_file_format=self.output_file_format, output_dir_format=self.output_dir_format, clobber=True, apply_rotation=True, ispreview=True, report=self.report) hdu = fits_cutouts[0] self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(1) self.progress_bar.reset() QApplication.processEvents() if hdu is None: raise Exception("Could not make cutout. " "Object may be out of the image's range.") if self.session is not None: iv = StandaloneImageViewer(hdu.data) iv.setWindowFlags(iv.windowFlags() | Qt.Tool) iv.show() else: import matplotlib.pyplot as plt plt.imshow(hdu.data) plt.show()
def setup_method(self, method): im = np.random.random((3, 3)) self.w = StandaloneImageViewer(im)