def cr_text_static(self, fname, names, waves, spec, f_width, wl_low, wl_high): #self.writeMessage("- continuum removal: " + fname) out_dir = self.outputSCRDirEntry.get() out_dir = out_dir + "/" + str(wl_low) + "-" + str(wl_high) d_norm = self.depthNormalizedIntVar.get() if not os.path.exists(out_dir): os.makedirs(out_dir) mt_out_path = out_dir + "/mt_" + fname[:fname.rfind('.')] + ".csv" cr_out_path = out_dir + "/cr_" + fname[:fname.rfind('.')] + ".csv" #self.writeMessage("- setup") CR_module.cr_text_setup(waves, f_width, mt_out_path, cr_out_path) for i in range(len(spec)): #self.writeMessage("\t - spectra " + str(i+1) + "/" + str(len(spec))) CR_module.cr_text(spec[i], waves, f_width, names[i], d_norm) CR_module.cr_text_teardown()
def cr_text_dynamic(self, mt_out_path, cr_out_path, waves, n_waves, image, n_cols): self.writeMessage("cr_text_dynamic") wt = self.wave_thresh srange_min = float(self.shortRangeStartEntry.get()) srange_max = float(self.shortRangeStopEntry.get()) lrange_min = float(self.longRangeStartEntry.get()) lrange_max = float(self.longRangeStopEntry.get()) kernel = int(self.kernelEntry.get()) if kernel % 2 == 0: self.writeMessage("Error. Kernel size must be odd.") return # # validate # if (srange_max - srange_min < wt) or (lrange_min - srange_max < wt) or (lrange_max - lrange_min < wt): self.writeMessage("Error. Bad wavelength range.") return ss0 = self.shortRangeZeroIntVar.get() ss1 = self.shortRangeMinIntVar.get() ss2 = self.shortRangeMaxIntVar.get() ls0 = self.longRangeZeroIntVar.get() ls1 = self.longRangeMinIntVar.get() ls2 = self.longRangeMaxIntVar.get() if ss0 == 0 and ss1 == 0 and ss2 == 0: self.writeMessage("Error. Must select short wavelength strategy.") return if ls0 == 0 and ls1 == 0 and ls2 == 0: self.writeMessage("Error. Must select short wavelength strategy.") return s_strat = 0 if ss1 == 1: s_strat = 1 if ss2 == 1: s_strat = 2 l_strat = 0 if ls1 == 1: l_strat = 1 if ls2 == 1: l_strat = 2 (cr_width, low, high) = \ self.compute_cr_band_extents(waves, srange_min, lrange_max) cr_waves = waves[low:high+1] # # run # self.writeMessage("\tcr_text_setup") CR_module.cr_text_setup(cr_waves, cr_width, mt_out_path, cr_out_path) self.writeMessage("Processing:") for col in range(n_cols): #self.writeMessage("\tcolumn " + str(col+1) + "/" + str(n_cols)) spectrum = [list[col] for list in image] cr_spect = spectrum[low:high+1] (low_i, high_i) =\ CR_module.cr_dynamic_range(\ spectrum,\ waves,\ n_waves,\ s_strat,\ l_strat,\ srange_min,\ srange_max,\ lrange_min,\ lrange_max,\ kernel) if low_i < low or low_i > high: self.writeMessage("Error: low_i to high or low:" + str(low_i)) return; if high_i < low or high_i > high: self.writeMessage("Error: high_i to high or low:" + str(high_i)) return; offset = low_i - low f_width = high_i - low_i + 1 self.writeMessage("\t" + str(col+1) + "/" + str(n_cols) + "[" + str(low) + "," + str(low_i) + "," + str(high_i) + "," + str(high) + "]") #pass in the exact spectra CR_module.cr_text_dynamic(\ cr_spect,\ cr_waves,\ cr_width, f_width, offset) CR_module.cr_text_teardown() self.writeMessage("Done!")