Skip to content
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

Integrate Astropy units into the HEK Results table #7059

Closed

Conversation

aritrasinha108
Copy link
Contributor

PR Description

This PR is a part of the GSOC 2023 project where we intend to improve the HEK Representation in Sunpy. This specific PR integrates astropy.units into the results produced by the HEK class on making queries for solar data (an astropy.Table). This will help the end users to get a more organized and compiled form of results.

TODO

  • Integrate 'hemispere/millihemisphere' as a unit once it is defined properly
  • Parse astropy.coordinates.SkyCoord objects for Chaincode type properties once the inconsistency issue is resolved.

@aritrasinha108 aritrasinha108 requested a review from a team as a code owner June 10, 2023 18:34
@nabobalis nabobalis marked this pull request as draft June 11, 2023 14:34
@nabobalis nabobalis added the net Affects the net submodule label Jun 11, 2023
sunpy/net/hek/hek.py Outdated Show resolved Hide resolved
sunpy/net/hek/hek.py Outdated Show resolved Hide resolved
sunpy/net/hek/hek.py Outdated Show resolved Hide resolved

u.add_enabled_aliases({"steradian": u.sr, "arcseconds": u.arcsec, "degrees": u.deg, "sec": u.s})
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will need to be added to the function that converts the units and then have it remove the aliases. We don't want these to be permanent.

@nabobalis
Copy link
Contributor

I think some unit tests to ensure the files are read correctly would be good.

try:
unit = u.Unit(str.lower())
except ValueError:
unit = u.Unit(str.capitalize())
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if this fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed this function a bit. Could you please check and let me know if it's fine?

sunpy/net/hek/hek.py Outdated Show resolved Hide resolved
Comment on lines 525 to 526
"is_unit_prop": false,
"is_chaincode": false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the false values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed them and refactored the code for these changes

sunpy/net/hek/hek.py Outdated Show resolved Hide resolved
sunpy/net/hek/hek.py Outdated Show resolved Hide resolved
return table

@staticmethod
def _parse_astropy_unit(str):
Copy link
Contributor

@nabobalis nabobalis Jul 7, 2023

Choose a reason for hiding this comment

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

This function will need to be written.

units = str.split(" per ")
unit = None
if len(units) >1:
unit = HEKClient._parse_astropy_unit(units[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this method need to be part of the HEKClient?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder actually if any of these need to be attached to the client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where can be move them? Actually I found a utility function called _parse_times inside the client only so I wrote all the others here only.

Copy link
Contributor

Choose a reason for hiding this comment

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

We move them into a seperate utils.py file? At least outside of the client itself.

@@ -96,6 +113,125 @@ def _parse_times(table):
table[tkey].format = 'iso'
return table

@staticmethod
def _parse_unit(table, attribute, is_coord_prop = False):
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these new functions will need documentation strings and unit tests.

sunpy/net/hek/hek.py Outdated Show resolved Hide resolved

u.add_enabled_aliases({"steradian": u.sr, "arcseconds": u.arcsec, "degrees": u.deg, "sec": u.s, "Emx": u.Mx, "Amperes": u.A, "ergs": u.erg})
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this be better in the unit mapping below?

@dstansby dstansby added the Needs Adoption PRs that were abandoned but should be picked up again and merged in label Oct 22, 2023
Copy link

Hello 👋, Thanks for your contribution to sunpy!
I have marked this pull request as stale because there hasn't had any activity in five months. If you are still working on this, or if it's waiting on a maintainer to look at it then please let us know and we will keep it open. Please add a comment with: @sunpy/sunpy-developers to get someone's attention.
If nobody comments on this pull request for another month, it will be closed.

@github-actions github-actions bot added the Stale The bot will close this PR after 6 months label Mar 21, 2024
Copy link

Hello again 👋, We want to thank you again for your contribution to sunpy!
This pull request has had no activity since my last reminder, so I am going to close it. If at any time you want to come back to this please feel free to reopen it! If you want to discuss this, please add a comment with: @sunpy/sunpy-developers and someone will get back to you soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Adoption PRs that were abandoned but should be picked up again and merged in net Affects the net submodule Stale The bot will close this PR after 6 months
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants