Skip to content

Commit

Permalink
fixed subtracting the bias from the flat in skyfit2. added a flag to …
Browse files Browse the repository at this point in the history
…enable it if desired.
  • Loading branch information
dvida committed Nov 1, 2024
1 parent e5ca6ca commit 86c1d28
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Utils/SkyFit2.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def __len__(self):

class PlateTool(QtWidgets.QMainWindow):
def __init__(self, input_path, config, beginning_time=None, fps=None, gamma=None, use_fr_files=False, \
geo_points_input=None, startUI=True, mask=None, nobg=False, flipud=False):
geo_points_input=None, startUI=True, mask=None, nobg=False, flipud=False, flatbiassub=False):
""" SkyFit interactive window.
Arguments:
Expand All @@ -462,6 +462,7 @@ def __init__(self, input_path, config, beginning_time=None, fps=None, gamma=None
startUI: [bool] Start the GUI. True by default.
nobg: [bool] Do not subtract the background for photometry. False by default.
flipud: [bool] Flip the image upside down. False by default.
flatbiassub: [bool] Subtract flat and bias frames. False by default.
"""

super(PlateTool, self).__init__()
Expand Down Expand Up @@ -490,6 +491,9 @@ def __init__(self, input_path, config, beginning_time=None, fps=None, gamma=None
# Store the flip upside down flag
self.flipud = flipud

# Store the flat and bias subtraction flag
self.flatbiassub = flatbiassub

# Extract the directory path if a file was given
if os.path.isfile(self.dir_path):
self.dir_path, _ = os.path.split(self.dir_path)
Expand Down Expand Up @@ -2762,6 +2766,10 @@ def loadState(self, dir_path, state_name, beginning_time=None, mask=None):
if not hasattr(self, "flipud"):
self.flipud = False

# Update the possibly missing flag for subtracting the bias from the flat
if not hasattr(self, "flatbiassub"):
self.flatbiassub = False

# If the paired stars are a list (old version), reset it to a new version where it's an object
if isinstance(self.paired_stars, list):

Expand Down Expand Up @@ -3110,8 +3118,8 @@ def keyPressEvent(self, event):
# Set focus back on the SkyFit window
self.activateWindow()

# Apply the dark to the flat
if self.flat_struct is not None:
# Apply the dark to the flat if the flatbiassub flag is set
if self.flatbiassub and (self.flat_struct is not None):

self.flat_struct.applyDark(self.dark)

Expand Down Expand Up @@ -6524,6 +6532,9 @@ def getVisibleUnmarkedStarsAndDistanceToMarked(marked_x_list, marked_y_list, min

arg_parser.add_argument('-m', '--mask', metavar='MASK_PATH', type=str,
help="Path to a mask file which will be applied to the star catalog")

arg_parser.add_argument('--flatbiassub', action="store_true", \
help="Subtract the bias from the flat. False by default.")



Expand Down Expand Up @@ -6624,7 +6635,7 @@ def getVisibleUnmarkedStarsAndDistanceToMarked(marked_x_list, marked_y_list, min
# Init SkyFit
plate_tool = PlateTool(input_path, config, beginning_time=beginning_time, fps=cml_args.fps, \
gamma=cml_args.gamma, use_fr_files=cml_args.fr, geo_points_input=cml_args.geopoints,
mask=mask, nobg=cml_args.nobg, flipud=cml_args.flipud)
mask=mask, nobg=cml_args.nobg, flipud=cml_args.flipud, flatbiassub=cml_args.flatbiassub)


# Run the GUI app
Expand Down

0 comments on commit 86c1d28

Please sign in to comment.