Skip to content

light_travel_time is broken for Time objects with ndim > 1 #5191

Description

@StuartLittlefair

Reshaping a Time object to ndim greater than 1 breaks light_travel_time, with the following error:

...
/usr/local/lib/python3.5/site-packages/astropy/coordinates/builtin_frames/icrs_cirs_transforms.py in gcrs_to_icrs(gcrs_coo, icrs_frame)
    171     astrom = erfa.apcs13(jd1, jd2, pv)
    172 
--> 173     i_ra, i_dec = aticq(gcrs_ra, gcrs_dec, astrom)
    174 
    175     if gcrs_coo.data.get_name() == 'unitspherical' or gcrs_coo.data.to_cartesian().x.unit == u.one:

/usr/local/lib/python3.5/site-packages/astropy/coordinates/builtin_frames/utils.py in aticq(ri, di, astrom)
    184 
    185     # Bias-precession-nutation, giving GCRS proper direction.
--> 186     ppr = erfa.trxp(astrom['bpn'], pos)
    187 
    188     # Aberration, giving GCRS natural direction

/usr/local/lib/python3.5/site-packages/astropy/_erfa/core.py in trxp(r, p)
  24006 
  24007     #Create the output array, based on the broadcasted shape, adding the generated dimensions if needed
> 24008     broadcast = numpy.broadcast(numpy.int32(0.0), numpy.int32(0.0), r_in[...,0,0], p_in[...,0])
  24009     trp_out = numpy.empty(broadcast.shape + (3,), dtype=numpy.double)
  24010 

ValueError: shape mismatch: objects cannot be broadcast to a single shape

Activity

  1. StuartLittlefair commented on Jul 26, 2016

    @StuartLittlefair
    ContributorAuthor

    The issue here is a tricky one, arising because the coordinate transformations are not particularly shape-aware.

    So at https://github.com/astropy/astropy/blob/master/astropy/time/core.py#L599 we have

    itrs = location.get_itrs(obstime=self)

    which for an (N, M) shaped Time gives an ITRS frame with an (N, M) shaped obstime attribute and scalar xyz attributes.

    Then at https://github.com/astropy/astropy/blob/master/astropy/time/core.py#L609 we have

    gcrs_coo = itrs.transform_to(GCRS(obstime=self))

    This goes through the transformation ITRS->CIRS->GCRS. The resulting GCRS frame has (N, M) shaped obstime but the ra and dec properties are shaped (N*M, ) - as does the intermediate CIRS frame. The next transformation from GCRS to ICRS here inevitably fails because of this mismatch.

    To solve this issue a large part of the transformation code is going to have to become shape aware, which is a significant code refactor and also should wait until #4123 and #5104 are in, since the refactored code will be much cleaner after code in those PRs has been merged.

  2. StuartLittlefair commented on Aug 26, 2016

    @StuartLittlefair
    ContributorAuthor

    Just to say this issue is magically fixed by #5254.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions