Skip to content

Add basic example building Mars reference frames. - #14990

Merged
mhvk merged 1 commit into
astropy:mainfrom
oudeis-io:basic-body-frame
Jul 6, 2023
Merged

mhvk merged 1 commit into
astropy:mainfrom
oudeis-io:basic-body-frame

Conversation

@cmarmo

@cmarmo cmarmo commented Jun 26, 2023

Copy link
Copy Markdown
Member

Description

This pull request addresses item 1 in #14820 (review).
The example about creating a reference frame for Mars is cleaned up (thanks @mhvk for your explanations, I was climbing the wrong mountain... 😕), the ITRS test is added.

I've kept the definition of a BaseBodyCoordinateFrame even if for now it looks unnecessary. Here's why:

  • I have listed some attributes (unused for now) which will be useful in the follow-up, hopefully for the implementation of the transformations between coordinate frames. The NAIF code, for example, is going to help in retrieving orbital info (perhaps reusing some machinery in solar_system.py). The observer position (as in sunpy), will be available in the next major version of WCSLIB.
  • Imagery from satellites (Jupiter's and Saturn's) are becoming common, I would like astropy providing an abstraction tool for the definition of new body frames rather than a hard-coded list of bodies which will need updates each time a new object is mapped.

DId I successfully make my case? 😇

As always, thanks for considering this pull request!

This work is funded by the Europlanet 2024 Research Infrastructure (RI) Grant.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see "When to rebase and squash commits".
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.


from .icrs import ICRS

__all__ = ["BaseBodyCoordinateFrame"]

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.

This is technically a new API, so this PR needs a change log.

@cmarmo

cmarmo commented Jun 28, 2023

Copy link
Copy Markdown
Member Author

For some reason my last commit is not taken into account ... I'm going to close and reopen the PR, to see if CI are triggered.

@cmarmo cmarmo closed this Jun 28, 2023
@cmarmo cmarmo reopened this Jun 28, 2023
@cmarmo
cmarmo force-pushed the basic-body-frame branch from f4cd096 to a096b98 Compare June 30, 2023 01:42
@cmarmo

cmarmo commented Jun 30, 2023

Copy link
Copy Markdown
Member Author

Still trying to justify the introduction of a base class ... I have added a North Pole coordinates attribute to the class. The ephemerids of the prime meridian should also be there but they depend on the observation time, so maybe a generic method to be overwritten would be better.... but it is beyond the scope of this pull request.
I would be more comfortable having a generic base class for the follow-up of planetary applications...

@cmarmo
cmarmo force-pushed the basic-body-frame branch 2 times, most recently from 2640414 to e092916 Compare July 4, 2023 21:26

@mhvk mhvk left a comment

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.

@cmarmo - thanks for the attempt at splitting out and apologies for being a bit tardy.

I think this PR still introduces BaseBodyCoordinateFrame in a way that is unclear and would suggest to simplify it so we can just merge the example you made, and focus on how to implement the actual frame elsewhere. In particular, as per my previous comment, "this should not be in builtin_frames. In principle, if it stays really basic and adds a bit more than it does now to BaseCoordinateFrame, it could be in base_frame.py. Alternatively, it might make more sense in solar_system.py, including machinery to generate planet-specific frames on demand, though my sense is that perhaps for starters we should stick it in wcs."

The more I think about it, the better it seems to have the minimal version constructed on the spot in wcs, where we can just use what is needed, without yet worrying about how to transform to other systems.

@cmarmo
cmarmo force-pushed the basic-body-frame branch from e092916 to d329ef8 Compare July 5, 2023 19:41
@cmarmo cmarmo changed the title Add basic body-fixed frame and Mars example. Add basic example building Mars reference frames. Jul 5, 2023
@cmarmo

cmarmo commented Jul 5, 2023

Copy link
Copy Markdown
Member Author

@mhvk , I have applied your comments. As this PR no longer adds a new class I guess there is no need for a changelog?

@mhvk mhvk left a comment

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.

OK, looks good. Just one request to add a bit of clarification.

Comment thread examples/coordinates/plot_mars-coordinate-frame.py
# representation with respect to the spherical model, assuming the point on the
# surface of the body (``height = 0``)

mars_sphere = MarsCoordinateFrame(lon=np.linspace(0, 2*np.pi, 128)*u.radian,

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.

Since I am still asking for an edit, could you align the indentations while you are at it?

(Also, I'd do np.linspace(0, 360, 121) * u.deg - radians are just so annoying! but up to you.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hope this is what you had in mind...

@mhvk mhvk left a comment

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.

Yes, all good now!

@mhvk mhvk added Affects-dev PRs and issues that do not impact an existing Astropy release no-changelog-entry-needed labels Jul 5, 2023

@mhvk mhvk left a comment

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.

Sorry, I think we can improve the plot still a little -- I'll check at home...

mars_ocentric = MarsCoordinateFrame(
lon=np.linspace(0, 360, 128)*u.deg,
lat=np.linspace(-90, 90, 128)*u.deg,
representation_type=MarsBestFitOcentricAeroid)

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.

Just to be sure, is this plot the one you expected?
image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

is this plot the one you expected?

Yes, I checked the trends with lat and long and it seems to me that they are correct.... their readability could probably be improved...

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.

OK. I wasn't quite sure how to read the figure, but after a bit more staring think I've got it. Not quite sure how to improve it, so maybe fine to leave it as is.


fig, ax = plt.subplots(2, subplot_kw={"projection": "3d"})

ax[0].scatter(

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.

Sorry to see at this only now, but in principle we should not use private properties and we should be able to use units... (using astropy.visualization.quantity_support()) I'll have a closer look tonight or tomorrow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm checking the use of quantity_support and how to get rid of the private properties.

@mhvk

mhvk commented Jul 5, 2023

Copy link
Copy Markdown
Contributor

@cmarmo - I couldn't push to your repository directly so made a PR to it - see oudeis-io#1

@cmarmo

cmarmo commented Jul 5, 2023

Copy link
Copy Markdown
Member Author

I couldn't push to your repository directly so made a PR to it - see oudeis-io#1

Sorry! I didn't check the PR before pushing new commits... I'm going to merge your pr after fixing the conflicts.

@mhvk

mhvk commented Jul 5, 2023

Copy link
Copy Markdown
Contributor

I think the last 3 commits now do nothing -- you can check with git diff HEAD~3. If so, maybe just git rebase -i HEAD~6 and get rid of those?

@cmarmo

cmarmo commented Jul 5, 2023

Copy link
Copy Markdown
Member Author

Yes, rebasing and fixing pre-commit where I messed things up...

@cmarmo
cmarmo force-pushed the basic-body-frame branch 2 times, most recently from 32ebc44 to e0dc584 Compare July 6, 2023 00:12
@cmarmo
cmarmo force-pushed the basic-body-frame branch from e0dc584 to e878d5a Compare July 6, 2023 00:14

@mhvk mhvk left a comment

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.

Great! Will set this to be merged once tests pass.

@mhvk
mhvk enabled auto-merge July 6, 2023 00:26
@mhvk
mhvk merged commit 2ba1afc into astropy:main Jul 6, 2023
@cmarmo
cmarmo deleted the basic-body-frame branch July 6, 2023 01:26
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 coordinates Docs no-changelog-entry-needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants