Skip to content

Coordinate Representation Classes#10

Merged
eteq merged 47 commits intoeteq:coordinates-ape5from
Cadair:ape5-repr
Apr 17, 2014
Merged

Coordinate Representation Classes#10
eteq merged 47 commits intoeteq:coordinates-ape5from
Cadair:ape5-repr

Conversation

@Cadair
Copy link
Copy Markdown

@Cadair Cadair commented Apr 4, 2014

Have a very merry Friday.

@Cadair
Copy link
Copy Markdown
Author

Cadair commented Apr 4, 2014

ping @astrofrog

@astrofrog
Copy link
Copy Markdown

@eteq - there are a few changes compared to the API document:

  • PhysicistSphericalRepresentation is PhysicsSphericalRepresentation
  • representation=... is now a class method instead, simplifying the code a lot
  • We've added the unitspherical representation

Transformations are implemented in a simple way - by default, all transformations go through cartesian, but one can add short cuts by overloading represent_as. It's simple, but it works well. We still need to overload some of the represent_as methods for e.g. UnitSpherical but that's just optimization, and doesn't change the functionality.

Also, what exactly is the physics spherical representation? At the moment, it simply renames lon to phi and lat to theta, but should theta = 90 - lat?

astrofrog and others added 28 commits April 4, 2014 14:36
Implemented CartesianRepresentation, SphericalRepresentation and CylindricalRepresentation.
Implemented transformations between the three Representations by to_cartesian and from_cartesian methods.

Contains contributions by @astrofrog.
Achievement Unlocked: 100% test coverage
@astrofrog
Copy link
Copy Markdown

@Cadair - my fixes are in Cadair#1

@astrofrog
Copy link
Copy Markdown

I'm going to punt on the __getitem__ for now. I suggest we try and get this in already and then open a new pull request to add other features such as slicing.

@eteq
Copy link
Copy Markdown
Owner

eteq commented Apr 17, 2014

@astrofrog - I'm fine on punting on __getitem__ in this PR, but are you fine with the API plan of including this? Its relevant because if so, I can just delegate __geitem__ from the frame classes to the representations. (And presumable the high-level classes can do the same to the frame classes, @taldcroft)

@astrofrog
Copy link
Copy Markdown

@eteq - absolutely, I think slicing should work. Do we want to allow scalar representation objects, and if so, should slicing just return an exception?

@eteq
Copy link
Copy Markdown
Owner

eteq commented Apr 17, 2014

@astrofrog - yeah, I would say so... CartesianRepresentation(1,2,3) should be different from CartesianRepresentation([1], [2], [3]), after all. I think you can get away with all of the representations doing something like:

def __getitem__(self, slc):
    return self.__class__(self.x[slc], self.y[slc], self.z[slc])

or similar, and then let the initializer decide if that's valid? But maybe its more complicated then that...

@astrofrog
Copy link
Copy Markdown

@Cadair - see Cadair#2 for some fixes and implementation of __getitem__ - it was as simple as @eteq pointed out.

@mhvk
Copy link
Copy Markdown

mhvk commented Apr 17, 2014

@astrofrog - agree to keep it simple for now. My guess would be that in the end we want an underlying vector class, which also allows addition, etc.

I was also thinking of writing a quick __str__ and __repr__; where would I send a PR?

Implemented __getitem__ on all the coordinate representation objects
@Cadair
Copy link
Copy Markdown
Author

Cadair commented Apr 17, 2014

@mhvk send a pull request to Cadair/astropy:ape5-repr

@eteq
Copy link
Copy Markdown
Owner

eteq commented Apr 17, 2014

@mhvk @astrofrog - I'm actually marginally against implementing __add__ and such because it won't always mean the same thing for different representations (for Cartesian it might make sense, but everything else is ambiguous). But I agree we can decide that later.

__getitem__ does need to be in for 0.4, though, if we want to have the catalog-matching stuff in the high-level classe. That's pretty useless without 1D indexing (which means we also need it in the frame and representation classes).

EDIT: Oh, I see @astrofrog added that already - awesome!

@astrofrog
Copy link
Copy Markdown

I think I'm missing something, but did we ever discuss adding __add__? I agree it should not be added for now.

@eteq
Copy link
Copy Markdown
Owner

eteq commented Apr 17, 2014

@astrofrog - thats what I thought @mhvk was saying in his last comment? And are you done making changes now, @astrofrog and @Cadair ? If so, I can merge this and @mhvk can issue a PR against eteq/astropy:coordinates-ape5 . That will make it easier to start hooking this into the frames stuff.

@astrofrog
Copy link
Copy Markdown

Ah I see - sorry for the confusion. I need to make one more commit to address a comment @mhvk made, then we are good to go.

@astrofrog
Copy link
Copy Markdown

@Cadair - can you merge in Cadair#3

@mhvk
Copy link
Copy Markdown

mhvk commented Apr 17, 2014

No worry about __add__ for now. I'll make a PR. My sense would be that __mul__ is more important (add distances). Anyway, all for later.

Ensure that distance=[1 * u.m, 10 * u.m] gets converted to a Distance object
@astrofrog
Copy link
Copy Markdown

@eteq - this is good to merge!

@eteq
Copy link
Copy Markdown
Owner

eteq commented Apr 17, 2014

Alright, merging now! @mhvk - you can issue your __str__ and __repr__ to my eteq/astropy:coordinates-ape5 , then.

eteq added a commit that referenced this pull request Apr 17, 2014
Representation Classes for Coordinates
@eteq eteq merged commit 6e4e103 into eteq:coordinates-ape5 Apr 17, 2014
eteq pushed a commit that referenced this pull request Jul 25, 2014
Minor re-wording/linking of overview about coordinates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants