Skip to content

Commit

Permalink
Bump named-arrays to v0.17.1 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie authored Nov 11, 2024
1 parent 0761557 commit 779349c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 53 deletions.
48 changes: 15 additions & 33 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ and display as a false-color movie.
.. jupyter-execute::

import IPython.display
import dataclasses
import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
Expand All @@ -56,15 +55,11 @@ and display as a false-color movie.
# brightest spectral line
wavelength_center = obs.wavelength_center.ndarray.mean()

# Define a tuple of the temporal and spatial axes
axis_txy = (obs.axis_time, obs.axis_detector_x, obs.axis_detector_y)

# Take the mean of the wavelength over the spatial
# and temporal axes since it is constant
wavelength = obs.inputs.wavelength.mean(obs.axis_time)

# Convert to Doppler velocity
velocity = wavelength.to(
# Average wavelength over time and convert to Doppler velocity
obs.inputs = obs.inputs.explicit
obs.inputs.wavelength = obs.inputs.wavelength.mean(
axis=obs.axis_time,
).to(
unit=u.km / u.s,
equivalencies=u.doppler_optical(wavelength_center),
)
Expand All @@ -74,22 +69,10 @@ and display as a false-color movie.
velocity_max = +100 * u.km / u.s

# Define the spectral normalization curve
spd_max = np.nanpercentile(
vmax = np.nanpercentile(
a=obs.outputs,
q=99.5,
axis=axis_txy,
)

# Convert the spectral radiance to
# red/green/blue channels
rgb, colorbar = na.colorsynth.rgb_and_colorbar(
spd=obs.outputs,
wavelength=velocity,
axis=obs.axis_wavelength,
spd_min=0 * u.DN,
spd_max=spd_max,
wavelength_min=velocity_min,
wavelength_max=velocity_max,
axis=(obs.axis_time, obs.axis_detector_x, obs.axis_detector_y),
)

# Display the result as an RGB movie
Expand All @@ -100,17 +83,16 @@ and display as a false-color movie.
gridspec_kw=dict(width_ratios=[.9, .1]),
constrained_layout=True,
)
ani = na.plt.pcolormovie(
obs.inputs.time,
obs.inputs.position.x,
obs.inputs.position.y,
C=rgb,
ani, colorbar = na.plt.rgbmovie(
C=obs,
axis_time=obs.axis_time,
axis_rgb=obs.axis_wavelength,
axis_wavelength=obs.axis_wavelength,
ax=ax[0],
kwargs_animation=dict(
interval=500,
)
vmin=0 * u.DN,
vmax=vmax,
wavelength_min=velocity_min,
wavelength_max=velocity_max,
interval=500,
)
na.plt.pcolormesh(
C=colorbar,
Expand Down
32 changes: 13 additions & 19 deletions iris/sg/_spectrograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,11 @@ class SpectrographObservation(
wavelength_min = wavelength_center - 0.5 * u.AA
wavelength_max = wavelength_center + 0.5 * u.AA
# Convert the spectral radiance to
# red/green/blue channels
rgb, colorbar = na.colorsynth.rgb_and_colorbar(
spd=obs.outputs,
wavelength=obs.inputs.wavelength.mean(obs.axis_time),
axis=obs.axis_wavelength,
spd_min=0 * u.DN,
spd_max=np.nanpercentile(
a=obs.outputs,
q=99,
axis=(obs.axis_time, obs.axis_detector_x, obs.axis_detector_y),
),
# spd_norm=lambda x: np.nan_to_num(np.sqrt(x)),
wavelength_min=wavelength_min,
wavelength_max=wavelength_max,
# Define the spectral normalization curve
vmax = np.nanpercentile(
a=obs.outputs,
q=99,
axis=(obs.axis_time, obs.axis_detector_x, obs.axis_detector_y),
)
# Isolate the first raster of the observation
Expand All @@ -83,11 +73,15 @@ class SpectrographObservation(
gridspec_kw=dict(width_ratios=[.9,.1]),
constrained_layout=True,
)
na.plt.pcolormesh(
obs.inputs.position[index],
C=rgb[index],
axis_rgb=obs.axis_wavelength,
colorbar = na.plt.rgbmesh(
obs.inputs[index],
C=obs.outputs[index],
axis_wavelength=obs.axis_wavelength,
ax=ax[0],
vmin=0 * u.DN,
vmax=vmax,
wavelength_min=wavelength_min,
wavelength_max=wavelength_max,
)
na.plt.pcolormesh(
C=colorbar,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ classifiers = [
dependencies = [
"astropy",
"requests",
"named-arrays==0.16.0",
"named-arrays==0.17.1",
]
dynamic = ["version"]

Expand Down

0 comments on commit 779349c

Please sign in to comment.