forked from astropy/astropy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_testing.py
More file actions
72 lines (63 loc) · 1.81 KB
/
_testing.py
File metadata and controls
72 lines (63 loc) · 1.81 KB
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
62
63
64
65
66
67
68
69
70
71
72
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing utilities. Not part of the public API!"""
from astropy.wcs import WCS
from astropy.wcs.wcsapi import BaseHighLevelWCS
def assert_wcs_seem_equal(wcs1, wcs2):
"""Just checks a few attributes to make sure wcs instances seem to be
equal.
"""
__tracebackhide__ = True
if wcs1 is None and wcs2 is None:
return
assert wcs1 is not None
assert wcs2 is not None
if isinstance(wcs1, BaseHighLevelWCS):
wcs1 = wcs1.low_level_wcs
if isinstance(wcs2, BaseHighLevelWCS):
wcs2 = wcs2.low_level_wcs
assert isinstance(wcs1, WCS)
assert isinstance(wcs2, WCS)
if wcs1 is wcs2:
return
assert wcs1.wcs.compare(wcs2.wcs)
def _create_wcs_simple(naxis, ctype, crpix, crval, cdelt):
wcs = WCS(naxis=naxis)
wcs.wcs.crpix = crpix
wcs.wcs.crval = crval
wcs.wcs.cdelt = cdelt
wcs.wcs.ctype = ctype
return wcs
def create_two_equal_wcs(naxis):
return [
_create_wcs_simple(
naxis=naxis,
ctype=["deg"] * naxis,
crpix=[10] * naxis,
crval=[10] * naxis,
cdelt=[1] * naxis,
),
_create_wcs_simple(
naxis=naxis,
ctype=["deg"] * naxis,
crpix=[10] * naxis,
crval=[10] * naxis,
cdelt=[1] * naxis,
),
]
def create_two_unequal_wcs(naxis):
return [
_create_wcs_simple(
naxis=naxis,
ctype=["deg"] * naxis,
crpix=[10] * naxis,
crval=[10] * naxis,
cdelt=[1] * naxis,
),
_create_wcs_simple(
naxis=naxis,
ctype=["m"] * naxis,
crpix=[20] * naxis,
crval=[20] * naxis,
cdelt=[2] * naxis,
),
]