encoding not working completely

Errors and unexpected results
User avatar
Jon
Posts: 192
Joined: Fri Jan 09, 2009 8:44 pm
Location: Madison, WI

Re: encoding not working completely

Post by Jon »

Hi Joleen,

Regrettably, I didn't think of this in time for the 1.5 release. :x However, the latest nightly builds should work a bit better due to the following commits:

Commit 4a7a2d7...

Commit 150a802...
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: encoding not working completely

Post by joleenf »

Hi Jon,

Thanks. I probably won't upgrade to the 1.6 beta version until after the MUG meeting.

Joleen
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: encoding not working completely

Post by joleenf »

Hi Bob,

I am working in McIDAS-V 1.6 beta 1. The problem of an extra angstrom symbol being tacked onto the "µ" symbol is back. I tried importing my editfile with a UTF-8 encoding, and had no luck. I also tested adding a "µm" print using annotate. Both produced the extra character. If I set the layer label in a script, I can go back and correct the text in the GUI, but the extra character does not appear in the script.

Thanks,
Joleen

les.py
(1.02 KiB) Downloaded 288 times


Data at ftp://ftp.ssec.wisc.edu/pub/ssec/joleenf/

Also, is it odd that "setLayerLabel" returns "NoneType?" Should this return the handle to the layer label?

Thanks,
Joleen
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: encoding not working completely

Post by joleenf »

This is not isolated to the editfile command. I can replicate the problem in the jython shell without editfile, using a command like

"activeDisplay().annotate('TEST µm', line=500, element=500)"

Joleen
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: encoding not working completely

Post by joleenf »

This is what happens when I save a bundle with the µm symbol in some text:

Screen Shot 2016-01-05 at 9.18.59 AM.png
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: encoding not working completely

Post by bobc »

Hi Joleen -

I'm replicating the problem you are seeing with the mu character. It looks like something broke between 1.5 and now, where the mu character doesn't work correctly with setLayerLabel or annotate. By chance, do you know if this used to work in 1.6beta1 at one time?

The only workaround I have for now is with annotate, where you can use unicode to get the mu character:

Code: Select all

activeDisplay().annotate('GOES-13 %timestamp% 0.65'+u'\u03BC'+'m', line=320, element=100)

I'm wondering if this is related to inquiry 2040, where there have been changes with encoding since the release of 1.5. I will bounce this off the programmer to see if he has any thoughts on what might have happened.

As for setLayerLabel returning none, this seems to be consistent with the output of other functions that can operate on a layer, such as setEnhancement and setVerticalPosition. Do you expect this to return the string of the layer label? For example, the same output if you were to run:

Code: Select all

myLabel = lesLayer.getLayerLabel()
print myLabel

This returns: GOES-13 %timestamp% 0.65µm

Thanks -
Bob Carp
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: encoding not working completely

Post by joleenf »

Hi,

It seems that encoding is working well from the shell. Now, I have a script in which some of the code is contained in the jython library. One part of that code uses the data from a satellite file to create a label. I would like to use µm again, but this does not work when contained in the jython library. I have tried to use

# -*- coding: utf-8 -*-

as outlined in https://www.python.org/dev/peps/pep-0263/ but that produces an error when trying to save in the jython library. I have tried variations on encoding, and none seem to work.

Currently I am trying myLabel = '{} {} {} {} \n {}'.format(satellite.name(), satellite.wavelength(),u'\u03BC', 'm', timestampStr) with a very strange result for what should be 'µ' (as well as I have not properly captured the satellite name, I am working on that...)

Screen Shot 2016-02-16 at 9.29.14 AM.png


Joleen
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: encoding not working completely

Post by bobc »

Hi Joleen -

Thanks for reporting this. I wrote this up as Inquiry 2268.

- Bob
Post Reply