Hi Ethan,
Sorry to pester, but I'd like to tie a few ends up before I go away for
a while. Do you think the code below will work as I intend?
Cheers, Jon
-----Original Message-----
From: Jon Blower
Sent: 17 September 2010 20:35
To: 'Ethan Davis'
Cc: John Caron
Subject: RE: VariableDS.getOriginalVariable() in TDS
Hi Ethan,
OK, that's good to know, thanks. Do you think the following code will
work as a means to guarantee getting data values that are enhanced
exactly once?
NetcdfDataset nc = ...
boolean enhanced =
nc.getEnhanceMode().contains(Enhance.ScaleMissingDefer); // * See below
GridDatatype grid = ...
VariableDS enhancedVar = grid.getVariable();
Variable origVar = var.getOriginalVariable();
float val;
if (origVar == null) {
val = enhancedVar.read(...);
if (!enhanced) {
val = enhancedVar.convertScaleOffsetMissing(val);
}
} else {
val = origVar.read(...);
val = enhancedVar.convertScaleOffsetMissing(val);
}
* Is it safer to do contains(ScaleMissingDefer) or
!contains(ScaleMissing)?
Cheers, Jon
-----Original Message-----
From: Ethan Davis [mailto:address@hidden]
Sent: 17 September 2010 18:30
To: Jon Blower
Cc: John Caron
Subject: Re: VariableDS.getOriginalVariable() in TDS
Hi Jon,
Is there a way to get an "unenhanced", plain Variable
from a GridDatatype in THREDDS?
There is not a way to do this in a general way. In particular, variables
from FMRC datasets and other aggregations will not always (ever?) have a
single unenhanced variable behind them.
Getting the handling of enhancements "right" is going to take some
careful thinking and probably a hefty refactoring of the enhance mode
code as well as the whole stack of Variable/Dataset wrapping code.
We figure this will all come together for TDS 4.10 which we have planned
for sometime after the Singularity or the Mayan calendar ends, whichever
comes last. ;-)
All kidding aside, we will review the enhance mode code for TDS 4.3 but
it may be more than we can chew off for 4.3. And, frankly, access to
unenhanced data for aggregations and such may not be feasible.
Ethan
On 9/10/2010 6:39 AM, Jon Blower wrote:
Hi John and Ethan,
I'm porting my latest ncWMS enhancements (mainly simplifications) to
THREDDS-WMS. In order to avoid ambiguities and unintended behaviour
concerning dataset enhancements, I've started to use a formulation
like
this:
// Doesn't care about enhance mode used when opening the NetcdfDataset
float readData(GridDatatype grid)
{
VariableDS var = grid.getVariable();
Variable origVar = var.getOriginalVariable();
float val = readDataFromOriginalVariable(origVar);
val = var.convertScaleOffsetMissing(val);
return val;
}
In ncWMS this works fine and guarantees that we read "raw" values from
disk, and that the enhancements are applied exactly once. But in TDS,
origVar turns out to be null (I should have been prepared from this
from
the javadoc). Is there a way to get an "unenhanced", plain Variable
from a GridDatatype in THREDDS?
Cheers, Jon
--
Dr Jon Blower
Technical Director, Reading e-Science Centre
Environmental Systems Science Centre
University of Reading
Harry Pitt Building, 3 Earley Gate
Reading RG6 6AL. UK
Tel: +44 (0)118 378 5213
Fax: +44 (0)118 378 6413
address@hidden
http://www.nerc-essc.ac.uk/People/Staff/Blower_J.htm