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

increase min sunpy #63

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

increase min sunpy #63

wants to merge 8 commits into from

Conversation

nabobalis
Copy link
Contributor

@nabobalis nabobalis commented Jul 23, 2024

This supersedes #48

  • Fixes Add towncrier #49
  • Renamed FortranTracer to PerformanceTracer
  • Deprecated FortranTracer
  • streamtracer is now a hard dep
  • Deprecated bunch of utils I think we don't need anymore.
  • Bunch of package updates
  • Trying to tidy up the example gallery
  • Adaptmap removed due to upstream support in sunpy

This turned into a large PR. I could split it out but i'm lazy.

@nabobalis nabobalis force-pushed the sunpy_version branch 3 times, most recently from 3b12579 to d4d8d35 Compare July 24, 2024 00:09
@nabobalis nabobalis marked this pull request as draft July 24, 2024 00:09
@nabobalis nabobalis marked this pull request as ready for review July 24, 2024 00:10
@nabobalis nabobalis marked this pull request as draft July 24, 2024 00:10
@nabobalis nabobalis force-pushed the sunpy_version branch 4 times, most recently from 1ba30c9 to d28706f Compare July 24, 2024 01:17
hmi_map.meta.update(_earth_obs_coord_meta(hmi_map.meta['date-obs']))


def load_adapt(adapt_path):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We dont have the same loader in sunpy but we can now load them directly. But only the first one.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know enough about the data to know if the other ones are useful, but if there isn't a drop in replacement then maybe we shouldn't yank it?

Also deprecations please 👼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

Cadair
Cadair previously requested changes Jul 24, 2024
Copy link
Member

@Cadair Cadair left a comment

Choose a reason for hiding this comment

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

Thanks @nabobalis

I think we need to be deprecating stuff, I made the first version 1.0.0 for a reason, I think stability is important here.

I will let @jgieseler and @STBadman chime in on things like load_adapt and fix_hmi_meta specifically, but I would like a review from at least one of them before we merge.

docs/installing.rst Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
sunkit_magex/pfss/tests/test_tracers.py Outdated Show resolved Hide resolved
sunkit_magex/pfss/tracing.py Outdated Show resolved Hide resolved
hmi_map.meta.update(_earth_obs_coord_meta(hmi_map.meta['date-obs']))


def load_adapt(adapt_path):
Copy link
Member

Choose a reason for hiding this comment

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

I don't know enough about the data to know if the other ones are useful, but if there isn't a drop in replacement then maybe we shouldn't yank it?

Also deprecations please 👼

@nabobalis nabobalis force-pushed the sunpy_version branch 5 times, most recently from 6af00f1 to bfacbe8 Compare July 24, 2024 22:44
@nabobalis nabobalis force-pushed the sunpy_version branch 5 times, most recently from 2d7c5db to 1f03469 Compare July 25, 2024 19:51
@@ -42,7 +42,6 @@ def __init__(self, br, nr, rss):
sunkit_magex.pfss.utils.is_full_sun_synoptic_map(br, error=True)

self._map_in = copy.deepcopy(br)
self.dtime = self.map.date
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we need this but it should be reference_date if we do.

Copy link
Member

Choose a reason for hiding this comment

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

I'd probably not remove this property from the Input class, so 👍 making it reference_date.

@nabobalis nabobalis marked this pull request as ready for review July 25, 2024 19:52
@nabobalis
Copy link
Contributor Author

I need to patch sunpy 6.0.0 first and then this should pass.

@nabobalis nabobalis requested a review from Cadair August 22, 2024 19:54
@nabobalis
Copy link
Contributor Author

nabobalis commented Sep 17, 2024

But I'm a bit confused regarding fix_hmi_meta. You state that it's deprecated because this is now fixed within sunpy when you load a HMI file. But if I download a HMI file (with files = Fido.fetch(...)) and then open it with hmi_map = sunpy.map.Map(files[0]), all the things fix_hmi_meta should fix are still in it, like hmi_map.meta['cunit2'] = 'Sine Latitude'. Am I doing it wrong?

Oh in that case, I was very wrong and we should fix that in the map source.

The reason I said that was it was in the notes:

If you have sunpy > 2.1 installed, this function is not needed as sunpy
will automatically make these fixes.

But clearly I didn't check.

@jgieseler
Copy link
Member

Yes, I saw that comment as well and was confused. That's why I was wondering if I do the loading in a wrong way.

@nabobalis
Copy link
Contributor Author

Oh I am confused, sunpy doesn't change the meta anymore. If you access the attributes of the map, those should be correct now. I think .units?

@jgieseler
Copy link
Member

Oh I am confused, sunpy doesn't change the meta anymore. If you access the attributes of the map, those should be correct now. I think .units?

Hm, I don't know. But I just checked and run some old code that uses fix_hmi_meta. I run it with applying fix_hmi_meta and also without (i.e., just loading the HMI file with sunpy). The resulting figures look the same, only in the latter case, some SunpyMetadataWarning are printed:

Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]
2024-09-17 18:19:50 - sunpy - INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere.
WARNING: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer.
For frame 'heliographic_stonyhurst' the following metadata is missing: hgln_obs,hglt_obs,dsun_obs
For frame 'heliographic_carrington' the following metadata is missing: crlt_obs,dsun_obs,crln_obs
 [sunpy.map.mapbase]
2024-09-17 18:19:50 - sunpy - WARNING: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer.
For frame 'heliographic_stonyhurst' the following metadata is missing: hgln_obs,hglt_obs,dsun_obs
For frame 'heliographic_carrington' the following metadata is missing: crlt_obs,dsun_obs,crln_obs

@nabobalis
Copy link
Contributor Author

Oh I am confused, sunpy doesn't change the meta anymore. If you access the attributes of the map, those should be correct now. I think .units?

Hm, I don't know. But I just checked and run some old code that uses fix_hmi_meta. I run it with applying fix_hmi_meta and also without (i.e., just loading the HMI file with sunpy). The resulting figures look the same, only in the latter case, some SunpyMetadataWarning are printed:

Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]
2024-09-17 18:19:50 - sunpy - INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere.
WARNING: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer.
For frame 'heliographic_stonyhurst' the following metadata is missing: hgln_obs,hglt_obs,dsun_obs
For frame 'heliographic_carrington' the following metadata is missing: crlt_obs,dsun_obs,crln_obs
 [sunpy.map.mapbase]
2024-09-17 18:19:50 - sunpy - WARNING: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer.
For frame 'heliographic_stonyhurst' the following metadata is missing: hgln_obs,hglt_obs,dsun_obs
For frame 'heliographic_carrington' the following metadata is missing: crlt_obs,dsun_obs,crln_obs

Ah I see, yeah but we should not be fixing these metadata ourselves but letting sunpy emit them. These are legit issues with the FITS files and having some special helper function for it is not something we should be doing in sunkit-magex.

@nabobalis nabobalis marked this pull request as draft December 30, 2024 16:52
@nabobalis nabobalis marked this pull request as ready for review December 30, 2024 17:05
@nabobalis
Copy link
Contributor Author

Dob build is failing due to JSOC. I can skip the examples.

@@ -36,6 +37,7 @@ def _earth_obs_coord_meta(obstime):
return _observer_coord_meta(sunpy.coordinates.get_earth(obstime))


@deprecated('1.0', message="This is now fixed within sunpy when you load a HMI file.")
def fix_hmi_meta(hmi_map):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the only fix not in sunpy core is:

    # Fix observer coordinate
    if 'hglt_obs' not in hmi_map.meta:
        hmi_map.meta.update(_earth_obs_coord_meta(hmi_map.meta['date-obs']))

We can talk about adding it but that becomes an open question for the other SDO or earth based observatories.

- pfss.utils.fix_hmi_meta
- pfss.utils.load_adapt

These functions are no longer needed and will be removed.
Copy link
Member

Choose a reason for hiding this comment

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

Are there alternatives we can direct people to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an example on how to load the adapt maps. FOr the fix meta, we have the how to.

I can link to both.

@@ -79,6 +81,7 @@ def fix_hmi_meta(hmi_map):
hmi_map.meta.update(_earth_obs_coord_meta(hmi_map.meta['date-obs']))


@deprecated('1.0', message="This is not required anymore. An example of how to load an ADAPT file is available in the documentation.")
Copy link
Member

Choose a reason for hiding this comment

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

I'd either link to it or say use sunpy.map.Map or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Cadair
Copy link
Member

Cadair commented Feb 4, 2025

I'm generally happy with this and we should ship a release, so if we can get the CI fixed and one of @jgieseler or @STBadman are ok with this we should merge it.

@STBadman
Copy link
Contributor

STBadman commented Feb 4, 2025 via email

@Cadair
Copy link
Member

Cadair commented Feb 4, 2025

yep, that's fine no rush!

@nabobalis nabobalis force-pushed the sunpy_version branch 2 times, most recently from b6256f4 to 5eb8e40 Compare February 4, 2025 22:12
"scipy>=1.10.1",
"streamtracer>=2.2.0",
"sunpy[map]>=6.0.1,!=6.0.0",
"matplotlib>=3.5.0", # Needed to solve the correct env for oldestdeps
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 didn't know how else to handle it

Comment on lines +44 to +47
if hasattr(scipy.special, "sph_harm_y"):
return -scipy.special.sph_harm_y(l, m, phi, theta)
if hasattr(scipy.special, "sph_harm"):
return -scipy.special.sph_harm(m, l, phi, theta)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works.

m = 0
c = zss**(-l-2) * ((2*l + 1) / (l + 1 + l * zss**(-2*l - 1)))
f = analytic.Br(l, m, zss)
phi = 0 * u.deg
theta = 0 * u.deg
assert f(zss, theta, phi) == -0.5 * np.sqrt(3 / np.pi) * c
np.testing.assert_allclose(f(zss, theta, phi), -0.5 * np.sqrt(3 / np.pi) * c)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a floating point difference now at the 8th decime.

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.

Add towncrier
4 participants