From c4dcda6852f1617b360bebd0e21e15c4dc602f26 Mon Sep 17 00:00:00 2001 From: Roy Smart Date: Sun, 3 Nov 2024 00:30:56 -0600 Subject: [PATCH] Bump `named-arrays` to 0.14.2 (#18) --- docs/index.rst | 17 +++++++++++------ iris/sg/_spectrograph.py | 7 ++----- iris/sg/background/_background.py | 17 +++++++++-------- pyproject.toml | 2 +- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 49d445b..d835355 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -61,7 +61,7 @@ and display as a false-color movie. # Take the mean of the wavelength over the spatial # and temporal axes since it is constant - wavelength = obs.inputs.wavelength.mean(axis_txy) + wavelength = obs.inputs.wavelength.mean(obs.axis_time) # Convert to Doppler velocity velocity = wavelength.to( @@ -92,9 +92,6 @@ and display as a false-color movie. wavelength_max=velocity_max, ) - # Isolate the angular position of each RGB point - position = obs.inputs.position.mean(obs.axis_wavelength) - # Display the result as an RGB movie with astropy.visualization.quantity_support(): fig, ax = plt.subplots( @@ -105,8 +102,8 @@ and display as a false-color movie. ) ani = na.plt.pcolormovie( obs.inputs.time, - position.x, - position.y, + obs.inputs.position.x, + obs.inputs.position.y, C=rgb, axis_time=obs.axis_time, axis_rgb=obs.axis_wavelength, @@ -131,6 +128,14 @@ and display as a false-color movie. IPython.display.HTML(ani.to_jshtml()) +References +========== + +.. bibliography:: + +| + + Indices and tables ================== diff --git a/iris/sg/_spectrograph.py b/iris/sg/_spectrograph.py index 34daaea..8f0ad72 100644 --- a/iris/sg/_spectrograph.py +++ b/iris/sg/_spectrograph.py @@ -57,7 +57,7 @@ class SpectrographObservation( # red/green/blue channels rgb, colorbar = na.colorsynth.rgb_and_colorbar( spd=obs.outputs, - wavelength=obs.inputs.wavelength.mean(("detector_x", "detector_y")), + wavelength=obs.inputs.wavelength.mean(obs.axis_time), axis=obs.axis_wavelength, spd_min=0 * u.DN, spd_max=np.nanpercentile( @@ -70,9 +70,6 @@ class SpectrographObservation( wavelength_max=wavelength_max, ) - # Isolate the angular position of each RGB point - position = obs.inputs.position.mean(obs.axis_wavelength) - # Isolate the first raster of the observation index = {obs.axis_time: 0} @@ -85,7 +82,7 @@ class SpectrographObservation( constrained_layout=True, ) na.plt.pcolormesh( - position[index], + obs.inputs.position[index], C=rgb[index], axis_rgb=obs.axis_wavelength, ax=ax[0], diff --git a/iris/sg/background/_background.py b/iris/sg/background/_background.py index 2a86dce..21c80e3 100644 --- a/iris/sg/background/_background.py +++ b/iris/sg/background/_background.py @@ -73,10 +73,11 @@ def average( ) """ obs = obs.copy_shallow() + shape = obs.shape obs.inputs = na.TemporalSpectralPositionalVectorArray( time=obs.inputs.time.ndarray.jd.mean(), - wavelength=obs.inputs.wavelength.mean(axis), - position=obs.inputs.position.mean(axis), + wavelength=obs.inputs.wavelength.broadcast_to(shape).mean(axis), + position=obs.inputs.position.broadcast_to(shape).mean(axis), ) obs.outputs = np.nanmedian(obs.outputs, axis=axis) return obs @@ -740,8 +741,8 @@ def estimate( ) ax[0].set_title("original") na.plt.pcolormesh( - obs.inputs.position.x[index].mean(obs.axis_wavelength), - obs.inputs.position.y[index].mean(obs.axis_wavelength), + obs.inputs.position.x[index], + obs.inputs.position.y[index], C=np.nanmean(obs.outputs.value[index], axis=obs.axis_wavelength), ax=ax[0], norm=mappable.norm, @@ -749,8 +750,8 @@ def estimate( ) ax[1].set_title("corrected") na.plt.pcolormesh( - obs_nobg.inputs.position.x[index].mean(obs.axis_wavelength), - obs_nobg.inputs.position.y[index].mean(obs.axis_wavelength), + obs_nobg.inputs.position.x[index], + obs_nobg.inputs.position.y[index], C=np.nanmean(obs_nobg.outputs.value[index], axis=obs.axis_wavelength), ax=ax[1], norm=mappable.norm, @@ -781,12 +782,12 @@ def estimate( with astropy.visualization.quantity_support(): fig, ax = plt.subplots() na.plt.plot( - obs.inputs.wavelength.mean(axis=axis_txy), + obs.inputs.wavelength.mean(obs.axis_time), np.nanmedian(obs.outputs, axis=axis_txy), label="original", ) na.plt.plot( - obs_nobg.inputs.wavelength.mean(axis=axis_txy), + obs_nobg.inputs.wavelength.mean(obs.axis_time), np.nanmedian(obs_nobg.outputs, axis=axis_txy), label="corrected", ) diff --git a/pyproject.toml b/pyproject.toml index 3cda02a..26ef34a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ classifiers = [ dependencies = [ "astropy", "requests", - "named-arrays==0.14.1", + "named-arrays==0.14.2", ] dynamic = ["version"]