4.14. imarith¶
returns the data of fits file
- Fits.imarith(other, operand: str, output=None, override=False) Self¶
Performs an arithmetic operation on the
Fitsobject.Notes
This method can perform operations with numeric values or another
Fitsobject.If
otheris numeric, each element of the matrix will be processed using that number.If
otheris anotherFitsobject, element-wise operations will be performed.
Parameters
otherUnion[Self, float, int]Either a
Fitsobject, a float, or an integer.operandstrThe operation as a string. One of
["+", "-", "*", "/"].outputOptional[str]New path to save the resulting file.
overridebool, optional, default=FalseIf
True, will overwrite theoutputpath if a file already exists.
Returns
FitsA new
Fitsobject representing the result of the arithmetic operation.
Raises
ValueErrorIf the given
othervalue is not aFits,float, orint.ValueErrorIf
operandis not one of["+", "-", "*", "/", "**", "^"].
4.14.1. Example:¶
from myraflib import Fits
fits = Fits.sample()
other = fits.data()
new_fits_1 = fits.imarith(2, "+")
new_fits_2 = fits.imarith(other, "+")
new_fits_3 = fits.imarith(2, "-")
new_fits_4 = fits.imarith(other, "-")
new_fits_5 = fits.imarith(2, "*")
new_fits_6 = fits.imarith(other, "*")
new_fits_7 = fits.imarith(2, "/")
new_fits_8 = fits.imarith(other, "/")
new_fits_9 = fits.imarith(2, "**") # or ^
new_fits_10 = fits.imarith(other, "**") # or ^