Skip to content

Commit

Permalink
Ad test for fit_psf_with_polynom
Browse files Browse the repository at this point in the history
  • Loading branch information
saimn committed Jul 19, 2019
1 parent c4810f3 commit 110dafb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os

# import sys
# sys.path.insert(0, os.path.abspath('.'))
from pkg_resources import get_distribution
Expand Down
4 changes: 2 additions & 2 deletions muse_psfr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def _setup_logging():

_setup_logging()

from .psfrec import * # noqa
from pkg_resources import DistributionNotFound, get_distribution # noqa

from pkg_resources import get_distribution, DistributionNotFound # noqa
from .psfrec import * # noqa

try:
__version__ = get_distribution(__name__).version
Expand Down
3 changes: 2 additions & 1 deletion muse_psfr/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
import io
import sys
import logging
import sys

from astropy.io import fits

from muse_psfr import __version__, compute_psf_from_sparta, create_sparta_table
Expand Down
22 changes: 21 additions & 1 deletion muse_psfr/test_psfrec.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import os

import pytest
from astropy.io import fits
from astropy.table import Table
from numpy.testing import assert_allclose

from muse_psfr import compute_psf_from_sparta, plot_psf, create_sparta_table
from muse_psfr import (
compute_psf_from_sparta,
create_sparta_table,
fit_psf_with_polynom,
plot_psf,
)
from muse_psfr.cli import main


Expand All @@ -24,6 +30,20 @@ def test_reconstruction(tmpdir):
assert_allclose(fit[1]['fwhm'], 0.85, atol=1e-2)


def test_fit_poly(tmpdir):
tbl = create_sparta_table()
hdul = fits.HDUList([tbl])
res = compute_psf_from_sparta(hdul, lmin=500, lmax=900, nl=9)
fit = Table.read(res['FIT_ROWS'])
res = fit_psf_with_polynom(fit['lbda'], fit['fwhm'][:, 0], fit['n'],
deg=(5, 5), output=1)
assert_allclose(res['fwhm_pol'][0], 0.65, atol=1e-2)
assert_allclose(res['beta_pol'][0], 0.78, atol=1e-2)
# fit[1] at 550nm matches roughly res[8] (550.1)
assert_allclose(res['beta_fit'][8], fit[1]['n'], atol=1e-2)
assert_allclose(res['fwhm_fit'][8], fit[1]['fwhm'], atol=1e-2)


def test_reconstruction2(tmpdir):
tbl = create_sparta_table()
# Modify values for the first LGS
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys

from setuptools import setup

if sys.version_info < (3, 5):
Expand Down

0 comments on commit 110dafb

Please sign in to comment.