Skip to content

Commit

Permalink
Merge pull request #27 from bcaddy/master-iss13
Browse files Browse the repository at this point in the history
Fix 2D User Defined Plots (issue #13)
  • Loading branch information
ntoles authored Aug 17, 2024
2 parents cf9f6b4 + 0ad512d commit f7c8cbc
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/energy_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def update_data(self, output):

if self.GetPlotParam('masked'):
zval = ma.masked_array(self.hist2d[0])
zval[zval == 0] = ma.masked
zval[zval <= 0] = ma.masked
zval *= float(zval.max())**(-1)
tmplist = [zval[~zval.mask].min(), zval.max()]
tmplist = [zval[np.logical_not(zval.mask)].min(), zval.max()]
else:
zval = np.copy(self.hist2d[0])
zval[zval==0] = 0.5
Expand Down
4 changes: 2 additions & 2 deletions src/energy_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ def LoadData(self):

if self.GetPlotParam('masked'):
zval = ma.masked_array(self.hist2d[0])
zval[zval == 0] = ma.masked
zval[zval <= 0] = ma.masked
zval *= float(zval.max())**(-1)
tmplist = [zval[~zval.mask].min(), zval.max()]
tmplist = [zval[np.logical_not(zval.mask)].min(), zval.max()]
else:
zval = np.copy(self.hist2d[0])
zval[zval==0] = 0.5
Expand Down
9 changes: 5 additions & 4 deletions src/fields_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ def NormFieldHandler(self, *args):
if self.parent.GetPlotParam('normalize_fields') == self.NormFieldVar.get():
pass
else:
if ~self.parent.GetPlotParam('twoD'):
if not self.parent.GetPlotParam('twoD'):
tmplblstr = self.parent.GetPlotParam('yaxis_label')[self.FieldTypeVar.get()]
if self.NormFieldVar.get():
if self.parent.GetPlotParam('field_type') ==0:
Expand Down Expand Up @@ -1395,7 +1395,7 @@ def RadioField(self):
self.parent.SetPlotParam('show_x', False, update_plot = False)
self.parent.SetPlotParam('show_y', False, update_plot = False)
self.parent.SetPlotParam('show_z', False, update_plot = False)
if ~self.parent.GetPlotParam('twoD'):
if not self.parent.GetPlotParam('twoD'):
self.parent.linex[0].set_visible(False)
self.parent.anx.set_visible(False)
self.parent.liney[0].set_visible(False)
Expand All @@ -1418,7 +1418,8 @@ def RadioField(self):
self.parent.SetPlotParam('show_x', False, update_plot = False)
self.parent.SetPlotParam('show_y', False, update_plot = False)
self.parent.SetPlotParam('show_z', False, update_plot = False)
if ~self.parent.GetPlotParam('twoD'):
if not self.parent.GetPlotParam('twoD'):
print(f"{self.parent.GetPlotParam('twoD') = }")
self.parent.linex[0].set_visible(False)
self.parent.anx.set_visible(False)
self.parent.liney[0].set_visible(False)
Expand Down Expand Up @@ -1608,7 +1609,7 @@ def SaveStr(self):
tmplist2.append(tmplist)

self.subplot.SetPlotParam('1D_label',tmplist2, update_plot =False)
if ~self.subplot.GetPlotParam('twoD'):
if not self.subplot.GetPlotParam('twoD'):
self.subplot.axes.set_ylabel(self.subplot.GetPlotParam('yaxis_label')[3])
self.subplot.anx.set_text(self.subplot.GetPlotParam('1D_label')[3][0])
self.subplot.any.set_text(self.subplot.GetPlotParam('1D_label')[3][1])
Expand Down
6 changes: 3 additions & 3 deletions src/mag_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def update_data(self, output):


if self.GetPlotParam('mag_plot_type') == 1: # Set f to deltaB/B0
if ~np.isnan(self.parent.btheta):
if not np.isnan(self.parent.btheta):
self.ylabel = r'$|\delta B|/B_0$'
self.ann_label = r'$|\delta B|/B_0$'
else:
Expand All @@ -115,7 +115,7 @@ def update_data(self, output):


if self.GetPlotParam('mag_plot_type') == 2: # Set f to deltaB_perp/B0
if ~np.isnan(self.parent.btheta):
if not np.isnan(self.parent.btheta):
self.ylabel = r'$|\delta B_\perp|/B_0$'
self.ann_label = r'$|\delta B_\perp|/B_0$'
else:
Expand All @@ -138,7 +138,7 @@ def update_data(self, output):


if self.GetPlotParam('mag_plot_type') == 3: # Set f to deltaB_para/B0
if ~np.isnan(self.parent.btheta):
if not np.isnan(self.parent.btheta):
self.ylabel = r'$\delta B_\parallel/B_0$'
self.ann_label = r'$\delta B_\parallel/B_0$'
else:
Expand Down
6 changes: 3 additions & 3 deletions src/mag_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def LoadData(self):
# self.parent.DataDict['xi_perpmin_max'+str(self.ind)] = list(self.min_max)

if self.GetPlotParam('mag_plot_type') == 1: # Set f to deltaB/B0
if ~np.isnan(self.parent.btheta):
if not np.isnan(self.parent.btheta):
self.ylabel = r'$|\delta B|/B_0$'
self.ann_label = r'$|\delta B|/B_0$'
else:
Expand All @@ -155,7 +155,7 @@ def LoadData(self):


if self.GetPlotParam('mag_plot_type') == 2: # Set f to deltaB_perp/B0
if ~np.isnan(self.parent.btheta):
if not np.isnan(self.parent.btheta):
self.ylabel = r'$|\delta B_\perp|/B_0$'
self.ann_label = r'$|\delta B_\perp|/B_0$'
else:
Expand All @@ -176,7 +176,7 @@ def LoadData(self):
self.parent.DataDict['deltaB_perp'] = self.f

if self.GetPlotParam('mag_plot_type') == 3: # Set f to deltaB_para/B0
if ~np.isnan(self.parent.btheta):
if not np.isnan(self.parent.btheta):
self.ylabel = r'$\delta B_\parallel/B_0$'
self.ann_label = r'$\delta B_\parallel/B_0$'
else:
Expand Down
8 changes: 4 additions & 4 deletions src/phase_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def update_data(self, output):
inRange *= energy <= self.GetPlotParam('E_max')
elif self.GetPlotParam('set_E_max'):
inRange = energy <= self.GetPlotParam('E_max')
inRange *= ~nan_ind
inRange *= np.logical_not(nan_ind)
if self.GetPlotParam('weighted'):
self.hist2d = Fast2DWeightedHist(self.y_values[inRange], self.x_values[inRange], self.weights[inRange], self.pmin,self.pmax, self.GetPlotParam('pbins'), self.xmin,self.xmax, self.GetPlotParam('xbins')), [self.pmin, self.pmax], [self.xmin, self.xmax]

Expand All @@ -229,9 +229,9 @@ def update_data(self, output):
try:
if self.GetPlotParam('masked'):
zval = ma.masked_array(self.hist2d[0])
zval[zval == 0] = ma.masked
zval[zval <= 0] = ma.masked
zval *= float(zval.max())**(-1)
tmplist = [zval[~zval.mask].min(), zval.max()]
tmplist = [zval[np.logical_not(zval.mask)].min(), zval.max()]
else:
zval = np.copy(self.hist2d[0])
zval[zval==0] = 0.5
Expand Down Expand Up @@ -330,7 +330,7 @@ def update_data(self, output):
zval = ma.masked_array(self.hist2d[0])
zval[zval == 0] = ma.masked
zval *= float(zval.max())**(-1)
tmplist = [zval[~zval.mask].min(), zval.max()]
tmplist = [zval[np.logical_not(zval.mask)].min(), zval.max()]
else:
zval = np.copy(self.hist2d[0])
zval[zval==0] = 0.5
Expand Down
6 changes: 3 additions & 3 deletions src/phase_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def LoadData(self):
inRange *= energy <= self.GetPlotParam('E_max')
elif self.GetPlotParam('set_E_max'):
inRange = energy <= self.GetPlotParam('E_max')
inRange *= ~nan_ind
inRange *= np.logical_not(nan_ind)
if self.GetPlotParam('weighted'):
self.hist2d = Fast2DWeightedHist(self.y_values[inRange], self.x_values[inRange], self.weights[inRange], self.pmin,self.pmax, self.GetPlotParam('pbins'), self.xmin,self.xmax, self.GetPlotParam('xbins')), [self.pmin, self.pmax], [self.xmin, self.xmax]

Expand All @@ -340,7 +340,7 @@ def LoadData(self):
zval = ma.masked_array(self.hist2d[0])
zval[zval == 0] = ma.masked
zval *= float(zval.max())**(-1)
tmplist = [zval[~zval.mask].min(), zval.max()]
tmplist = [zval[np.logical_not(zval.mask)].min(), zval.max()]
else:
zval = np.copy(self.hist2d[0])
zval[zval==0] = 0.5
Expand Down Expand Up @@ -439,7 +439,7 @@ def LoadData(self):
zval = ma.masked_array(self.hist2d[0])
zval[zval == 0] = ma.masked
zval *= float(zval.max())**(-1)
tmplist = [zval[~zval.mask].min(), zval.max()]
tmplist = [zval[np.logical_not(zval.mask)].min(), zval.max()]
else:
zval = np.copy(self.hist2d[0])
zval[zval==0] = 0.5
Expand Down

0 comments on commit f7c8cbc

Please sign in to comment.