Re: decimalPlaces leading to loss of data

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Nov 10 2009 - 17:08:04 MST

*You* are not using integers *but* the underlying code is. Note after

xTmp = x*shift ;===> xTmp = -999.05

there is
  
iTmp = floattointeger(xTmp) ; iTmp = -999
[iTmp@_FillValue=-999]

It turns out that because iTmp was not explicitly defined prior to
the 'floattointeger' , the result used the default _FillValue
for integer type which is -999, the _FillValue was propogated
back to the

    xTmp = iTmp/shift

Since 'xTmp' already had a _FillValue= 1e20, NCL converted the

-999 to 1e20.
======================
As solution for right now:

data_all_f = doubletofloat(fdata->$var$)
saveFill = data_all_f@_FillValue
data_all_f@_FillValue = -9999.

data_all = decimalPlaces(data_all_f,2,True)
data_all_f@_FillValue = saveFIll

===========================

Bridget Thrasher wrote:
> Rick, I saw that, too, but I'm running the latest version, 5.1.1, so
> I'm hoping the issue noted on that page is in fact gone.
>
> Dennis, I'm not sure I understand how that relates to my example since
> I'm not using any integers, but simply rounding my floats to 2 decimal
> places. None of my values is anywhere close to -999, and my fill value
> is 1e20.
>
> Either way, I got around the problem by using
> round(data_all*100.,0)/100. But it would be nice to know why
> decimalPlaces didn't give the same result.
>
> On Tue, Nov 10, 2009 at 9:10 AM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>> wrote:
>
> I see the issue. I generated 100,00 random numbers and was able
> to get one value that failed.
>
> In a nutshell,
>
> x = -9.9995
> shift = 100.
> xTmp = x*shift ;===> xTmp = -999.05
>
> iTmp = floattointeger(xTmp) ; iTmp = -999
>
> -999 is the default missing value for "floattointeger"
>
>
>
>
> Rick Brownrigg wrote:
>
> Hi Bridget,
>
> Are you by chance running an earlier version of NCL? I
> noticed a comment in the docs for "decimalPlaces" that
> this function does not work correctly for NCL v. 5.0.0 and
> earlier, if the data contain negative numbers. It does not
> spell out how "does not work" manifests.
>
> http://www.ncl.ucar.edu/Document/Functions/Contributed/decimalPlaces.shtml
>
> Rick
>
> On Nov 9, 2009, at 4:18 PM, Bridget Thrasher wrote:
>
> I'm running a complete array (no missing values) through
> the decimalPlaces function and am getting an output array
> that contains missing values. Is this correct?
>
> data_all_f = doubletofloat(fdata->$var$)
> printVarSummary(data_all_f)
> print(num(ismissing(data_all_f)))
> printMinMax(data_all_f,True)
> data_all = decimalPlaces(data_all_f,2,True)
> printVarSummary(data_all)
> print(num(ismissing(data_all)))
> printMinMax(data_all,True)
>
>
> Variable: data_all_f
> Type: float
> Total Size: 116640000 bytes
> 29160000 values
> Number of Dimensions: 3
> Dimensions and sizes: [1800] x [90] x [180]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 1e+20
> (0) 0
> (0) (0) min=-73.7207 max=45.3083
>
>
> Variable: data_all
> Type: float
> Total Size: 116640000 bytes
> 29160000 values
> Number of Dimensions: 3
> Dimensions and sizes: [1800] x [90] x [180]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 1e+20
> (0) 2147
> (0) (0) min=-73.72 max=45.31
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Nov 10 17:07:43 2009

This archive was generated by hypermail 2.1.8 : Wed Nov 11 2009 - 12:48:56 MST