[ncl-talk] Putting in non-zeroes, getting back zeroes.

Mary Haley haley at ucar.edu
Wed Dec 7 09:53:14 MST 2016


Barry,

You have a couple of bugs in your code:

First, I'm not sure if this is a bug, but you have:

    xlat_m = xlat2d_m(:,nx/2)
    xlon_m = xlon2d_m(nx/2,:)

I think you meant to do:

    xlat_m = xlat2d_m(:,nx/2)
    xlon_m = xlon2d_m(ny/2,:)   ; note the "ny/2"

Second, and this is a very subtle bug, you have:

   rscan = (/2, 1.0, 0.2/)
   rscan = (/1/)

What's happening is that you are first setting rscan to an array of three
elements. Then, you set rscan to 1, but what this is doing is keeping the
original array of three elements, and setting them all to 1. You are
effectively passing rscan = (/1,1,1/) to the function, which apparently
doesn't work. If you want rscan to be a scalar of value 1, you either need
to use:

rscan := 1    ;  ":=" effectively removes the "old" rscan
              ; and creates a new one with just 1 element.

or simply comment out the first line:

; rscan = (/2, 1.0, 0.2/)

This is why clean code is so important!  I didn't notice this bug at first
until I completely stripped your code bare so that it only had the absolute
required code I needed for doing the calculation. I noticed it started
working when I did that, so I had to go back and see what was different
between your code and the stripped down code. I've attached the stripped
down code so you can see what this looks like. Note that I removed a bunch
of "new" statements. You don't need these.

When you have a bunch of commented out code, you have to be very careful
that you are commenting out *everything* that you don't need, otherwise it
becomes confusing what is actually happening in the script.

If you continue to have problems with scripts, please send us *clean*
scripts that we can easily look at. Otherwise, it's very time-consuming to
go through all the commented and uncommented code to figure out what's
happening.

Thanks,

--Mary


On Tue, Dec 6, 2016 at 1:13 PM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Hi:
>
> I am trying to interpolate station observations to a grid, but getting
> back all zeroes.
>
> http://www.ncl.ucar.edu/Document/Functions/Contributed/obj_
> anal_ic_Wrap.shtml
>
> I have checked that the three arrays for lat, lon, and obs are filled, as
> well as the grid itself.
>
> Thank you for your suggestions.
>
> Barry Lynn
> P.S. I will add mapping functions next...
> P.P.S: I cannot attach the xlat,xlon file, which are xlat and xlon files
> for the northeastern US because they are 4.5 MB, and 1.5 mb is the limit.
>
> --
> Barry H. Lynn, Ph.D
> Senior 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
> US 914 432 3108
>
> _______________________________________________
> 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/20161207/7d43bad0/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: map_obs_bare.ncl
Type: application/octet-stream
Size: 1452 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161207/7d43bad0/attachment.obj 


More information about the ncl-talk mailing list