Re: [netcdf-java] Can I tell if a GridDatatype is "enhanced"?

Hi Jon,

Not very straight forward and there may be some loopholes I'm missing
that John can comment on when he returns.

If you call getVariable() on your GridDataype, you will get the backing
VariableDS. Call getEnhanceMode() on that and you'll get an
EnumSet<NetcdfDataset.Enhance>. If that Set contains
Enhance.ScaleMissing, the data you get back will have already had the
scale/offset/missing applied. If that set contains
Enhance.ScaleMissingDefer, you can directly use
VariableDS.convertScaleOffsetMissing() to convert the data.

VariableDs also implements VariableEnhance.enhance(Set<Enhance>) but the
comments say "DO NOT USE DIRECTLY. public by accident". I'll leave it to
John to explain that and comment on the possibility of exposing any of
this directly through the GridDatatype.

Ethan

On 2/8/2010 8:05 AM, Jonathan Blower wrote:
> Hi,
> 
> I'm writing a method along the lines of:
> 
> double[] extractDataFrom(GridDatatype grid);
> 
> where the GridDatatype is being passed to me by "foreign" code out of my
> control.  Do I have any way of telling whether the GridDatatype is
> "enhanced", i.e. whether scale/offset/missing attributes are
> automatically applied when I extract data?
> 
> And does it matter?  Can I program defensively to take care of both
> situations (enhanced and not enhanced)?  I'm worried that simply
> applying convertScaleOffsetMissing() to a value from an enhanced
> GridDatatype might actually apply the enhancements twice and hence give
> me the wrong answer.
> 
> Thanks,
> Jon



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