-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transforming geometry loses frame attributes #2277
Comments
mmh. You give an instance of a Frame that has no focal length. Frames are immutable, so I don't really see a way how to fix that for this specific example. This would work:
but only if the current frame as a focal_length attribute. astropy also allows using frame classes not instances in
|
Yes, I guess frames don't work in the way I would like - it's a bit annoying to have to pass all frame attributes to a new Frame that has the same ones, but maybe there is no option. SOmething like: camframe = CameraFrame(focal_length=12*u.m, obstime=Time.now())
newframe = EngineeringCameraFrame(camframe)
# or even
newframe = EngineeringCameraFrame(**camframe.frame_attributes) where any common attributes are copied would be nice. Or maybe there is a canonical way to do this that I am missing? Do you really have to set all attributes? (for CameraFrame and EngineeringFrame there are already 5 attributes, so it can get annoying). |
For example, when I do this, the frame attributes are retained, so why are they not in the CameraFrame case? c1 = SkyCoord(ra=12*u.h, dec=10*u.deg, frame="icrs", obstime=t.Time.now())
c2 = c1.transform_to("fk4")
print(c2)
c2 still has an obstime, it was not reset to 0 |
Ah, yes, I see it's the difference between passing an instance and a class... So perhaps it is fixable in CameraGeometry. It does seem like the "correct" way is to pass classes not instances, at least it allows attributes to be assigned in the SkyCoord class c3 = SkyCoord(x=11*u.m, y=0*u.m, obstime=t.Time.now(), focal_length=14*u.m, frame=CameraFrame)
c3.transform_to(EngineeringCameraFrame)
<SkyCoord (CameraFrame: focal_length=14.0 m, rotation=0.0 rad, telescope_pointing=None, obstime=2023-03-02 18:02:46.329504, location=None): (x, y) in m
(11., 0.)> |
@kosack And the fact that SkyCoord retains any frame attributes and attaches them if the current frame also has these attributes. That's why the high-level SkyCoord attribute is preferred over frame instances. So maybe a fix would also be to have |
The current fix I made was just to support passing frame classes, But I like the idea of using a SkyCoord internally (and even exposing it). The previous |
Describe the bug
Transforming a CameraGeometry that has a
focal_length
attribute toEngineeringCameraFrame
resets that frame attribute.To Reproduce
Expected behavior
Frame attributes are retained, so further transforms (like back to TelescopeFrame) work
The text was updated successfully, but these errors were encountered: