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

Error creating plots in plotpfl #1

Open
glwagner opened this issue May 10, 2019 · 3 comments
Open

Error creating plots in plotpfl #1

glwagner opened this issue May 10, 2019 · 3 comments

Comments

@glwagner
Copy link

When attempting to execute /cases/OCSPapa/case_run, plotpfl throws the error:

Traceback (most recent call last):
  File "/Users/gregorywagner/Projects/gotm/gotmwork/tools/plotpfl", line 275, in <module>
    main()
  File "/Users/gregorywagner/Projects/gotm/gotmwork/tools/plotpfl", line 112, in main
    im = plt.contourf(dttime, z, np.transpose(mdl), levels, extend='both')
  File "/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2818, in contourf
    ret = ax.contourf(*args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py", line 1717, in inner
    return func(ax, *args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 5827, in contourf
    contours = mcontour.QuadContourSet(self, *args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/matplotlib/contour.py", line 853, in __init__
    kwargs = self._process_args(*args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/matplotlib/contour.py", line 1447, in _process_args
    x, y, z = self._contour_args(args, kwargs)
  File "/anaconda3/lib/python3.6/site-packages/matplotlib/contour.py", line 1528, in _contour_args
    x, y, z = self._check_xyz(args[:3], kwargs)
  File "/anaconda3/lib/python3.6/site-packages/matplotlib/contour.py", line 1557, in _check_xyz
    x = np.asarray(x, dtype=np.float64)
  File "/anaconda3/lib/python3.6/site-packages/numpy/core/numeric.py", line 492, in asarray
    return array(a, dtype, copy=False, order=order)
TypeError: float() argument must be a string or a number, not 'real_datetime'
@glwagner
Copy link
Author

glwagner commented May 10, 2019

It seems this particular error can be alleviated by converting dttime from a real_datetime object into an ordinary python datetime object via:

dttime = np.array(
        [datetime.datetime(t.year, t.month, t.day, t.hour, t.minute, t.second, t.microsecond) 
            for t in dttime]
    )

below this line:

dttime = nctime_to_datetime(nctime, tidx_start=tidx_start, tidx_end=tidx_end+1)

See the change here:

https://github.com/glwagner/gotmwork/blob/b830d1f6b0a6bbd24e6e00408017fdfb4b74429f/tools/gotmtool.py#L120

I still don't get a plot showing up though, and I can't find it (if it was saved anywhere).

@qingli411
Copy link
Owner

@glwagner I noticed this error when upgrading to matplotlib 3. matplotlib 2.2.2 works fine. I'm going to fix it. For now, there are two workaround:

  1. You can simply comment out the last line of /case/OCSPapa/case_run, which does the plotting.
  2. You can copy my Conda environment using gotm_env.yml in the develop branch. All the tools should work fine in this environment.

@glwagner
Copy link
Author

Awesome, thank you.

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

2 participants