[ncl-talk] If statements and Fill_Values

Beáta Szabó-Takács szabo.b at czechglobe.cz
Fri Jan 10 02:21:00 MST 2020


Dear Karin and Barry,
I checked different ways to skip the _FillValues. Here is my brief script:

begin

  input = addfile("NetCDF_2017_07_18.nc","r")
  CL=input->cLayer1                                                        ;First cloud layer, its _FillValue is -9900
  CL1 = new((/5400/), typeof(CL), 1e20)
  CL2 = new((/5400/), typeof(CL), 1e20)
  CL3 = new((/5400/), typeof(CL), 1e20)
  CL4 = new((/5400/), typeof(CL), 1e20)

   do n=1,5399

             if(CL(n).eq.CL at _FillValue)then
                  continue
             else
                 CL1(n) = CL(n)
              end if

            if(all(ismissing(CL)))then
                   continue
           else
                  CL2(n) = CL(n)
           end if

            if(CL(n).ne.CL at _FillValue)then
                  CL3(n) = CL(n)
            end if

           if(.not.ismissing(CL(n)))then
                CL4(n) = CL(n)
           end if

   end do

   print(CL1(1:500))
   print(CL2(1:500))
   print(CL3(1:500))
   print(CL4(1:500))

end

Unfortunately, none of the if statements skip the _FillValues. I do not understand why.
Beata

From: ncl-talk [mailto:ncl-talk-bounces at ucar.edu] On Behalf Of Karin Meier-Fleischer via ncl-talk
Sent: Friday, January 10, 2020 9:26 AM
To: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] If statements and Fill_Values

Hi,

what about

if(all(ismissing(ratio_hr))) then
   continue
end if

-Karin
Am 10.01.20 um 09:17 schrieb Barry Lynn via ncl-talk:
Hi:

I will give it a try.

In the meantime, I am wondering why you suggest the ne, rather than the equal to with a continue and an else?

On Fri, Jan 10, 2020 at 9:52 AM Beáta Szabó-Takács <szabo.b at czechglobe.cz<mailto:szabo.b at czechglobe.cz>> wrote:
Dear Barry,
The continue will proceed directly to the next iteration. Try to skip the _FillValues by:

if(max(ratio_hr).ne.ratio_hr at _FillValue.and<mailto:ratio_hr).ne.ratio_hr at _FillValue.and>. min(ratio_hr).ne.ratio_hr at _FillValue)then<mailto:.ne.ratio_hr at _FillValue)then>
statement(s)
end if

I hope it solves your issue.
Kind regards,
Beata

From: ncl-talk [mailto:ncl-talk-bounces at ucar.edu<mailto:ncl-talk-bounces at ucar.edu>] On Behalf Of Barry Lynn via ncl-talk
Sent: Friday, January 10, 2020 7:40 AM
To: ncl-talk <ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>>
Subject: [ncl-talk] If statements and Fill_Values

Hi:

I am trying to skip a loop where all the numbers (min/max) are _FillValues.


min=9.96921e+36   max=9.96921e+36



However, I get this error, even though my if statement is checking this.



fatal:The result of the conditional expression yields a missing value. NCL can not determine branch, see ismissing function


  if (max(ratio_hr).eq.ratio_hr at _FillValue.and.min(ratio_hr).eq.ratio_hr at _FillValue)then<mailto:.eq.ratio_hr at _FillValue.and.min(ratio_hr).eq.ratio_hr at _FillValue)then>

   continue

  else

Is there someway around this?

Thank you
--
Barry H. Lynn, Ph.D
Senior Associate Scientist, Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525


--
Barry H. Lynn, Ph.D
Senior Associate Scientist, Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525



_______________________________________________

ncl-talk mailing list

ncl-talk at ucar.edu<mailto: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/20200110/f3f936fc/attachment.html>


More information about the ncl-talk mailing list