10.5. Spectroscopy

The tools for plasma spectroscopy.

10.5.1. Spectroscopic instruments

Spectroscopic instruments such as polychromators and spectrometers simplify the setup of properties of the observers and rendering pipelines. The instruments are not connected to the scenegraph, so they cannot observe the world. However, the instruments have properties, such as min_wavelength, max_wavelength, spectral_bins, pipeline_properties, with which the observer can be configured. The Cherab core package provides base classes for spectroscopic instruments, so machine-specific packages can build more advance instruments from them, such as instruments with spectral properties based on the actual experimental setup for a given shot/pulse.

class cherab.tools.spectroscopy.SpectroscopicInstrument(name='')

Base class for spectroscopic instruments (spectrometers, polychromators, etc.). This is an abstract class.

Parameters

name (str) – Instrument name.

Variables
  • pipeline_classes (list) – The list of pipeline classes used with this instrument.

  • pipeline_kwargs (list) – The list of dicts with keywords passed to init methods of pipeline classes used with this instrument.

  • min_wavelength (float) – Lower wavelength bound for spectral range.

  • max_wavelength (float) – Upper wavelength bound for spectral range.

  • spectral_bins (int) – The number of spectral samples over the wavelength range.

create_pipelines()

Returns a list of new pipelines created according to pipeline_classes and keyword arguments.

class cherab.tools.spectroscopy.PolychromatorFilter(wavelengths, samples, normalise=False, name='')

Defines a polychromator filter as a Raysect’s InterpolatedSF.

Parameters
  • wavelengths (object) – 1D array of wavelengths in nanometers.

  • samples (object) – 1D array of spectral samples.

  • normalise (bool) – True/false toggle for whether to normalise the spectral function so its integral equals 1.

  • name (str) – Filter name (e.g. “H-alpha filter”). Default is ‘’.

Variables
  • min_wavelength (float) – Lower wavelength bound of the filter’s spectral range in nm.

  • max_wavelength (float) – Upper wavelength bound of the filter’s spectral range in nm.

class cherab.tools.spectroscopy.TrapezoidalFilter(central_wavelength, window=3.0, flat_top=None, name='')

Bases: cherab.tools.spectroscopy.polychromator.PolychromatorFilter

Symmetrical trapezoidal polychromator filter.

Parameters
  • wavelength (float) – Central wavelength of the filter in nm.

  • window (float) – Size of the filtering window in nm. Default is 3.

  • flat_top (float) – Size of the flat top part of the filter in nm. Default is None (equal to window).

  • name (str) – Filter name (e.g. “H-alpha filter”). Default is ‘’.

class cherab.tools.spectroscopy.Polychromator(filters, min_bins_per_window=10, name='')

Bases: cherab.tools.spectroscopy.instrument.SpectroscopicInstrument

A polychromator assembly with a set of different filters.

Parameters
  • filters (list) – List of the PolychromatorFilter instances.

  • min_bins_per_window (int) – Minimal number of spectral bins per filtering window. Default is 10.

  • name (str) – Polychromator name.

>>> from raysect.optical import World
>>> from raysect.optical.observer import FibreOptic
>>> from cherab.tools.spectroscopy import Polychromator, TrapezoidalFilter
>>>
>>> world = World()
>>> h_alpha_filter = TrapezoidalFilter(656.1, name='H-alpha filter')
>>> ciii_465nm_filter = TrapezoidalFilter(464.8, name='CIII 465 nm filter')
>>> polychromator = Polychromator([h_alpha_filter, ciii_465nm_filter], name='MyPolychromator')
>>> fibreoptic = FibreOptic(name="MyFibreOptic", parent=world)
>>> fibreoptic.min_wavelength = polychromator.min_wavelength
>>> fibreoptic.max_wavelength = polychromator.max_wavelength
>>> fibreoptic.spectral_bins = polychromator.spectral_bins
>>> fibreoptic.pipelines = polychromator.create_pipelines()
class cherab.tools.spectroscopy.Spectrometer(wavelength_to_pixel, min_bins_per_pixel=1, name='')

Bases: cherab.tools.spectroscopy.instrument.SpectroscopicInstrument

Spectrometer that can accommodate multiple spectra.

Spectrometer is initialized with a sequence of calibration arrays (one array per accommodated spectrum) containing the wavelengths of the pixel borders. Namely, the values \(w_{k}^{i}\) and \(w_{k}^{i+1}\) define the spectral range of the pixel \(p_i\) of the k-th spectrum. After the spectrum is ray-traced, it can be recalibrated with spectrometer.calibrate(spectrum).

Note that Raysect cannot raytrace the spectra with non-constant spectral resolution. Thus, the actual number of spectral bins of raytraced spectrum is defined with min_bins_per_pixel attribute.

Parameters
  • wavelength_to_pixel (tuple) – Wavelength-to-pixel calibration arrays.

  • min_bins_per_pixel (int) – Minimal number of spectral bins per pixel. Default is 1.

  • name (str) – Spectrometer name.

Variables

wavelengths (tuple) – Central wavelengths of the pixels.

>>> from raysect.optical import World, Spectrum
>>> from raysect.optical.observer import FibreOptic
>>> from cherab.tools.spectroscopy import Spectrometer
>>> from matplotlib import pyplot as plt
>>>
>>> wavelength_to_pixel = ([400., 400.5, 401.5, 402., 404.],
>>>                        [600., 600.5, 601.5, 602., 604., 607.])
>>> spectrometer = Spectrometer(wavelength_to_pixel, min_bins_per_pixel=5,
>>>                             name='MySpectrometer')
>>>
>>> world = World()
>>> fibreoptic = FibreOptic(name="MyFibreOptic", parent=world)
>>> fibreoptic.min_wavelength = spectrometer.min_wavelength
>>> fibreoptic.max_wavelength = spectrometer.max_wavelength
>>> fibreoptic.spectral_bins = spectrometer.spectral_bins
>>> fibreoptic.pipelines = spectrometer.create_pipelines()
>>> ...
>>> fibreoptic.observe()
>>> spectrum = Spectrum(fibreoptic.min_wavelength, fibreoptic.max_wavelength, fibreoptic.spectral_bins)
>>> spectrum.samples[:] = fibreoptic.pipelines[0].mean
>>> calibrated_spectra = spectrometer.calibrate(spectrum)
>>> wavelengths = spectrometer.wavelengths
>>>
>>> plt.plot(wavelengths[0], calibrated_spectra[0])
>>> plt.show()
calibrate(spectrum)

Calibrates the spectrum according to the wavelength_to_pixel arrays by averaging it over the pixel widths.

Parameters

spectrum (Spectrum) – Spectrum to calibrate.

Returns

A tuple of calibrated spectra as ndarrays.

class cherab.tools.spectroscopy.CzernyTurnerSpectrometer(diffraction_order, grating, focal_length, pixel_spacing, diffraction_angle, accommodated_spectra, min_bins_per_pixel=1, name='')

Bases: cherab.tools.spectroscopy.spectrometer.Spectrometer

Czerny-Turner spectrometer.

The Czerny-Turner spectrometer is initialized with the parameters of the diffraction scheme and a sequence of accommodated spectra, each of which is determined by the lower wavelength bound and the number of pixels.

This spectrometer automatically fills the wavelength-to-pixel calibration arrays according to the parameters of the diffraction scheme.

Parameters
  • diffraction_order (int) – Diffraction order.

  • grating (float) – Diffraction grating in nm-1.

  • focal_length (float) – Focal length in nm.

  • pixel_spacing (float) – Pixel to pixel spacing on CCD in nm.

  • diffraction_angle (float) – Angle between incident and diffracted light in degrees.

  • accommodated_spectra (tuple) – A sequence of (min_wavelength, pixels) pairs, specifying the lower wavelength bound and the number of pixels of accommodated spectra.

  • min_bins_per_pixel (int) – Minimal number of spectral bins per pixel. Default is 1.

  • name (str) – Spectrometer name.

Variables

wavelength_to_pixel (tuple) – Wavelength-to-pixel calibration arrays.

>>> from raysect.optical import World
>>> from raysect.optical.observer import FibreOptic
>>> from cherab.tools.spectroscopy import CzernyTurnerSpectrometer
>>>
>>> world = World()
>>> hires_spectrometer = CzernyTurnerSpectrometer(1, 2.e-3, 1.e9, 2.e4, 10.,
>>>                                               ((600., 512), (700., 128)),
>>>                                               name='MySpectrometer')
>>> fibreoptic = FibreOptic(name="MyFibreOptic", parent=world)
>>> fibreoptic.min_wavelength = hires_spectrometer.min_wavelength
>>> fibreoptic.max_wavelength = hires_spectrometer.max_wavelength
>>> fibreoptic.spectral_bins = hires_spectrometer.spectral_bins
>>> fibreoptic.pipelines = hires_spectrometer.create_pipelines()
resolution(wavelength)

Calculates spectral resolution in nm for a given wavelength.

Parameters

wavelength – Wavelength in nm.

Returns

Resolution in nm.