SciPy

darkhistory.spec.spectra.Spectra

class darkhistory.spec.spectra.Spectra(spec_arr, eng=None, in_eng=None, rs=None, spec_type='dNdE', rebin_eng=None)

Structure for a collection of Spectrum objects.

Spectra should be viewed as a collection of spectra of particles at different redshifts, or as a collection of spectra produced by injected particles over a range of energies.

Individual Spectrum objects can be accessed by taking slices of the Spectra object.

Parameters:
spec_arrlist of Spectrum or ndarray of length N

List of Spectrum objects or arrays to be stored together.

spec_type{‘N’, ‘dNdE’}, optional

The type of entries. Default is ‘dNdE’.

engndarray of length M, optional

Array of energy abscissa of each spectrum. Specify only if spec_arr is an ndarray.

in_engndarray of length N, optional

Array of injection energies corresponding to each spectrum, if relevant.

rsndarray of length N, optional

Array of redshifts corresponding to each spectrum, if relevant.

rebin_engndarray, optional

New abscissa to rebin all of the spectra into, if specified.

Attributes:
engndarray of length M

Array of energy abscissa of each spectrum.

in_engndarray of length N

Array of injection energies corresponding to each spectrum.

rsndarray of length N

Array of redshifts corresponding to each spectrum.

grid_valsndarray of shape (N,M)

2D array of the raw data, indexed by either (rs, eng) or (in_eng, eng).

spec_type{‘N’, ‘dNdE’}

The type of values stored.

N_underflowndarray

Array of underflow particles for each Spectrum.

eng_underflowndarray

Array of underflow particles for each Spectrum.

Methods

append(spec)

Appends a new Spectrum.

at_rs(new_rs[, interp_type, bounds_err, ...])

Interpolates the transfer function at a new redshift.

integrate_each_spec([weight])

Sums over each individual spectrum with some weight.

plot(ax[, ind, step, indtype, fac])

Plots the contained Spectrum objects.

rebin(out_eng)

Re-bins all Spectrum objects according to a new abscissa.

redshift(rs_arr)

Redshifts the stored spectra.

sum_specs([weight])

Sums all of spectra with some weight.

switch_spec_type([target])

Switches between the type of values to be stored.

totN([bound_type, bound_arr])

Returns the total number of particles in part of the spectra.

toteng([bound_type, bound_arr])

Returns the total energy of particles in part of the spectra.

Examples

Indexing into Spectra to obtain a Spectrum object:

>>> from darkhistory.spec.spectrum import Spectrum
>>> eng = np.array([1, 10, 100, 1000])
>>> spec_arr = [Spectrum(eng, np.ones(4)*i, spec_type='N') for i in np.arange(9)]
>>> test_spectra = Spectra(spec_arr)
>>> test_spectra[3].N
array([3., 3., 3., 3.])
__init__(spec_arr, eng=None, in_eng=None, rs=None, spec_type='dNdE', rebin_eng=None)

Methods

__add__(other)

Adds two Spectra instances together, or an array to the Spectra.

__delattr__(name, /)

Implement delattr(self, name).

__dir__(/)

Default dir() implementation.

__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getitem__(key)

__getstate__(/)

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__(/)

Return hash(self).

__init__(spec_arr[, eng, in_eng, rs, ...])

__init_subclass__

This method is called when a class is subclassed.

__iter__()

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__mul__(other)

Takes a product with the spectra with a Spectra object, array or number.

__ne__(value, /)

Return self!=value.

__neg__()

Negates the spectra.

__new__(*args, **kwargs)

__radd__(other)

Adds two Spectra instances together, or an array to the spectra.

__reduce__(/)

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__(/)

Return repr(self).

__rmul__(other)

Takes a product with the spectra with a Spectra object, array or number.

__rsub__(other)

Subtracts this Spectra from another or an array.

__rtruediv__(other)

Divides an object by the spectra.

__setattr__(name, value, /)

Implement setattr(self, name, value).

__setitem__(key, value)

__sizeof__(/)

Size of object in memory, in bytes.

__str__(/)

Return str(self).

__sub__(other)

Subtracts a Spectra or array from this Spectra.

__subclasshook__

Abstract classes can override this to customize issubclass().

__truediv__(other)

Divides the spectra by another object.

append(spec)

Appends a new Spectrum.

at_rs(new_rs[, interp_type, bounds_err, ...])

Interpolates the transfer function at a new redshift.

integrate_each_spec([weight])

Sums over each individual spectrum with some weight.

plot(ax[, ind, step, indtype, fac])

Plots the contained Spectrum objects.

rebin(out_eng)

Re-bins all Spectrum objects according to a new abscissa.

redshift(rs_arr)

Redshifts the stored spectra.

sum_specs([weight])

Sums all of spectra with some weight.

switch_spec_type([target])

Switches between the type of values to be stored.

totN([bound_type, bound_arr])

Returns the total number of particles in part of the spectra.

toteng([bound_type, bound_arr])

Returns the total energy of particles in part of the spectra.

Attributes

N_underflow

__annotations__

__array_priority__

__dict__

__doc__

__module__

__weakref__

list of weak references to the object

eng

eng_underflow

grid_vals

in_eng

rs

spec_type