Re: Questions about VisAD units.

Gianluca,

>Date: Sun, 20 May 2001 23:31:04 +0200
>From: "Gianluca" <gianlucky@xxxxxxxxx>
>Organization: ?
>To: <visad-list@xxxxxxxxxxxxx>
>Subject: Questions about VisAD units.
>Keywords: 200105202133.f4KLXSp29605

The above message contained the following:

>           I have some questions about VisAD units.
> I have some oceanographic's model output in netCDF files, and I will
> want to visualize them using SpreadSheet. The problem is that some
> oceanographic units (as salinity, viscosity, ect.) are not present in
> VisAD DefaultUnitsDB.class, and so I have some question to you.
> 
> 1) Could I add new units to the DefaultUnitsDB?

You could add units to DefaultUnitsDB or create a class that
incorporates both DefaultUnitsDB and a local unit database into a single
UnitsDB interface.

> 2) I see that there are three unit constructors: ps( ), pn( ), px( ). I
> must use this methods to add new unit?

Those methods are "protected" and shouldn't be used.  Instead, you
should use the putName(...) and putSymbol(...) methods of UnitsDB.

> 3) For example, one of my variable is U (velocity) who has unit "m/s",
> does VisAD know that it has to take "m" and divide for "s", or I must
> create a unit "m/s" with, for example:
>                     px( "m/s", get("m").divide(get("s"))); ??

The method visad.data.units.Parser.parse(String) can already decode the
string "m/s" -- you don't need to add that unit.

> 4) extending 3). Other unit is "m^2/s^2". I have to write "m2/s2" or
> "m^2/s^2" when I make the netCDF file?

The unit parser can correctly decode either string:

    ~/java/visad/visad/data: java visad.data.units.UnitParser
    Enter a unit specification or ^D to quit: m2/s2
    unit = m2.s-2
    definition = m2.s-2
    Enter a unit specification or ^D to quit: m^2/s^2
    unit = m2.s-2
    definition = m2.s-2
    Enter a unit specification or ^D to quit: ^D

I suggest that you not use the "^" character because it is non-standard.

> 5) I have a variable named "sigma" that is no-dimensional. How could I
> add to DefaultUnitsDB?
>                     px("sigma", "null");  is good??

The following will add the unit "sigma" as a non-dimensional unit 1 to
the default unit database:

    visad.data.units.DefaultUnitsDB.putName(
        "sigma", visad.CommonUnit.dimensionless)

Other units are possible:

    visad.data.units.DefaultUnitsDB.putName(
        "PSU", new visad.data.units.ScaledUnit(.001))

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


  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: