Loading DataReductionGIANOB/DataReductionGIANOB.py +5 −5 Original line number Diff line number Diff line Loading @@ -57,10 +57,10 @@ class DataReduction: self.global_start = 0 # Window m = get_monitors() self.width = int(m[0].width * 0.95) self.height = int(m[0].height * 0.8) self.displace_x = int(m[0].width * 0.04) self.displace_y = int(m[0].height * 0.04) self.width = int(m[0].width * 0.9) self.height = int(m[0].height * 0.75) self.displace_x = 0 # int(m[0].width * 0.04) self.displace_y = 0 # int(m[0].height * 0.04) self.path_default = path_default self.dialog = None self.window = tk.Tk() Loading @@ -77,7 +77,7 @@ class DataReduction: self.window.resizable(True, True) # self.window.option_add('*Dialog.msg.width', 50) # Input frame self.frame_gofio = Frame_Gofio(self.window, self, path_default, int(0.95*self.width), int(0.95*self.height)) self.frame_gofio = Frame_Gofio(self.window, self, path_default, int(0.9*self.width), int(0.9*self.height)) # self.window.rowconfigure(0, weight=1) self.window.columnconfigure(0, weight=1) Loading DataReductionGIANOB/Frame_Gofio.py +47 −20 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ matplotlib.use('TkAgg') import matplotlib.pyplot as plt # noinspection PyTypeChecker,SqlNoDataSourceInspection class Frame_Gofio: gui = None frame_gofio = None Loading @@ -55,7 +56,7 @@ class Frame_Gofio: self.path_fromheader = "" self.global_exc = 0 self.gofio_folder_program = "" username = os.environ.get('USER') # username = os.environ.get('USER') self.gui = gui self.frame_gofio = tk.Frame(window, highlightbackground="black", highlightthickness=1, padx=5, pady=2) # Loading @@ -79,7 +80,7 @@ class Frame_Gofio: nights = DataInterface.get_target_nights( self.path_target, target_list[0], "Transmission", self.option_list_instrument[0], 0 ) except: except Exception as e: nights = "" self.target_name, self.target_radius, self.target_mass, self.target_gravity, self.target_t_eq, self.target_stellar_radius, self.target_stellar_mass, self.target_p0, self.target_hjd0, self.target_period, self.target_vsys, self.target_limph, self.target_kp, self.target_ecc, self.target_opi, self.target_stellar_teff, self.target_ra, self.target_dec, self.target_a_Rs_ratio, self.target_projected_obliquity, self.target_inclination, self.target_v_sini = DataInterface.get_target_info( self.path_target, target_list[0]) Loading Loading @@ -526,6 +527,15 @@ class Frame_Gofio: self.chosen_flat_var_post.set(self.option_list_flat[0]) self.opt_flat_mode_post = tk.OptionMenu(self.tab_post_gofio, self.chosen_flat_var_post, *self.option_list_flat) self.opt_flat_mode_post.grid(column=2, row=2, sticky=tk.W) # Observation Mode self.label = tk.Label(master=self.tab_post_gofio, text='Observation Mode (giano, crires): ', font=('Sans', '9', 'bold')) self.label.grid(column=3, row=2, sticky=tk.W, ) self.option_list_obs_mode = ["Nodding", "Stare"] self.chosen_obs_mode_var_post = tk.StringVar(value="Nodding") self.chosen_obs_mode_var_post.set(self.option_list_obs_mode[0]) self.opt_obs_mode_post = tk.OptionMenu(self.tab_post_gofio, self.chosen_obs_mode_var_post, *self.option_list_obs_mode) self.opt_obs_mode_post.grid(column=4, row=2, columnspan=2, sticky=tk.W) # Help Button for Second Phase Reduction help_text_post_gofio = { Loading Loading @@ -1275,6 +1285,7 @@ class Frame_Gofio: def fromgofio(self): night = self.night.get("1.0", tk.END).strip() separate_A_B = self.chosen_separation_var.get() obs_mode = self.chosen_obs_mode_var_post.get() night_results = night + "AB" if separate_A_B else night target = self.chosen_target_var.get() instrument = self.chosen_instrument_var_post.get() Loading Loading @@ -1309,32 +1320,30 @@ class Frame_Gofio: listB = list() if instrument == "criresp": folder = Path(dirr) if self.chosen_single_var_criresp.get() == "Nodding": if obs_mode == "Nodding": # Trova file A e B dictA = {int(f.stem.split("_")[-1]): f for f in folder.glob("cr2res_obs_nodding_extractedA_*.fits")} dictB = {int(f.stem.split("_")[-1]): f for f in folder.glob("cr2res_obs_nodding_extractedB_*.fits")} if not separate_A_B: # Tutti gli indici trovati if separate_A_B: all_indices = sorted(set(dictA.keys()) | set(dictB.keys())) listAB = [] for i in all_indices: if i in dictA: listAB.append(dictA[i]) listA.append(dictA[i]) if i in dictB: listAB.append(dictB[i]) listB.append(dictB[i]) else: # Tutti gli indici trovati all_indices = sorted(set(dictA.keys()) | set(dictB.keys())) listAB = [] for i in all_indices: if i in dictA: listA.append(dictA[i]) listAB.append(dictA[i]) if i in dictB: listB.append(dictB[i]) listAB.append(dictB[i]) else: listAB = list(folder.glob("cr2res_obs_staring_extracted_*.fits")) else: # for file in os.listdir(dirr): Loading @@ -1345,18 +1354,17 @@ class Frame_Gofio: listA.append(os.path.join(dirr, file)) elif "_B_" in file: listB.append(os.path.join(dirr, file)) # elif "_A_" in file or "_B_" in file: else: listAB.append(os.path.join(dirr, file)) # self.run_from_gofio.configure(state="disabled") if separate_A_B and instrument in ["gianob", "criresp"]: if separate_A_B and instrument in ["gianob", "criresp"] and obs_mode == "Nodding": if len(listA) == len(listB): self.procedure_fromgofio(listA, "A_", night, dirn, threshold_SNR_f, target, yaml_file, instrument) self.procedure_fromgofio(listB, "B_", night, dirn, threshold_SNR_f, target, yaml_file, instrument) else: print("The amount of files A is not equal to the amount of file B") else: else: # for nodding/stare mode of gianob/criresp and for espresso or harpsn self.procedure_fromgofio(listAB, "", night, dirn, threshold_SNR_f, target, yaml_file, instrument) self.run_from_gofio.configure(state="normal") Loading Loading @@ -1636,8 +1644,12 @@ class Frame_Gofio: def fromheader(self): separate_A_B = self.chosen_separation_var.get() obs_mode = self.chosen_obs_mode_var_post.get() night = self.night.get("1.0", tk.END).strip() if separate_A_B: if obs_mode == "Stare": messagebox.showinfo("Incompatibility", "Stare mode is not compatible with separation of A and B") return night += "AB" target = self.chosen_target_var.get() instrument = self.chosen_instrument_var_post.get() Loading @@ -1649,7 +1661,7 @@ class Frame_Gofio: [ "python3", str(Path(self.path_default, "DataReductionGIANOB", "fromheader.py")), self.path_fromheader, night, str(self.target_hjd0), str(self.target_period), str(self.target_limph), str(separate_A_B), self.path_default str(self.target_limph), str(separate_A_B), str(obs_mode), str(instrument), self.path_default ], stderr=subprocess.STDOUT, universal_newlines=True ) self.gui.window.after(500, self.check_proc_from_header) Loading Loading @@ -1688,8 +1700,12 @@ class Frame_Gofio: instrument) # Get the night identifier from the text widget, stripping any extra whitespace. separate_A_B = self.chosen_separation_var.get() night_str = self.night.get("1.0", tk.END).strip() # Determines if A and B channels are treated separately. obs_mode = self.chosen_obs_mode_var_post.get() night_str = self.night.get("1.0", tk.END).strip() if separate_A_B: if obs_mode == "Stare": messagebox.showinfo("Incompatibility", "Stare mode is not compatible with separation of A and B") return night_str += "AB" # Retrieve additional parameters from the GUI. niter = int(self.niter.get()) Loading @@ -1716,6 +1732,8 @@ class Frame_Gofio: pickle.dump(use_gauss, fo) pickle.dump(numpy_pearson, fo) pickle.dump(self.chosen_no_alignment_wcal_var.get(), fo) pickle.dump(instrument, fo) pickle.dump(obs_mode, fo) # Determine the names of the output PDF files. # For a specific instrument "gianob" with separate channels, use distinct filenames for A and B. if separate_A_B and instrument in ["gianob", "criresp"]: Loading Loading @@ -1752,13 +1770,18 @@ class Frame_Gofio: yaml_file = yaml.safe_load(f) pixel_dv = yaml_file["pixel_dv"] path_instrument = str( Path(self.path_target, target, "HR_Instruments", self.chosen_rad_mode_var_post.get(), instrument)) Path(self.path_target, target, "HR_Instruments", self.chosen_rad_mode_var_post.get(), instrument) ) separate_A_B = self.chosen_separation_var.get() night_str = self.night.get("1.0", tk.END).strip() # Determines if A and B channels are treated separately. minimum_lines = int(self.minimum_lines.get()) maximum_elements = int(self.maximum_elements.get()) threshold_km_s = float(self.threshold_km_s.get()) obs_mode = self.chosen_obs_mode_var_post.get() night_str = self.night.get("1.0", tk.END).strip() if separate_A_B: if obs_mode == "Stare": messagebox.showinfo("Incompatibility", "Stare mode is not compatible with separation of A and B") return night_str += "AB" # showf = self.chosen_show_wcal_var.get() starf = self.chosen_star_wcal_var.get() Loading Loading @@ -1791,7 +1814,7 @@ class Frame_Gofio: return pathf = str(Path(path_instrument, night_str)) # + os.sep + self.chosen_flat_var_post.get() + os.sep + yaml_file["files_type"] + os.sep if separate_A_B and instrument in ["gianob", "criresp"]: if separate_A_B and instrument in ["gianob", "criresp"] and obs_mode == "Nodding": specf = fits.open(str(Path(pathf, "A_aligned.fits"))) wlenf = fits.open(str(Path(pathf, "A_wlen.fits"))) with open(str(Path(pathf, "A_coefficient_pol.pkl")), "rb") as fo: Loading Loading @@ -1832,8 +1855,12 @@ class Frame_Gofio: path_instrument = str( Path(self.path_target, target, "HR_Instruments", self.chosen_rad_mode_var_post.get(), instrument)) separate_A_B = self.chosen_separation_var.get() night_str = self.night.get("1.0", tk.END).strip() # Determines if A and B channels are treated separately. obs_mode = self.chosen_obs_mode_var_post.get() night_str = self.night.get("1.0", tk.END).strip() if separate_A_B: if obs_mode == "Stare": messagebox.showinfo("Incompatibility", "Stare mode is not compatible with separation of A and B") return night_str += "AB" starf = self.chosen_star_test_var.get() use_plank = self.chosen_planck_test_var.get() Loading DataReductionGIANOB/fromheader.py +4 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ from astropy.time import Time import scipy.io as sio from pathlib import Path path_default = sys.argv[7] path_default = sys.argv[9] sys.path.append(path_default) os.chdir(path_default) from barycorrpy_fold import utc_tdb Loading @@ -21,8 +21,10 @@ target_hjd0 = float(sys.argv[3]) target_period = float(sys.argv[4]) target_limph = float(sys.argv[5]) separate_A_B = int(sys.argv[6]) obs_mode = sys.argv[7] instrument = sys.argv[8] print("STARTING fromheader") if separate_A_B: if separate_A_B and obs_mode == "Nodding": prefix = ["A_", "B_"] else: prefix = [""] Loading DataReductionGIANOB/procedure_align_pixel.py +28 −29 Original line number Diff line number Diff line Loading @@ -235,36 +235,33 @@ def procedure_align_pixel_opt(dataoff, niterf, path, prefix, interpol=None, gaus title_plot = "" # Compute shift statistics based on the alignment method. if interpol is not None: if separate_A_B: meanf = np.mean(shift[order_i, :]) rmsf = np.std(shift[order_i, :]) else: meanA = np.mean(shift[order_i, odd]) rmsA = np.std(shift[order_i, odd]) meanB = np.mean(shift[order_i, even]) rmsB = np.std(shift[order_i, even]) used_shift = shift title_plot = f"Ord {order_i} Drift (Interpol)" elif gauss is not None: if separate_A_B: meanf = np.mean(shift_fit[order_i, :]) rmsf = np.std(shift_fit[order_i, :]) else: meanA = np.mean(shift_fit[order_i, odd]) rmsA = np.std(shift_fit[order_i, odd]) meanB = np.mean(shift_fit[order_i, even]) rmsB = np.std(shift_fit[order_i, even]) used_shift = shift_fit title_plot = f"Ord {order_i} - Drift (Gaussian Fit)" # Plot the results. if separate_A_B: col_tr = "r" if prefix == "A_" else "b" trend = "A" if prefix == "A_" else "B" if separate_A_B or obs_mode == "Stare": if obs_mode == "Stare": trend = "Stare" col_tr = "r" else: if prefix == "A_": trend = "A" col_tr = "r" else: trend = "B" col_tr = "b" meanf = np.mean(used_shift[order_i, :]) rmsf = np.std(used_shift[order_i, :]) suptitle = f"Mean{trend} = {meanf:.2f} RMS = {rmsf:.3f}" plt.plot(full, shift[order_i, full], col_tr + "*", label=f"Shift {trend}") plt.axhline(meanf, color=col_tr, label=f"Mean {trend}") plt.xlabel("Image [#]") plt.ylabel("Shift [pixel]") plt.title(title_plot) plt.suptitle(f"Mean{trend} = {meanf:.2f} RMS = {rmsf:.3f}") else: meanA = np.mean(used_shift[order_i, odd]) rmsA = np.std(used_shift[order_i, odd]) meanB = np.mean(used_shift[order_i, even]) rmsB = np.std(used_shift[order_i, even]) suptitle = f"MeanA = {meanA:.2f} RMS = {rmsA:.3f} ; MeanB = {meanB:.2f} RMS = {rmsB:.3f}" plt.plot(odd, shift[order_i, odd], "b*", label="Odd images") plt.plot(even, shift[order_i, even], "r*", label="Even images") plt.axhline(meanA, color="b", label="MeanA") Loading @@ -272,7 +269,7 @@ def procedure_align_pixel_opt(dataoff, niterf, path, prefix, interpol=None, gaus plt.xlabel("Image [#]") plt.ylabel("Shift [pixel]") plt.title(title_plot) plt.suptitle(f"MeanA = {meanA:.2f} RMS = {rmsA:.3f} ; MeanB = {meanB:.2f} RMS = {rmsB:.3f}") plt.suptitle(suptitle) plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.) # Adjust right margin to make room for the legend. plt.subplots_adjust(right=0.75) Loading Loading @@ -314,8 +311,10 @@ with open(file_pkl, "rb") as fo: gaussf = pickle.load(fo) numpy_pearson_pkl = pickle.load(fo) no_alignment = pickle.load(fo) instrument = pickle.load(fo) obs_mode = pickle.load(fo) # if separate_A_B: if separate_A_B and obs_mode == "Nodding": if no_alignment: os.system("cp " + pathf + "/A_noaligned.fits " + pathf + "/A_aligned.fits") os.system("cp " + pathf + "/B_noaligned.fits " + pathf + "/B_aligned.fits") Loading Loading
DataReductionGIANOB/DataReductionGIANOB.py +5 −5 Original line number Diff line number Diff line Loading @@ -57,10 +57,10 @@ class DataReduction: self.global_start = 0 # Window m = get_monitors() self.width = int(m[0].width * 0.95) self.height = int(m[0].height * 0.8) self.displace_x = int(m[0].width * 0.04) self.displace_y = int(m[0].height * 0.04) self.width = int(m[0].width * 0.9) self.height = int(m[0].height * 0.75) self.displace_x = 0 # int(m[0].width * 0.04) self.displace_y = 0 # int(m[0].height * 0.04) self.path_default = path_default self.dialog = None self.window = tk.Tk() Loading @@ -77,7 +77,7 @@ class DataReduction: self.window.resizable(True, True) # self.window.option_add('*Dialog.msg.width', 50) # Input frame self.frame_gofio = Frame_Gofio(self.window, self, path_default, int(0.95*self.width), int(0.95*self.height)) self.frame_gofio = Frame_Gofio(self.window, self, path_default, int(0.9*self.width), int(0.9*self.height)) # self.window.rowconfigure(0, weight=1) self.window.columnconfigure(0, weight=1) Loading
DataReductionGIANOB/Frame_Gofio.py +47 −20 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ matplotlib.use('TkAgg') import matplotlib.pyplot as plt # noinspection PyTypeChecker,SqlNoDataSourceInspection class Frame_Gofio: gui = None frame_gofio = None Loading @@ -55,7 +56,7 @@ class Frame_Gofio: self.path_fromheader = "" self.global_exc = 0 self.gofio_folder_program = "" username = os.environ.get('USER') # username = os.environ.get('USER') self.gui = gui self.frame_gofio = tk.Frame(window, highlightbackground="black", highlightthickness=1, padx=5, pady=2) # Loading @@ -79,7 +80,7 @@ class Frame_Gofio: nights = DataInterface.get_target_nights( self.path_target, target_list[0], "Transmission", self.option_list_instrument[0], 0 ) except: except Exception as e: nights = "" self.target_name, self.target_radius, self.target_mass, self.target_gravity, self.target_t_eq, self.target_stellar_radius, self.target_stellar_mass, self.target_p0, self.target_hjd0, self.target_period, self.target_vsys, self.target_limph, self.target_kp, self.target_ecc, self.target_opi, self.target_stellar_teff, self.target_ra, self.target_dec, self.target_a_Rs_ratio, self.target_projected_obliquity, self.target_inclination, self.target_v_sini = DataInterface.get_target_info( self.path_target, target_list[0]) Loading Loading @@ -526,6 +527,15 @@ class Frame_Gofio: self.chosen_flat_var_post.set(self.option_list_flat[0]) self.opt_flat_mode_post = tk.OptionMenu(self.tab_post_gofio, self.chosen_flat_var_post, *self.option_list_flat) self.opt_flat_mode_post.grid(column=2, row=2, sticky=tk.W) # Observation Mode self.label = tk.Label(master=self.tab_post_gofio, text='Observation Mode (giano, crires): ', font=('Sans', '9', 'bold')) self.label.grid(column=3, row=2, sticky=tk.W, ) self.option_list_obs_mode = ["Nodding", "Stare"] self.chosen_obs_mode_var_post = tk.StringVar(value="Nodding") self.chosen_obs_mode_var_post.set(self.option_list_obs_mode[0]) self.opt_obs_mode_post = tk.OptionMenu(self.tab_post_gofio, self.chosen_obs_mode_var_post, *self.option_list_obs_mode) self.opt_obs_mode_post.grid(column=4, row=2, columnspan=2, sticky=tk.W) # Help Button for Second Phase Reduction help_text_post_gofio = { Loading Loading @@ -1275,6 +1285,7 @@ class Frame_Gofio: def fromgofio(self): night = self.night.get("1.0", tk.END).strip() separate_A_B = self.chosen_separation_var.get() obs_mode = self.chosen_obs_mode_var_post.get() night_results = night + "AB" if separate_A_B else night target = self.chosen_target_var.get() instrument = self.chosen_instrument_var_post.get() Loading Loading @@ -1309,32 +1320,30 @@ class Frame_Gofio: listB = list() if instrument == "criresp": folder = Path(dirr) if self.chosen_single_var_criresp.get() == "Nodding": if obs_mode == "Nodding": # Trova file A e B dictA = {int(f.stem.split("_")[-1]): f for f in folder.glob("cr2res_obs_nodding_extractedA_*.fits")} dictB = {int(f.stem.split("_")[-1]): f for f in folder.glob("cr2res_obs_nodding_extractedB_*.fits")} if not separate_A_B: # Tutti gli indici trovati if separate_A_B: all_indices = sorted(set(dictA.keys()) | set(dictB.keys())) listAB = [] for i in all_indices: if i in dictA: listAB.append(dictA[i]) listA.append(dictA[i]) if i in dictB: listAB.append(dictB[i]) listB.append(dictB[i]) else: # Tutti gli indici trovati all_indices = sorted(set(dictA.keys()) | set(dictB.keys())) listAB = [] for i in all_indices: if i in dictA: listA.append(dictA[i]) listAB.append(dictA[i]) if i in dictB: listB.append(dictB[i]) listAB.append(dictB[i]) else: listAB = list(folder.glob("cr2res_obs_staring_extracted_*.fits")) else: # for file in os.listdir(dirr): Loading @@ -1345,18 +1354,17 @@ class Frame_Gofio: listA.append(os.path.join(dirr, file)) elif "_B_" in file: listB.append(os.path.join(dirr, file)) # elif "_A_" in file or "_B_" in file: else: listAB.append(os.path.join(dirr, file)) # self.run_from_gofio.configure(state="disabled") if separate_A_B and instrument in ["gianob", "criresp"]: if separate_A_B and instrument in ["gianob", "criresp"] and obs_mode == "Nodding": if len(listA) == len(listB): self.procedure_fromgofio(listA, "A_", night, dirn, threshold_SNR_f, target, yaml_file, instrument) self.procedure_fromgofio(listB, "B_", night, dirn, threshold_SNR_f, target, yaml_file, instrument) else: print("The amount of files A is not equal to the amount of file B") else: else: # for nodding/stare mode of gianob/criresp and for espresso or harpsn self.procedure_fromgofio(listAB, "", night, dirn, threshold_SNR_f, target, yaml_file, instrument) self.run_from_gofio.configure(state="normal") Loading Loading @@ -1636,8 +1644,12 @@ class Frame_Gofio: def fromheader(self): separate_A_B = self.chosen_separation_var.get() obs_mode = self.chosen_obs_mode_var_post.get() night = self.night.get("1.0", tk.END).strip() if separate_A_B: if obs_mode == "Stare": messagebox.showinfo("Incompatibility", "Stare mode is not compatible with separation of A and B") return night += "AB" target = self.chosen_target_var.get() instrument = self.chosen_instrument_var_post.get() Loading @@ -1649,7 +1661,7 @@ class Frame_Gofio: [ "python3", str(Path(self.path_default, "DataReductionGIANOB", "fromheader.py")), self.path_fromheader, night, str(self.target_hjd0), str(self.target_period), str(self.target_limph), str(separate_A_B), self.path_default str(self.target_limph), str(separate_A_B), str(obs_mode), str(instrument), self.path_default ], stderr=subprocess.STDOUT, universal_newlines=True ) self.gui.window.after(500, self.check_proc_from_header) Loading Loading @@ -1688,8 +1700,12 @@ class Frame_Gofio: instrument) # Get the night identifier from the text widget, stripping any extra whitespace. separate_A_B = self.chosen_separation_var.get() night_str = self.night.get("1.0", tk.END).strip() # Determines if A and B channels are treated separately. obs_mode = self.chosen_obs_mode_var_post.get() night_str = self.night.get("1.0", tk.END).strip() if separate_A_B: if obs_mode == "Stare": messagebox.showinfo("Incompatibility", "Stare mode is not compatible with separation of A and B") return night_str += "AB" # Retrieve additional parameters from the GUI. niter = int(self.niter.get()) Loading @@ -1716,6 +1732,8 @@ class Frame_Gofio: pickle.dump(use_gauss, fo) pickle.dump(numpy_pearson, fo) pickle.dump(self.chosen_no_alignment_wcal_var.get(), fo) pickle.dump(instrument, fo) pickle.dump(obs_mode, fo) # Determine the names of the output PDF files. # For a specific instrument "gianob" with separate channels, use distinct filenames for A and B. if separate_A_B and instrument in ["gianob", "criresp"]: Loading Loading @@ -1752,13 +1770,18 @@ class Frame_Gofio: yaml_file = yaml.safe_load(f) pixel_dv = yaml_file["pixel_dv"] path_instrument = str( Path(self.path_target, target, "HR_Instruments", self.chosen_rad_mode_var_post.get(), instrument)) Path(self.path_target, target, "HR_Instruments", self.chosen_rad_mode_var_post.get(), instrument) ) separate_A_B = self.chosen_separation_var.get() night_str = self.night.get("1.0", tk.END).strip() # Determines if A and B channels are treated separately. minimum_lines = int(self.minimum_lines.get()) maximum_elements = int(self.maximum_elements.get()) threshold_km_s = float(self.threshold_km_s.get()) obs_mode = self.chosen_obs_mode_var_post.get() night_str = self.night.get("1.0", tk.END).strip() if separate_A_B: if obs_mode == "Stare": messagebox.showinfo("Incompatibility", "Stare mode is not compatible with separation of A and B") return night_str += "AB" # showf = self.chosen_show_wcal_var.get() starf = self.chosen_star_wcal_var.get() Loading Loading @@ -1791,7 +1814,7 @@ class Frame_Gofio: return pathf = str(Path(path_instrument, night_str)) # + os.sep + self.chosen_flat_var_post.get() + os.sep + yaml_file["files_type"] + os.sep if separate_A_B and instrument in ["gianob", "criresp"]: if separate_A_B and instrument in ["gianob", "criresp"] and obs_mode == "Nodding": specf = fits.open(str(Path(pathf, "A_aligned.fits"))) wlenf = fits.open(str(Path(pathf, "A_wlen.fits"))) with open(str(Path(pathf, "A_coefficient_pol.pkl")), "rb") as fo: Loading Loading @@ -1832,8 +1855,12 @@ class Frame_Gofio: path_instrument = str( Path(self.path_target, target, "HR_Instruments", self.chosen_rad_mode_var_post.get(), instrument)) separate_A_B = self.chosen_separation_var.get() night_str = self.night.get("1.0", tk.END).strip() # Determines if A and B channels are treated separately. obs_mode = self.chosen_obs_mode_var_post.get() night_str = self.night.get("1.0", tk.END).strip() if separate_A_B: if obs_mode == "Stare": messagebox.showinfo("Incompatibility", "Stare mode is not compatible with separation of A and B") return night_str += "AB" starf = self.chosen_star_test_var.get() use_plank = self.chosen_planck_test_var.get() Loading
DataReductionGIANOB/fromheader.py +4 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ from astropy.time import Time import scipy.io as sio from pathlib import Path path_default = sys.argv[7] path_default = sys.argv[9] sys.path.append(path_default) os.chdir(path_default) from barycorrpy_fold import utc_tdb Loading @@ -21,8 +21,10 @@ target_hjd0 = float(sys.argv[3]) target_period = float(sys.argv[4]) target_limph = float(sys.argv[5]) separate_A_B = int(sys.argv[6]) obs_mode = sys.argv[7] instrument = sys.argv[8] print("STARTING fromheader") if separate_A_B: if separate_A_B and obs_mode == "Nodding": prefix = ["A_", "B_"] else: prefix = [""] Loading
DataReductionGIANOB/procedure_align_pixel.py +28 −29 Original line number Diff line number Diff line Loading @@ -235,36 +235,33 @@ def procedure_align_pixel_opt(dataoff, niterf, path, prefix, interpol=None, gaus title_plot = "" # Compute shift statistics based on the alignment method. if interpol is not None: if separate_A_B: meanf = np.mean(shift[order_i, :]) rmsf = np.std(shift[order_i, :]) else: meanA = np.mean(shift[order_i, odd]) rmsA = np.std(shift[order_i, odd]) meanB = np.mean(shift[order_i, even]) rmsB = np.std(shift[order_i, even]) used_shift = shift title_plot = f"Ord {order_i} Drift (Interpol)" elif gauss is not None: if separate_A_B: meanf = np.mean(shift_fit[order_i, :]) rmsf = np.std(shift_fit[order_i, :]) else: meanA = np.mean(shift_fit[order_i, odd]) rmsA = np.std(shift_fit[order_i, odd]) meanB = np.mean(shift_fit[order_i, even]) rmsB = np.std(shift_fit[order_i, even]) used_shift = shift_fit title_plot = f"Ord {order_i} - Drift (Gaussian Fit)" # Plot the results. if separate_A_B: col_tr = "r" if prefix == "A_" else "b" trend = "A" if prefix == "A_" else "B" if separate_A_B or obs_mode == "Stare": if obs_mode == "Stare": trend = "Stare" col_tr = "r" else: if prefix == "A_": trend = "A" col_tr = "r" else: trend = "B" col_tr = "b" meanf = np.mean(used_shift[order_i, :]) rmsf = np.std(used_shift[order_i, :]) suptitle = f"Mean{trend} = {meanf:.2f} RMS = {rmsf:.3f}" plt.plot(full, shift[order_i, full], col_tr + "*", label=f"Shift {trend}") plt.axhline(meanf, color=col_tr, label=f"Mean {trend}") plt.xlabel("Image [#]") plt.ylabel("Shift [pixel]") plt.title(title_plot) plt.suptitle(f"Mean{trend} = {meanf:.2f} RMS = {rmsf:.3f}") else: meanA = np.mean(used_shift[order_i, odd]) rmsA = np.std(used_shift[order_i, odd]) meanB = np.mean(used_shift[order_i, even]) rmsB = np.std(used_shift[order_i, even]) suptitle = f"MeanA = {meanA:.2f} RMS = {rmsA:.3f} ; MeanB = {meanB:.2f} RMS = {rmsB:.3f}" plt.plot(odd, shift[order_i, odd], "b*", label="Odd images") plt.plot(even, shift[order_i, even], "r*", label="Even images") plt.axhline(meanA, color="b", label="MeanA") Loading @@ -272,7 +269,7 @@ def procedure_align_pixel_opt(dataoff, niterf, path, prefix, interpol=None, gaus plt.xlabel("Image [#]") plt.ylabel("Shift [pixel]") plt.title(title_plot) plt.suptitle(f"MeanA = {meanA:.2f} RMS = {rmsA:.3f} ; MeanB = {meanB:.2f} RMS = {rmsB:.3f}") plt.suptitle(suptitle) plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.) # Adjust right margin to make room for the legend. plt.subplots_adjust(right=0.75) Loading Loading @@ -314,8 +311,10 @@ with open(file_pkl, "rb") as fo: gaussf = pickle.load(fo) numpy_pearson_pkl = pickle.load(fo) no_alignment = pickle.load(fo) instrument = pickle.load(fo) obs_mode = pickle.load(fo) # if separate_A_B: if separate_A_B and obs_mode == "Nodding": if no_alignment: os.system("cp " + pathf + "/A_noaligned.fits " + pathf + "/A_aligned.fits") os.system("cp " + pathf + "/B_noaligned.fits " + pathf + "/B_aligned.fits") Loading