Skip to content

Rotation model split#2269

Merged
embray merged 7 commits into
astropy:masterfrom
embray:rotation-model-split
Apr 7, 2014
Merged

Rotation model split#2269
embray merged 7 commits into
astropy:masterfrom
embray:rotation-model-split

Conversation

@embray

@embray embray commented Apr 2, 2014

Copy link
Copy Markdown
Member

As discussed in #2149 and elsewhere, this removes the MatrixRotation2D model and replaces it with two new models: Rotation2D (essentially the same as the old MatrixRotation2D, but only accepts an angle parameter) and AffineTransformation2D which replaces the use of MatrixRotation2D with an arbitrary matrix, and also adds simple translations. This also incorporates/supersedes #2266 such that the sense of rotation used by Rotation2D is counter-clockwise.

A few notes on AffineTranformation2D:

  • For now I put it in astropy.modeling.projections which seemed like the most appropriate place for now, but I'm not sure. I'm open to other suggestions.
  • This PR does not attempt to resolve the problems with array values for parameters as addressed by support arrays as parameters #2149. Rather, making this split now allows simplification on support arrays as parameters #2149 and a few other issues by not requiring as many "special cases" that MatrixRotation2D seemed to demand.
  • It's clear that this could easily be extended to support transformations in more than 2 dimensions, but for now this is just serving as a direct replacement for the existing functionality (which really only practically supported 2 dimensions). This could be extended later if need be.
  • It's also true that in some sense Rotation2D could be implemented around AffineTransformation2D. The latter could also, eventually, be implemented as a composite model. But for the time being it's more straightforward to have a concrete implementation.

embray added 4 commits April 2, 2014 13:17
suggested a number of times.

This changes MatrixRotation2D to simply Rotation2D with a single
parameter: angle (currently given in degrees--Quantity support will
allow some more flexibility here).  Its inverse is to simply apply a
rotation by the same amount in the opposite direction.  Added a simple
test case for this because why not?
…f the old MatrixRotation2D where it could take an arbitrary 2D matrix. This specifically limits the matrix to 2x2 (hence 2D). This could easily be extended to be n-D but is currently just implementing what might have actually worked with the old MatrixRotation2D, with the addition of an additional 'translation' parameter which takes a translation vector, allowing the full range of affine transformations. Includes a couple simple tests.
…the sense or rotatioin is in fact counter-clockwise
@embray embray added the modeling label Apr 2, 2014
@embray

embray commented Apr 3, 2014

Copy link
Copy Markdown
Member Author

Oops, worth pointing out that the first half of this--the rotation model--was also done in #2149. I think the original version of that PR didn't have it, so I didn't realize that it was since updated with this feature. There it's called RotateByAngle2D but otherwise has an almost identical implementation. I'm fine with either way.

Comment thread astropy/modeling/projections.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Start with a one-line description to get nicer API docs listing:

 Perform an affine transformation in 2 dimensions.

@cdeil

cdeil commented Apr 4, 2014

Copy link
Copy Markdown
Member

I've added some inline comments with suggestions to improve the API docs for these classes a bit.
Otherwise 👍

@nden

nden commented Apr 4, 2014

Copy link
Copy Markdown
Contributor

Should this be a fittable model? It'd be nice to be able to fit an affine transform to 2 sets of (x,y) positions, for example.

@embray embray mentioned this pull request Apr 4, 2014
@embray

embray commented Apr 4, 2014

Copy link
Copy Markdown
Member Author

@nden I was thinking that too--there's no reason it couldn't be. I just wasn't sure if that was desired or not. I'll make the change.

@embray

embray commented Apr 4, 2014

Copy link
Copy Markdown
Member Author

@cdeil I think I've addressed all your comments. I have some plans in mind for improving the per-model doc pages in general, but for now this should bring the docs more or less in line for these models.

@nden I opened #2277 to track making this model fittable. It occurred to me as soon as I started working on it that in order for this to work we'll need the better support for array-like parameters in general.

@cdeil

cdeil commented Apr 4, 2014

Copy link
Copy Markdown
Member

👍 to merge this.

@embray embray added this to the v0.4.0 milestone Apr 7, 2014
embray added a commit that referenced this pull request Apr 7, 2014
@embray embray merged commit 09139d8 into astropy:master Apr 7, 2014
@embray embray deleted the rotation-model-split branch April 7, 2014 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants