Skip to content

Commit

Permalink
Review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
samaloney committed Apr 30, 2024
1 parent 722550f commit 74a5be4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 54 deletions.
6 changes: 3 additions & 3 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Reference
.. toctree::
:maxdepth: 2

calibration
coordinates
data
calibration
timeseries
science
map
product
science
science
timeseries
timeseries
visualisation

Expand Down
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
39 changes: 0 additions & 39 deletions stixpy/map/stix.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,3 @@ def plot(self, **kwargs):
res.axes.coords[1].set_format_unit(u.arcsec)

return res

# @property
# def wcs(self):
# if not self.coordinate_system.axis1 == 'SXLN-TAN' and self.coordinate_system.axis2 == 'SXLT-TAN':
# return super().wcs
#
# w2 = astropy.wcs.WCS(naxis=2)
#
# # Add one to go from zero-based to one-based indexing
# w2.wcs.crpix = u.Quantity(self.reference_pixel) + 1 * u.pix
# # Make these a quantity array to prevent the numpy setting element of
# # array with sequence error.
# # Explicitly call ``.to()`` to check that scale is in the correct units
# w2.wcs.cdelt = u.Quantity([self.scale[0].to(self.spatial_units[0] / u.pix),
# self.scale[1].to(self.spatial_units[1] / u.pix)])
# w2.wcs.crval = u.Quantity([self._reference_longitude, self._reference_latitude])
# w2.wcs.ctype = self.coordinate_system
# w2.wcs.pc = self.rotation_matrix
# w2.wcs.set_pv(self._pv_values)
# # FITS standard doesn't allow both PC_ij *and* CROTA keywords
# w2.wcs.crota = (0, 0)
# w2.wcs.cunit = self.spatial_units
# w2.wcs.dateobs = self.date.isot
# w2.wcs.aux.rsun_ref = self.rsun_meters.to_value(u.m)
#
# obs_frame = self.observer_coordinate
# if hasattr(obs_frame, 'frame'):
# obs_frame = obs_frame.frame
#
# w2.wcs.aux.hgln_obs = obs_frame.lon.to_value(u.deg)
# w2.wcs.aux.hglt_obs = obs_frame.lat.to_value(u.deg)
# w2.wcs.aux.dsun_obs = obs_frame.radius.to_value(u.m)
#
# w2.wcs.dateobs = self.date.utc.iso
#
# # Set the shape of the data array
# w2.array_shape = self.data.shape
#
# return w2

0 comments on commit 74a5be4

Please sign in to comment.