[ncl-talk] Problem on averaging variable

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Tue Jun 9 16:08:25 MDT 2020


It looks like your input data contains NaN's.  Otherwise you would probably
never see this.

> average_op_ncl :      dim_avg_n over dimension(s): lon
> (0)     min=nan   max=nan

In NCL, NaN's ara NaN's, not missing values.  Support for NaN's is not
clean.  If it was, we would not be having this conversation.  ;-)

There is more than one way to fix this.  Best practice IMO is to convert
all NaN's to missing values after reading input data, and before any other
calculations (except maybe for subsetting).  Please review NCL docs for
detecting, counting, and replacing NaN's.  In particular, see the
isnan_ieee function.

Depending on how much you care, you might also want to take a quick look at
the spatial and temporal distributions of NaN's in that model's file set.
NaN's are an anomaly.  They may or may not indicate a significant quality
problem in that data, something you might want to know about before further
efforts.


On Tue, Jun 9, 2020 at 3:41 PM Giorgio Graffino via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Dear NCL users,
> I have a weird issue on computing a simple avarage of a variable.
>
> I'm analysing a large subset of CMIP models to obtain density plots.
> However, there is a particular model I can't analyse: when I compute the
> average, all values in the variable becomes missing values. Here is the
> relevant snippet
>
> * printVarSummary(rho_9s_mask)*
> * printMinMax(rho_9s_mask,False) *
>
> *;; Create cross sections*
> * rho_9s_mask_ave = dim_avg_n_Wrap(rho_9s_mask,2)*
> * copy_VarCoords_1(rho_9s_mask,rho_9s_mask_ave)*
>
> * printVarSummary(rho_9s_mask_ave)*
> * printMinMax(rho_9s_mask_ave,False) *
>
> and here is what I obtain
>
> Variable: rho_9s_mask
> Type: float
> Total Size: 14493600 bytes
>            3623400 values
> Number of Dimensions: 3
> Dimensions and sizes:   [time | 165] x [lev | 61] x [lon | 360]
> Coordinates:
>            time: [181.25..60081.25]
>            lev: [   1..6525]
>            lon: [ 0..358.9818]
> Number Of Attributes: 1
>  _FillValue :  1e+20
> (0)     min=1020.5   max=1027.72
>
> Variable: rho_9s_mask_ave
> Type: float
> Total Size: 40260 bytes
>            10065 values
> Number of Dimensions: 2
> Dimensions and sizes:   [time | 165] x [lev | 61]
> Coordinates:
>            time: [181.25..60081.25]
>            lev: [   1..6525]
> Number Of Attributes: 2
>  _FillValue :  1e+20
>  average_op_ncl :      dim_avg_n over dimension(s): lon
> (0)     min=nan   max=nan
>
> This works for all models but one. I tried to use a different function for
> the average, but nothing changes. I also tried to compute the average on
> other dimensions: the problem occurs again when averaging on the lev
> coordinate, but it doesn't when averaging on the time coordinate. It seems
> that there is a problem in the coordinate, but everything looks alright in
> the variable before the averaging.
>
> Do you have any guess of what's wrong or any suggestion to help me?
>
> Thanks a lot,
> Giorgio
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200609/3111eccf/attachment.html>


More information about the ncl-talk mailing list