Skip to content

Non scalar times - #5085

Merged
eteq merged 4 commits into
astropy:masterfrom
StuartLittlefair:non-scalar-times
Jun 15, 2016
Merged

eteq merged 4 commits into
astropy:masterfrom
StuartLittlefair:non-scalar-times

Conversation

@StuartLittlefair

Copy link
Copy Markdown
Contributor

This PR makes changes which ensure that coordinates.get_moon can handle non-scalar times when using the builtin ephemeris. This PR fixes #5069.

"""
try:
rmat = np.array([rotation_matrix(this_obl, 'x') for this_obl in obl])
result = np.einsum('...ij,...jk->...ik', rmat, rnpb)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In numpy >=1.10, this is more efficiently done with np.matmul. Since eventually this should be used, we may as well replace now with (matmul should work for scalar case too):

from ...utils.compat import NUMPY_LT_1_10

if NUMPY_LT_1_10:
    try:
        result = np.einsum('...ij,...jk->...ik', rmat, rnpb)
    ...
else:
    result = np.matmul(rmat, rnpb)

@mhvk mhvk mentioned this pull request Jun 13, 2016
into a new array.
"""
try:
rmat = np.array([rotation_matrix(this_obl, 'x') for this_obl in obl])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to write that this seemed to be something rotation_matrix should be able to handle, when I realised it could not because it returns np.matrix. So, not for this PR, but see #5088.

@mhvk

mhvk commented Jun 13, 2016

Copy link
Copy Markdown
Contributor

@StuartLittlefair - could you also add a direct test for multidimensional ecliptic transforms? Ideally, more than 1-D, though that may well break other parts...

@eteq eteq added this to the v1.2.0 milestone Jun 15, 2016
@eteq

eteq commented Jun 15, 2016

Copy link
Copy Markdown
Member

Noting @mhvk's comment about this I ran into some problems with non-1D arrays... But I think that's better addressed as a speparate PR, as this at least gets the 1d case working. So merging!

@eteq eteq added no-changelog-entry-needed Affects-dev PRs and issues that do not impact an existing Astropy release labels Jun 15, 2016
@eteq
eteq merged commit f2d16a9 into astropy:master Jun 15, 2016
eteq added a commit that referenced this pull request Jun 15, 2016
@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

Thanks @eteq - I should have been explicit about N-D arrays. It does indeed cause problems but I think the solution is best implemented as a PR which also addresses #5088.

@StuartLittlefair
StuartLittlefair deleted the non-scalar-times branch June 15, 2016 08:06
@eteq

eteq commented Jun 15, 2016

Copy link
Copy Markdown
Member

@StuartLittlefair - fair enough - I've been seeing if I can get some "quick fix" solution for this particular pathway in time for 1.2, but #5088 is definitely a better solution once we can get it in.

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

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release Bug coordinates no-changelog-entry-needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_moon does not support non-scalar times

4 participants