Skip to content

Commit

Permalink
Updated to use colorsynth 0.1.3 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie authored Jul 31, 2024
1 parent 5c6e4bf commit c765b60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
19 changes: 16 additions & 3 deletions named_arrays/_scalars/scalar_named_array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,8 @@ def colorsynth_colorbar(
spd: na.AbstractScalarArray,
wavelength: None | na.AbstractScalarArray = None,
axis: None | str = None,
axis_wavelength: str = "_wavelength",
axis_intensity: str = "_intensity",
spd_min: None | float | u.Quantity | na.AbstractScalarArray = None,
spd_max: None | float | u.Quantity | na.AbstractScalarArray = None,
spd_norm: None | Callable = None,
Expand Down Expand Up @@ -1049,11 +1051,22 @@ def colorsynth_colorbar(
wavelength_min=wavelength_min.ndarray_aligned(shape) if wavelength_min is not None else wavelength_min,
wavelength_max=wavelength_max.ndarray_aligned(shape) if wavelength_max is not None else wavelength_max,
wavelength_norm=wavelength_norm,
squeeze=False,
)

intensity = na.ScalarArray(intensity, ("wavelength", "intensity"))
wavelength = na.ScalarArray(wavelength, ("wavelength", "intensity"))
rgb = na.ScalarArray(rgb, ("wavelength", "intensity", "rgb"))
axes_new = (axis_wavelength, axis_intensity) + axes

intensity = na.ScalarArray(intensity, axes_new)
wavelength = na.ScalarArray(wavelength, axes_new)
rgb = na.ScalarArray(rgb, axes_new)

shape_intensity = intensity.shape
shape_wavelength = wavelength.shape
shape_rgb = rgb.shape

intensity = intensity[{ax: 0 for ax in shape_intensity if shape_intensity[ax] == 1}]
wavelength = wavelength[{ax: 0 for ax in shape_wavelength if shape_wavelength[ax] == 1}]
rgb = rgb[{ax: 0 for ax in shape_rgb if shape_rgb[ax] == 1}]

return na.FunctionArray(
inputs=na.Cartesian2dVectorArray(
Expand Down
4 changes: 2 additions & 2 deletions named_arrays/colorsynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def colorbar(
fig, ax = plt.subplots()
na.plt.pcolormesh(
C=colorbar,
axis_rgb="rgb",
axis_rgb="wavelength",
ax=ax,
)
"""
Expand Down Expand Up @@ -314,7 +314,7 @@ def rgb_and_colorbar(
);
na.plt.pcolormesh(
C=colorbar,
axis_rgb="rgb",
axis_rgb="wavelength",
ax=axs[1],
)
axs[1].yaxis.tick_right()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies = [
"scipy",
'astropy',
"ndfilters",
"colorsynth==0.1.2",
"colorsynth==0.1.3",
]
dynamic = ["version"]

Expand Down

0 comments on commit c765b60

Please sign in to comment.