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 when plotting variables with dimensions specified #34

Closed
James-Crean opened this issue Feb 9, 2018 · 4 comments
Closed

Error when plotting variables with dimensions specified #34

James-Crean opened this issue Feb 9, 2018 · 4 comments
Assignees

Comments

@James-Crean
Copy link
Contributor

Plotting variables works fine so long as the latitude/logitude/time/etc are not changed.

When plotting a variable with dimensions other than the default the following error occurs:

exception: "CDMSError("Specification not acceptable: <type 'unicode'>, latitude",)"

Here is the relevant stack trace:

"Traceback (most recent call last):
  File "/Users/crean2/anaconda2/envs/nightly/lib/python2.7/site-packages/wslink/websocket.py", line 274, in onMessage
    results = func(obj, *args, **kwargs)
  File "build/bdist.macosx-10.9-x86_64/egg/vcs_server/Visualizer.py", line 35, in plot
    var = var.subRegion(**kargs)
  File "/Users/crean2/anaconda2/envs/nightly/lib/python2.7/site-packages/cdms2/avariable.py", line 767, in subRegion
    speclist = self._process_specs(specs, keys)
  File "/Users/crean2/anaconda2/envs/nightly/lib/python2.7/site-packages/cdms2/avariable.py", line 1262, in _process_specs
    i = self.getAxisIndex(k)
  File "/Users/crean2/anaconda2/envs/nightly/lib/python2.7/site-packages/cdms2/avariable.py", line 383, in getAxisIndex
    if axisMatches(self.getAxis(i), axis_spec):
  File "/Users/crean2/anaconda2/envs/nightly/lib/python2.7/site-packages/cdms2/axis.py", line 2577, in axisMatches
    str(type(specification)) + ', ' + str(specification))
CDMSError: Specification not acceptable: <type 'unicode'>, latitude
"
@James-Crean
Copy link
Contributor Author

Cdms2 will return this error if an axis name/key is unicode rather than an ascii string.

Works: {'latitude': [0,1]}
Errors: {u'latitude': [0,1]}

I tested a simple fix myself that replaces the following code block in Visualizer.py:

if ('subRegion' in op):
    kargs = op['subRegion']
    var = var.subRegion(**kargs)

with this:

if ('subRegion' in op):
    kargs = op['subRegion']
    fixed_kargs = {}
    for key in kargs.keys():
        fixed_kargs[str(key)] = kargs[key]
    var = var.subRegion(**fixed_kargs)

And subsetting began to work again.

@doutriaux1
Copy link
Contributor

@James-Crean can you file an issue for this on cdms repo? thx.

@scottwittenburg
Copy link
Collaborator

Hi @James-Crean and @doutriaux1 , I'm just checking if there's some action you want me to take here?

In the absence of some over-arching policy regarding character encodings, I'm not sure what to do on the web end. If we try and "clean" (by forcing everything to ascii strings) all the data that comes from people's different browsers, we could probably prevent this particular error, but then I think we will have ruled out the use of any other languages on the front end.

I'm not sure, but the right approach might be to formalize our notion of character encoding for a session, and then make sure the backend can handle that as long as it know what that encoding is.

@James-Crean
Copy link
Contributor Author

No worries Scott. We found that this is actually an issue with cdms, so vcs-js doesn't need to worry about the encodings. I'll closer this issue since there is nothing to be done here

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

3 participants