33import astropy .units as u
44from sunpy .coordinates import frames , transform_with_sun_center
55from sunpy .physics .differential_rotation import solar_rotate_coordinate
6+ from typing import List , Dict
67
78from frames import get_helioviewer_frame , get_earth_frame
89
@@ -26,6 +27,7 @@ def hgs2hpc(lat: float, lon: float, coord_time: Time, target: Time) -> SkyCoord:
2627 Desired observation time
2728 """
2829 hv_frame = get_helioviewer_frame (target )
30+
2931 with transform_with_sun_center ():
3032 coord = SkyCoord (
3133 lon * u .deg ,
@@ -37,3 +39,43 @@ def hgs2hpc(lat: float, lon: float, coord_time: Time, target: Time) -> SkyCoord:
3739 hpc = coord .transform_to (earth_frame )
3840 # Then apply the rotation as seen from Helioviewer
3941 return solar_rotate_coordinate (hpc , hv_frame .observer )
42+
43+
44+ def hgs2hpc_batch (coordinates : List [Dict ], target : Time ) -> List [Dict ]:
45+ """
46+ Batch process multiple HGS to HPC coordinate transformations
47+
48+ Parameters
49+ ----------
50+ coordinates : List[Dict]
51+ List of coordinate dictionaries with keys: lat, lon, coord_time
52+ target : Time
53+ Target observation time (same for all coordinates)
54+
55+ Returns
56+ -------
57+ List[Dict]
58+ List of results with keys: x, y
59+ """
60+ if not coordinates :
61+ return []
62+
63+ hv_frame = get_helioviewer_frame (target )
64+
65+ with transform_with_sun_center ():
66+ lats = [c ["lat" ] for c in coordinates ]
67+ lons = [c ["lon" ] for c in coordinates ]
68+ coord_time = [c ["coord_time" ] for c in coordinates ]
69+ coord = SkyCoord (
70+ lons ,
71+ lats ,
72+ unit = "deg,deg" ,
73+ frame = frames .HeliographicStonyhurst ,
74+ obstime = coord_time ,
75+ )
76+ # First convert to an hpc coordinate
77+ earth_frame = get_earth_frame (coord_time )
78+ hpc = coord .transform_to (earth_frame )
79+ # Then apply the rotation as seen from Helioviewer
80+ result = solar_rotate_coordinate (hpc , hv_frame .observer )
81+ return [{"x" : c .Tx .value .item (), "y" : c .Ty .value .item ()} for c in result ]
0 commit comments