Skip to content

Commit

Permalink
its all broken
Browse files Browse the repository at this point in the history
  • Loading branch information
nabobalis committed Feb 3, 2025
1 parent 8802c19 commit e3543dc
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/data_types/raster.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ As before, we will add the timestamps and exposure times as extra coordinates.
>>> from datetime import datetime, timedelta
>>> from astropy.time import Time
>>> from sunraster import SpectrogramCube
>>> from sunraster.meta import Meta
>>> from ndcube.meta import NDMeta
>>> # Define primary data array and WCS object.
>>> data = np.ones((3, 4, 5))
Expand All @@ -50,7 +50,7 @@ As before, we will add the timestamps and exposure times as extra coordinates.
>>> mask = np.zeros(data.shape, dtype=bool)
>>> # Define some RasterSequence metadata.
>>> exposure_times = np.ones(data.shape[0])/2 * u.s
>>> scan_meta = Meta({"exposure time": exposure_times}, axes={"exposure time": 0},
>>> scan_meta = NDMeta({"exposure time": exposure_times}, axes={"exposure time": 0},
... data_shape=data.shape)
>>> seq_meta = {"description": "This is a RasterSequence.", "exposure time" : exposure_times}
Expand Down
4 changes: 2 additions & 2 deletions docs/data_types/spectrogram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ Let's recreate our spectrogram object again, but this time with exposure times o
.. code-block:: python
>>> import astropy.units as u
>>> from sunraster.meta import Meta
>>> from ndcube.meta import NDMeta
>>> exposure_times = np.ones(data.shape[0])/2 * u.s
>>> # Create a metadata instance to hold the exposure times.
>>> # We must also assign the exposure time to the time axis, in this case, the 0th array axis.
>>> metadata = Meta({"exposure time": exposure_times}, axes={"exposure time": 0},
>>> metadata = NDMeta({"exposure time": exposure_times}, axes={"exposure time": 0},
... data_shape=data.shape)
>>> my_spectrograms = SpectrogramCube(data, input_wcs, uncertainty=uncertainties,
... mask=mask, meta=metadata, unit=u.ct)
Expand Down
7 changes: 4 additions & 3 deletions sunraster/instr/spice.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
from astropy.wcs import WCS

from ndcube import NDCollection
from ndcube.meta import NDMeta

from sunraster import RasterSequence, SpectrogramCube, SpectrogramSequence
from sunraster.meta import Meta, SlitSpectrographMetaABC
from sunraster.meta import SlitSpectrographMetaABC

__all__ = ["read_spice_l2_fits", "SPICEMeta"]

Expand Down Expand Up @@ -216,7 +217,7 @@ def _read_single_spice_l2_fits(
# Define metadata object.
meta = SPICEMeta(
hdu.header,
comments=_convert_fits_comments_to_key_value_pairs(hdu.header),
# comments=_convert_fits_comments_to_key_value_pairs(hdu.header),
data_shape=hdu.data.shape,
)
# Rename WCS time axis to time.
Expand Down Expand Up @@ -252,7 +253,7 @@ def _convert_fits_comments_to_key_value_pairs(fits_header):
return [(key, fits_header.comments[key]) for key in keys]


class SPICEMeta(Meta, metaclass=SlitSpectrographMetaABC):
class SPICEMeta(SlitSpectrographMetaABC, NDMeta):
# ---------- SPICE-specific convenience methods ----------
def _get_unit(self, key):
if comment := self.comments.get(key):
Expand Down
2 changes: 1 addition & 1 deletion sunraster/instr/tests/test_spice.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def spice_fits_header():
def spice_meta(spice_fits_header):
return SPICEMeta(
spice_fits_header,
comments=zip(spice_fits_header.keys(), spice_fits_header.comments),
# comments=zip(spice_fits_header.keys(), spice_fits_header.comments),
)


Expand Down
4 changes: 2 additions & 2 deletions sunraster/meta.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import abc

from ndcube.meta import NDMeta
from ndcube.meta import NDMetaABC

__all__ = ["RemoteSensorMetaABC", "SlitSpectrographMetaABC"]


class MetaABC(NDMeta):
class MetaABC(NDMetaABC):
@property
@abc.abstractmethod
def detector(self):
Expand Down
6 changes: 3 additions & 3 deletions sunraster/tests/test_spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from astropy.time import Time, TimeDelta
from astropy.wcs import WCS

from ndcube.meta import NDMeta
from ndcube.tests.helpers import assert_cubes_equal

import sunraster.spectrogram
from sunraster import SpectrogramCube
from sunraster.extern.meta import Meta

# Define a sample wcs object
H0 = {
Expand Down Expand Up @@ -77,7 +77,7 @@
(Time("2017-01-01") + TimeDelta(np.arange(TIME_DIM_LEN, TIME_DIM_LEN * 2), format="sec")),
),
]
meta_exposure0 = Meta({"exposure time": EXPOSURE_TIME}, axes={"exposure time": 0}, data_shape=SOURCE_DATA_DN.shape)
meta_exposure0 = NDMeta({"exposure time": EXPOSURE_TIME}, axes={"exposure time": 0}, data_shape=SOURCE_DATA_DN.shape)

spectrogram_DN0 = SpectrogramCube(
SOURCE_DATA_DN, wcs=WCS0, unit=u.ct, uncertainty=SOURCE_UNCERTAINTY_DN, meta=meta_exposure0
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_instrument_axes_slicing(item, expected):
assert all(sliced_cube.instrument_axes == expected)


def test_ndcube_components_after_slicing():
def test_components_after_slicing():
"""
Tests all cube components are correctly propagated by slicing.
"""
Expand Down
6 changes: 3 additions & 3 deletions sunraster/tests/test_spectrogramsequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from astropy.time import Time, TimeDelta
from astropy.wcs import WCS

from ndcube.meta import NDMeta
from ndcube.tests.helpers import assert_cubesequences_equal

from sunraster import RasterSequence, SpectrogramCube, SpectrogramSequence
from sunraster.extern.meta import Meta

# Define an sample wcs objects.
H0 = {
Expand Down Expand Up @@ -121,8 +121,8 @@
meta_seq = {
"a": 0,
}
meta_exposure0 = Meta({"exposure time": EXPOSURE_TIME}, axes={"exposure time": 0}, data_shape=SOURCE_DATA_DN.shape)
meta_exposure2 = Meta(
meta_exposure0 = NDMeta({"exposure time": EXPOSURE_TIME}, axes={"exposure time": 0}, data_shape=SOURCE_DATA_DN.shape)
meta_exposure2 = NDMeta(
{"exposure time": u.Quantity(np.zeros(SOURCE_DATA_DN.shape[2]) + SINGLES_EXPOSURE_TIME, unit=u.s)},
axes={"exposure time": 2},
data_shape=SOURCE_DATA_DN.shape,
Expand Down

0 comments on commit e3543dc

Please sign in to comment.