-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Image refactor
- Loading branch information
Showing
12 changed files
with
679 additions
and
46 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from pyobs.images.meta import AltAzOffsets | ||
|
||
|
||
def test_alt_az_offsets(): | ||
dalt = 1.0 | ||
daz = 2.0 | ||
|
||
meta = AltAzOffsets(dalt, daz) | ||
|
||
assert meta.dalt == dalt | ||
assert meta.daz == daz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pyobs.images.meta import ExpTime | ||
|
||
|
||
def test_exp_time(): | ||
exp_time = 1.0 | ||
meta = ExpTime(exp_time) | ||
|
||
assert meta.exptime == exp_time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from astropy.coordinates import Angle | ||
from pyobs.images.meta import OnSkyDistance | ||
|
||
|
||
def test_onskydistance(): | ||
distance = Angle(1.0, unit="deg") | ||
meta = OnSkyDistance(distance) | ||
|
||
assert meta.distance.unit == distance.unit | ||
assert meta.distance.value == distance.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from pyobs.images.meta import PixelOffsets | ||
|
||
|
||
def test_pixeloffsets(): | ||
dx = 1.0 | ||
dy = 2.0 | ||
|
||
meta = PixelOffsets(dx, dy) | ||
|
||
assert meta.dx == dx | ||
assert meta.dy == dy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from pyobs.images.meta import RaDecOffsets | ||
|
||
|
||
def test_radecoffsets(): | ||
dra = 1.0 | ||
ddec = 2.0 | ||
|
||
meta = RaDecOffsets(dra, ddec) | ||
|
||
assert meta.dra == dra | ||
assert meta.ddec == ddec | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import astropy | ||
|
||
from pyobs.images.meta import SkyOffsets | ||
from astropy.coordinates import SkyCoord, BaseCoordinateFrame | ||
|
||
|
||
def test_init(): | ||
coord0 = SkyCoord(ra=0.0, dec=0.0, unit="deg") | ||
coord1 = SkyCoord(ra=1.0, dec=1.0, unit="deg") | ||
|
||
meta = SkyOffsets(coord0, coord1) | ||
|
||
assert meta.coord0.ra.deg == coord0.ra.deg | ||
assert meta.coord0.dec.deg == coord0.dec.deg | ||
|
||
assert meta.coord1.ra.deg == coord1.ra.deg | ||
assert meta.coord1.dec.deg == coord1.dec.deg | ||
|
||
|
||
def test_to_frame_non_value(): | ||
coord0 = SkyCoord(ra=0.0, dec=0.0, unit="deg") | ||
coord1 = SkyCoord(ra=1.0, dec=1.0, unit="deg") | ||
|
||
meta = SkyOffsets(coord0, coord1) | ||
|
||
framed_coord0, framed_coord1 = meta._to_frame() | ||
|
||
assert framed_coord0.ra.deg == coord0.ra.deg | ||
assert framed_coord0.dec.deg == coord0.dec.deg | ||
|
||
assert framed_coord1.ra.deg == coord1.ra.deg | ||
assert framed_coord1.dec.deg == coord1.dec.deg | ||
|
||
|
||
def test_to_frame_w_value(mocker): | ||
""" | ||
Tests that SkyCoord.transform_to is correctly used | ||
""" | ||
frame = BaseCoordinateFrame() | ||
|
||
coord0 = SkyCoord(ra=0.0, dec=0.0, unit="deg") | ||
coord1 = SkyCoord(ra=1.0, dec=1.0, unit="deg") | ||
meta = SkyOffsets(coord0, coord1) | ||
|
||
mocker.patch("astropy.coordinates.SkyCoord.transform_to", return_value=0) | ||
|
||
x, y = meta._to_frame(frame) | ||
|
||
astropy.coordinates.SkyCoord.transform_to.assert_called_with(frame) | ||
|
||
assert x == 0 | ||
assert y == 0 | ||
|
||
|
||
def test_separation(mocker): | ||
""" | ||
Tests that _to_frame and separation is correctly used | ||
""" | ||
coord0 = SkyCoord(ra=0.0, dec=0.0, unit="deg") | ||
coord1 = SkyCoord(ra=1.0, dec=1.0, unit="deg") | ||
meta = SkyOffsets(coord0, coord1) | ||
|
||
mocker.patch.object(meta, "_to_frame", return_value=(coord0, coord1)) | ||
mocker.patch("astropy.coordinates.SkyCoord.separation", return_value=0) | ||
|
||
assert meta.separation() == 0 | ||
|
||
meta._to_frame.assert_called_once_with(None) | ||
astropy.coordinates.SkyCoord.separation.assert_called_once_with(coord1) | ||
|
||
|
||
def test_spherical_offsets(mocker): | ||
""" | ||
Tests that _to_frame and spherical_offsets_to is correctly used | ||
""" | ||
coord0 = SkyCoord(ra=0.0, dec=0.0, unit="deg") | ||
coord1 = SkyCoord(ra=1.0, dec=1.0, unit="deg") | ||
meta = SkyOffsets(coord0, coord1) | ||
|
||
mocker.patch.object(meta, "_to_frame", return_value=(coord0, coord1)) | ||
mocker.patch("astropy.coordinates.SkyCoord.spherical_offsets_to", return_value=(0, 1)) | ||
|
||
assert meta.spherical_offsets() == (0, 1) | ||
|
||
meta._to_frame.assert_called_once_with(None) | ||
astropy.coordinates.SkyCoord.spherical_offsets_to.assert_called_once_with(coord1.frame) |
Oops, something went wrong.