Skip to content

Commit

Permalink
change iframe output setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
cylammarco committed Mar 10, 2020
1 parent 0aa7167 commit 5c221dd
Showing 1 changed file with 68 additions and 23 deletions.
91 changes: 68 additions & 23 deletions aspired/aspired.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ def inspect(self,
log=True,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
'''
Display the reduced image with a supported plotly renderer or export
as json strings.
Expand Down Expand Up @@ -708,7 +709,10 @@ def inspect(self,
if jsonstring:
return fig.to_json()
if iframe:
pio.write_html(fig, 'reduced_image.html')
if open_iframe:
pio.write_html(fig, 'reduced_image.html')
else:
pio.write_html(fig, 'reduced_image.html', auto_open=False)
if renderer == 'default':
fig.show()
else:
Expand Down Expand Up @@ -1194,7 +1198,7 @@ def _gaus(self, x, a, b, x0, sigma):
return a * np.exp(-(x - x0)**2 / (2 * sigma**2)) + b

def _identify_spectra(self, f_height, display, renderer, jsonstring,
iframe):
iframe, open_iframe):
"""
Identify peaks assuming the spatial and spectral directions are
aligned with the X and Y direction within a few degrees.
Expand Down Expand Up @@ -1274,7 +1278,10 @@ def _identify_spectra(self, f_height, display, renderer, jsonstring,
if jsonstring:
return fig.to_json()
if iframe:
pio.write_html(fig, 'identify_spectra.html')
if open_iframe:
pio.write_html(fig, 'identify_spectra.html')
else:
pio.write_html(fig, 'identify_spectra.html', auto_open=False)
if renderer == 'default':
fig.show()
else:
Expand Down Expand Up @@ -1381,7 +1388,8 @@ def ap_trace(self,
display=False,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
'''
Aperture tracing by first using cross-correlation then the peaks are
fitting with a polynomial with an order of floor(nwindow, 10) with a
Expand Down Expand Up @@ -1658,7 +1666,10 @@ def ap_trace(self,
if jsonstring:
return fig.to_json()
if iframe:
pio.write_html(fig, 'ap_trace.html')
if open_iframe:
pio.write_html(fig, 'ap_trace.html')
else:
pio.write_html(fig, 'ap_trace.html', auto_open=False)
if renderer == 'default':
fig.show()
else:
Expand All @@ -1675,7 +1686,8 @@ def ap_trace_quick(self,
display=False,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
"""
This only works for bright spectra with good wavelength coverage.
Expand Down Expand Up @@ -1737,7 +1749,6 @@ def ap_trace_quick(self,

# detect peaks by summing in the spatial direction
self._identify_spectra(0.01,
1,
display=False,
renderer=renderer,
jsonstring=jsonstring,
Expand Down Expand Up @@ -1816,7 +1827,10 @@ def ap_trace_quick(self,
if jsonstring:
return fig.to_json()
if iframe:
pio.write_html(fig, 'ap_trace_quick.html')
if open_iframe:
pio.write_html(fig, 'ap_trace_quick.html')
else:
pio.write_html(fig, 'ap_trace_quick.html', auto_open=False)
if renderer == 'default':
fig.show()
else:
Expand Down Expand Up @@ -1989,7 +2003,10 @@ def ap_trace_quick(self,
if jsonstring:
return fig.to_json()
if iframe:
pio.write_html(fig, 'ap_trace_quick_' + str(j) + '.html')
if open_iframe:
pio.write_html(fig, 'ap_trace_quick_' + str(j) + 'html')
else:
pio.write_html(fig, 'ap_trace_quick_' + str(j) + 'html', auto_open=False)
if renderer == 'default':
fig.show()
else:
Expand Down Expand Up @@ -2063,7 +2080,8 @@ def ap_extract(self,
display=False,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
"""
Extract the spectra using the traces, support tophat or optimal
extraction. The sky background is fitted in one dimention only. The
Expand Down Expand Up @@ -2385,7 +2403,10 @@ def ap_extract(self,
if jsonstring:
return fig.to_json()
if iframe:
pio.write_html(fig, 'ap_extract_' + str(j) + '.html')
if open_iframe:
pio.write_html(fig, 'ap_extract_' + str(j) + 'html')
else:
pio.write_html(fig, 'ap_extract_' + str(j) + 'html', auto_open=False)
if renderer == 'default':
fig.show()
else:
Expand Down Expand Up @@ -2423,6 +2444,7 @@ def __init__(self, spec, arc=None, silence=False):
'''

self.spec = spec
self.nspec = spec.nspec

# If data provided is an numpy array
if isinstance(arc, np.ndarray):
Expand Down Expand Up @@ -2476,7 +2498,8 @@ def find_arc_lines(self,
display=False,
jsonstring=False,
renderer='default',
iframe=False):
iframe=False,
open_iframe=False):
'''
This function applies the trace(s) to the arc image then take median
average of the stripe before identifying the arc lines (peaks) with
Expand Down Expand Up @@ -2570,7 +2593,10 @@ def find_arc_lines(self,
if jsonstring:
return fig[j].to_json()
if iframe:
pio.write_html(fig[j], 'arc_lines_' + str(j) + '.html')
if open_iframe:
pio.write_html(fig[j], 'arc_lines_' + str(j) + 'html')
else:
pio.write_html(fig[j], 'arc_lines_' + str(j) + 'html', auto_open=False)
if renderer == 'default':
fig[j].show()
else:
Expand Down Expand Up @@ -2797,6 +2823,8 @@ def add_pfit(self, pfit, pfit_type='poly'):

if not isinstance(pfit, list):
self.pfit = [pfit]
else:
self.pfit = pfit

self.pfit_type = []

Expand Down Expand Up @@ -2880,7 +2908,8 @@ def load_standard(self,
display=False,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
'''
Read the standard flux/magnitude file. And return the wavelength and
flux/mag.
Expand Down Expand Up @@ -2939,7 +2968,8 @@ def load_standard(self,
def inspect_standard(self,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
'''
Display the standard star plot.
Expand Down Expand Up @@ -3003,7 +3033,10 @@ def inspect_standard(self,
if jsonstring:
return fig.to_json()
if iframe:
pio.write_html(fig, 'standard.html')
if open_iframe:
pio.write_html(fig, 'standard.html')
else:
pio.write_html(fig, 'standard.html', auto_open=False)
if renderer == 'default':
fig.show()
else:
Expand Down Expand Up @@ -3213,7 +3246,8 @@ def compute_sencurve(self,
display=False,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
'''
The sensitivity curve is computed by dividing the true values by the
wavelength calibrated standard spectrum, which is resampled with the
Expand Down Expand Up @@ -3325,7 +3359,8 @@ def add_sencurve(self, sencurve):
def inspect_sencurve(self,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
'''
Display the computed sensitivity curve.
Expand Down Expand Up @@ -3422,7 +3457,10 @@ def inspect_sencurve(self,
if jsonstring:
return fig.to_json()
if iframe:
pio.write_html(fig, 'senscurve.html')
if open_iframe:
pio.write_html(fig, 'senscurve.html')
else:
pio.write_html(fig, 'senscurve.html', auto_open=False)
if renderer == 'default':
fig.show()
else:
Expand Down Expand Up @@ -3578,7 +3616,8 @@ def inspect_reduced_spectrum(self,
wave_max=8000.,
renderer='default',
jsonstring=False,
iframe=False):
iframe=False,
open_iframe=False):
'''
Display the reduced spectra.
Expand Down Expand Up @@ -3706,7 +3745,10 @@ def inspect_reduced_spectrum(self,
if jsonstring:
return fig_sci[j].to_json()
if iframe:
pio.write_html(fig_sci[j], 'spectrum_' + str(j) + '.html')
if open_iframe:
pio.write_html(fig_sci[j], 'spectrum_' + str(j) + '.html')
else:
pio.write_html(fig_sci[j], 'spectrum_' + str(j) + '.html', auto_open=False)
if renderer == 'default':
fig_sci[j].show()
else:
Expand Down Expand Up @@ -3799,7 +3841,10 @@ def inspect_reduced_spectrum(self,
if jsonstring:
return fig_std.to_json()
if iframe:
pio.write_html(fig_std, 'spectrum_standard.html')
if open_iframe:
pio.write_html(fig_std, 'spectrum_standard.html')
else:
pio.write_html(fig_std, 'spectrum_standard.html', auto_open=False)
if renderer == 'default':
fig_std.show()
else:
Expand Down

0 comments on commit 5c221dd

Please sign in to comment.