PSpecContainer Class

PSpecContainer is a container for organizing collections of UVPSpec objects. It is based on HDF5.

class hera_pspec.PSpecContainer(filename, mode='r', keep_open=True, swmr=False, tsleep=0.1, maxiter=1)[source]

Container class for managing multiple UVPSpec objects.

get_pspec(group, psname=None, **kwargs)[source]

Get a UVPSpec power spectrum object from a given group.

Parameters:
  • group (str) – Which group the power spectrum belongs to.
  • psname (str, optional) – The name of the power spectrum to return. If None, extract all available power spectra.
  • kwargs (dict) – UVPSpec.read_from_group partial IO keyword arguments
Returns:

uvp – The specified power spectrum as a UVPSpec object (or a list of all power spectra in the group, if psname was not specified).

Return type:

UVPSpec or list of UVPSpec

groups()[source]

Return list of groups in the container.

Returns:group_list – List of group names.
Return type:list of str
save()[source]

Force HDF5 file to flush to disk.

set_pspec(group, psname, pspec, overwrite=False)[source]

Store a delay power spectrum in the container.

Parameters:
  • group (str) – Which group the power spectrum belongs to.
  • psname (str or list of str) – The name(s) of the power spectrum to return from within the group.
  • pspec (UVPSpec or list of UVPSpec) – Power spectrum object(s) to store in the container.
  • overwrite (bool, optional) – If the power spectrum already exists in the file, whether it should overwrite it or raise an error. Default: False (does not overwrite).
spectra(group)[source]

Return list of available power spectra.

Parameters:group (str) – Which group to list power spectra from.
Returns:ps_list – List of names of power spectra in the group.
Return type:list of str
tree(return_str=True)[source]

Output a string containing a tree diagram of groups and the power spectra that they contain.

Parameters:return_str (bool, optional) – If True, return the tree as a string, otherwise return as a dictionary
Returns:Tree structure of HDF5 file
Return type:str or dict