Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions analysator/plot/plot_colormap3dslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def plot_colormap3dslice(filename=None,
pass_vars=None, pass_times=None, pass_full=False,
fsaved=None, fsavedlinewidth=0.5, fsavedcolour="black", fsavedlinestyle="solid",
fluxrope=0, fluxropelinewidth=0.5, fluxropecolour=None, fluxropelinestyle=None,
amr=None, amrlinewidths=None, amrcolours=None, amrlinestyles=None,
amr=None, amrlinewidths=0.5, amrcolours='black', amrlinestyles='solid',
nomask=None,
Earth=None,
highres=None,
Expand Down Expand Up @@ -1261,7 +1261,10 @@ def exprMA_cust(exprmaps, requestvariables=False):
AMRmap = np.ma.array(AMRmap, mask=XYmask)

for i,val in enumerate(amr):
pt.plot.cell_edgecontours(ax1,XmeshPass,YmeshPass,AMRmap,val-0.1,linewidth=amrlinewidthslist[i], colors=amrcolourslist[i], linestyle=amrlinestyleslist[i])
try:
pt.plot.cell_edgecontours(ax1,XmeshPass,YmeshPass,AMRmap,val-0.1,linewidth=amrlinewidthslist[i], colors=amrcolourslist[i], linestyle=amrlinestyleslist[i])
except:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See commit 3d6414c

I think this should be changed to an if statement now or at the very least the exception should be printed as it is also possible that matplotlib could fail, in which case this would mask the exception given from it.

I'm not sure the val can even cause an exception to occur alone, or did you have some specific case where it did happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message that happens for an AMR level not present in the plotted region is long, non-descript and occurring inside matplotlib/NumPy. I think it happens when the array corresponding to an otherwise valid AMR level is empty. I guess this could be checked before passing the arrays to cell_edgecontours to make the error handling more transparent

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe best to add the handling into the function no? If this is an issue that can occur elsewhere that would be best as this function is also used elsewhere couple times.

logging.info(f"AMR level {val} not found in the selected region!")


if Earth:
Expand Down