[ncl-talk] Trouble with masking data for new file
Buzan, Jonathan
jbuzan at purdue.edu
Fri Apr 16 11:30:36 MDT 2021
Hi Adam,
That did it! It was related to the overwriting every line. Thanks!
Cheers,
-Jonathan
[cid:4BAF6E4E-BDA9-4DE0-9820-4F0E29A484F1]
On Apr 16, 2021, at 7:10 PM, Adam Phillips <asphilli at ucar.edu<mailto:asphilli at ucar.edu>> wrote:
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<mailto: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
<Screen Shot 2021-04-16 at 4.26.06 PM.png>
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:
<Screen Shot 2021-04-16 at 5.02.56 PM.png>
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:
<Screen Shot 2021-04-16 at 5.04.10 PM.png>
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<mailto: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/<http://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/c4495496/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2021-04-16 at 7.29.47 PM.png
Type: image/png
Size: 27902 bytes
Desc: Screen Shot 2021-04-16 at 7.29.47 PM.png
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210416/c4495496/attachment.png>
More information about the ncl-talk
mailing list