Spectrum

class popurri.spectrum.Spectrum(filin, inst, dirout='./', obj=None, tag='', headertable=None, ord_ref=None, ordcut=True, saveordnoncut=False, readblaze=True, dirblaze=None, filblaze=None)

Bases: object

Spectrum class

Main data attributes of the Spectrum class: - dataspec: Dictionary with spectrum data (wavelength, flux, blaze…). - dataheader: Dictionary with general parameters from the header. - dataord: Pandas DataFrame with per order data such as the S/N.

Other attributes of the Spectrum class: - filin: Input file. - filname: File name without extension nor path. - inst: Instrument keyword. - obj: Object name. - tag: String tag for the spectrum. - dirout: Output directory. - Spectrograph: popurri Spectrograph object. - ords_real: Real order numbers. - ord_ref: Reference order. - pixel_ms: Pixel size in velocity [m/s]. - nord: Number of orders. - ords: List of orders (starting with 0 for the bluest order). - npix: Number of pixels per order. - header: Raw header (astropy.io.fits.header.Header object).

Methods Summary

dopplershift(v[, rel, x, xnew])

v : float

fig_dataord(y[, filout, sh, sv, figsize])

fig_spectrum([filout, sh, sv, figsize])

fig_spectrum_map([filout, sh, sv, figsize])

fig_spectrum_pix([filout, sh, sv, figsize])

plot_dataord(y[, ax, x, z, ords, xlabel, ...])

kwargs for scatter plot (not errorbar) cmap in kwargs

plot_spectrum([ax, ords, x, y, wmin, wmax, ...])

Plot spectrum flux vs wavelength (or pixel), for the orders in ords.

plot_spectrum_map([ax, ords, pixs, xlabel, ...])

Plot spectrum flux matrix, all orders (orders in y-axis, pixel in x-axis). ords: list-like, optional Orders to plot (in zero-based notation). If None, plot all orders. Cannot be a single order. pixs: list-like, optional Pixels to plot. If None, plot all pixels. Cannot be a single pixel. ordtype : 'real' or 'zero', default 'real' If 'real', the real order number is plotted. If 'zero', the zero-based order number is plotted.

plot_spectrum_pix([ax, ords, x, y, pmin, ...])

Plot spectrum normalised flux + offset vs pixel for the orders in ords.

Methods Documentation

dopplershift(v, rel=True, x='w', xnew='wshift')
vfloat

Doppler shift, m/s

fig_dataord(y, filout=None, sh=False, sv=True, figsize=(8, 6), **kwargs)
fig_spectrum(filout=None, sh=False, sv=True, figsize=(16, 4), **kwargs)
fig_spectrum_map(filout=None, sh=False, sv=True, figsize=(8, 6), **kwargs)
fig_spectrum_pix(filout=None, sh=False, sv=True, figsize=(16, 16), **kwargs)
plot_dataord(y, ax=None, x=None, z=None, ords=None, xlabel=None, ylabel=None, zlabel=None, title='', zorder=0, s=100, edgecolors='k', linewidths=0.5, ecolor=None, elinewidth=1.5, capsize=3, markeredgewidth=1.5, **kwargs)

kwargs for scatter plot (not errorbar) cmap in kwargs

plot_spectrum(ax=None, ords=None, x='w', y='f', wmin=None, wmax=None, normflux=None, offset=0, legendlabel=None, legend=False, legendloc=None, xunit='A', xlabel=None, ylabel='Flux', title='', lw=1, linestyle='-', alpha=1, alphaother=0.7, zorder=0, color=None, colorother=None, cmap=None, cbar=False)

Plot spectrum flux vs wavelength (or pixel), for the orders in ords.

Parameters:
x, ystr

Parameters to plot from Spectrum.dataspec. Default to ‘w’ and ‘f’.

ords: list-like, optional

Orders to plot. If None, plot all orders.

wmin, wmax: floats, optional

Wavelength range to plot. Must be in the same units as w (and xunit).

normfluxfunction

Function to normalise the spectrum. Default is None. max, mean…

offsetfloat

Offset to add to the spectrum. To ne used with normflux and pixel in the x axis. Default is None.

cstr, optional

Plot all orders with the same color, alternating alpha. Overrides cmap.

cmapstr, optional
cbarbool, optional
TODO add colorbar if using cmap?
plot_spectrum_map(ax=None, ords=None, pixs=None, xlabel='Pixel', ylabel='Order', cblabel='Flux', title='', ordtype='zero', vmin=None, vmax=None, cmap='viridis')

Plot spectrum flux matrix, all orders (orders in y-axis, pixel in x-axis). ords: list-like, optional

Orders to plot (in zero-based notation). If None, plot all orders. Cannot be a single order.

pixs: list-like, optional

Pixels to plot. If None, plot all pixels. Cannot be a single pixel.

ordtype‘real’ or ‘zero’, default ‘real’

If ‘real’, the real order number is plotted. If ‘zero’, the zero-based order number is plotted.

plot_spectrum_pix(ax=None, ords=None, x='pix', y='f', pmin=None, pmax=None, normflux=<function nanmax>, offset=1, legend=False, legendloc=None, xunit=None, xlabel='Pixel', ylabel='Norm. flux + offset', title='', lw=1, linestyle='-', alpha=1, zorder=0, color=None, cmap=None, cbar=False)

Plot spectrum normalised flux + offset vs pixel for the orders in ords.

Parameters:
x, ystr

Parameters to plot from Spectrum.dataspec. Default to ‘w’ and ‘f’.

ords: list-like, optional

Orders to plot. If None, plot all orders.

wmin, wmax: floats, optional

Wavelength range to plot. Must be in the same units as w (and xunit).

normfluxfunction

Function to normalise the spectrum. Default is None. max, mean…

offsetfloat

Offset to add to the spectrum. To ne used with normflux and pixel in the x axis. Default is None.

cstr, optional

Plot all orders with the same color, alternating alpha. Overrides cmap.

cmapstr, optional
cbarbool, optional
TODO add colorbar if using cmap