Skip to content

Commit

Permalink
Pipeline Capabilities (#231)
Browse files Browse the repository at this point in the history
Starts the process of a pipeline into data reduction.
  • Loading branch information
kjkoeller authored Jun 16, 2023
1 parent 5d393c4 commit 4feff69
Showing 1 changed file with 70 additions and 43 deletions.
113 changes: 70 additions & 43 deletions EclipsingBinaries/IRAF_Reduction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Author: Kyle Koeller
Created: 11/08/2022
Last Edited: 05/09/2023
Last Edited: 06/15/2023
This program is meant to automatically do the data reduction of the raw images from the
Ball State University Observatory (BSUO) and SARA data. The new calibrated images are placed into a new folder as to
Expand Down Expand Up @@ -40,57 +40,84 @@
location = "bsuo"


def main():
def main(path="", pipeline=False):
"""
This function calls all other functions in order of the calibration.
:param path: the path to the raw images
:param pipeline: if the user wants to use the pipeline or not
:return: outputs all calibration images into a new reduced folder designated by the user.
"""

# allows the user to input where the raw images are and where the calibrated images go to
path = input("Please enter a file pathway (i.e. C:\\folder1\\folder2\\[raw]) to where the raw images are or type "
"the word 'Close' to leave: ")
# path = "C:\\Users\\Kyle\\OneDrive\\PhysicsAstro\\Astronomy\\Code\\IRAF\\Calibration"
if path.lower() == "close":
exit()
# path = "Calibration2"
calibrated = input("Please enter a file pathway for a new calibrated folder to not overwrite the original images "
"(C:\\folder1\\folder2\\[calibrated]): ")
# calibrated = "C:\\test"
# checks whether the file paths from above are real
while True:
try:
images_path = Path(path)
calibrated_data = Path(calibrated)
break
except FileNotFoundError:
print("Files were not found. Please try again.\n")
path = input("Please enter a file path or folder name (if this code is in the same main folder): ")
calibrated = input("Please enter a name for a new calibrated folder to not overwrite the original images: ")

print("\nDo you want to load default options like gain and read noise? The defaults are for BSUO")
while True:
default_ans = input("To load defaults type 'Default' otherwise type 'New' to enter values: ")
# default_ans = "default"
if default_ans.lower() == "default":
break
elif default_ans.lower() == "new":
default()
break
if not pipeline:
# allows the user to input where the raw images are and where the calibrated images go to
path = input("Please enter a file pathway (i.e. C:\\folder1\\folder2\\[raw]) to where the raw images are or type "
"the word 'Close' to leave: ")
# path = "C:\\Users\\Kyle\\OneDrive\\PhysicsAstro\\Astronomy\\Code\\IRAF\\Calibration"
if path.lower() == "close":
exit()
# path = "Calibration2"
calibrated = input("Please enter a file pathway for a new calibrated folder to not overwrite the original images "
"(C:\\folder1\\folder2\\[calibrated]): ")
# calibrated = "C:\\test"
# checks whether the file paths from above are real
while True:
try:
images_path = Path(path)
calibrated_data = Path(calibrated)
break
except FileNotFoundError:
print("Files were not found. Please try again.\n")
path = input("Please enter a file path or folder name (if this code is in the same main folder): ")
calibrated = input("Please enter a name for a new calibrated folder to not overwrite the original images: ")

print("\nDo you want to load default options like gain and read noise? The defaults are for BSUO")
while True:
default_ans = input("To load defaults type 'Default' otherwise type 'New' to enter values: ")
# default_ans = "default"
if default_ans.lower() == "default":
break
elif default_ans.lower() == "new":
default()
break
else:
print("Please either enter 'Default' or 'New'.\n")

calibrated_data.mkdir(exist_ok=True)
files = ccdp.ImageFileCollection(images_path)

zero, overscan_region, trim_region = bias(files, calibrated_data, path)
if not dark_bool:
master_dark = None
else:
print("Please either enter 'Default' or 'New'.\n")

calibrated_data.mkdir(exist_ok=True)
files = ccdp.ImageFileCollection(images_path)
master_dark = dark(files, zero, calibrated_data, overscan_region, trim_region)

zero, overscan_region, trim_region = bias(files, calibrated_data, path)
if not dark_bool:
master_dark = None
flat(files, zero, master_dark, calibrated_data, overscan_region, trim_region)
science_images(files, calibrated_data, zero, master_dark, trim_region, overscan_region)
else:
master_dark = dark(files, zero, calibrated_data, overscan_region, trim_region)

flat(files, zero, master_dark, calibrated_data, overscan_region, trim_region)
science_images(files, calibrated_data, zero, master_dark, trim_region, overscan_region)
calibrated = input(
"Please enter a file pathway for a new calibrated folder to not overwrite the original images "
"(C:\\folder1\\folder2\\[calibrated]): ")
# calibrated = "C:\\test"
# checks whether the file paths from above are real
while True:
try:
images_path = Path(path)
calibrated_data = Path(calibrated)
break
except FileNotFoundError:
print("Files were not found. Please try again.\n")
path = input("Please enter a file path or folder name (if this code is in the same main folder): ")
calibrated = input(
"Please enter a name for a new calibrated folder to not overwrite the original images: ")

calibrated_data.mkdir(exist_ok=True)
files = ccdp.ImageFileCollection(images_path)

zero, overscan_region, trim_region = bias(files, calibrated_data, path)
flat(files, zero, master_dark, calibrated_data, overscan_region, trim_region)
science_images(files, calibrated_data, zero, master_dark, trim_region, overscan_region)


def default():
Expand Down

0 comments on commit 4feff69

Please sign in to comment.