NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi Gianluca- I'm sure Steve Emmerson will reply to your extension questions and indicate how they can be used with the netCDf adapter, but I have just a few comments: 1) salinity and viscosity are quantities that have units and are not units themselves. 2) m/s is supported already as is m^2/s^2. I've attached a test program that will parse a string and return a unit or indicate that the unit is not supported in VisAD (i.e., not in the default units data base). If the units are specified correctly in the netCDF file, then they should be parsed correctly by the data adapter. (see the next note for specifying them correctly) 3) The unit specification is case sensitive. m/s is not the same as M/S. Using the test program: java TestUnit m/s Unit = m.s-1 java TestUnit M/S Unit = 1000000.0 kg.m2.s-3.A-2 Don Murray > Gianluca wrote: > > Hi all, > 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? > > 2) I see that there are three unit constructors: ps( ), pn( ), px( ). > I must use this methods to add new unit? > > 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"))); ?? > > 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? > > 5) I have a variable named "sigma" that is no-dimensional. How could I > add to DefaultUnitsDB? > px("sigma", "null"); is good?? > > Ciao e Grazie, > Gianluca > > -- ************************************************************* Don Murray UCAR Unidata Program dmurray@xxxxxxxxxxxxxxxx P.O. Box 3000 (303) 497-8628 Boulder, CO 80307 http://www.unidata.ucar.edu/staff/donm *************************************************************
import visad.*; import visad.data.units.*; public class TestUnit { public static void main(String[] args) { if (args.length < 1) { System.out.println("Must supply unit string"); System.exit(0); } try { Unit unit = Parser.parse(args[0]); System.out.println("Unit = " + unit); } catch (Exception e) { System.out.println("Unknown unit"); } } }
visad
archives: