Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBP branch #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions spectractor/extractor/dispersers.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,12 @@ def load_files(self, verbose=False):
a = np.loadtxt(filename)
self.N_input = a[0]
self.N_err = a[1]
else:
raise FileNotFoundError(f"Failed to load {filename} for {self.label}")

filename = os.path.join(self.data_dir, self.label, "full_name.txt")
if os.path.isfile(filename):
with open(filename, 'r') as f:
for line in f: # MFL: you really just want the last line of the file?
self.full_name = line.rstrip('\n')
else:
raise FileNotFoundError(f"Failed to load {filename} for {self.label}")

filename = os.path.join(self.data_dir, self.label, "transmission.txt")
if os.path.isfile(filename):
Expand Down
19 changes: 12 additions & 7 deletions spectractor/extractor/spectroscopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,22 +472,24 @@ def print_detected_lines(self, output_file_name="", overwrite=False, print_table
popt = line.fit_popt
peak_pos = popt[bgd_npar + 3 * j + 1]
FWHM = np.abs(popt[bgd_npar + 3 * j + 2]) * 2.355
signal_level = popt[bgd_npar + 3 * j]
err = np.sqrt(line.fit_pcov[bgd_npar + 3 * j + 1, bgd_npar + 3 * j + 1])
amplitude = popt[bgd_npar + 3 * j]
detected_err = np.sqrt(line.fit_pcov[bgd_npar + 3 * j + 1, bgd_npar + 3 * j + 1])
amplitude_err = np.sqrt(line.fit_pcov[bgd_npar + 3 * j, bgd_npar + 3 * j])
if line.high_snr:
rows.append((line.label, line.wavelength, peak_pos, peak_pos - line.wavelength, err,
FWHM, signal_level, line.fit_snr, line.fit_chisq, line.fit_eqwidth_mod,
rows.append((line.label, line.wavelength, peak_pos, peak_pos - line.wavelength, detected_err,
FWHM, amplitude, amplitude_err, line.fit_snr, line.fit_chisq, line.fit_eqwidth_mod,
line.fit_eqwidth_data))
j += 1
t = None
if len(rows) > 0:
t = Table(rows=rows, names=(
'Line', 'Tabulated', 'Detected', 'Shift', 'Err', 'FWHM', 'Amplitude', 'SNR', 'Chisq', 'Eqwidth_mod',
'Line', 'Tabulated', 'Detected', 'Shift', 'Detected_err', 'FWHM', 'Amplitude', 'Amplitude_err', 'SNR', 'Chisq', 'Eqwidth_mod',
'Eqwidth_data'),
dtype=('a12', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4'))
dtype=('a12', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4', 'f4'))
for col in t.colnames[1:6]:
t[col].unit = 'nm'
t[t.colnames[5]].unit = amplitude_units
t[t.colnames[6]].unit = amplitude_units
for col in t.colnames[-2:]:
t[col].unit = 'nm'
t[t.colnames[-3]].unit = 'reduced'
Expand Down Expand Up @@ -598,13 +600,16 @@ def print_detected_lines(self, output_file_name="", overwrite=False, print_table
AR4 = Line(727.294, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR5 = Line(738.393, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR6 = Line(750.387, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR6_2 = Line(751.465, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR7 = Line(763.511, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR8 = Line(772.376, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR9 = Line(794.818, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR10 = Line(800.616, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR10_2 = Line(801.479, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR11 = Line(811.531, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR12 = Line(826.452, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR13 = Line(842.465, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR13_2 = Line(840.621, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR14 = Line(852.144, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR15 = Line(866.794, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
AR16 = Line(912.297, atmospheric=False, label=r'$Ar$', label_pos=[0.007, 0.02])
Expand All @@ -614,7 +619,7 @@ def print_detected_lines(self, output_file_name="", overwrite=False, print_table
HG13 = Line(1013.976, atmospheric=False, label=r'$Hg$', label_pos=[0.007, 0.02])

HGAR_LINES = [HG1, HG2, HG3, HG4, HG5, HG6, HG7, HG8, HG9, HG10, HG11, HG12,
AR1, AR2, AR3, AR4, AR5, AR6, AR7, AR8, AR9, AR10, AR11, AR12, AR13, AR14, AR15, AR16, AR17, AR18, AR19, HG13]
AR1, AR2, AR3, AR4, AR5, AR6, AR6_2, AR7, AR8, AR9, AR10, AR10_2, AR11, AR12, AR13_2, AR13, AR14, AR15, AR16, AR17, AR18, AR19, HG13]

if __name__ == "__main__":
import doctest
Expand Down