Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
48e3ccb
Add the dither pattern util from AstroHuntsman with some minor changes:
wtgee Nov 23, 2018
c83e5ef
Base commit of dither testing
wtgee Nov 23, 2018
01afd6e
Mostly just rearranging to get within line-width limits
wtgee Nov 23, 2018
3eee887
Adding the plot utility function for the dither
wtgee Nov 23, 2018
bd0389a
Adding an option to put a finder chart on the back of the dither
wtgee Nov 23, 2018
0de12d7
Simplifying the plot to only require the generated positions
wtgee Nov 23, 2018
d805bed
Cleaning up docstrings
wtgee Nov 23, 2018
3628a45
Adding doctest examples
wtgee Nov 24, 2018
2e40488
Changing variable name and cleaning up based on review
wtgee Nov 24, 2018
7089e89
Fixing param name
wtgee Nov 24, 2018
582415a
Small change to hit some split coverage
wtgee Nov 24, 2018
7f46494
Fixing helper function (it's not a method)
wtgee Nov 24, 2018
27feb38
Merge branch 'develop' of https://github.com/panoptes/POCS into dithe…
wtgee Nov 24, 2018
0f091b6
Merge branch 'dithering-utils' of github.com:wtgee/POCS into ditherin…
wtgee Nov 24, 2018
c88f01b
Dithering Utils
wtgee Nov 24, 2018
d0bea7e
Add baseline plots
wtgee Nov 24, 2018
c360d7d
Restoring the normal tolerance on the mpl image comparison.
wtgee Nov 24, 2018
e787017
Attemping to upload bad images after test failure
wtgee Nov 24, 2018
32fdcb0
More trying to get images to work.
wtgee Nov 24, 2018
64bf586
Adding in the actual save path to make it work
wtgee Nov 24, 2018
594bc4c
Trying an alternative temporary image upload location
wtgee Nov 24, 2018
46a8179
Minor typos (sigh)
wtgee Nov 24, 2018
4674d1d
I sure do love testing things on travis one upload at a time!
wtgee Nov 24, 2018
dc484d2
Still trying to simply output the url
wtgee Nov 24, 2018
6210dcc
Seriously though. This is my last attempt. This is why people leave t…
wtgee Nov 24, 2018
2b54e19
Ok, I lied. I'm trying agian.
wtgee Nov 24, 2018
462d4fe
How about not removint the text?
wtgee Nov 25, 2018
8411178
Making tolerance on diff image high enough to not fail, which basically
wtgee Nov 25, 2018
a7721e1
Put failed image upload directly in travis
wtgee Nov 25, 2018
b153f77
Try new script (will fail) with no tolerance. This means at least two
wtgee Nov 25, 2018
aa7e765
And yet here I am, still working on it...
wtgee Nov 25, 2018
cc57754
Deep breaths...
wtgee Nov 25, 2018
45dc0cb
Revert "Put failed image upload directly in travis"
wtgee Nov 25, 2018
76d7375
Changing back the tolerance, which makes it so it is not really being…
wtgee Nov 25, 2018
7d41d0e
Adding comment about test
wtgee Nov 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ cache:
- $PANDIR/astrometry/
after_success:
- bash <(curl -s https://codecov.io/bash)
after_failure:
- bash scripts/testing/failed-images-upload.sh ${POCS}/test_images/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamessynge when you get a chance I would appreciate your thoughts on this.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
191 changes: 191 additions & 0 deletions pocs/tests/utils/test_dither.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import pytest
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.coordinates import Angle

from pocs.utils import dither


def test_dice9_SkyCoord():
base = SkyCoord("16h52m42.2s -38d37m12s")

positions = dither.get_dither_positions(base_position=base,
num_positions=12,
pattern=dither.dice9,
pattern_offset=30 * u.arcminute)

assert isinstance(positions, SkyCoord)
assert len(positions) == 12
# postion 0 should be the base position
assert positions[0].separation(base) < Angle(1e12 * u.degree)
# With no random offset positions 9, 10, 11 should be the same as 0, 1, 2
assert positions[0:3].to_string() == positions[9:12].to_string()
# Position 1 should be 30 arcminute offset from base, in declination direction only
assert base.spherical_offsets_to(
positions[1])[0].radian == pytest.approx(Angle(0 * u.degree).radian)
assert base.spherical_offsets_to(
positions[1])[1].radian == pytest.approx(Angle(0.5 * u.degree).radian)
# Position 3 should be 30 arcminute offset from base in RA only.
assert base.spherical_offsets_to(
positions[3])[0].radian == pytest.approx(Angle(0.5 * u.degree).radian)
assert base.spherical_offsets_to(
positions[3])[1].radian == pytest.approx(Angle(0 * u.degree).radian)


def test_dice9_string():
base = "16h52m42.2s -38d37m12s"

positions = dither.get_dither_positions(base_position=base,
num_positions=12,
pattern=dither.dice9,
pattern_offset=30 * u.arcminute)

base = SkyCoord(base)

assert isinstance(positions, SkyCoord)
assert len(positions) == 12
# postion 0 should be the base position
assert positions[0].separation(base) < Angle(1e12 * u.degree)
# With no random offset positions 9, 10, 11 should be the same as 0, 1, 2
assert positions[0:3].to_string() == positions[9:12].to_string()
# Position 1 should be 30 arcminute offset from base, in declination direction only
assert base.spherical_offsets_to(
positions[1])[0].radian == pytest.approx(Angle(0 * u.degree).radian)
assert base.spherical_offsets_to(
positions[1])[1].radian == pytest.approx(Angle(0.5 * u.degree).radian)
# Position 3 should be 30 arcminute offset from base in RA only.
assert base.spherical_offsets_to(
positions[3])[0].radian == pytest.approx(Angle(0.5 * u.degree).radian)
assert base.spherical_offsets_to(
positions[3])[1].radian == pytest.approx(Angle(0 * u.degree).radian)


def test_dice9_bad_base_position():
with pytest.raises(ValueError):
dither.get_dither_positions(base_position=42,
num_positions=42,
pattern=dither.dice9,
pattern_offset=300 * u.arcsecond)


def test_dice9_random():
base = SkyCoord("16h52m42.2s -38d37m12s")

# Offsets don't have units so added as arcseconds
positions = dither.get_dither_positions(base_position=base,
num_positions=12,
pattern=dither.dice9,
pattern_offset=30 * 60,
random_offset=30)

assert isinstance(positions, SkyCoord)
assert len(positions) == 12
# postion 0 should be the base position
assert positions[0].separation(base) < Angle(30 * 2**0.5 * u.arcsecond)

angle_0 = Angle(0 * u.degree).radian
angle_05 = Angle(0.5 * u.degree).radian
angle_30 = Angle(30 * u.arcsecond).radian
position_1_offset = base.spherical_offsets_to(positions[1])
position_3_offset = base.spherical_offsets_to(positions[3])

# Position 1 should be 30 arcminute offset from base, in declination direction only
assert position_1_offset[0].radian == pytest.approx(angle_0, abs=angle_30)
assert position_1_offset[1].radian == pytest.approx(angle_05, abs=angle_30)

# Position 3 should be 30 arcminute offset from base in RA only.
assert position_3_offset[0].radian == pytest.approx(angle_05, abs=angle_30)
assert position_3_offset[1].radian == pytest.approx(angle_0, abs=angle_30)


def test_random():
base = SkyCoord("16h52m42.2s -38d37m12s")

positions = dither.get_dither_positions(base_position=base,
num_positions=12,
random_offset=30 * u.arcsecond)
assert isinstance(positions, SkyCoord)
assert len(positions) == 12

angle_0 = Angle(0 * u.degree).radian
angle_30 = Angle(30 * u.arcsecond).radian
position_0_offset = base.spherical_offsets_to(positions[0])
position_1_offset = base.spherical_offsets_to(positions[1])

assert position_0_offset[0].radian == pytest.approx(angle_0, abs=angle_30)
assert position_0_offset[1].radian == pytest.approx(angle_0, abs=angle_30)

assert position_1_offset[0].radian == pytest.approx(angle_0, abs=angle_30)
assert position_1_offset[1].radian == pytest.approx(angle_0, abs=angle_30)


def test_dice5():
base = SkyCoord("16h52m42.2s -38d37m12s")

positions = dither.get_dither_positions(base_position=base,
num_positions=12,
pattern=dither.dice5,
pattern_offset=30 * u.arcminute)

assert isinstance(positions, SkyCoord)
assert len(positions) == 12
# postion 0 should be the base position
assert positions[0].separation(base) < Angle(1e12 * u.degree)
# With no random offset positions 5, 6, 7 should be the same as 0, 1, 2
assert positions[0:3].to_string() == positions[5:8].to_string()
# Position 1 should be 30 arcminute offset from base, in RA and dec
assert base.spherical_offsets_to(
positions[1])[0].radian == pytest.approx(Angle(0.5 * u.degree).radian)
assert base.spherical_offsets_to(
positions[1])[1].radian == pytest.approx(Angle(0.5 * u.degree).radian)
# Position 3 should be 30 arcminute offset from base in RA and dec
assert base.spherical_offsets_to(positions[3])[0].radian == pytest.approx(
Angle(-0.5 * u.degree).radian)
assert base.spherical_offsets_to(positions[3])[1].radian == pytest.approx(
Angle(-0.5 * u.degree).radian)


def test_custom_pattern():
base = SkyCoord("16h52m42.2s -38d37m12s")
cross = ((0, 0),
(0, 1),
(1, 0),
(0, -1),
(-1, 0))

positions = dither.get_dither_positions(base_position=base,
num_positions=12,
pattern=cross,
pattern_offset=1800 * u.arcsecond)

assert isinstance(positions, SkyCoord)
assert len(positions) == 12
# postion 0 should be the base position
assert positions[0].separation(base) < Angle(1e12 * u.degree)
# With no random offset positions 5, 6, 7 should be the same as 0, 1, 2
assert positions[0:3].to_string() == positions[5:8].to_string()
# Position 3 should be 30 arcminute offset from base, in declination direction only
assert base.spherical_offsets_to(
positions[3])[0].radian == pytest.approx(Angle(0 * u.degree).radian)
assert base.spherical_offsets_to(positions[3])[1].radian == pytest.approx(
Angle(-0.5 * u.degree).radian)
# Position 4 should be 30 arcminute offset from base in RA only.
assert base.spherical_offsets_to(positions[4])[0].radian == pytest.approx(
Angle(-0.5 * u.degree).radian)
assert base.spherical_offsets_to(
positions[4])[1].radian == pytest.approx(Angle(0 * u.degree).radian)


# Note that the tolerance is way to high for this to be an effective test but
# we are waiting on some clarity from the module.
# https://github.com/matplotlib/pytest-mpl/issues/81
@pytest.mark.mpl_image_compare(baseline_dir='baseline_images', tolerance=15)
def test_plot_dither(tmpdir):
base = SkyCoord("16h52m42.2s -38d37m12s")
positions = dither.get_dither_positions(base_position=base,
num_positions=12,
pattern=dither.dice9,
pattern_offset=30 * u.arcminute)

dither_figure = dither.plot_dither_pattern(positions)
return dither_figure
Loading