Re: elevation becomes altitude

John,

>Date: Tue, 17 Sep 2002 12:00:45 -0700
>From: "John J Brecht" <john.brecht@xxxxxxx>
>Organization: SRI
>To: visad-list@xxxxxxxxxxxxx
>Subject: Re: elevation becomes altitude
>Keywords: 200209171901.g8HJ17106917

The above message contained the following:

> That sounds like the solution I'm looking for.  I see these two methods 
> in the API docs:
> 
> QuantityDB add(java.lang.String[] definitions, java.lang.String[] aliases)
>           Adds the given quantities and aliases to the database.
>          
> void add(java.lang.String name, java.lang.String unitSpec)
>           Adds a quantity to the database given a name and a display 
> unit specification.
> 
> I take it I should use the first one, correct?

It sounds like you want to create your own Plain instance that uses a
different quantity database.  I would try to avoid this because I think
it might be more work than is necessary.

> I also want to keep my 
> temperature units as Celsius or Farenheit rather than have them 
> converted to Kelvin.  Can I accomplish this in the same way?

Plain won't change the units used by the incoming data.  If the data in
the dataset is in degrees Celsius, then a FlatField created from that
data will also have degrees Celsius.  The default unit of the RealType,
however, will be that of the quantity in the netCDF quantity database.

If you want to display a given quantity in a given unit, then you should
invoke ScalarMap.setOverrideUnit(Unit) on the relevant ScalarMap.

Similarly, if you want to override the name of a RealType (e.g. you want
"Elevation" rather than "Altitude"), then invoke RealType.alias(String)
on the relevant RealType.

> Is the 
> overall way to do this to call StandardQuantityDB.instance(), use the 
> add() methods to modify it, and then initialize my Plain  object with 
> the custom QuantityDB?  E.g:
> 
> StandardQuantityDB qdb = StandardQuantityDB.instance();
> String[] definitions =  new String[] {"Elevation", "m", Temperature", 
> "degF"};
> String[] aliases = new String[] {"Elevation", "Temperature"};
> QuantityDB myQdb = qdb.add(definitions, aliases);
> Plain saver = new Plain(myQdb);

You can try this.  I don't know if it will work.

> When should the other add method be used?

It doesn't matter.  The array method is just a convenience method.

> Why does one add method 
> return a new QuantityDB while the other operates on the existing one?

I probably had a good reason at the time, but it eludes me now.

Regards,
Steve Emmerson   <http://www.unidata.ucar.edu>