diff --git a/xija/component/heat/solar.py b/xija/component/heat/solar.py index ad528b59..d7d99da3 100644 --- a/xija/component/heat/solar.py +++ b/xija/component/heat/solar.py @@ -570,6 +570,7 @@ def __init__( pitch_comp="pitch", simz_comp="sim_z", dh_heater_comp="dh_heater", + eclipse_comp=None, P_pitches=None, P_vals=None, dP_pitches=None, @@ -586,6 +587,7 @@ def __init__( self.pitch_comp = self.model.get_comp(pitch_comp) self.simz_comp = self.model.get_comp(simz_comp) self.dh_heater_comp = self.model.get_comp(dh_heater_comp) + self.eclipse_comp = self.model.get_comp(eclipse_comp) self.P_pitches = np.array( [45.0, 55.0, 70.0, 90.0, 150.0] if (P_pitches is None) else P_pitches, dtype=float, @@ -682,6 +684,10 @@ def dvals(self): # Increase heat power for times when detector housing heater is enabled self._dvals[self.dh_heater_comp.dvals] += self.dh_heater + # Set power to 0.0 during eclipse (where eclipse_comp.dvals == True) + if self.eclipse_comp is not None: + self._dvals[self.eclipse_comp.dvals] = 0.0 + return self._dvals def plot_solar_heat__pitch(self, fig, ax): diff --git a/xija/gui_fit/plots.py b/xija/gui_fit/plots.py index 24a486a3..0054a337 100644 --- a/xija/gui_fit/plots.py +++ b/xija/gui_fit/plots.py @@ -668,6 +668,7 @@ def __init__(self, plot_name, plots_box): canvas.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed ) + self.canvas = canvas toolbar = NavigationToolbar(canvas, parent=None) delete_plot_button = QtWidgets.QPushButton("Delete") @@ -807,20 +808,19 @@ def update(self, first=False): if first: [line.remove() for line in self.ax.get_lines()] plot_func(fig=self.fig, ax=self.ax) - if self.plot_method.endswith("time"): - self.ax.fmt_xdata = mdates.DateFormatter("%Y:%j:%H:%M:%S") - self.ax.autoscale(enable=False, axis="x") if first: if self.plot_method.endswith("time"): self.show_fills() - if mw.show_radzones: - self.add_annotation("radzones") - if mw.show_line: - self.add_annotation("line") + if mw.show_radzones: + self.add_annotation("radzones") + if mw.show_line: + self.add_annotation("line") if mw.show_limits: self.add_annotation("limits") self.fig.canvas.draw_idle() - self.fig.canvas.flush_events() + if self.plot_method.endswith("time"): + self.ax.fmt_xdata = mdates.DateFormatter("%Y:%j:%H:%M:%S") + self.ax.autoscale(enable=False, axis="x") class PlotsBox(QtWidgets.QVBoxLayout): @@ -864,28 +864,25 @@ def reset_plots(self): def add_plot_box(self, plot_name): plot_name = str(plot_name) + self.main_window.cbp.add_plot_button.setCurrentIndex(0) if plot_name == "Add plot..." or plot_name in self.plot_names: return print("Adding plot ", plot_name) plot_box = PlotBox(plot_name, self) self.addLayout(plot_box) plot_box.update(first=True) - self.main_window.cbp.add_plot_button.setCurrentIndex(0) - self.update_plot_boxes() + self.plot_boxes.append(plot_box) + self.plot_names.append(plot_name) def delete_plot_box(self, plot_name): - for pb in self.plot_boxes: + for i, pb in enumerate(list(self.plot_boxes)): if pb.plot_name == plot_name: - pb.fig.clear() + self.plot_boxes.pop(i) + self.plot_names.pop(i) self.removeItem(pb) clear_layout(pb) + break self.update() - self.update_plot_boxes() - # This is a hack to get the axes to appear correctly - # on the rest of the plots after deleting one, somehow - # related to clearing the figure above - for pb in self.plot_boxes: - pb.ax.set_xlim() def update_plots(self, first=False): mw = self.main_window @@ -920,13 +917,6 @@ def remove_ignores(self): pb.fig.canvas.draw_idle() self.update_plots() - def update_plot_boxes(self): - self.plot_boxes = [] - self.plot_names = [] - for plot_box in self.findChildren(PlotBox): - self.plot_boxes.append(plot_box) - self.plot_names.append(plot_box.plot_name) - def update_xline(self): for pb in self.plot_boxes: pb.update_xline()