<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Adam,
<div class=""><br class="">
</div>
<div class="">That did it! It was related to the overwriting every line. Thanks!</div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class="">-Jonathan</div>
<div class=""><br class="">
</div>
<div class=""><img apple-inline="yes" id="B761C5A0-D9D8-4EEC-A69D-0B3C0E08A84D" src="cid:4BAF6E4E-BDA9-4DE0-9820-4F0E29A484F1" class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Apr 16, 2021, at 7:10 PM, Adam Phillips <<a href="mailto:asphilli@ucar.edu" class="">asphilli@ucar.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hi Jonathan,
<div class="">I think the issue is related to your last set of where calls:</div>
<div class="">
<div class="">cntrycodes_regionALL = where(cntrycodes_region01.eq.1,1,cntrycodes_regionALL)</div>
<div class="">cntrycodes_regionALL = where(cntrycodes_region02.eq.2,2,cntrycodes_regionALL)</div>
<div class="">cntrycodes_regionALL = where(cntrycodes_region03.eq.3,3,cntrycodes_regionALL)</div>
</div>
<div class=""><br class="">
</div>
<div class="">Running small tests here, each call is likely overwriting the cntrycodes_regionALL array on each line. This is one of those situations where the coding looks right (to me at least), but where is behaving differently than I would expect. I think
this has to do with how the where function interprets areas set to _FillValue. Try changing the above lines to this:</div>
<div class="">
<div class="">cntrycodes_regionALL = where(ismissing(cntrycodes_regionALL).and.cntrycodes_region01.eq.1,1,cntrycodes_regionALL)</div>
<div class="">
<div class="">cntrycodes_regionALL = where(ismissing(cntrycodes_regionALL).and.cntrycodes_region02.eq.2,2,cntrycodes_regionALL)</div>
</div>
<div class="">
<div class="">cntrycodes_regionALL = where(ismissing(cntrycodes_regionALL).and.cntrycodes_region03.eq.3,3,cntrycodes_regionALL)</div>
<div class=""></div>
</div>
<div class="">(and make sure cntrcodes_regionALL has a _FillValue attribute set)..</div>
<div class=""></div>
</div>
<div class=""><br class="">
</div>
<div class="">Let ncl-talk know if that doesn't work.</div>
<div class="">Adam</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Fri, Apr 16, 2021 at 9:05 AM Buzan, Jonathan via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank" class="">ncl-talk@mailman.ucar.edu</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="">Hi NCL-Talk,
<div class=""><br class="">
</div>
<div class="">I have something conceptually wrong in my head with NCL.</div>
<div class=""><br class="">
</div>
<div class="">I am attempting to take a .nc file with countries, and map them onto regions.</div>
<div class=""><br class="">
</div>
<div class="">Country Map</div>
<div class=""><br class="">
</div>
<div class=""><span id="cid:178db6c25bc55e4f0bf1"><Screen Shot 2021-04-16 at 4.26.06 PM.png></span></div>
<div class=""><br class="">
</div>
<div class=""><span style="white-space:pre-wrap" class=""></span></div>
<div class=""><br class="">
</div>
<div class="">I use:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">cntrycodes!0 = "lat"</div>
<div class="">cntrycodes&lat = lat</div>
<div class="">cntrycodes!1 = "lon"</div>
<div class="">cntrycodes&lon = lon</div>
<div class="">cntrycodes@long_name = "Country Codes"</div>
<div class="">cntrycodes@missing_value = cntrycodes@_FillValue</div>
</div>
<div class="">…</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">cntrycodes_region04 = where(cntrycodes.eq.7,4,cntrycodes_region04)</div>
<div class="">cntrycodes_region04 = where(cntrycodes.eq.10,4,cntrycodes_region04)</div>
<div class="">cntrycodes_region04 = where(cntrycodes.eq.13,4,cntrycodes_region04)</div>
</div>
<div class="">…</div>
<div class="">
<div class="">cntrycodes_region04 = where(cntrycodes.eq.145,4,cntrycodes_region04)</div>
<div class="">cntrycodes_region04 = where(cntrycodes.eq.152,4,cntrycodes_region04)</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I get:</div>
<div class=""><span id="cid:178db6c25bcba22cfa12"><Screen Shot 2021-04-16 at 5.02.56 PM.png></span></div>
<div class=""><br class="">
</div>
<div class="">I do this for 16 regions.</div>
<div class="">Then I try to put it together:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">cntrycodes_regionALL = where(cntrycodes_region01.eq.1,1,cntrycodes_regionALL)</div>
<div class="">cntrycodes_regionALL = where(cntrycodes_region02.eq.2,2,cntrycodes_regionALL)</div>
<div class="">cntrycodes_regionALL = where(cntrycodes_region03.eq.3,3,cntrycodes_regionALL)</div>
</div>
<div class="">…</div>
<div class="">
<div class="">cntrycodes_regionALL = where(cntrycodes_region15.eq.15,15,cntrycodes_regionALL)</div>
<div class="">cntrycodes_regionALL = where(cntrycodes_region16.eq.16,16,cntrycodes_regionALL)</div>
</div>
<div class=""><br class="">
</div>
<div class="">And I get:</div>
<div class=""><span id="cid:178db6c25bc23936be53"><Screen Shot 2021-04-16 at 5.04.10 PM.png></span></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I am not sure what I am doing wrong. But I have a feeling it is with how I am using the where function.</div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class="">-Jonathan</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""></div>
</div>
_______________________________________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank" class="">ncl-talk@mailman.ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote>
</div>
<br clear="all" class="">
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">
<div class=""><span class=""><font color="#888888" class="">Adam Phillips <br class="">
</font></span></div>
<span class=""><font color="#888888" class="">Associate Scientist, </font></span><span class=""><font color="#888888" class="">Climate and Global Dynamics Laboratory, NCAR<br class="">
</font></span></div>
</div>
<div class=""><span class=""><font color="#888888" class=""><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank" class="">www.cgd.ucar.edu/staff/asphilli/</a>
</font></span><span class=""><font color="#888888" class="">303-497-1726 </font></span></div>
<span class=""><font color="#888888" class=""></font></span>
<div class="">
<div class=""><span class=""><font color="#888888" class=""><br class="">
</font></span>
<div class=""><span class=""><font color="#888888" class=""><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank" class=""></a></font></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>