/
fPlot.py
47 lines (40 loc) · 1.52 KB
/
fPlot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
#
# fPlot.py -- Plotting function for embedded matplotlib widget with Ginga.
#
# Thanks for Eric Jeschke (eric@naoj.org), https://github.com/ejeschke/ginga
# Copyleft, Yücel Kılıç (yucelkilic@myrafproject.org) and Mohammad Niaei Shameoni (mshemuni@myrafproject.org).
# This is open-source software licensed under a GPLv3 license.
import sys
import logging
from ginga.mplw.ImageViewCanvasMpl import ImageViewCanvas
from ginga.mplw.FigureCanvasQt import setup_Qt
from ginga.AstroImage import AstroImage
class FitsPlot(object):
def __init__(self, chartDev):
self.chartDev = chartDev
# use_logger = False
# logger = log.get_logger(null=not use_logger, log_stderr=True)
# self.logger = logger
self.logger = None
# create a ginga object and tell it about the figure
self.chartDev.fig.clf()
fi = ImageViewCanvas(logger=self.logger)
# Two subplots, the axes array is 1-d
fi.enable_autocuts('on')
fi.set_autocut_params('zscale')
fi.set_figure(self.chartDev.fig)
fi.ui_setActive(True)
self.fitsimage = fi
setup_Qt(chartDev, fi)
# enable all interactive features
fi.get_bindings().enable_all(True)
self.fitsimage = fi
def load(self, fitspath):
# clear plotting area
self.chartDev.fig.gca().cla()
# load an image
image = AstroImage(self.logger)
image.load_file(fitspath)
self.fitsimage.set_image(image)
self.fitsimage.add_axes()