Commit bbf90c3c authored by PAduverne's avatar PAduverne
Browse files

add the option to save the background as png, and not necessarily as a fits file.

parent 2bd5af8e
......@@ -106,7 +106,7 @@ def subtract(data, bkg):
def sub_background(data, header, image_name, n_sigma=3.0, box_size=(30, 30),
bkg_estimator='sex', filter_size=(3, 3), mask=None,
path2save=None, png=False):
path2save=None, fits=None, png=False):
"""
Perform the background subtraction in a fits image.
Possible to save the background and the backgrounds subtracted image
......@@ -136,6 +136,8 @@ def sub_background(data, header, image_name, n_sigma=3.0, box_size=(30, 30),
The default is None.
path2save : str, optional
Path where the are saved. The default is None.
fits : Bool, optional
Used to save the background as a fits file. The default is False.
png : Bool, optional
Used to save the background as a png file. The default is False.
......@@ -166,22 +168,24 @@ def sub_background(data, header, image_name, n_sigma=3.0, box_size=(30, 30),
# Save clean image if required
if path2save is not None:
clean_filename = os.path.join(path2save,
'clean_' + image_name + '.fits')
createFITS(data_cleaned, header, filename=clean_filename)
# Save background image
background_filename = os.path.join(path2save,
'background/background_' +
image_name)
createFITS(background_array, header,
filename=background_filename+'.fits')
# Save RMS image
RMS_filename = os.path.join(path2save,
'background/rms_' + image_name)
createFITS(background_rms, header,
filename=RMS_filename+'.fits')
if fits:
clean_filename = os.path.join(path2save,
'clean_' + image_name + '.fits')
createFITS(data_cleaned, header, filename=clean_filename)
# Save background image
createFITS(background_array, header,
filename=background_filename+'.fits')
# Save RMS image
RMS_filename = os.path.join(path2save,
'background/rms_' + image_name)
createFITS(background_rms, header,
filename=RMS_filename+'.fits')
if png:
plot_background(data, background_array, dif=False,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment