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

Enable plotting of cfdm fields with cfplot #166

Open
sadielbartholomew opened this issue Dec 17, 2021 · 0 comments
Open

Enable plotting of cfdm fields with cfplot #166

sadielbartholomew opened this issue Dec 17, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@sadielbartholomew
Copy link
Member

sadielbartholomew commented Dec 17, 2021

In recent discussions relating to the CF Training course, we agreed it would be useful to be able to plot cfdm fields, and not just cf-python fields, with cfplot. Some work would probably need to be done on both the cfdm and cfplot side to make this possible.

For example, with the latest versions of all of the libraries, taking a simple example (lifted from the documentation and using one of the sample data sets) with trying to plot a field read-in via cf and cfdm separately, the cf field plots fine but the cfdm one runs into some cfplot errors due to shape:

>>> import cfplot as cfp
>>> import cf
>>> import cfdm

>>> cf.__version__
'3.11.0'
>>> cfdm.__version__
'1.9.0.1'
>>> cfp.__version__
'3.1.17'

>>> cf_f = cf.read('tas_A1.nc')[0]
>>> cfdm_f = cfdm.read('tas_A1.nc')[0]

>>> cfp.con(cf_f[0,0::])  # plots successfully
>>> cfp.con(cfdm_f[0,0::])  # errors
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sadie/anaconda3/envs/cf-env/lib/python3.8/site-packages/cfplot/cfplot.py", line 401, in con
    check_data(field, x, y)
  File "/home/sadie/anaconda3/envs/cf-env/lib/python3.8/site-packages/cfplot/cfplot.py", line 3779, in check_data
    raise Warning(errstr)
Warning: 
Input arguments incorrectly shaped:
x has shape:(73,)
y has shape:(1,)
field has shape(1, 73, 96)

Expected x=xpts, y=ypts, field=(ypts,xpts)
x=npts, y=npts, field=npts
or x=[ypts, xpts], y=[ypts, xpts], field=[ypts, xpts]
@sadielbartholomew sadielbartholomew added the enhancement New feature or request label Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant