# Path: photometry/plots.py
# def plots_interactive(backend=('Qt5Agg', 'MacOSX', 'Qt4Agg', 'Qt5Cairo', 'TkAgg')):
# def plots_noninteractive():
# def plot_image(image, ax=None, scale='log', cmap=None, origin='lower', xlabel=None,
# 	ylabel=None, cbar=None, clabel='Flux ($e^{-}s^{-1}$)', cbar_ticks=None,
# 	cbar_ticklabels=None, cbar_pad=None, cbar_size='5%', title=None,
# 	percentile=95.0, vmin=None, vmax=None, offset_axes=None, color_bad='k', **kwargs):
# def plot_image_fit_residuals(fig, image, fit, residuals=None, percentile=95.0):
# def plot_outline(img, ax=None, threshold=0.5, **kwargs):
# def save_figure(path, fig=None, fmt='png', **kwargs):


import os
import numpy as np
import glob
from scipy.io import loadmat
from scipy.interpolate import RectBivariateSpline
from .plots import plt, plot_image
	def plot(self):
		"""
		Create a plot of the shape of the PSF.
		"""

		stars = np.array([
			[self.ref_row-self.stamp[0], self.ref_column-self.stamp[2], 1],
		])

		y = np.linspace(-6, 6, 500)
		x = np.linspace(-6, 6, 500)
		xx, yy = np.meshgrid(y, x)

		spline = self.splineInterpolation(x, y, grid=True)
		spline += np.abs(spline.min()) + 1e-14
		spline = np.log10(spline)

		img = self.integrate_to_image(stars)

		fig = plt.figure()
		ax = fig.add_subplot(121)
		ax.contourf(yy, xx, spline, 20, cmap='bone_r')
		ax.set_xlim(-6, 6)
		ax.set_ylim(-6, 6)
		ax.axis('equal')

		ax = fig.add_subplot(122)
		plot_image(img, ax=ax)
		ax.scatter(stars[:,1], stars[:,0], c='r', alpha=0.5)


# Path: photometry/plots.py
# def plots_interactive(backend=('Qt5Agg', 'MacOSX', 'Qt4Agg', 'Qt5Cairo', 'TkAgg')):
# def plots_noninteractive():
# def plot_image(image, ax=None, scale='log', cmap=None, origin='lower', xlabel=None,
# 	ylabel=None, cbar=None, clabel='Flux ($e^{-}s^{-1}$)', cbar_ticks=None,
# 	cbar_ticklabels=None, cbar_pad=None, cbar_size='5%', title=None,
# 	percentile=95.0, vmin=None, vmax=None, offset_axes=None, color_bad='k', **kwargs):
# def plot_image_fit_residuals(fig, image, fit, residuals=None, percentile=95.0):
# def plot_outline(img, ax=None, threshold=0.5, **kwargs):
# def save_figure(path, fig=None, fmt='png', **kwargs):


# Path: photometry/psf.py
import os
import numpy as np
import glob
from scipy.io import loadmat
from scipy.interpolate import RectBivariateSpline
from .plots import plt, plot_image

	def plot(self):
		"""
		Create a plot of the shape of the PSF.
		"""

		stars = np.array([
			[self.ref_row-self.stamp[0], self.ref_column-self.stamp[2], 1],
		])

		y = np.linspace(-6, 6, 500)
		x = np.linspace(-6, 6, 500)
		xx, yy = np.meshgrid(y, x)

		spline = self.splineInterpolation(x, y, grid=True)
		spline += np.abs(spline.min()) + 1e-14
		spline = np.log10(spline)

		img = self.integrate_to_image(stars)

		fig = plt.figure()
		ax = fig.add_subplot(121)
		ax.contourf(yy, xx, spline, 20, cmap='bone_r')
		ax.set_xlim(-6, 6)
		ax.set_ylim(-6, 6)
		ax.axis('equal')

		ax = fig.add_subplot(122)
		plot_image(img, ax=ax)
		ax.scatter(stars[:,1], stars[:,0], c='r', alpha=0.5)


		plt.tight_layout()