/usr/lib/python3/dist-packages/photutils/isophote/tests/test_model.py is in python3-photutils 0.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import numpy as np
import pytest
from astropy.io import fits
from astropy.tests.helper import remote_data
from .make_test_data import make_test_image
from ..ellipse import Ellipse
from ..geometry import EllipseGeometry
from ..model import build_ellipse_model
from ...datasets import get_path
try:
import scipy # noqa
HAS_SCIPY = True
except ImportError:
HAS_SCIPY = False
@remote_data
@pytest.mark.skipif('not HAS_SCIPY')
def test_model():
path = get_path('isophote/M105-S001-RGB.fits',
location='photutils-datasets', cache=True)
hdu = fits.open(path)
data = hdu[0].data[0]
hdu.close()
g = EllipseGeometry(530., 511, 10., 0.1, 10./180.*np.pi)
ellipse = Ellipse(data, geometry=g, threshold=1.e5)
isophote_list = ellipse.fit_image()
model = build_ellipse_model(data.shape, isophote_list,
fill=np.mean(data[10:100, 10:100]))
assert data.shape == model.shape
residual = data - model
assert np.mean(residual) <= 5.0
assert np.mean(residual) >= -5.0
@pytest.mark.skipif('not HAS_SCIPY')
def test_model_simulated_data():
data = make_test_image(eps=0.5, pa=np.pi/3., noise=1.e-2,
random_state=123)
g = EllipseGeometry(256., 256., 10., 0.5, np.pi/3.)
ellipse = Ellipse(data, geometry=g, threshold=1.e5)
isophote_list = ellipse.fit_image()
model = build_ellipse_model(data.shape, isophote_list,
fill=np.mean(data[0:50, 0:50]))
assert data.shape == model.shape
residual = data - model
assert np.mean(residual) <= 5.0
assert np.mean(residual) >= -5.0
|