Re: netCDF and other things


Bill Hibbard wrote:

Actually, the cursor readout embedded in the display does
use the override unit. You can see it at about line 648 of in the setCursorStringVector() method.
But the format Kevin is complaining about, such as:

  SlantRange: xxx.xxxxx 1000.0 m
  Height: yyy.yyyyy 1000.0 m

looks like its using km as the Unit but just using the wrong
String for km, namely '1000.0 m'. I recall there's a way to
change the String for a Unit, but cannot recall or quickly
find it. Perhaps Steve can tell us.

Guess I should have check the code first. ;-)

Actually, now that I'm looking at the code, I see:

            if (overrideUnit != null && !overrideUnit.equals(rtunit) &&
                (!Unit.canConvert(rtunit, CommonUnit.secondsSinceTheEpoch) ||
                 rtunit.getAbsoluteUnit().equals(rtunit))) {
              dval[0] = (float)
                overrideUnit.toThis((double) dval[0], rtunit);
              r = new Real(real, dval[0], overrideUnit);

and in this case, overrideUnit.equals(rtunit), so this section of
code never gets called and it uses the rtunit (1000.0 m).  If the
check for equality is removed, it works.  Maybe this should be
changed to allow for this?

For now, when you create your RealTypes, use the cloned unit
instead of the one from parser.  From your previous note, change it

    { kilometer ="kilometer").clone("km"); }
    catch (ParseException P)
    { System.out.println("Parse exception: " + P); }

    r = RealType.getRealType("R", kilometer, null);
    h = RealType.getRealType("Height", kilometer, null);
    s = RealType.getRealType("SlantRange", kilometer, null);

This will not work if there is already a RealType defined with
the same name, but a compatible unit (not equal).  In that case,
the method above would work.  Confused yet? ;-)

Sorry for the bum steer.

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