Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EarthClimate/makeplot.py is failing #259

Open
deitrr opened this issue Jan 17, 2024 · 1 comment
Open

EarthClimate/makeplot.py is failing #259

deitrr opened this issue Jan 17, 2024 · 1 comment

Comments

@deitrr
Copy link
Contributor

deitrr commented Jan 17, 2024

This seems to be sensitive to the version of some package, but I can't figure out which package(s) are the issue.

In examples/EarthClimate, python makeplot.py fails with this error:

Traceback (most recent call last):
File "/home/rdeitrick/vplanet_test_sims/EarthClimate_copy0/makeplot.py", line 415, in
comp2huybers("Earth", show=False)
File "/home/rdeitrick/vplanet_test_sims/EarthClimate_copy0/makeplot.py", line 108, in comp2huybers
c = plt.contourf(
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/pyplot.py", line 2492, in contourf
__ret = gca().contourf(
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/init.py", line 1414, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 6319, in contourf
contours = mcontour.QuadContourSet(self, *args, **kwargs)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/contour.py", line 812, in init
kwargs = self._process_args(*args, **kwargs)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/contour.py", line 1446, in _process_args
x, y, z = self._contour_args(args, kwargs)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/contour.py", line 1490, in _contour_args
z = ma.masked_invalid(z, copy=False)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/numpy/ma/core.py", line 2360, in masked_invalid
res = masked_where(~(np.isfinite(a)), a, copy=copy)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/numpy/ma/core.py", line 1936, in masked_where
cond = mask_or(cond, a._mask)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/numpy/ma/core.py", line 1746, in mask_or
return make_mask(m1, copy=copy, shrink=shrink, dtype=dtype)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/numpy/ma/core.py", line 1640, in make_mask
result = _shrink_mask(result)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/numpy/ma/core.py", line 1549, in _shrink_mask
if m.dtype.names is None and not m.any():
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/astropy/units/quantity.py", line 2001, in any
raise TypeError(
TypeError: cannot evaluate truth value of quantities. Evaluate array with q.value.any(...)

The weird thing is that the script still works in an old environment, but not when I create a new environment, even if I specify the same versions of matplotlib and astropy. I suspect another package is the issue, but can't figure out which one.

I've tried adding .value to unitful quantities inside the contourf call. This removes the above issue but generates a new issue with vplot:

Traceback (most recent call last):
File "/home/rdeitrick/vplanet_test_sims/EarthClimate_copy0/makeplot.py", line 415, in
comp2huybers("Earth", show=False)
File "/home/rdeitrick/vplanet_test_sims/EarthClimate_copy0/makeplot.py", line 255, in comp2huybers
plt.savefig(path / f"EarthClimateMilankovitch.{ext}")
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/pyplot.py", line 1119, in savefig
res = fig.savefig(*args, **kwargs) # type: ignore[func-returns-value]
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/figure.py", line 3390, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 2187, in print_figure
result = print_method(
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 2043, in
print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/backends/backend_pdf.py", line 2807, in print_pdf
self.figure.draw(renderer)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/matplotlib/artist.py", line 39, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/vplot-1.0.5-py3.9.egg/vplot/figure.py", line 353, in draw
self._add_labels()
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/vplot-1.0.5-py3.9.egg/vplot/figure.py", line 179, in _add_labels
unit, _, label, physical_type = _get_array_info(
File "/home/rdeitrick/anaconda3/envs/test_a6/lib/python3.9/site-packages/vplot-1.0.5-py3.9.egg/vplot/figure.py", line 33, in _get_array_info
physical_type = array.unit.physical_type.title()
AttributeError: 'PhysicalType' object has no attribute 'title'

So far, the only way I've gotten around this entirely is to remove vplot completely, and add .value to all quantities getting passed to plotting functions... but there must be a way of getting this working properly with vplot, surely?

@deitrr
Copy link
Contributor Author

deitrr commented Jan 25, 2024

I can confirm that this error is occurring when I setup my environment using the provided .yml file (instead of a custom environment), unfortunately. So the mystery continues...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant