Skip to content

Commit 2917f16

Browse files
committed
cleaned up plot_spectral_cube
1 parent 3eb8472 commit 2917f16

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/visualastro/plotting/science/wcs_plots.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,12 @@ def plot_spectral_cube(
330330
vmax: float | _Unset = _UNSET,
331331
norm: Literal['asinh', 'asinhnorm', 'log', 'power', 'twoslope', 'linear'] | None | _Unset = _UNSET,
332332
percentile: tuple[float, float] | _Unset = _UNSET,
333-
stack_method=None,
333+
stack_method: Literal['mean', 'median', 'sum', 'max', 'min', 'std'] | _Unset = _UNSET,
334334
radial_vel: float | None = None,
335-
spectral_unit=None,
335+
spectral_unit: u.UnitBase | None = None,
336336
cmap: Colormap | str | _Unset = _UNSET,
337-
mask_non_pos=None,
337+
mask_non_pos: bool | _Unset = _UNSET,
338+
axis: int = 0,
338339
**kwargs
339340
) -> list[AxesImage]:
340341
"""
@@ -443,7 +444,7 @@ def plot_spectral_cube(
443444
444445
Returns
445446
-------
446-
images : matplotlib.image.AxesImage or list of matplotlib.image.AxesImage
447+
images : list[matplotlib.image.AxesImage]
447448
Image object if a single array is provided, otherwise a list of image
448449
objects created by `ax.imshow`.
449450
@@ -458,7 +459,9 @@ def plot_spectral_cube(
458459
_param('vmax', vmax, config.vmax),
459460
_param('norm', norm, config.norm),
460461
_param('percentile', percentile, config.percentile),
462+
_param('stack_method', stack_method, config.stack_cube_method),
461463
_param('cmap', cmap, config.cmap),
464+
_param('mask_non_pos', mask_non_pos, config.mask_non_positive),
462465
],
463466
additional_kwargs=[
464467
_kwarg('as_title', False),
@@ -469,9 +472,9 @@ def plot_spectral_cube(
469472
_kwarg('mask_out_val', config.mask_out_value),
470473
_kwarg('stack_method', config.stack_cube_method),
471474
_kwarg('radial_velocity', config.radial_velocity),
472-
_kwarg('mask_non_pos', config.mask_non_positive),
473475
_kwarg('linear_width', config.linear_width),
474476
_kwarg('gamma', config.gamma),
477+
_kwarg('vcenter', None),
475478
],
476479
copy_kwargs=[
477480
_kwarg('plot_ellipse', False),
@@ -483,6 +486,7 @@ def plot_spectral_cube(
483486
plot_params = _extract_plot_util_kwargs(kwargs)
484487

485488
cubes = to_list(cubes)
489+
idxs = as_list(idx)
486490
cmaps = to_list(params.cmap)
487491

488492
ref_unit = ensure_common_unit(cubes, on_mismatch=config.unit_mismatch)
@@ -504,7 +508,7 @@ def plot_spectral_cube(
504508

505509
# return data cube slices
506510
cube_slice = stack_cube(
507-
cube, idx=idx, method=stack_method, axis=0
511+
cube, idx=_cycle(idxs, i), method=stack_method, axis=axis
508512
)
509513
data = get_value(cube_slice)
510514

@@ -519,6 +523,7 @@ def plot_spectral_cube(
519523
percentile=params.percentile,
520524
linear_width=params.linear_width,
521525
gamma=params.gamma,
526+
vcenter=params.vcenter,
522527
)
523528

524529
cm = get_cmap(_cycle(cmaps, i))
@@ -530,7 +535,7 @@ def plot_spectral_cube(
530535
else:
531536
imshow_kwargs.pop('vmin', None)
532537
imshow_kwargs.pop('vmax', None)
533-
imshow_kwargs['norm'] = cube_norm
538+
imshow_kwargs.update(norm=cube_norm)
534539

535540
im = ax.imshow(
536541
data,
@@ -562,7 +567,6 @@ def plot_spectral_cube(
562567
plot_params, ax,
563568
im_list=images,
564569
ref_unit=ref_unit,
565-
colorbar=True
566570
)
567571

568572
return images

0 commit comments

Comments
 (0)