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

UKCP projection fails to plot due to previous AttributeError #59

Closed
sadielbartholomew opened this issue Jul 19, 2024 · 2 comments · Fixed by #74
Closed

UKCP projection fails to plot due to previous AttributeError #59

sadielbartholomew opened this issue Jul 19, 2024 · 2 comments · Fixed by #74
Assignees
Labels

Comments

@sadielbartholomew
Copy link
Member

sadielbartholomew commented Jul 19, 2024

As evidenced by the Example 31 of the new regression test suite:

======================================================================
ERROR: test_example_31 (__main__.ExamplesTest.test_example_31)
Test Example 31.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/slb93/git-repos/cf-plot/cfplot/test/test_examples.py", line 997, in test_example_31
    cfp.con(f, lines=False)
  File "/home/slb93/git-repos/cf-plot/cfplot/cfplot.py", line 4037, in con
    _plot_map_axes(
  File "/home/slb93/git-repos/cf-plot/cfplot/cfplot.py", line 2982, in _plot_map_axes
    if plotvars.proj == "UKCP" and plotvars.grid:
                                   ^^^^^^^^^^^^^
AttributeError: 'pvars' object has no attribute 'grid'

from the minimal reproducer code:

        f = cf.read(f"<path to 'cfplot_data' dir of data files for tests>/ukcp_rcm_test.nc")[0]
        cfp.mapset(proj="UKCP", resolution="50m")  # fails here with the above issue

Looks like a very quick fix to me, but I will wait to get the rest of the test issues diagnosed before putting in the fixes.

@sadielbartholomew
Copy link
Member Author

OK for some reason, in interactive Python that line works fine, but when run as part of the test suite it fails with the above, so there is some cfp plotting variable setup which is required to re-create this one. I will investigate further once I know what is failing across the test suite.

@sadielbartholomew
Copy link
Member Author

Update: I can recreate this locally, with the following calls from the example (note the previous cfp.con calls which work):

>>> f = cf.read("cfplot_data/ukcp_rcm_test.nc")[0]
>>> cfp.con(f, lines=False)
>>> cfp.setvars(grid_x_spacing=1, grid_y_spacing=1)
>>> cfp.con(f, lines=False)
>>> cfp.mapset(proj="UKCP", resolution="50m")
>>> cfp.con(f, lines=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/slb93/git-repos/cf-plot/cfplot/cfplot.py", line 4037, in con
    _plot_map_axes(
  File "/home/slb93/git-repos/cf-plot/cfplot/cfplot.py", line 2982, in _plot_map_axes
    if plotvars.proj == "UKCP" and plotvars.grid:
                                   ^^^^^^^^^^^^^
AttributeError: 'pvars' object has no attribute 'grid'

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

Successfully merging a pull request may close this issue.

1 participant