User utilities

The following functions/classes provide convenience functionality for users of the library.

Input and Output

glass.save_cls(filename, cls)[source]

Save a list of Cls to file.

Uses numpy.savez() internally. The filename should therefore have a .npz suffix, or it will be given one.

Parameters:
Return type:

None

glass.load_cls(filename)[source]

Load a list of Cls from file.

Uses numpy.load() internally.

Parameters:

filename (str) – The name of the file to load from.

Returns:

The list of Cls.

Return type:

list[ndarray[Any, dtype[float64]] | Sequence[float]]

glass.write_catalog(filename, *, ext=None)[source]

Write a catalogue into a FITS file.

ext is the optional name of the extension. To be used as a context manager:

# create the catalogue writer
with write_catalog("catalog.fits") as out:
    ...
    # write catalogue columns RA, DEC, E1, E2, WHT with given arrays
    out.write(RA=lon, DEC=lat, E1=eps1, E2=e2, WHT=w)

Note

Requires the fitsio package.

Parameters:
  • filename (Path) – The name of the file to write to.

  • ext (str | None) – The file extension.

Yields:

writer – The writer object.

Return type:

Generator[_FitsWriter]