[ncl-talk] Help
Arun Kumar Dwivedi
dwivedi.arunkumar at gmail.com
Fri Aug 4 03:05:37 MDT 2017
Thank you all. It solved my problems.
Thanks & Regards
Arun Kumar Dwivedi,
On Tue, Aug 1, 2017 at 8:27 PM, Dennis Shea <shea at ucar.edu> wrote:
> There can't be a function for everything.
>
> A generalization of Guido's suggestion
>
> X = where(x.ne.0, x, x at _FillValue)
> xavg = dim_avg_n_Wrap(X, nDim) ; read documentation
> printVarSummary(xavg)
> printMinMax(xavg, 0)
> delete(X)
>
> or, less clear but without a temporary array
>
> xavg = dim_avg_n_Wrap(where(x.ne.0, x, x at _FillValue), nDim)
> printVarSummary(xavg)
> printMinMax(xavg, 0)
>
> On Tue, Aug 1, 2017 at 8:47 AM, Guido Cioni <guidocioni at gmail.com> wrote:
>
>> No, there is officially no function, but you can define a new one that
>> does the job pretty well.
>>
>> Here is the prototype that goes before the program "begin".
>>
>> function avg_zeros(x:numeric)
>> ; compute average not considering zeros,
>> ; --> in: rain rate
>> ; <-- out: average rain rate
>> local N
>> begin
>> N=num(x .ne. 0)
>> return(sum(x)/ N)
>> end
>>
>> Example of a function call
>>
>> rain=avg_zeros(ts->precp_r)
>>
>> Cheers
>>
>> On 1. Aug 2017, at 08:32, Arun Kumar Dwivedi <dwivedi.arunkumar at gmail.com>
>> wrote:
>>
>> Hello All,
>>
>> In NCL ,how to calculate average of any array or data while ignoring all
>> the zeros
>> If there is any command or function, kindly let me know.
>>
>> Thanks & Regards
>> Arun Kumar Dwivedi,
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>> Guido Cioni
>> http://guidocioni.altervista.org
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170804/a9217731/attachment.html
More information about the ncl-talk
mailing list