Re: Units problem

Hi Chet,

I'm not sure how you're printing the FlatField, but I did
find a bug in FlatField.toString() that could cause your
problem.  I am at the AMS Conference in Long Beach this
week and cannot update our source server, but did put the
fix at:

  ftp://hyde.ssec.wisc.edu/pub/incoming/FlatField.java

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html


On Mon, 10 Jan 2000, Eugene Tan wrote:

> We can't seem to convert some units properly. This is what we have:
> 
> (in a for loop to print out the original units)
> Units: 
> oldUnits: Cel
> oldUnits: Cel
> oldUnits: degrees_north
> 
> We then change all the Cel (celsius) units to Kelvin by doing this:
> 
> Unit[] newUnits = Unit.copyUnitsArray(oldUnits);
> Unit toUnit = SI.kelvin;
> 
> for (int i=0; i < oldUnits.length; i++) {
>     if (newUnits[i].toString().equals("Cel")) {
>         newUnits[i]=toUnit;
>     }
> }
> 
> Printing out the new units array:
> (in a for loop to print out the new units)
> Units: 
> newUnits: K
> newUnits: K
> newUnits: degrees_north
> 
> We then create a FlatField ie.
> 
> FlatField newField
>     new FlatField((FunctionType) field.getType(),
>                 field.getDomainSet(),
>                 null, 
>                 null,
>                 field.getRangeSets(),
>                 newUnits);
> 
> When I printed out the contents of newField, this is the output I get:
> Component: 0    Type: MinTemp   Value: NaN      Units: Cel
> Component: 1    Type: MaxTemp   Value: NaN      Units: Cel
> Component: 2    Type: WindDir   Value: NaN      Units: degrees_north
> 
> which is wrong. We want to convert the units for Component 0 & 1 to
> Kelvin but it keeps returning "Cel". Can anyone identify what we're doing
> wrong please?
> 
> Eug.
> 
>    _--_|\     Eugene Tan <E.Tan@xxxxxxxxxx>
>   /      \    AutoTAF Project Developer 
>   \_.--.*/    Bureau of Meteorology, Melbourne, VIC 3001, Australia
>         v     Telephone: +613 9669 4652
> 
> 
> 


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