[ncl-talk] Trouble with masking data for new file

Adam Phillips asphilli at ucar.edu
Fri Apr 16 11:10:03 MDT 2021


Hi Jonathan,
I think the issue is related to your last set of where calls:
cntrycodes_regionALL =
where(cntrycodes_region01.eq.1,1,cntrycodes_regionALL)
cntrycodes_regionALL =
where(cntrycodes_region02.eq.2,2,cntrycodes_regionALL)
cntrycodes_regionALL =
where(cntrycodes_region03.eq.3,3,cntrycodes_regionALL)

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:
cntrycodes_regionALL =
where(ismissing(cntrycodes_regionALL).and.cntrycodes_region01.eq.1,1,cntrycodes_regionALL)
cntrycodes_regionALL =
where(ismissing(cntrycodes_regionALL).and.cntrycodes_region02.eq.2,2,cntrycodes_regionALL)
cntrycodes_regionALL =
where(ismissing(cntrycodes_regionALL).and.cntrycodes_region03.eq.3,3,cntrycodes_regionALL)
(and make sure cntrcodes_regionALL has a _FillValue attribute set)..

Let ncl-talk know if that doesn't work.
Adam




On Fri, Apr 16, 2021 at 9:05 AM Buzan, Jonathan via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Hi NCL-Talk,
>
> I have something conceptually wrong in my head with NCL.
>
> I am attempting to take a .nc file with countries, and map them onto
> regions.
>
> Country Map
>
>
>
> I use:
>
> cntrycodes!0 = "lat"
> cntrycodes&lat = lat
> cntrycodes!1 = "lon"
> cntrycodes&lon = lon
> cntrycodes at long_name = "Country Codes"
> cntrycodes at missing_value = cntrycodes at _FillValue
>>
>
> cntrycodes_region04 = where(cntrycodes.eq.7,4,cntrycodes_region04)
> cntrycodes_region04 = where(cntrycodes.eq.10,4,cntrycodes_region04)
> cntrycodes_region04 = where(cntrycodes.eq.13,4,cntrycodes_region04)
>> cntrycodes_region04 = where(cntrycodes.eq.145,4,cntrycodes_region04)
> cntrycodes_region04 = where(cntrycodes.eq.152,4,cntrycodes_region04)
>
>
> I get:
>
> I do this for 16 regions.
> Then I try to put it together:
>
> cntrycodes_regionALL =
> where(cntrycodes_region01.eq.1,1,cntrycodes_regionALL)
> cntrycodes_regionALL =
> where(cntrycodes_region02.eq.2,2,cntrycodes_regionALL)
> cntrycodes_regionALL =
> where(cntrycodes_region03.eq.3,3,cntrycodes_regionALL)
>> cntrycodes_regionALL =
> where(cntrycodes_region15.eq.15,15,cntrycodes_regionALL)
> cntrycodes_regionALL =
> where(cntrycodes_region16.eq.16,16,cntrycodes_regionALL)
>
> And I get:
>
>
> I am not sure what I am doing wrong. But I have a feeling it is with how I
> am using the where function.
>
> Cheers,
> -Jonathan
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk



-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210416/701738a1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2021-04-16 at 4.26.06 PM.png
Type: image/png
Size: 37590 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210416/701738a1/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2021-04-16 at 5.02.56 PM.png
Type: image/png
Size: 17198 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210416/701738a1/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2021-04-16 at 5.04.10 PM.png
Type: image/png
Size: 13174 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210416/701738a1/attachment-0002.png>


More information about the ncl-talk mailing list