-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
Conversation
3b12579
to
d4d8d35
Compare
1ba30c9
to
d28706f
Compare
hmi_map.meta.update(_earth_obs_coord_meta(hmi_map.meta['date-obs'])) | ||
|
||
|
||
def load_adapt(adapt_path): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally use load_adapt
almost every day i do research with sunkit-magex and send people examples which use it. It's very useful to be able to in one line get all the realizations loaded into a Map and then decide what to do next (choose one, average them all etc.), so i'd advocate that this function would be useful to have somewhere. I get that handling specific magnetograms doesn't make sense to be the job of sunkit-magex
- could it be possible to house it in sunpy.map ? Is the direct use of astropy.io.fits
problematic?
In any case, I'm good with this being deprecated for now and having this discussion elsewhere. Is it bad practise to have a long message here. if not, I suggest :
message = "Use sunpy.map.Map to load the first realization (see <link to examples/utils/reproject_car_to_cea.py>) or see https://docs.sunpy.org/en/latest/generated/gallery/saving_and_loading_data/load_adapt_fits_into_map.html on how to load all realizations"
There was a problem hiding this 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.
hmi_map.meta.update(_earth_obs_coord_meta(hmi_map.meta['date-obs'])) | ||
|
||
|
||
def load_adapt(adapt_path): |
There was a problem hiding this comment.
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 👼
6af00f1
to
bfacbe8
Compare
2d7c5db
to
1f03469
Compare
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this property might originally have been needed when the input and output had individual plot methods, i think that was removed since they contain maps with their own plot methods. I'd be ok dropping it as proposed here if nothing breaks.
I need to patch sunpy 6.0.0 first and then this should pass. |
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. |
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 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. |
de8000d
to
d57aef3
Compare
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this being deprecated but tracking the discussion elsewhere
changelog/63.breaking.2.rst
Outdated
- pfss.utils.fix_hmi_meta | ||
- pfss.utils.load_adapt | ||
|
||
These functions are no longer needed and will be removed. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
sunkit_magex/pfss/utils.py
Outdated
@@ -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.") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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. |
Sorry, this has been on my to-do list to review for ages - just reading the
conversation I think I agree with the changes but I'd like to try out a
workflow with ADAPT and HMI and make sure I understand it all. I'm at a
workshop first half of this week but I will have time on Thursday if you're
ok to wait till then.
…On Tue, Feb 4, 2025, 09:27 Stuart Mumford ***@***.***> wrote:
I'm generally happy with this and we should ship a release, so if we can
get the CI fixed and one of @jgieseler <https://github.com/jgieseler> or
@STBadman <https://github.com/STBadman> are ok with this we should merge
it.
—
Reply to this email directly, view it on GitHub
<#63 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANC6CA4U3A5ARJCLXRLS7A32ODE63AVCNFSM6AAAAABLLLNBVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZUGEZDQNJZGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
yep, that's fine no rush! |
b6256f4
to
5eb8e40
Compare
5eb8e40
to
9552abf
Compare
"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 |
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for the new version (sph_harm_y
) theta and phi should be swapped as well. in the old version theta was in the exponent, phi was in the Pn^m term, now swapped.
if hasattr(scipy.special, "sph_harm_y"):
return -scipy.special.sph_harm_y(l, m, theta, phi)
if hasattr(scipy.special, "sph_harm"):
return -scipy.special.sph_harm(m, l, phi, theta)
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, it is probably scientifically something interesting to understand (uncertainty in field line tracing) but nothing to worry about for the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost everything looks good except the deprecation of FortranTracer looks to be broken - it's inheriting a child Class and as I understand it, this needs to be passed to .super()
Otherwise, I'm ok with load_adapt and fix_hmi_meta being deprecated and discussion of any gaps in capability moving to sunpy.
Thanks for all this work!
class FortranTracer(PerformanceTracer): | ||
@deprecated('1.0', message='This class has been renamed to PerformanceTracer as this now does not use Fortran.') | ||
def __init__(*args, **kwargs): | ||
super().__init__(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think super() needs to be given PerformanceTracer as an argument (https://www.geeksforgeeks.org/python-runtimeerror-super-no-arguments/)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(i see the deprecation warning but then i get an error that super has no args)
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, it is probably scientifically something interesting to understand (uncertainty in field line tracing) but nothing to worry about for the code.
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this property might originally have been needed when the input and output had individual plot methods, i think that was removed since they contain maps with their own plot methods. I'd be ok dropping it as proposed here if nothing breaks.
@@ -11,9 +11,8 @@ To enable this simply `install numba`_ and use `sunkit_magex.pfss` as normal. | |||
Streamline tracing | |||
================== | |||
|
|||
`sunkit_magex.pfss` has two streamline tracers: a pure python `sunkit_magex.pfss.tracing.PythonTracer` and a complied tracer `sunkit_magex.pfss.tracing.FortranTracer`. | |||
The compiled version is significantly faster, using the `streamtracer`_ package. | |||
`sunkit_magex.pfss` uses a complied tracer `sunkit_magex.pfss.tracing.PerformanceTracer` using the `streamtracer`_ package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since we're not removing the pythontracer and there isn't a default behavior implemented anywhere yet we should still mention it here, like it was originally but just change FortranTracer to PerformanceTracer in the old line 14,
@@ -7,13 +7,13 @@ | |||
""" | |||
import matplotlib.pyplot as plt | |||
import numpy as np | |||
from _helpers import pffspy_output, phi_fline_coords, theta_fline_coords |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how much of a headache would correcting the typo pffspy_output
-> pfsspy_output
be? Maybe i can do a separate PR
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for the new version (sph_harm_y
) theta and phi should be swapped as well. in the old version theta was in the exponent, phi was in the Pn^m term, now swapped.
if hasattr(scipy.special, "sph_harm_y"):
return -scipy.special.sph_harm_y(l, m, theta, phi)
if hasattr(scipy.special, "sph_harm"):
return -scipy.special.sph_harm(m, l, phi, theta)
hmi_map.meta.update(_earth_obs_coord_meta(hmi_map.meta['date-obs'])) | ||
|
||
|
||
def load_adapt(adapt_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally use load_adapt
almost every day i do research with sunkit-magex and send people examples which use it. It's very useful to be able to in one line get all the realizations loaded into a Map and then decide what to do next (choose one, average them all etc.), so i'd advocate that this function would be useful to have somewhere. I get that handling specific magnetograms doesn't make sense to be the job of sunkit-magex
- could it be possible to house it in sunpy.map ? Is the direct use of astropy.io.fits
problematic?
In any case, I'm good with this being deprecated for now and having this discussion elsewhere. Is it bad practise to have a long message here. if not, I suggest :
message = "Use sunpy.map.Map to load the first realization (see <link to examples/utils/reproject_car_to_cea.py>) or see https://docs.sunpy.org/en/latest/generated/gallery/saving_and_loading_data/load_adapt_fits_into_map.html on how to load all realizations"
@@ -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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this being deprecated but tracking the discussion elsewhere
This supersedes #48
This turned into a large PR. I could split it out but i'm lazy.