Skip to content

Commit

Permalink
Review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
samaloney committed Apr 29, 2024
1 parent c0395e3 commit d1545c0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
1 change: 0 additions & 1 deletion examples/imaging_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from stixpy.imaging.em import em
from stixpy.product import Product


logger = logging.getLogger(__name__)
logger.setLevel("DEBUG")

Expand Down
8 changes: 4 additions & 4 deletions stixpy/coordinates/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def stix_wcs_to_frame(wcs):
hgs_latitude = wcs.wcs.aux.hglt_obs
hgs_distance = wcs.wcs.aux.dsun_obs

observer = HeliographicStonyhurst(hgs_latitude * u.deg,
hgs_longitude * u.deg,
hgs_distance * u.m,
observer = HeliographicStonyhurst(lat=hgs_latitude * u.deg,
lon=hgs_longitude * u.deg,
radius=hgs_distance * u.m,
obstime=dateobs,
rsun=rsun)

Expand All @@ -113,7 +113,7 @@ def stix_wcs_to_frame(wcs):
def stix_frame_to_wcs(frame, projection='TAN'):
r"""
For a given frame, this function returns the corresponding WCS object.
It registers the WCS coordinates types from their associated frame in the
`astropy.wcs.utils.celestial_frame_to_wcs` registry.
Expand Down
25 changes: 22 additions & 3 deletions stixpy/coordinates/tests/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import pytest
from astropy.coordinates import SkyCoord
from astropy.wcs import WCS
from sunpy.coordinates import get_horizons_coord
from sunpy.coordinates.frames import HeliographicStonyhurst, Helioprojective
from sunpy.map import Map, make_fitswcs_header
from sunpy.map.mapbase import SpatialPair

from stixpy.coordinates.frames import STIXImaging, stix_frame_to_wcs, stix_wcs_to_frame
from stixpy.map.stix import STIXMap
Expand Down Expand Up @@ -42,10 +44,19 @@ def stix_frame():
frame = STIXImaging(**frame_args)
return frame


def test_stix_wcs_to_frame(stix_wcs):
frame = stix_wcs_to_frame(stix_wcs)
assert isinstance(frame, STIXImaging)

assert frame.obstime.isot == '2024-01-01T00:00:00.000'
assert frame.rsun == 695700 * u.km
assert frame.observer == HeliographicStonyhurst(10 * u.deg,
20 * u.deg,
1.5e11 * u.m,
obstime='2024-01-01T00:00:00.000')



def test_stix_wcs_to_frame_none():
w = WCS(naxis=2)
Expand Down Expand Up @@ -73,10 +84,18 @@ def test_stix_frame_to_wcs_none():
wcs = stix_frame_to_wcs(Helioprojective())
assert wcs is None

@pytest.mark.remote_data
def test_stix_frame_map():
data = np.random.rand(10, 10)
coord = SkyCoord(0 * u.arcsec, 0 * u.arcsec, obstime='now', observer='earth', frame=STIXImaging)
header = make_fitswcs_header(data, coord, scale=[2, 2]*u.arcsec/u.pix, telescope='STIX',
data = np.random.rand(512, 512)
obstime = '2023-01-01 12:00:00'
solo = get_horizons_coord('solo', time=obstime)
coord = SkyCoord(0 * u.arcsec, 0 * u.arcsec, obstime=obstime, observer=solo, frame=STIXImaging)
header = make_fitswcs_header(data, coord, scale=[8, 8] * u.arcsec / u.pix, telescope='STIX',
instrument='STIX', observatory='Solar Orbiter')
smap = Map((data, header))
assert isinstance(smap, STIXMap)
assert smap.coordinate_system == SpatialPair(axis1='SXLN-TAN', axis2='SXLT-TAN')
assert isinstance(smap.coordinate_frame, STIXImaging)
smap.plot()
smap.draw_limb()
smap.draw_grid()
5 changes: 1 addition & 4 deletions stixpy/coordinates/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
import astropy.units as u
import numpy as np
import pytest
from astropy.tests.helper import assert_quantity_allclose
from astropy.time import Time
from sunpy.coordinates import HeliographicStonyhurst, Helioprojective

from stixpy.coordinates.frames import STIXImaging


def assert_quantity_allclose(x, param):
pass


@pytest.mark.skip(reason="Test data maybe incorrect")
@pytest.mark.remote_data
def test_transforms_with_know_values():
Expand Down

0 comments on commit d1545c0

Please sign in to comment.