<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Please CC <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a> when following up with a question that was originally posted on ncl-talk, unless we ask you to take it offline.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thanks for the code, but I still can't debug this without having access to the data.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">This code was written to be used with WRF data, which I can't tell from your script if this is what you have.</div><div class="gmail_default" style="font-size:small"><br>When we ask for a "clean script", what we mean is a very minimal code that we can run to see if we can reproduce the error.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">In this case, the best thing to do is to write all the variables that are being passed to wrf_cape_3d to a NetCDF file, and then the clean script would only need to read these variables back in and call wrf_cape_3d.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">So, in your script, add the following code before you call wrf_cape_3d:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">system("rm <a href="http://wrfcapebug.nc">wrfcapebug.nc</a>")</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">fout = addfile("<a href="http://wrfcapebug.nc">wrfcapebug.nc</a>","c")</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">fout->level_ECMWF_3D = level_ECMWF_3D</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">fout->TK_decode      = TK_decode</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">fout->rv_levels      = rv_levels</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">fout->GPH_decode     = GPH_decode</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">fout->z2D_decode     = z2D_decode</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">fout->sp_decode      = sp_decode</font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">When you run the script, a NetCDF file called "<a href="http://wrfcapebug.nc">wrfcapebug.nc</a>" will get created that has the variables needed by wrf_cape_3d.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You can then send me the <a href="http://wrfcapebug.nc">wrfcapebug.nc</a> file (it's okay to send it just to me and not to <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>).</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The clean script would look like this:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">f = addfile("<a href="http://wrfcapebug.nc">wrfcapebug.nc</a>","r")</font></div><div class="gmail_default"><font face="monospace, monospace">level_ECMWF_3D = f->level_ECMWF_3D</font></div><div class="gmail_default"><font face="monospace, monospace">TK_decode      = f->TK_decode</font></div><div class="gmail_default"><font face="monospace, monospace">rv_levels      = f->rv_levels</font></div><div class="gmail_default"><font face="monospace, monospace">GPH_decode     = f->GPH_decode<span style="white-space:pre">     </span></font></div><div class="gmail_default"><font face="monospace, monospace">z2D_decode     = f->z2D_decode</font></div><div class="gmail_default"><font face="monospace, monospace">sp_decode      = f->sp_decode</font></div><div class="gmail_default"><font face="monospace, monospace">cape = wrf_cape_3d (100*level_ECMWF_3D,TK_decode,rv_levels,GPH_decode/9.5,abs(z2D_decode/9.8),sp_decode,False)</font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thanks,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 20, 2019 at 11:23 PM nafiseh pegahfar <<a href="mailto:pegahfar@inio.ac.ir">pegahfar@inio.ac.ir</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
        Sorry  taking up your time.</div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
        I can't join github.</div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
        Hence, I attached my code and the figure.</div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
        the problem is that "cape_1000minus925" is ranged between 
"min=77.92554515113014" and " max=3696.247648956266", 
while the figure shows NaN values. for example cape_1000minus925 at lat=20 
and lon=60 is NaN.</div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
        It would be highly appreciated if you help me in this issue.</div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
         </div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
        Variable: cape_1000minus925<br>
        Type: double<br>
        Total Size: 52488 bytes<br>
                    6561 
values<br>
        Number of Dimensions: 2<br>
        Dimensions and sizes:    [latitude | 81] x [longitude | 
81]<br>
        Coordinates:<br>
                    
latitude: [15.5..25.5]<br>
                    
longitude: [58.5..68.5]<br>
        Number Of Attributes: 1<br>
          _FillValue :    9.969209968386869e+36<br>
        (0)    min=77.92554515113014   
max=3696.247648956266<br>
        (0)    lat20_lon60_cape_diff=9.969209968386869e+36<br>
         </div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
         </div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
         </div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
         </div>
<div style="font-size:13.3333px;font-family:serif;color:rgb(0,0,0);font-weight:400;font-style:normal">
         </div>
<div style="font-family:serif;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">
        Best Regards<br>
        =================================<br>
        Nafiseh Pegahfar<br>
        Assistant Professor<br>
        Iranian National Institute for Oceanography and Atmospheric Science<br>
        (<a href="http://www.inio.ac.ir" target="_blank">http://www.inio.ac.ir</a>)<br>
        Phone: (0098)21- 66944873-5 Ext. 224<br>
        Fax: (0098)21- 66944869<br>
        Email: (<a href="mailto:pegahfar@inio.ac.ir" target="_blank">pegahfar@inio.ac.ir</a>)<br>
        (<a href="mailto:pegahfar@ut.ac.ir" target="_blank">pegahfar@ut.ac.ir</a>)<br>
        =================================<br>
        <br>
        <blockquote style="padding-right:0px;padding-left:5px;margin-left:5px;border-left:2px solid rgb(0,0,0);margin-right:0px">
                -----Original Message-----<br>
                From: Mary Haley <<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>><br>
                To: nafiseh pegahfar <<a href="mailto:pegahfar@inio.ac.ir" target="_blank">pegahfar@inio.ac.ir</a>><br>
                Cc: Ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
                Date: Mon, 14 Jan 2019 09:04:19 -0700<br>
                Subject: Re: [ncl-talk] nan value for cape function<br>
                <br>
                <div dir="ltr">
                        <div dir="ltr">
                                <div class="gmail_default" style="font-size:small">
                                         </div>
                                <div class="gmail_default" style="font-size:small">
                                        We cannot debug this problem with the information you've given us, 
because I don't know exactly how you are calling the routine.</div>
                                <div class="gmail_default" style="font-size:small">
                                         </div>
                                <div class="gmail_default" style="font-size:small">
                                        Please use our GitHub issues page to submit a bug report and provide a 
small, clean program that illustrates the error:</div>
                                <div class="gmail_default" style="font-size:small">
                                         </div>
                                <div class="gmail_default">
                                        <a href="https://github.com/NCAR/ncl/issues" target="_blank">
https://github.com/NCAR/ncl/issues</a></div>
                                <div class="gmail_default">
                                         </div>
                                <div class="gmail_default">
                                        Thanks,</div>
                                <div class="gmail_default">
                                         </div>
                                <div class="gmail_default">
                                        --Mary</div>
                                <div class="gmail_default">
                                         </div>
                        </div>
                </div>
                <br>
                <div class="gmail_quote">
                        <div dir="ltr">
                                On Thu, Jan 10, 2019 at 9:42 PM nafiseh pegahfar <<a href="mailto:pegahfar@inio.ac.ir" target="_blank">pegahfar@inio.ac.ir</a>> wrote:</div>
                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                                <div>
                                        <div>
                                                Hello,</div>
                                        <div>
                                                Thank you for your kindly attention.</div>
                                        <div>
                                                I checked and all units were correct as: </div>
                                        <div>
                                                <pre style="background-color:rgb(255,255,255);white-space:pre-wrap">level=925,00
TK=300.6299140816899
rv=0.008510922866573187
GPH=723.139880629395
z=0.7325572010323265
p=100078.4522848937</pre>
                                                <div>
                                                        while the NaN values still exist. The NaN values are occurred at 
places with rv<0.01.</div>
                                                <div>
                                                         </div>
                                        </div>
                                        <div>
                                                Best Regards<br>
                                                =================================<br>
                                                Nafiseh Pegahfar<br>
                                                Assistant Professor<br>
                                                Iranian National Institute for Oceanography and Atmospheric Science<br>
                                                (<a href="http://www.inio.ac.ir" target="_blank"> 
http://www.inio.ac.ir</a>)<br>
                                                Phone: (0098)21- 66944873-5 Ext. 224<br>
                                                Fax: (0098)21- 66944869<br>
                                                Email: (<a href="mailto:pegahfar@inio.ac.ir" target="_blank"> 
pegahfar@inio.ac.ir</a>)<br>
                                                (<a href="mailto:pegahfar@ut.ac.ir" target="_blank"> 
pegahfar@ut.ac.ir</a>)<br>
                                                =================================<br>
                                                <br>
                                                <blockquote style="padding-right:0px;padding-left:5px;margin-left:5px;border-left:2px solid rgb(0,0,0);margin-right:0px">
                                                        -----Original Message-----<br>
                                                        From: Mary Haley <<a href="mailto:haley@ucar.edu" target="_blank"> 
haley@ucar.edu</a>><br>
                                                        To: nafiseh pegahfar <<a href="mailto:pegahfar@inio.ac.ir" target="_blank">pegahfar@inio.ac.ir</a>><br>
                                                        Cc: "<a href="mailto:ncl-talk@ucar.edu" target="_blank"> 
ncl-talk@ucar.edu</a>" <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
                                                        Date: Thu, 10 Jan 2019 09:36:22 -0700<br>
                                                        Subject: Re: [ncl-talk] nan value for cape function<br>
                                                        <br>
                                                        <div dir="ltr">
                                                                <div dir="ltr">
                                                                        <div class="gmail_default" style="font-size:small">
                                                                                Hello,</div>
                                                                        <div class="gmail_default" style="font-size:small">
                                                                                 </div>
                                                                        <div class="gmail_default" style="font-size:small">
                                                                                I think you need to check your input units again.  You 
didn't indicate exactly how you are calling wrf_cape_3d, but if you read 
the documentation at:</div>
                                                                        <div class="gmail_default" style="font-size:small">
                                                                                 </div>
                                                                        <div class="gmail_default">
                                                                                <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/wrf_cape_3d.shtml" target="_blank">
http://www.ncl.ucar.edu/Document/Functions/Built-in/wrf_cape_3d.shtml</a>
</div>
                                                                        <div class="gmail_default">
                                                                                 </div>
                                                                        <div class="gmail_default">
                                                                                you will see that that the model pressure values need to be in 
units of Pa, while the units of  surface pressure must be hPa. I'm 
not sure why the function was written this way, but you need to make sure 
you have the correct units.</div>
                                                                        <div class="gmail_default">
                                                                                 </div>
                                                                        <div class="gmail_default">
                                                                                If you continue to have problems, please respond back to ncl-talk 
with this information. It would help if you could provide a short test 
program that shows the values you are inputting and the incorrect values 
that are coming from the function. Also, we need to know what version of NCL 
you're running. </div>
                                                                        <div class="gmail_default">
                                                                                 </div>
                                                                        <div class="gmail_default">
                                                                                Thanks,</div>
                                                                        <div class="gmail_default">
                                                                                 </div>
                                                                        <div class="gmail_default">
                                                                                --Mary</div>
                                                                        <div class="gmail_default">
                                                                                 </div>
                                                                </div>
                                                        </div>
                                                        <br>
                                                        <div class="gmail_quote">
                                                                <div dir="ltr">
                                                                        On Tue, Jan 8, 2019 at 9:23 PM nafiseh pegahfar <<a href="mailto:pegahfar@inio.ac.ir" target="_blank">pegahfar@inio.ac.ir</a> 
> wrote:</div>
                                                                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                                                                        <div>
                                                                                <div>
                                                                                        <pre style="white-space:pre-wrap">To whom it may concern,

I used "wrf_cape_3d" function to calculate Cape. for this aim I 
used 3D vand 
2D values. unfortunately in some points (based on lat/lon)  NaN value for 
cape is seen. I am sure that all data have correct units. Input values for a 




point is reported as below:

cape=9.969209968386869e+36

level=92500
TK=300.6299140816899
rv=0.008510922866573187
GPH=723.139880629395
z=0.7325572010323265
p=100078.4522848937
I think where rv value is less that 0.01, this nan value appears.
please help me to overcome to these nan values

</pre>
                                                                                </div>
                                                                                <div>
                                                                                        Best Regards<br>
                                                                                        =================================<br>
                                                                                        Nafiseh Pegahfar<br>
                                                                                        Assistant Professor<br>
                                                                                        Iranian National Institute for Oceanography and Atmospheric 
Science<br>
                                                                                        (<a href="http://www.inio.ac.ir" target="_blank"> 
http://www.inio.ac.ir</a>)<br>
                                                                                        Phone: (0098)21- 66944873-5 Ext. 224<br>
                                                                                        Fax: (0098)21- 66944869<br>
                                                                                        Email: (<a href="mailto:pegahfar@inio.ac.ir" target="_blank"> 
pegahfar@inio.ac.ir</a>)<br>
                                                                                        (<a href="mailto:pegahfar@ut.ac.ir" target="_blank"> 
pegahfar@ut.ac.ir</a>)<br>
                                                                                        =================================</div>
                                                                        </div>
                                                                        _______________________________________________<br>
                                                                        ncl-talk mailing list<br>
                                                                        <a href="mailto:ncl-talk@ucar.edu" target="_blank">
ncl-talk@ucar.edu</a><br>
                                                                        List instructions, subscriber options, unsubscribe:<br>
                                                                        <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">
http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote>
                                                        </div>
                                                </blockquote>
                                        </div>
                                        <div>
                                                 </div>
                                </div>
                        </blockquote>
                </div>
        </blockquote>
</div>
<div style="font-family:serif;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">
         </div>
</div>
</blockquote></div>