Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions arccnet/utils/transformations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import sunpy.map
from sunpy.coordinates.frames import HeliographicStonyhurst

from astropy import units as u
from astropy.coordinates import SkyCoord


Comment on lines +6 to +7
Copy link
Member Author

Choose a reason for hiding this comment

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

add __all__

def reproject_instrument(
Copy link
Contributor

Choose a reason for hiding this comment

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

Names are hard but a think should rename this changes scale and distance of observer of a map using reproject it not the full retroject? Should prob also support the reproject keywords.

sunpy_map: sunpy.map.Map,
radius: u.Quantity = 1 * u.au,
scale: u.Quantity = u.Quantity([0.5, 0.5], u.arcsec / u.pixel),
):
"""
Reproject a `sunpy.map.Map` to a new observer location with a specified radius and plate scale.

Parameters:
-----------
sunpy_map : `sunpy.map.Map`
The input map to be reprojected.

radius : `astropy.units.quantity.Quantity`, optional
The radius at which the new observer is located. Default is 1 astronomical unit (1*u.au).

scale : `astropy.units.quantity.Quantity`, optional
The plate scale of the output map. Default is [0.5, 0.5] arcsec per pixel.

Returns:
--------
out_map : `sunpy.map.Map`
The reprojected map with the specified observer location, radius, and plate scale.

"""

original_observer = sunpy_map.reference_coordinate.frame.observer

new_observer = SkyCoord(
0 * u.arcsec,
0 * u.arcsec,
frame="helioprojective",
rsun=sunpy_map.reference_coordinate.rsun,
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you checked if the rsun value in the reprojected maps is scaled properly, I assume it is but good to check. I know its a draft but some tests would be good later

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is a good plan. I am not sure if this is the way to do it, but a start

obstime=original_observer.obstime,
observer=HeliographicStonyhurst(
original_observer.lon,
original_observer.lat,
radius,
obstime=original_observer.obstime,
rsun=original_observer.rsun,
),
)

out_header = sunpy.map.make_fitswcs_header(
sunpy_map.data.shape,
new_observer,
scale=scale,
)

out_map = sunpy_map.reproject_to(out_header)

return out_map