4.9. add

Performs an addition operation on the Fits object.


Fits.add(other, output=None, override=False) Self

Performs an addition operation on the Fits object.

Notes

This method can add numeric values or another Fits object.

  • If other is numeric, each element of the matrix will be added to that number.

  • If other is another Fits object, element-wise summation will be performed.

Parameters

otherUnion[Self, float, int]

Either a Fits object, a float, or an integer.

outputOptional[str]

New path to save the resulting file.

overridebool, optional, default=False

If True, will overwrite the output path if a file already exists.

Returns

Fits

A new Fits object representing the result of the addition.

Raises

FileExistsError

If the file already exists and override is False.


4.9.1. Example:

from myraflib import Fits

fits = Fits.sample()
other = Fits.sample()

new_fits_1 = fits.add(120)
new_fits_2 = fits + 120

new_fits_3 = fits.add(other)
new_fits_4 = fits + other