Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Re: Why?

Hi Eugene,

> trying to convert the units for our variables? This is what the CDL file
> looks like before it's converted into netCDF:
> 
> netcdf taf {
>   dimensions:
>     Time = unlimited;
>   variables:
>     double Time(Time);
>     double MinTemp(Time);
>       MinTemp:long_name = "minimumTemperature";
>       MinTemp:units = "celsius";
>     double MaxTemp(Time);
>       MaxTemp:long_name = "maximumTemperature";
>       MaxTemp:units = "celsius";
>   data:
>       Time = 0, 10800, 21600, 32400, 43200, 54000, 64800, 75600, 86400,
>              97200, 108000, 118800, 129600, 140400, 151200, 162000;
>       MinTemp = NaN,NaN,37,23,30,32,NaN,30,31,31,31,31,18.2,21.1,NaN,NaN;
>       MaxTemp = NaN,20,25,29,29,26,22,20,18,18,21,25,24,NaN,NaN,NaN;
> }
> 
> The program throws an exception at this line:
> 
> predictedField = (FieldImpl)f.resample(validSet, Data.NEAREST_NEIGHBOR,
>                                        Data.INDEPENDENT);
> 
> This is what we get from printStackTrace():
> 
> visad.UnitException: Attempt to convert from unit "K" to unit "s"
>         at visad.DerivedUnit.toThis(DerivedUnit.java:653)
>         at visad.ScaledUnit.toThis(ScaledUnit.java:445)
>         at visad.OffsetUnit.toThis(OffsetUnit.java:338)
>         at visad.OffsetUnit.toThis(OffsetUnit.java:375)
>         at visad.Unit.toThis(Unit.java:437)
>         at visad.Unit.transformUnits(Unit.java:142)
>         at
> visad.CoordinateSystem.transformCoordinates(CoordinateSystem.java:334)
>         at visad.FlatField.resample(FlatField.java:3198)
>         at
> au.gov.bom.aifs.autotaf.DataRepresentation.FieldManipulation.interpolateProjection(FieldManipulation.java:206)
>         at
> au.gov.bom.aifs.autotaf.DataRepresentation.FieldManipulation.interpolateField(FieldManipulation.java:252)
>         at progTest.main(progTest.java:35)
> 
> If we remove all the units from our CDL file, it works fine. We've also
> tried using "kelvin" instead of "celsius" but ended up with the same
> results. We've been trying to find a way to fix this up but have come to a
> dead end. Can someone please help?

This Exception is being thrown when it tries to convert Units
from 'validSet' to the domain Set of FlatField 'f'.  I am not
an expert on CDL, but it looks like the domain of 'f' is
Time with Units 's' (for seconds).  From the UnitException
message I'd guess that 'validSet' must have Units 'K' (for
Kelvin).  That is, you are trying to resample a field over
a time domain to a set of temperature values.  Make sure that
'validSet' is a set of times with 's' Units.  You could do
a print of 'validSet' at this point to see if its Units are
'K'.

Please let me know if still have problems.

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

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690