Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sliceable MetaData Class #455

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
ff9b13e
First draft of a sliceable meta obect.
DanRyanIrish Aug 13, 2021
6d0d254
Refactor Meta. Tests now passing.
DanRyanIrish Aug 14, 2021
9166378
Add overwrite option to Meta.add.
DanRyanIrish Aug 14, 2021
a2248c7
Fixes codestyle.
DanRyanIrish Aug 14, 2021
02cdcbb
Adds #455 changelog.
DanRyanIrish Aug 14, 2021
eb57c05
Codestyle fixes.
DanRyanIrish Aug 14, 2021
96b8ab9
Slice meta if possible when slicing NDCube.
DanRyanIrish Aug 14, 2021
303320a
Add docstrings to Meta object.
DanRyanIrish Aug 14, 2021
3cc208d
Create remove method for Meta.
DanRyanIrish Aug 16, 2021
2b5d507
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Aug 21, 2021
041cd1b
Make Meta more memory efficient.
DanRyanIrish Aug 23, 2021
3bdf4a6
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Aug 25, 2021
cd13518
Add Meta to top-level init imports.
DanRyanIrish Aug 25, 2021
ad88f5f
Enable Meta object's shape to be set without axes being set.
DanRyanIrish Aug 25, 2021
873d5b7
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Oct 15, 2021
1d54ba3
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Nov 3, 2021
f8c59ed
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Nov 4, 2021
4611e1e
Avoid possible indexing error when dropping axes during slicing of Me…
DanRyanIrish Nov 4, 2021
048e0ed
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Nov 10, 2021
aa817fd
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Nov 18, 2021
cf923f9
Make NDCube slice meta if it has a magic attribute.
DanRyanIrish Nov 18, 2021
b0e21be
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Aug 26, 2022
7df22e7
Merge branch 'main' into meta
DanRyanIrish May 7, 2024
bbe6c12
Fixes codestyle.
DanRyanIrish May 7, 2024
86dc366
Reverting unintented changes to __init__.py
DanRyanIrish May 7, 2024
7160dc3
Apply suggestions from code review
DanRyanIrish May 8, 2024
b3d439c
Adds nitpicky exceptions for Meta docstring.
DanRyanIrish May 8, 2024
1f04d62
Try fixing hyperlink to "iterable"
DanRyanIrish May 8, 2024
c27d904
Apply suggestions from code review
nabobalis May 8, 2024
8291189
Apply suggestions from code review
nabobalis May 8, 2024
5604de0
Apply suggestions from code review
nabobalis May 8, 2024
cdece82
Apply suggestions from code review
nabobalis May 8, 2024
51617e6
Update ndcube/tests/test_meta.py
nabobalis May 8, 2024
72bccb0
Change denotation of metadata not associated with axes in Meta class …
DanRyanIrish May 9, 2024
120596d
Make NDCube.rebin remove axis-awareness from metadata associated with…
DanRyanIrish May 9, 2024
f3fc5a2
Merge branch 'meta' of https://github.com/DanRyanIrish/ndcube into meta
DanRyanIrish May 9, 2024
ad39c81
Fix codestyle
DanRyanIrish May 9, 2024
ad0e532
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish May 9, 2024
d01f6f6
Add test of meta handling by NDCube.rebin.
DanRyanIrish May 10, 2024
d5ae2ef
Add rebin capability to Meta.
DanRyanIrish May 13, 2024
181d86d
Fix codestyle.
DanRyanIrish May 13, 2024
f17ba0b
Adds tests for Meta.rebin.
DanRyanIrish May 13, 2024
da8df25
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish May 19, 2024
fb45151
Support scalar axis-aware metadata.
DanRyanIrish May 19, 2024
9726b65
Add support for axis-aware metadata that give a scalar per axis.
DanRyanIrish May 19, 2024
a626602
Clarify behavior of axis-aligned and grid-aligned metadata and fix co…
DanRyanIrish May 20, 2024
e848e9f
Make API of Meta.rebin more flexible.
DanRyanIrish May 20, 2024
500843f
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Jul 2, 2024
754385e
change name for metadata used by Meta class from header to meta
DanRyanIrish Jul 2, 2024
e8f9535
Update ndcube/meta.py
DanRyanIrish Jul 2, 2024
fef0de6
Rename Meta to NDMeta.
DanRyanIrish Jul 2, 2024
28eafbb
Move ndcube_can_slice and ndcube_can_rebin to class attributes of NDM…
DanRyanIrish Jul 2, 2024
40b8b26
Create NDMetaABC.
DanRyanIrish Jul 2, 2024
3ba2d9c
Move slicing by data item in NDMeta to new slice method.
DanRyanIrish Jul 2, 2024
f723445
Change NDMeta.shape to data_shape.
DanRyanIrish Jul 2, 2024
6d84e56
Make NDMeta infer data_shape if not provided.
DanRyanIrish Jul 2, 2024
bf078bd
Refactor NDMeta.rebin to take bin_shape as input.
DanRyanIrish Jul 2, 2024
81b84e5
Remove data_shape kwarg from NDMeta init.
DanRyanIrish Jul 2, 2024
b526e3e
Fix codestyle.
DanRyanIrish Jul 2, 2024
cdc3f8f
Add setter for NDMeta.data_shape.
DanRyanIrish Jul 2, 2024
2373209
Replace NDMeta.remove with __delitem__.
DanRyanIrish Jul 2, 2024
6d38c67
Make NDCube.meta have same shape as NDCube if meta is axis-aware.
DanRyanIrish Jul 2, 2024
fb788f7
Fix codestyle.
DanRyanIrish Jul 3, 2024
f315ca6
Apply suggestions from code review
DanRyanIrish Jul 4, 2024
d81db9e
Change NDMeta.comments to key_comments.
DanRyanIrish Jul 4, 2024
b59cbff
Merge branch 'meta' of https://github.com/DanRyanIrish/ndcube into meta
DanRyanIrish Jul 4, 2024
5776dca
Make NDMeta.original_header read-only.
DanRyanIrish Jul 4, 2024
5076384
First incomplete version of docs on NDMeta.
DanRyanIrish Jul 8, 2024
bebcf1f
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Jul 13, 2024
8127514
First complete draft of metadata narrative docs.
DanRyanIrish Jul 14, 2024
c4a83aa
Enable NDMeta to accept data shape on instantiation.
DanRyanIrish Jul 14, 2024
d79a5e6
Enable NDCubeSequence and NDCollection to support sliceable metadata.
DanRyanIrish Jul 14, 2024
7f9f042
Add tests for meta slicing via NDCubeSequence and NDCollection.
DanRyanIrish Jul 16, 2024
e35c34c
Merge branch 'main' of https://github.com/sunpy/ndcube into meta
DanRyanIrish Jul 20, 2024
a58c705
Fixes to make NDMeta slicing work, especially as part of an NDCollect…
DanRyanIrish Jul 20, 2024
944b0df
Some docs bugfixes relating to NDMeta.
DanRyanIrish Jul 21, 2024
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
1 change: 1 addition & 0 deletions changelog/455.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Sliceable `~ndcube.meta.Meta` class for axis-associated metadata.
2 changes: 2 additions & 0 deletions docs/nitpick-exceptions
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ py:class a set-like object providing a view on D's keys
py:class an object providing a view on D's values
py:class None. Remove all items from D.
py:class a shallow copy of D
py:class v, remove specified key and return the corresponding value.
py:class None. Update D from dict/iterable E and F.
DanRyanIrish marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion ndcube/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"""
from .extra_coords.extra_coords import ExtraCoords, ExtraCoordsABC
from .global_coords import GlobalCoords, GlobalCoordsABC
from .meta import NDMeta
from .ndcollection import NDCollection
from .ndcube import NDCube, NDCubeBase
from .ndcube_sequence import NDCubeSequence, NDCubeSequenceBase
from .version import version as __version__

__all__ = ['NDCube', 'NDCubeSequence', "NDCollection", "ExtraCoords", "GlobalCoords", "ExtraCoordsABC", "GlobalCoordsABC", "NDCubeBase", "NDCubeSequenceBase", "__version__"]
__all__ = ['NDCube', 'NDCubeSequence', "Meta", "NDCollection", "ExtraCoords", "GlobalCoords", "ExtraCoordsABC", "GlobalCoordsABC", "NDCubeBase", "NDCubeSequenceBase", "__version__"]
19 changes: 18 additions & 1 deletion ndcube/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from astropy.time import Time, TimeDelta
from astropy.wcs import WCS

from ndcube import ExtraCoords, GlobalCoords, NDCube, NDCubeSequence
from ndcube import ExtraCoords, GlobalCoords, NDCube, NDCubeSequence, NDMeta

# Force MPL to use non-gui backends for testing.
try:
Expand Down Expand Up @@ -334,6 +334,23 @@ def ndcube_4d_ln_lt_l_t(wcs_4d_t_l_lt_ln):
return NDCube(data_cube, wcs=wcs_4d_t_l_lt_ln)


@pytest.fixture
def ndcube_4d_axis_aware_meta(wcs_4d_t_l_lt_ln):
shape = (5, 8, 10, 12)
wcs_4d_t_l_lt_ln.array_shape = shape
data_cube = data_nd(shape, dtype=int)
meta = NDMeta({"a": "scalar",
"slit position": np.arange(shape[0], dtype=int),
"pixel label": np.arange(np.prod(shape[:2])).reshape(shape[:2]),
"line": ["Si IV"] * shape[2],
"exposure time": ([2] * shape[-1]) * u.s},
axes={"slit position": 0,
"pixel label": (0, 1),
"line": (2,),
"exposure time": 3})
return NDCube(data_cube, wcs=wcs_4d_t_l_lt_ln, meta=meta)


@pytest.fixture
def ndcube_4d_uncertainty(wcs_4d_t_l_lt_ln):
shape = (5, 8, 10, 12)
Expand Down
Loading
Loading