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

Improving HEK Representation #7619

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft

Conversation

ahmedhosssam
Copy link
Contributor

This PR includes the work that has been done in GSoC 23 but in a new and fresh branch to start GSoC 24.
I've migrated GSoC 23 commits and resolved most of the conflicts, it needs a review to see if there is any conflict remaining.

@nabobalis
Copy link
Contributor

You will need to add regions to https://github.com/sunpy/sunpy/blob/main/pyproject.toml#L77 so it is installed.

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
sunpy/net/hek/util.py Outdated Show resolved Hide resolved
sunpy/net/hek/util.py Outdated Show resolved Hide resolved
sunpy/net/hek/hek.py Outdated Show resolved Hide resolved
sunpy/net/hek/util.py Outdated Show resolved Hide resolved
sunpy/net/hek/util.py Outdated Show resolved Hide resolved
with u.add_enabled_units([cm2, m2, m3]), u.set_enabled_aliases(aliases):
if is_coord_prop:
coord1_unit, coord2_unit, coord3_unit = None, None, None
coord_units = re.split(r'[, ]', str)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what units would split here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The coordination units, right?
For example arcsec,arcsec

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see. Is that the only one or are there more?

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'm not sure, but this is the only example I saw in the json files. Maybe another usage would be (X, Y, Z)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you run the code and see how many and what units trigger this?

sunpy/net/hek/utils.py Outdated Show resolved Hide resolved
@nabobalis
Copy link
Contributor

Looks like there is a merge conflict with sunpy/main now. Can you merge that in and resolve that?

@@ -12,6 +17,23 @@
def foostrwrap(request):
return hek.attrs._StringParamAttrWrapper("foo")

@pytest.fixture
def read_unit_attributes():
UNIT_FILE_PATH = Path(os.path.dirname(__file__)) / "../unit_properties.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there another way to get this file path without having to add the ".."?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not import this from the utils file?

elif attribute["frame"] == "heliocentric":
coord1_unit = u.R_sun
coord2_unit = u.deg
elif attribute["frame"] == "icrs":
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you tell me which attributes give an icrs value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bound_ChainCode and Skel_ChainCode

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you start a document or make a note of this? I want to make sure we capture any of this quirks but not via code comments.

coord1_unit = u.Unit(coord_units[0])
coord2_unit = u.Unit(coord_units[1])
coord3_unit = u.Unit(coord_units[2])
return locals()[unit_prop]
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 to do this?!

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 think the three units should be the same, so we can just do this:

if unit_prop in ["coord1_unit", "coord2_unit", "coord3_unit", "event_coordunit"]:
    coord_units = re.split(r'[, ]', unit)
    return u.Unit(coord_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.

Can you try that and see how it goes?

sunpy/net/hek/utils.py Outdated Show resolved Hide resolved
Comment on lines +15 to +16
UNIT_FILE_PATH = Path(os.path.dirname(__file__)) / "unit_properties.json"
COORD_FILE_PATH = Path(os.path.dirname(__file__)) / "coord_properties.json"
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 these can be added to the all and imported else where as required.

COORD_FILE_PATH = Path(os.path.dirname(__file__)) / "coord_properties.json"

def freeze(obj):
""" Create hashable representation of result dict. """
Copy link
Contributor

@nabobalis nabobalis May 31, 2024

Choose a reason for hiding this comment

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

Suggested change
""" Create hashable representation of result dict. """
"""
Create a hashable representation of a dict or list.
Otherwise returns the original input.
"""

Copy link
Contributor

Choose a reason for hiding this comment

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

I take issue with the function name but that's a separate conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants