Skip to content

Commit

Permalink
Merge branch 'develop' into add-info-to-exposure-page
Browse files Browse the repository at this point in the history
  • Loading branch information
mfixstsci committed Feb 19, 2024
2 parents 56e1f95 + d308390 commit fba04e6
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 144 deletions.
24 changes: 12 additions & 12 deletions jwql/edb/engineering_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,12 +736,12 @@ def bokeh_plot(self, show_plot=False, savefig=False, out_dir='./', nominal_value
fig = add_limit_boxes(fig, yellow=yellow_limits, red=red_limits)

# Make the x axis tick labels look nice
fig.xaxis.formatter = DatetimeTickFormatter(microseconds=["%d %b %H:%M:%S.%3N"],
seconds=["%d %b %H:%M:%S.%3N"],
hours=["%d %b %H:%M"],
days=["%d %b %H:%M"],
months=["%d %b %Y %H:%M"],
years=["%d %b %Y"]
fig.xaxis.formatter = DatetimeTickFormatter(microseconds="%d %b %H:%M:%S.%3N",
seconds="%d %b %H:%M:%S.%3N",
hours="%d %b %H:%M",
days="%d %b %H:%M",
months="%d %b %Y %H:%M",
years="%d %b %Y"
)
fig.xaxis.major_label_orientation = np.pi / 4

Expand Down Expand Up @@ -1202,12 +1202,12 @@ def plot_data_plus_devs(self, use_median=False, show_plot=False, savefig=False,
fig_dev.line(data_dates, dev, color='red')

# Make the x axis tick labels look nice
fig_dev.xaxis.formatter = DatetimeTickFormatter(microseconds=["%d %b %H:%M:%S.%3N"],
seconds=["%d %b %H:%M:%S.%3N"],
hours=["%d %b %H:%M"],
days=["%d %b %H:%M"],
months=["%d %b %Y %H:%M"],
years=["%d %b %Y"]
fig_dev.xaxis.formatter = DatetimeTickFormatter(microseconds="%d %b %H:%M:%S.%3N",
seconds="%d %b %H:%M:%S.%3N",
hours="%d %b %H:%M",
days="%d %b %H:%M",
months="%d %b %Y %H:%M",
years="%d %b %Y"
)
fig.xaxis.major_label_orientation = np.pi / 4

Expand Down
30 changes: 15 additions & 15 deletions jwql/instrument_monitors/common_monitors/edb_telemetry_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
from bokeh.embed import components, json_item
from bokeh.layouts import gridplot
from bokeh.models import BoxAnnotation, ColumnDataSource, DatetimeTickFormatter, HoverTool, Range1d
from bokeh.models import Tabs, TabPanel
from bokeh.models.layouts import Tabs
from bokeh.plotting import figure, output_file, save, show
from bokeh.palettes import Turbo256
from jwql.database import database_interface
Expand Down Expand Up @@ -991,14 +991,14 @@ def get_dependency_data(self, dependency, starttime, endtime):
if dependency["name"] in self.query_results:

# We need the full time to be covered
if ((self.query_results[dependency["name"]].requested_start_time <= starttime) and
(self.query_results[dependency["name"]].requested_end_time >= endtime)):
if ((self.query_results[dependency["name"]].requested_start_time <= starttime)
and (self.query_results[dependency["name"]].requested_end_time >= endtime)):

logging.info(f'Dependency {dependency["name"]} is already present in self.query_results.')

# Extract data for the requested time range
matching_times = np.where((self.query_results[dependency["name"]].data["dates"] >= starttime) &
(self.query_results[dependency["name"]].data["dates"] <= endtime))
matching_times = np.where((self.query_results[dependency["name"]].data["dates"] >= starttime)
& (self.query_results[dependency["name"]].data["dates"] <= endtime))
dep_mnemonic = {"dates": self.query_results[dependency["name"]].data["dates"][matching_times],
"euvalues": self.query_results[dependency["name"]].data["euvalues"][matching_times]}

Expand Down Expand Up @@ -1138,16 +1138,16 @@ def get_history_every_change(self, mnemonic, start_date, end_date):
devs = []

# Keep only data that fall at least partially within the plot range
if (((np.min(row.time) > self._plot_start) & (np.min(row.time) < self._plot_end))
| ((np.max(row.time) > self._plot_start) & (np.max(row.time) < self._plot_end))):
if (((np.min(row.time) > self._plot_start) & (np.min(row.time) < self._plot_end))
| ((np.max(row.time) > self._plot_start) & (np.max(row.time) < self._plot_end))):
times.extend(row.time)
values.extend(row.mnemonic_value)
medians.append(row.median)
devs.append(row.stdev)
hist[row.dependency_value] = (times, values, medians, devs)
else:
if (((np.min(row.time) > self._plot_start) & (np.min(row.time) < self._plot_end))
| ((np.max(row.time) > self._plot_start) & (np.max(row.time) < self._plot_end))):
if (((np.min(row.time) > self._plot_start) & (np.min(row.time) < self._plot_end))
| ((np.max(row.time) > self._plot_start) & (np.max(row.time) < self._plot_end))):
hist[row.dependency_value] = (row.time, row.mnemonic_value, row.median, row.stdev)

return hist
Expand Down Expand Up @@ -2143,12 +2143,12 @@ def plot_every_change_data(data, mnem_name, units, show_plot=False, savefig=True
fig = add_limit_boxes(fig, yellow=yellow_limits, red=red_limits)

# Make the x axis tick labels look nice
fig.xaxis.formatter = DatetimeTickFormatter(microseconds=["%d %b %H:%M:%S.%3N"],
seconds=["%d %b %H:%M:%S.%3N"],
hours=["%d %b %H:%M"],
days=["%d %b %H:%M"],
months=["%d %b %Y %H:%M"],
years=["%d %b %Y"]
fig.xaxis.formatter = DatetimeTickFormatter(microseconds="%d %b %H:%M:%S.%3N",
seconds="%d %b %H:%M:%S.%3N",
hours="%d %b %H:%M",
days="%d %b %H:%M",
months="%d %b %Y %H:%M",
years="%d %b %Y"
)
fig.xaxis.major_label_orientation = np.pi / 4

Expand Down
2 changes: 1 addition & 1 deletion jwql/tests/test_data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def test_get_anomaly_form_post_group(mocker):
assert update_mock.call_count == 2
"""


@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to django models.')
def test_get_dashboard_components():
request = MockPostRequest()

Expand Down
22 changes: 11 additions & 11 deletions jwql/utils/interactive_preview_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def create_bokeh_image(self):
plot_width = min_dim

fig = figure(tools='pan,reset,save', match_aspect=True,
plot_width=plot_width, plot_height=plot_height)
width=plot_width, height=plot_height)
fig.add_tools(BoxZoomTool(match_aspect=True))
fig.add_tools(WheelZoomTool(zoom_on_axis=False))

Expand Down Expand Up @@ -256,7 +256,7 @@ def line_plots(self, main_figure):
for index_direction in directions:
if index_direction == 'x':
# column plots
fig = figure(plot_width=200, plot_height=main_figure.height, tools='',
fig = figure(width=200, height=main_figure.height, tools='',
y_axis_location='right', margin=(0, 0, 0, 30))
fig.toolbar.logo = None

Expand All @@ -280,7 +280,7 @@ def line_plots(self, main_figure):

else:
# row plots
fig = figure(plot_height=200, plot_width=main_figure.width, tools='')
fig = figure(height=200, width=main_figure.width, tools='')
fig.toolbar.logo = None

fig.y_range = Range1d()
Expand Down Expand Up @@ -387,7 +387,7 @@ def line_plots(self, main_figure):
idx = line[i].data_source.data['x'];
}
for (let j=0; j < data.length; j++) {
if (idx[j] >= match_range.start
if (idx[j] >= match_range.start
&& idx[j] <= match_range.end) {
if (Number.isFinite(data[j])) {
min_val = Math.min(data[j], min_val);
Expand Down Expand Up @@ -444,7 +444,7 @@ def add_hover_tool(self, source, images):
hover_callback = CustomJS(args={'s': source, 'd': hover_div,
'u': self.signal_units, 'dq': is_dq}, code="""
const idx = cb_data.index.image_indices;
if (idx.length > 0) {
if (idx.length > 0) {
var x = idx[0].dim1;
var y = idx[0].dim2;
var flat = idx[0].flat_index;
Expand All @@ -471,25 +471,25 @@ def add_hover_tool(self, source, images):
}
label = "Value (" + u + ")";
}
d.text = "<div style='margin:20px'><h5>Pixel Value</h5>" +
"<div style='display:table; border-spacing: 2px'>" +
"<div style='display:table-row'>" +
d.text = "<div style='margin:20px'><h5>Pixel Value</h5>" +
"<div style='display:table; border-spacing: 2px'>" +
"<div style='display:table-row'>" +
"<div style='display:table-cell; text-align:right'>(x, y) =</div>" +
"<div style='display:table-cell'>(" + x + ", " + y + ")</div>" +
"</div>"
if ('ra' in s.data && 'dec' in s.data) {
var ra = s.data['ra'][0][flat].toPrecision(8);
var dec = s.data['dec'][0][flat].toPrecision(8);
d.text += "<div style='display:table-row'>" +
d.text += "<div style='display:table-row'>" +
"<div style='display:table-cell; text-align:right'>RA (deg)=</div>" +
"<div style='display:table-cell'>" + ra + "</div>" +
"</div>" +
"<div style='display:table-row'>" +
"<div style='display:table-row'>" +
"<div style='display:table-cell; text-align:right'>Dec (deg)=</div>" +
"<div style='display:table-cell'>" + dec + "</div>" +
"</div>"
}
d.text += "<div style='display:table-row'>" +
d.text += "<div style='display:table-row'>" +
"<div style='display:table-cell; text-align:right'>" + label + "=</div>" +
"<div style='display:table-cell'>" + val + "</div></div></div></div>";
} else {
Expand Down
13 changes: 7 additions & 6 deletions jwql/website/apps/jwql/bokeh_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

from bokeh.embed import components
from bokeh.layouts import layout
from bokeh.models import TabPanel, Tabs
from bokeh.models import DatetimeTickFormatter
from bokeh.models.layouts import TabPanel, Tabs
from bokeh.plotting import figure, output_file
import numpy as np
import pysiaf
Expand Down Expand Up @@ -282,10 +283,10 @@ def generic_telemetry_plot(times, values, name, nominal_value=None, yellow_limit
if nominal_value is not None:
fig.line(times, np.repeat(nominal_value, len(times)), line_dash='dashed')

fig.xaxis.formatter = DatetimeTickFormatter(hours=["%d %b %H:%M"],
days=["%d %b %H:%M"],
months=["%d %b %Y %H:%M"],
years=["%d %b %Y"],
fig.xaxis.formatter = DatetimeTickFormatter(hours="%d %b %H:%M",
days="%d %b %H:%M",
months="%d %b %Y %H:%M",
years="%d %b %Y"
)
fig.xaxis.major_label_orientation = np.pi / 4

Expand Down Expand Up @@ -401,7 +402,7 @@ def standard_monitor_plot_layout(instrument, plots):
elif instrument.lower() == 'niriss':
full_frame_lists = [
[plots['NIS_CEN']]
]
]
elif instrument.lower() == 'miri':
full_frame_lists = [
[plots['MIRIM_FULL']]
Expand Down
Loading

0 comments on commit fba04e6

Please sign in to comment.