AbsorberPlotter
- class salsa.AbsorberPlotter(abs_ext, ion_name='H I', ftype='gas', absorber_fields=[], markers=True, mark_plot_args=None, figure=None)
Bases:
objectCreate’s plot to easily see where absorbers are found along the light ray both directly and through resulting spectra. Uses absorber extractor as base class.
- Parameters:
abs_ext (AbsorberExtractor object) – Absorber extractor used to extract the data we want to plot. Can be any of the child classes; e.g. SPICEAbsorberExtractor
ion_name (string, optional) – Name of the ion to extract absorbers of and plot Default: “H I”
ftype (string, optional) – Field type for ion fields. Allows ion fields to be added if not already present. Default: “gas”
absorber_fields (list of strings, optional) – Additional ions to include in plots/Spectra, enter as list.
markers (bool, optional) – whether to include markers on light ray and number density plot
mark_plot_args (dict, optional) –
set the property of markers if they are to be plotted. optional settings are:
marker_spacing: determines how far apart markers are in kpc.
marker_shape: shape of marker see matplotlib for notation
marker_cmap: colormap used to differentiate markers any other property that can be passer to matplotlib scatter
figure (matplotlib figure, optional) – where the multi_plot will be plotted. creates one if none is specified.
Notes
ion names should be in following notaion: neutral Hydrogen–>”H I”, 5-times ionized Oxygen –> “O VI”
Methods Summary
close()close all opened files
create_slice([center, slice_field, ...])Create a slice in the Dataset along the path of the ray.
plot_lambda_space([wavelength_width, ...])Use trident to plot the absorption spectrum of the ray.
plot_multiplot([outfname, center, ...])Combines the slice plot, number density plot, and (optionally) spectrum plot into one image and saves it to disk.
plot_num_density(ax_num_dense[, ...])Plots the number density at different lengths along the ray
plot_vel_space([velocity_width, ax_vel])Use trident to plot the absorption spectrum of the ray in velocity space.
Methods Documentation
- close()
close all opened files
- create_slice(center=None, slice_field=None, north_vector=[0, 0, 1], plot_ray=True, cmap='magma', height=None, width=None)
Create a slice in the Dataset along the path of the ray. Choose to keep the Z direction maintained.
- Parameters:
center (array type, optional) – Center of the slice in code_length. If None, then defaults to domain_center
slice_field (string, optional) – Field to plot. Defaults to the number density for the ion associated with the abs_ext attribute.
north_vector (array type, optional) – vector used to fix the orientation of the slice plot. Defaults to z-axis
plot_ray (bool) – Whether to annotate ray/markers to the slice plot or to just calculate the marker positions for placing on los_velocity plot
cmap (str) – the colormap to use for the slice. Default: ‘magma’
height (float, optional) – dimension for the figure
width (float, optional) – dimension for the figure
- Returns:
slice – Slice with ray annotated. This SlicePlot is also saved to the .slice attribute.
- Return type:
yt SlicePlot
- plot_lambda_space(wavelength_width=30, wavelength_res=0.1, ax=None, **kwargs)
Use trident to plot the absorption spectrum of the ray. Plot in wavelegnth (lambda) space.
- Parameters:
wavelength_width (float, optional) – sets the wavelength range of the spectrum plot. defaults to 300 Angstroms
wavelength_res (float, optional) – width of wavelength bins in spectrum plot. default 0.1 Angstrom
ax (matplotlib axis) – axis in which to draw the spectra plot
- Returns:
wavelength (YT array) – Array of wavelength values of the generated spectra (in km/s)
flux (YT array) – Array of the normalized flux values of the generated spectra
- plot_multiplot(outfname=None, center=None, slice_field=None, north_vector=[0, 0, 1], cmap='magma', make_spectra=True, plot_spice_intervals=True, annotate_column_density=True, velocity_width=3000, **kwargs)
Combines the slice plot, number density plot, and (optionally) spectrum plot into one image and saves it to disk.
Can supply any optional keyword arguments supported by plot_num_density and plot_vel_space.
- Parameters:
outfname (str , optional) – the file name/path in which to save the file defaults to being unsaved. Default: None
gal_center (array type, optional) – Center of the slice in code_length. If None, then defaults to domain_center
slice_field (string, optional) – Field to plot. Defaults to the number density for the ion associated with the abs_ext attribute.
north_vector (array type, optional) – vector used to fix the orientation of the slice plot. Defaults to z-axis
cmap (Colormap, optional) – the color map to use for the slice plot. Default: magma
plot_spice_intervals (bool, optional) – whether or not to shade the absorber intervals found by SPICE in the number density plot
make_spectrum (bool, optional) – whether to include the spectrum plot or not. Given that the transition from yt 3 to yt 4 has affected Trident’s spectra generation (https://github.com/trident-project/trident/issues/217), you may wish to not include this plot. Default: True
annotate_column_density (bool, optional) – whether or not to annotate the column densities of absorbers in the spectrum plot
velocity_width (float, optional) – velocity range of the spectrum plot in km/s
- Returns:
fig (matplotlib figure:) – figure multi_plot is drawn on
axes (matplotlib axes) – axes the three lower plots are drawn on
- plot_num_density(ax_num_dense, num_dense_min=None, num_dense_max=None, ax_prop2=None, prop2_name='velocity_los', prop2_units=None, plot_spice_intervals=False, plot_kwargs={}, **kwargs)
Plots the number density at different lengths along the ray
- Parameters:
ax_num_dense (matplotlib axis) – axis in which to draw the number density plot
num_dense_min (float, optional) – Sets the lower limit for the number density plot. If None, defaults to 0.01 times the median number density
num_dense_max (float, optional) – Sets the upper limit for the number density plot. If None, defaults to 100 times the median number density
ax_prop2 (matplotlib axis, optional) – axis in which to draw the second field. if None, no plot is made Default: None
prop2_name (str, optional) – Field to plot in second plot. Default:’velocity_los’
prop2_units (str, optional) – The units to use in the second field. Defaults: None
plot_spice_intervals (bool, optional) – If using a SPICEAbsorberExtractor, plot the SPICE intervals. Has no effect for any other AbsorberExtractor class.
plot_kwargs (dict, optional) – A Dictionary of plot kwargs to be passed to the pyplot.plot function. Default: {}
- plot_vel_space(velocity_width=3000, ax_vel=None, **kwargs)
Use trident to plot the absorption spectrum of the ray in velocity space. Uses the wavelength centers and velocity resolution of the AbsorberExtractor to generate the spectrum.
- Parameters:
velocity_width (float, optional) – sets the velocity range of spectrum plot in units of km/s
ax_vel (matplotlib axis object, optional) – an axis in which to draw the velocity plot. If None, no plot is not drawn. Default: None
- Returns:
velocity (YT array) – Array of velocity values of the generated spectra (in km/s)
flux (YT array) – Array of the normalized flux values of the generated spectra