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

Bugfix for integer slicing of an EISCube #118

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions eispac/core/eiscube.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,13 @@ def _slice(self, item):
slice_str = '['
for i, sl_obj in enumerate(item):
delim = '' if i == 0 else ', '
start = '' if sl_obj.start is None else str(sl_obj.start)
stop = '' if sl_obj.stop is None else str(sl_obj.stop)
step = '' if sl_obj.step is None else ':'+str(sl_obj.step)
slice_str = slice_str + delim + start + ':' + stop + step
if isinstance(sl_obj, int):
slice_str = slice_str + delim +str(sl_obj)
else:
start = '' if sl_obj.start is None else str(sl_obj.start)
stop = '' if sl_obj.stop is None else str(sl_obj.stop)
step = '' if sl_obj.step is None else ':'+str(sl_obj.step)
slice_str = slice_str + delim + start + ':' + stop + step
slice_str = slice_str + ']'
kwargs['meta']['notes'].append(f'Sliced with EISCube{slice_str}')

Expand Down
25 changes: 25 additions & 0 deletions eispac/tests/test_read_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,28 @@ def test_total_intensity(test_data_filepath):
eis_cube = eispac.read_cube(test_data_filepath, 192.394)
sum_inten = eis_cube.sum_spectra()
assert isinstance(sum_inten, NDCube)

def test_slice_box(test_data_filepath):
eis_cube = eispac.read_cube(test_data_filepath, 192.394)
slice_cube = eis_cube[0:10,0:10,:]
assert isinstance(slice_cube, NDCube)

def test_slice_step(test_data_filepath):
eis_cube = eispac.read_cube(test_data_filepath, 192.394)
slice_cube = eis_cube[:,1,:]
assert isinstance(slice_cube, NDCube)

def test_slice_point(test_data_filepath):
eis_cube = eispac.read_cube(test_data_filepath, 192.394)
slice_cube = eis_cube[1,1,:]
assert isinstance(slice_cube, NDCube)

def test_extract_pix(test_data_filepath):
eis_cube = eispac.read_cube(test_data_filepath, 192.394)
point_cube = eis_cube.extract_points([[0,0], [1,1]], units='pixel')
assert isinstance(point_cube, NDCube)

def test_extract_arcsec(test_data_filepath):
eis_cube = eispac.read_cube(test_data_filepath, 192.394)
point_cube = eis_cube.extract_points([[0,-200], [20,-160]], units='arcsec')
assert isinstance(point_cube, NDCube)
Loading