Re: [idvusers] Changing unit of FlatField from celsius to meter using Jython

Hi Patrick-

Patrick Koethur wrote:
Is there a way of changing the unit of a FlatField from celsius to meter using Jython scripting? I've tried a lot different approaches, but haven't come up with a solution yet.

Since it's physically impossible to convert between these units the
typical approaches (like below) don't work.  There is a Jython

newUnit(field, varname, unitname)

in which will replace the units with incompatible units.
Basically, it creates a new RealType using the new name and unit
and sets that for the samples of the FlatField.  Using this will
allow you to do what you want.  Just be sure to use "celsius" or
"degC" for the unit name, not "C".  "C" is for Coulomb (as the
Cookie Monster would say. ;-))

For example: ucar.visad.Util.clone(|visad.Data data, visad.MathType type|) doesn't work because the units are not convertable...

I'm really at a loss. Every little hint is much appreciated.

Try the suggestion above and let us know if it doesn't work.

Just curious, why are you changing from celsius to meter?  Is
it to display the temperatures as a height in the main display?

Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307