SEV, NPS and OF

class cait.versatile.NPS(data: Optional[Union[numpy.ndarray, cait.versatile.iterators.iteratorbase.IteratorBaseClass]] = None)[source]

Bases: cait.versatile.analysisobjects.arraywithbenefits.ArrayWithBenefits

Object representing a Noise Power Spectrum (NPS). It can either be created by averaging the Fourier transformed events from an EventIterator, from an np.ndarray or read from a DataHandler or xy-file.

If created from an EventIterator, the (constant) baseline is removed automatically. To improve the quality of the NPS, a window function is often applied to the noise traces before performing the Fourier transform and averaging (see Numerical Recipes by Press, Teukolsky, Vetterling, Flannery chapter 13.4.1). This can only be achieved when we still have the original noise traces, i.e. when we construct the NPS from an iterator. Instead of just a bare iterator it you can pass the iterator it.with_processing([vai.RemoveBaseline(), vai.TukeyFiltering()]) to NPS.

Parameters

data (Union[np.array, Type[IteratorBaseClass]]) – The data to use for the NPS. If None, an empty NPS is created. If np.ndarray, each row in the array is interpreted as an NPS for separate channels. If iterator (possibly from multiple channels) an NPS is calculated by averaging the Fourier transformed events returned by the iterator. Defaults to None.

classmethod from_dh(dh, group: str = 'noise', dataset: str = 'nps')[source]

Construct NPS from DataHandler.

Parameters
  • dh (DataHandler) – The DataHandler instance to read from.

  • group (str) – The HDF5 group where the NPS is stored.

  • dataset (str) – The HDF5 dataset where the NPS is stored.

Returns

Instance of NPS.

Return type

NPS

classmethod from_file(fname: str, src_dir: str = '')[source]

Construct NPS from xy-file.

Parameters
  • fname (str) – Filename to look for (without file-extension)

  • out_dir (str) – Directory to look in. Defaults to ‘’ which means searching current directory. Optional

Returns

Instance of NPS.

Return type

NPS

show(dt_us: Optional[int] = None, **kwargs)[source]

Plot NPS for all channels. To inspect just one channel, you can index NPS first and call .show on the slice.

Parameters
  • dt_us (int) – Length of a sample in microseconds. If provided, the x-axis is a frequency axis. Otherwise it’s the sample index.

  • kwargs (Any) – Keyword arguments passed on to cait.versatile.Line.

to_dh(dh, group: str = 'noise', dataset: str = 'nps', **kwargs)[source]

Save NPS to DataHandler.

Parameters
  • dh (DataHandler) – The DataHandler instance to write to.

  • group (str) – The HDF5 group where the NPS should be stored.

  • dataset (str) – The HDF5 dataset where the NPS should be stored.

  • kwargs (Any) – Keyword arguments for DataHandler.set.

to_file(fname: str, out_dir: str = '')[source]

Write NPS to xy-file.

Parameters
  • fname (str) – Filename to use (without file-extension)

  • out_dir (str) – Directory to write to. Defaults to ‘’ which means writing to current directory. Optional

class cait.versatile.OF(*args: Any)[source]

Bases: cait.versatile.analysisobjects.arraywithbenefits.ArrayWithBenefits

Object representing an Optimum Filter (OF). It can either be created from a Standard Event (SEV) and a Noise Power Spectrum (NPS), from an np.ndarray or read from a DataHandler or xy-file.

Parameters

args – The data to use for the OF. If None, an empty OF is created. If np.ndarray, each row in the array is interpreted as an OF for separate channels. If instances of class:SEV and class:NPS, the OF is calculated from them. Defaults to None.

>>> sev = vai.SEV().from_dh(dh)
>>> nps = vai.NPS().from_dh(dh)
>>> of = vai.OF(sev, nps)
classmethod from_dh(dh, group: str = 'optimumfilter', dataset: str = 'optimumfilter*')[source]

Construct OF from DataHandler.

Parameters
  • dh (DataHandler) – The DataHandler instance to read from.

  • group (str) – The HDF5 group where the OF is stored.

  • dataset (str) – The HDF5 dataset where the OF is stored. The star * denotes the position of the suffixes ‘_real’ and ‘_imag’.

Returns

Instance of OF.

Return type

OF

classmethod from_file(fname: str, src_dir: str = '')[source]

Construct OF from xy-file.

Parameters
  • fname (str) – Filename to look for (without file-extension)

  • out_dir (str) – Directory to look in. Defaults to ‘’ which means searching current directory. Optional

Returns

Instance of OF.

Return type

OF

show(dt_us: Optional[int] = None, **kwargs)[source]

Plot OF for all channels. To inspect just one channel, you can index OF first and call .show on the slice.

Parameters
  • dt_us (int) – Length of a sample in microseconds. If provided, the x-axis is a frequency axis. Otherwise it’s the sample index.

  • kwargs (Any) – Keyword arguments passed on to cait.versatile.Line.

to_dh(dh, group: str = 'optimumfilter', dataset: str = 'optimumfilter*', **kwargs)[source]

Save OF to DataHandler.

Parameters
  • dh (DataHandler) – The DataHandler instance to write to.

  • group (str) – The HDF5 group where the OF should be stored.

  • dataset (str) – The HDF5 dataset where the OF should be stored. The star * denotes the position of the suffixes ‘_real’ and ‘_imag’.

  • kwargs (Any) – Keyword arguments for DataHandler.set.

to_file(fname: str, out_dir: str = '')[source]

Write OF to xy-file.

Parameters
  • fname (str) – Filename to use (without file-extension)

  • out_dir (str) – Directory to write to. Defaults to ‘’ which means writing to current directory. Optional

class cait.versatile.SEV(data: Optional[Union[numpy.ndarray, cait.versatile.iterators.iteratorbase.IteratorBaseClass]] = None)[source]

Bases: cait.versatile.analysisobjects.arraywithbenefits.ArrayWithBenefits

Object representing a Standard Event (SEV). It can either be created by averaging events from an EventIterator, from an np.ndarray or read from a DataHandler or xy-file.

If created from an EventIterator, the (constant) baseline is removed automatically.

Parameters

data (Union[np.array, Type[IteratorBaseClass]]) – The data to use for the SEV. If None, an empty SEV is created. If np.ndarray, each row in the array is interpreted as a SEV for separate channels. If iterator (possibly from multiple channels) a SEV is calculated by averaging the events returned by the iterator. Defaults to None.

classmethod from_dh(dh, group: str = 'stdevent', dataset: str = 'event')[source]

Construct SEV from DataHandler.

Parameters
  • dh (DataHandler) – The DataHandler instance to read from.

  • group (str) – The HDF5 group where the SEV is stored.

  • dataset (str) – The HDF5 dataset where the SEV is stored.

Returns

Instance of SEV.

Return type

SEV

classmethod from_file(fname: str, src_dir: str = '')[source]

Construct SEV from xy-file.

Parameters
  • fname (str) – Filename to look for (without file-extension)

  • out_dir (str) – Directory to look in. Defaults to ‘’ which means searching current directory. Optional

Returns

Instance of SEV.

Return type

SEV

show(dt_us: Optional[int] = None, **kwargs)[source]

Plot SEV for all channels. To inspect just one channel, you can index SEV first and call .show on the slice.

Parameters
  • dt_us (int) – Length of a sample in microseconds. If provided, the x-axis is a microsecond axis. Otherwise it’s the sample index.

  • kwargs (Any) – Keyword arguments passed on to cait.versatile.Line.

to_dh(dh, group: str = 'stdevent', dataset: str = 'event', **kwargs)[source]

Save SEV to DataHandler.

Parameters
  • dh (DataHandler) – The DataHandler instance to write to.

  • group (str) – The HDF5 group where the SEV should be stored.

  • dataset (str) – The HDF5 dataset where the SEV should be stored.

  • kwargs (Any) – Keyword arguments for DataHandler.set.

to_file(fname: str, out_dir: str = '')[source]

Write SEV to xy-file.

Parameters
  • fname (str) – Filename to use (without file-extension)

  • out_dir (str) – Directory to write to. Defaults to ‘’ which means writing to current directory. Optional