Skip to content

Commit

Permalink
undoing previous direct commit to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
awhoward committed Dec 18, 2023
1 parent 3230bf4 commit 70c053d
Showing 1 changed file with 37 additions and 70 deletions.
107 changes: 37 additions & 70 deletions modules/quicklook/src/analyze_l2.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,47 +93,19 @@ def plot_CCF_grid(self, chip=None, annotate=False,
ax = axes[oo]

# Plot vertical lines for RVs and add top annotations
if oo == 0:
try:
this_RV = self.rv_header['CCD1RV1']
this_RV_text = f"{this_RV:.5f}" + r' km s$^{-1}$'
data_present = True
except:
this_RV = 0.
this_RV_text = 'No RV reported - CCD1RV1 missing from header'
data_present = False
if oo == 0:
this_RV = self.rv_header['CCD1RV1']
this_RV_text = f"{this_RV:.5f}" + r' km s$^{-1}$'
elif oo == 1:
try:
this_RV = self.rv_header['CCD1RV2']
this_RV_text = f"{this_RV:.5f}" + r' km s$^{-1}$'
data_present = True
except:
this_RV = 0.
this_RV_text = 'No RV reported - CCD1RV1 missing from header'
data_present = False
this_RV = self.rv_header['CCD1RV2']
this_RV_text = f"{this_RV:.5f}" + r' km s$^{-1}$'
elif oo == 2:
try:
this_RV = self.rv_header['CCD1RV3']
this_RV_text = f"{this_RV:.5f}" + r' km s$^{-1}$'
data_present = True
except:
this_RV = 0.
this_RV_text = 'No RV reported - CCD1RV1 missing from header'
data_present = False
this_RV = self.rv_header['CCD1RV3']
this_RV_text = f"{this_RV:.5f}" + r' km s$^{-1}$'
elif oo == 3:
try:
this_RV = self.rv_header['CCD1RVC']
data_present = True
except:
this_RV = 0
data_present = False
this_RV = self.rv_header['CCD1RVC']
elif oo == 4:
try:
this_RV = self.rv_header['CCD1RVS']
data_present = True
except:
this_RV = 0.
data_present = False
this_RV = self.rv_header['CCD1RVS']
if oo < 3:
# Annotation and line for orderlet-averaged RV
ax.plot([this_RV, this_RV], [0, n_orders*0.5+0.5], color='k')
Expand All @@ -155,31 +127,28 @@ def plot_CCF_grid(self, chip=None, annotate=False,
# Iterate over orders
for o in range(n_orders):
if orderlet == 'CAL':
if data_present:
this_CCF = CCF_data[oo, o, :]
if np.nanpercentile(this_CCF,99) < 0:
norm_CCF = np.divide(this_CCF+np.nanpercentile(this_CCF,0.1),
np.nanpercentile(this_CCF+np.nanpercentile(this_CCF,0.1),90))
this_CCF = CCF_data[oo, o, :]
if np.nanpercentile(this_CCF,99) < 0:
norm_CCF = np.divide(this_CCF+np.nanpercentile(this_CCF,0.1),
np.nanpercentile(this_CCF+np.nanpercentile(this_CCF,0.1),90))
else:
if np.nanpercentile(this_CCF,[90]) == 0:
norm_CCF = this_CCF
else:
if np.nanpercentile(this_CCF,[90]) == 0:
norm_CCF = this_CCF
else:
norm_CCF = np.divide(this_CCF, np.nanpercentile(this_CCF,[90]))
norm_CCF = np.divide(this_CCF, np.nanpercentile(this_CCF,[90]))
elif orderlet == 'SKY':
if data_present:
this_CCF = CCF_data[oo, o, :]
if np.nanpercentile(this_CCF,99) < 0:
norm_CCF = np.divide(this_CCF+np.nanpercentile(this_CCF,0.1),
np.nanpercentile(this_CCF+np.nanpercentile(this_CCF,0.1),90))
this_CCF = CCF_data[oo, o, :]
if np.nanpercentile(this_CCF,99) < 0:
norm_CCF = np.divide(this_CCF+np.nanpercentile(this_CCF,0.1),
np.nanpercentile(this_CCF+np.nanpercentile(this_CCF,0.1),90))
else:
if np.nanpercentile(this_CCF,[90]) == 0:
norm_CCF = this_CCF
else:
if np.nanpercentile(this_CCF,[90]) == 0:
norm_CCF = this_CCF
else:
norm_CCF = np.divide(this_CCF, np.nanpercentile(this_CCF,[90]))
norm_CCF = np.divide(this_CCF, np.nanpercentile(this_CCF,[90]))
elif (np.sum(CCF_data[oo, o, :]) != 0): # SCI1/SCI2/SCI3 - only show if CCF was computed
if data_present:
this_CCF = CCF_data[oo, o, :]
norm_CCF = np.divide(this_CCF, np.nanpercentile(this_CCF,[99]))
this_CCF = CCF_data[oo, o, :]
norm_CCF = np.divide(this_CCF, np.nanpercentile(this_CCF,[99]))
# The zoom feature is not yet implemented
#if zoom:
# middle = len(RVgrid) // 4
Expand All @@ -191,9 +160,8 @@ def plot_CCF_grid(self, chip=None, annotate=False,
# Plot CCF for this order and orderlet
ax.plot([min(RVgrid)], [0]) # make a dot in the corner to insure that the colors are different on each row
current_color = ax.lines[-1].get_color()
if data_present:
if np.sum(CCF_data[oo, o, :]) != 0:
ax.plot(RVgrid, norm_CCF + o*0.5, color=current_color)
if np.sum(CCF_data[oo, o, :]) != 0:
ax.plot(RVgrid, norm_CCF + o*0.5, color=current_color)

# Add additional annotations
ax.text(RVgrid[-1]+0.75, 1+o*0.5-0.10, str(o), color=current_color, verticalalignment='center', horizontalalignment='left', fontsize=11)
Expand All @@ -213,16 +181,15 @@ def plot_CCF_grid(self, chip=None, annotate=False,
# color=current_color, verticalalignment='center', horizontalalignment='right', fontsize=11)

# Determine mask per order and include in title
if data_present:
if (oo == 0) or (oo == 1) or (oo == 2):
this_mask = ' (' + CCF_header['SCI_MASK'] + ' mask)'
if oo == 3:
this_mask = ' (' + CCF_header['CAL_MASK'] + ' mask)'
if oo == 4:
this_mask = ' (' + CCF_header['SKY_MASK'] + ' mask)'
ax.set_title(orderlet + ' CCF' + this_mask, fontsize=18)
ax.set_xlabel('RV (km/s)', fontsize=18)
if (oo == 0) or (oo == 1) or (oo == 2):
this_mask = ' (' + CCF_header['SCI_MASK'] + ' mask)'
if oo == 3:
this_mask = ' (' + CCF_header['CAL_MASK'] + ' mask)'
if oo == 4:
this_mask = ' (' + CCF_header['SKY_MASK'] + ' mask)'
ax.grid(False)
ax.set_title(orderlet + ' CCF' + this_mask, fontsize=18)
ax.set_xlabel('RV (km/s)', fontsize=18)

# Add overall title to array of plots
ax = fig.add_subplot(111, frame_on=False)
Expand Down

0 comments on commit 70c053d

Please sign in to comment.