subtract_spectral_line#
- iris.sg.background.subtract_spectral_line(obs, axis_wavelength)[source]#
Fit obs using
fit()and subtract themodel_spectral_line()component.- Parameters:
obs (SpectrographObservation) – The observation to remove the spectral line from.
axis_wavelength (str) – The logical axis corresponding to increasing wavelength.
- Return type:
Examples
Subtract the spectral line from an averaged spectrograph observation.
import matplotlib.pyplot as plt import astropy.units as u import astropy.visualization import named_arrays as na import iris # Load a spectrograph observation obs = iris.sg.SpectrographObservation.from_time_range( time_start=astropy.time.Time("2021-09-23T06:00"), time_stop=astropy.time.Time("2021-09-23T07:00"), ) # Save the time and raster axes axis = (obs.axis_time, obs.axis_detector_x) # Compute the average along the time and raster axes avg = iris.sg.background.average( obs=obs, axis=axis, ) # Subtract the spectral line from the average bg = iris.sg.background.subtract_spectral_line( obs=avg, axis_wavelength=obs.axis_wavelength, ) # Plot the result with astropy.visualization.quantity_support(): fig, ax = plt.subplots() img = na.plt.pcolormesh( bg.inputs.wavelength, bg.inputs.position.y, C=bg.outputs.value, vmin=-5, vmax=+5, ) ax.set_xlabel(f"wavelength ({ax.get_xlabel()})") ax.set_ylabel(f"helioprojective $y$ ({ax.get_ylabel()})") fig.colorbar( mappable=img.ndarray.item(), ax=ax, label=f"average spectral radiance ({obs.outputs.unit})", )