|
15 | 15 | import astropy.utils.data as aud
|
16 | 16 | from astropy.logger import log
|
17 | 17 |
|
| 18 | +from ...exceptions import InputWarning |
18 | 19 | from ...utils import chunk_read, chunk_report, class_or_instance, commons
|
19 | 20 | from ...utils.process_asyncs import async_to_sync_docstr, async_to_sync
|
20 | 21 | from ...utils.docstr_chompers import remove_sections, prepend_docstr_nosections
|
@@ -80,6 +81,30 @@ def test_parse_coordinates_4():
|
80 | 81 | assert c.to_string() == coordinates
|
81 | 82 |
|
82 | 83 |
|
| 84 | +def test_parse_coordinates_return_frame(): |
| 85 | + # String input should return in icrs frame |
| 86 | + coords = commons.parse_coordinates('266.40498829 -28.93617776') |
| 87 | + assert coords.frame.name == 'icrs' |
| 88 | + |
| 89 | + # SkyCoord input without return_frame should return in original frame |
| 90 | + galactic = coord.SkyCoord('0 0', unit='deg', frame='galactic') |
| 91 | + coords = commons.parse_coordinates(galactic) |
| 92 | + assert coords.frame.name == 'galactic' |
| 93 | + |
| 94 | + # Parse a SkyCoord in galactic frame into icrs frame |
| 95 | + galactic = coord.SkyCoord('0 0', unit='deg', frame='galactic') |
| 96 | + icrs = galactic.transform_to('icrs') # Expected result |
| 97 | + coords = commons.parse_coordinates(galactic, return_frame='icrs') |
| 98 | + assert icrs.ra.deg == coords.ra.deg |
| 99 | + assert icrs.dec.deg == coords.dec.deg |
| 100 | + assert galactic.frame.name == 'galactic' |
| 101 | + assert coords.frame.name == 'icrs' |
| 102 | + |
| 103 | + # Warn if transformation fails |
| 104 | + with pytest.warns(InputWarning, match='Failed to transform coordinates'): |
| 105 | + coords = commons.parse_coordinates(galactic, return_frame='invalid') |
| 106 | + |
| 107 | + |
83 | 108 | col_1 = [1, 2, 3]
|
84 | 109 | col_2 = [0, 1, 0, 1, 0, 1]
|
85 | 110 | col_3 = ['v', 'w', 'x', 'y', 'z']
|
|
0 commit comments