Repository navigation
Conversation
8593562 to
9ccff22
Compare
f0b88f3 to
bc08ff6
Compare
72386ac to
c05c77f
Compare
| class StaticMatrixTransform(CoordinateTransform): | ||
| return newrep | ||
|
|
||
| class AffineTransform(BaseAffineTransform): |
There was a problem hiding this comment.
This (and probably BaseAffineTransform) should be in __all__ , right? That is, they shold be considered public API?
6f68461 to
d74bd6a
Compare
bc08ff6 to
2725e80
Compare
16dce30 to
0960e2b
Compare
f08e128 to
03f04dd
Compare
04c773b to
db13a87
Compare
mhvk
left a comment
There was a problem hiding this comment.
This looks very good, and my comments are mostly minor, but for larger ones, see astropy#6218 (comment) (so discussion stays on the astropy github site).
| rotation = rotation_matrix(-np.arcsin(z_d), 'y') | ||
| representation = (intrep - translation).transform(rotation) | ||
| translation = CartesianRepresentation(gcf.galcen_distance * [1., 0., 0.]) | ||
| z_d = (gcf.z_sun / gcf.galcen_distance).decompose() |
There was a problem hiding this comment.
Why the decompose? I'd think the arcsin would (effectively) do that for you.
There was a problem hiding this comment.
Yea, not sure - that was in there before, but will update now since I'm touching this code.
| bary_sun_pos = get_body_barycentric('sun', hcrs_coo.obstime) | ||
| newrep = hcrs_coo.cartesian + bary_sun_pos | ||
| return icrs_frame.realize_frame(newrep) | ||
| bary_sun_vel = None |
There was a problem hiding this comment.
It's used on L298, a few lines below this.
There was a problem hiding this comment.
Oh, I see what you mean now :)
| @frame_transform_graph.transform(AffineTransform, ICRS, HCRS) | ||
| def icrs_to_hcrs(icrs_coo, hcrs_frame): | ||
| # this is just an origin translation so without a distance it cannot go ahead | ||
| if icrs_coo.data.__class__ == UnitSphericalRepresentation: |
There was a problem hiding this comment.
While you are here, replace == with is (or do isinstance(icrs_coo.data, UnitSphericalRepresentation))
| # already got unregistered when trans2 was created. | ||
| trans2.unregister(frame_transform_graph) | ||
|
|
||
|
|
There was a problem hiding this comment.
Two empty lines between functions is actually pep8...
| """ | ||
|
|
||
| def _apply_transform(self, fromcoord, matrix, vectors): | ||
| from .representation import (CartesianRepresentation, |
There was a problem hiding this comment.
Ran in to circular import issues, but I'll check again to confirm.
| newdiff = newdiff.transform(matrix) | ||
|
|
||
| if vectors is not None and vectors[1] is not None: | ||
| vel_offset = CartesianRepresentation(vectors[1]) |
There was a problem hiding this comment.
Same as above, vectors[1] should probably be CartesianRepresentation. Or, perhaps better, just let it be an associated CartesianDifferential?
| subclasses. | ||
| """ | ||
|
|
||
| def _apply_transform(self, fromcoord, matrix, vectors): |
There was a problem hiding this comment.
Move to CartesianRepresentation.transform? (since this may be discussion to keep, see larger comment in the astropy thread: astropy#6218 (comment))
| newdiff = newdiff.represent_as(CartesianDifferential) | ||
| newrep._differentials = (newdiff,) | ||
|
|
||
| if issubclass(fromcoord.data.__class__, UnitSphericalRepresentation): |
There was a problem hiding this comment.
Just isinstance(fromcoord.data, UnitSphericalRepresentation)?
There was a problem hiding this comment.
Sure - I think this was also in the code already, but will change.
| vel_offset = CartesianRepresentation(vectors[1]) | ||
| newdiff = newdiff + vel_offset | ||
|
|
||
| newdiff = newdiff.represent_as(CartesianDifferential) |
There was a problem hiding this comment.
I think here it would be better to represent it back as the type it was before, with newrep as a base.
| def __call__(self, fromcoord, toframe): | ||
|
|
||
| M, vec = self.transform_func(fromcoord, toframe) | ||
| newrep = self._apply_transform(fromcoord, M, vec) |
There was a problem hiding this comment.
So this would become
newrep = fromcoord.represent_as(CartesianRepresentation).transform(M, vec)
db13a87 to
3abf575
Compare
…ocity offset vector
…ials and assume transform funcs return representations
4de3f11 to
df5081f
Compare
…n and all differentials to cartesian form
…pty dict is passed
| # Note: the above docstring gets overridden for differentials. | ||
| raise NotImplementedError() | ||
|
|
||
| def to_cartesian_with_differentials(self): |
There was a problem hiding this comment.
Am still not too keen to add this to representation, as I don't like the duplication of to_cartesian and find the name rather long (but don't have a better suggestion).
How about using it for .cartesian on a frame, though? For that case, I feel there is no doubt one wants to transform the derivatives as well, and we know that we only have first-order to worry about. I guess that means adapting represent_as. We can always decide to move it down to representation later.
| return dict() | ||
|
|
||
| if not self.differentials: | ||
| if not self.differentials and differential_class: |
There was a problem hiding this comment.
Only fail if an empty dict is passed and there are no differentials - this allows for slightly cleaner code elsewhere.
No description provided.