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

cdscan error with Python 3 #239

Closed
zshaheen opened this issue Apr 27, 2018 · 7 comments
Closed

cdscan error with Python 3 #239

zshaheen opened this issue Apr 27, 2018 · 7 comments
Assignees
Labels

Comments

@zshaheen
Copy link
Contributor

When running a command like this:

cdscan -x test.xml /p/user_pub/work/E3SM/1_0/piControl/1deg_atm_60-30km_ocean/atmos/129x256/model-output/mon/ens1/v1/20180129.DECKv1b_piControl.ne30_oEC.edison.cam.h0*nc

with cdms 3.0 on a Python 3 env, I get the following error:

Finding common directory ...
Common directory: /p/user_pub/work/E3SM/1_0/piControl/1deg_atm_60-30km_ocean/atmos/129x256/model-output/mon/ens1/v1/
Scanning files ...
/p/user_pub/work/E3SM/1_0/piControl/1deg_atm_60-30km_ocean/atmos/129x256/model-output/mon/ens1/v1/20180129.DECKv1b_piControl.ne30_oEC.edison.cam.h0.0001-01.nc
Traceback (most recent call last):
  File "/export/shaheen2/anaconda2/envs/acme_diags_env_dev_py3/bin/cdscan", line 1840, in <module>
    main(sys.argv)
  File "/export/shaheen2/anaconda2/envs/acme_diags_env_dev_py3/bin/cdscan", line 1153, in main
    varnames.append(axisvar.id)
AttributeError: 'dict_keys' object has no attribute 'append'

In Python 3, dict.keys() returns an object of type dict_keys, not a list. All that's needed is to do varnames = list(varnames) before any of the statements using varnames, like the offending line varnames.append(axisvar.id) .

@zshaheen
Copy link
Contributor Author

This is not an issue with the Python 2 version.

@dnadeau4
Copy link
Contributor

Are you using python3?

@zshaheen
Copy link
Contributor Author

@dnadeau4 Yes, I believe I was.

@dnadeau4
Copy link
Contributor

found it, there now variables.keys() return a dictionary instead of a list.

@dnadeau4
Copy link
Contributor

cdscan

1134         varnames = list(f.variables.keys())
1135 
1136         # Try to force all axes to be included, but only small ones, length<100.
1137         # This section was motivated by a need to preserve the cloud axes isccp_prs,isccp_tau.
1138         # If we ever need to preserve longer axes as well, we could create one
1139         # variable per axis...

@durack1
Copy link
Member

durack1 commented Jul 20, 2020

@forsyth2 @jasonb5 this might be another issue that can be closed due to #399?

@jasonb5
Copy link
Contributor

jasonb5 commented Jul 23, 2020

@durack1 This looks like a duplicate. The fix will be included with CDAT 8.2.1. Thanks!

@jasonb5 jasonb5 closed this as completed Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants