LM-SAL / aiapy

Python library for AIA data analysis
https://aiapy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Account for use of reference_date property #345

Closed wtbarnes closed 2 months ago

wtbarnes commented 2 months ago

This PR includes a few fixes to account for the existence of the new reference_dateproperty on Map which is the correct date to use when constructing the coordinate frame and observer coordinate.

This also now assumes the existence of the "T_OBS" key in the metadata since this is what is used for constructing reference_date in the case of an AIA map.

Since reference_date was only introduced in sunpy v6 we should decide how to go about using this property or just make the minimum version of sunpy v6.

See also sunpy/sunpy#7810

Summary by Sourcery

Update the code to use the 'reference_date' property for constructing coordinate frames and observer coordinates, assuming the presence of 'T_OBS' in metadata for AIA maps. Adjust tests to reflect these changes and improve accuracy.

Bug Fixes:

Enhancements:

Tests:

sourcery-ai[bot] commented 2 months ago

Reviewer's Guide by Sourcery

This pull request updates the aiapy library to account for the new reference_date property introduced in sunpy v6. The changes primarily affect the fix_observer_location and update_pointing functions in the aiapy/calibrate/meta.py file, as well as related tests in aiapy/calibrate/tests/test_meta.py. The PR aims to improve the accuracy of coordinate frame and observer coordinate calculations by using the correct reference date.

File-Level Changes

Change Details Files
Update observer location calculation to use reference_date
  • Replace smap.date with smap.reference_date in fix_observer_location function
  • Add comments explaining the use of T_OBS as reference date in sunpy v6
aiapy/calibrate/meta.py
Modify handling of T_OBS in update_pointing function
  • Remove fallback to smap.date when T_OBS is missing
  • Add FIXME comment about adjusting code once sunpy v6 is the minimum supported version
aiapy/calibrate/meta.py
Update tests to account for small numerical differences
  • Replace exact equality assertions with approximate equality checks using u.allclose
  • Remove test for missing T_OBS warning
aiapy/calibrate/tests/test_meta.py

Sequence Diagram

sequenceDiagram
    participant Client
    participant fix_observer_location
    participant smap
    Client->>fix_observer_location: Call with smap
    fix_observer_location->>smap: Get reference_date
    smap-->>fix_observer_location: Return reference_date
    fix_observer_location->>fix_observer_location: Calculate observer location
    fix_observer_location->>smap: Update meta with new location
    fix_observer_location-->>Client: Return updated smap

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
nabobalis commented 2 months ago

I will leave it up to you @wtbarnes when you want to merge.