[ncl-talk] missing value and if condition
Dennis Shea
shea at ucar.edu
Tue May 7 15:16:43 MDT 2019
Virtually *ALL interpreted languages *[NCL, Python, Matlab, GrADS, ...] are
'slow'. This is often noted for large multiple do loop cases.
The key in any of these languages is to use the utilities:
; check entire array
if (*any*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/any.shtml>(*ismissing*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ismissing.shtml>(RH)))
then
print("RH: _FillValue present skip processing")
else
' ...
end if
---
Some prefer the .not. operator before the *any*
if (*.not.* *any*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/any.shtml>(*ismissing*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ismissing.shtml>(RH)))
then
...
else
print("RH: _FillValue present skip processing"
end if
---
; check each temporal intex
do nt=0,ntim-1
if (*any*(*ismissing*(RH(*nt*,:,:,:)))) then ;
RH(time,level,lt,lon)
print("RH: _FillValue present skip processing")
else
' ...
end if
...
end do
On Tue, May 7, 2019 at 2:43 PM Anahita Amiri Farahani <aamir003 at ucr.edu>
wrote:
> Hi all,
>
> I am trying to use if condition in ncl for my case but apparently ncl is
> really slow when the loops are large, do you have any suggestions to modify
> this code:
>
> do i=0,419
> do j=0,95
> do k=0,143
>
> if (ismissing(RH_1(i,j,k))) then
>
> print("Your data is missing. Cannot create plot.")
>
> else
>
> print("You can plot.")
>
> end if
> end do
> end do
> end do
>
> Thanks,
> Ana
> _______________________________________________
> 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/20190507/2fc78ca2/attachment.html>
More information about the ncl-talk
mailing list