Skip to content

Commit b3f53f5

Browse files
committed
in-progress band-aid fix to astropy#4926
1 parent e10f239 commit b3f53f5

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎astropy/coordinates/builtin_frames/icrs_cirs_transforms.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ def icrs_to_gcrs(icrs_coo, gcrs_frame):
121121
# first set up the astrometry context for ICRS<->GCRS
122122
pv = np.array([gcrs_frame.obsgeoloc.value,
123123
gcrs_frame.obsgeovel.value])
124+
if len(pv.shape) > 2:
125+
pv = pv.transpose(list(range(len(pv.shape))[2:])+[0,1])
124126

125127
jd1, jd2 = get_jd12(gcrs_frame.obstime, 'tdb')
126128
astrom = erfa.apcs13(jd1, jd2, pv)
@@ -167,6 +169,9 @@ def gcrs_to_icrs(gcrs_coo, icrs_frame):
167169
# coordinate direction
168170
pv = np.array([gcrs_coo.obsgeoloc.value,
169171
gcrs_coo.obsgeovel.value])
172+
if len(pv.shape) > 2:
173+
pv = pv.transpose(list(range(len(pv.shape))[2:])+[0,1])
174+
170175
jd1, jd2 = get_jd12(gcrs_coo.obstime, 'tdb')
171176
astrom = erfa.apcs13(jd1, jd2, pv)
172177

@@ -200,7 +205,9 @@ def gcrs_to_icrs(gcrs_coo, icrs_frame):
200205

201206
@frame_transform_graph.transform(FunctionTransform, GCRS, GCRS)
202207
def gcrs_to_gcrs(from_coo, to_frame):
203-
if (np.all(from_coo.obstime == to_frame.obstime)
208+
if (from_coo.obstime.shape == to_frame.obstime.shape
209+
and np.all(from_coo.obstime == to_frame.obstime)
210+
and from_coo.obsgeoloc.shape == to_frame.obsgeoloc.shape
204211
and np.all(from_coo.obsgeoloc == to_frame.obsgeoloc)):
205212
return to_frame.realize_frame(from_coo.data)
206213
else:

‎astropy/coordinates/tests/test_regression.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,14 @@ def test_regression_4996():
229229

230230

231231
def test_regression_4926():
232-
times = Time('2010-01-1') + np.arange(20)*u.day
232+
times = Time('2010-01-1') + np.arange(4)*u.day
233233
green = get_builtin_sites()['greenwich']
234234

235-
get_moon(times, green)
235+
gcs = get_moon(times, green)
236+
aas = gcs.transform_to(AltAz(location=green, obstime=times))
237+
238+
scalar_gcs = [get_moon(time, green) for time in times]
239+
scalar_aas = [gc.transform_to(AltAz(location=green, obstime=time))
240+
for gc, time in zip(gcs, times)]
241+
242+
assert_quantity_allclose(aas.alt, [aa.alt for aa in scalar_aas])

0 commit comments

Comments
 (0)