<div dir="ltr"><div class="gmail_default" style="font-size:small">Lin,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">In order to properly debug this, I would need to have a *clean* script and your input data files. I haven NO idea what your data looks like, how it is ordered, what missing values it has, etc, so I have no way of telling you to create the mask array.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">But, yes, you could be very right that the issue is that you are subscripting "hlat", and not subscripting "hsic" in the way.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">If latitude and longitude are indeed coordinate arrays of hsic, then you should not read latitude and longitude separately off the file, because they are attached to hsic. And, if you subscript hsic, the latitude/longitude coordinate arrays will automatically be subscripted in the same way.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">So, you really only need this:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace"> hsic = fi->sic({-90.:-50.},:)</font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">and then DstGridLat and DstGridLon should be set as follows, by using the latitude and longitude coordinate arrays that are attached to hsic:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace"> Opt@DstGridLat = hsic&latitude</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace"> Opt@DstGridLon = hsic&longitude</font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I do not know how the internals of the source and destination masking work, but if you google "ESMF regrid masking" you will find this short description:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><div class="gmail_default"><ul style="font-size:small"><li>Destination masking: Allow some points (usually representative of land masses) of the destination grid to not be included in the interpolation.<br><br></li><li>Source masking: Allow some points of the source grid to not be included in the interpolation.</li></ul><div style="font-size:small">So, yes, the destination mask should be working, but it is imperative that you apply the correct mask! You simply want an array of 0s and 1s, with 0s at the locations that you *don't* want regridding to occur.</div><div style="font-size:small"><br></div><div style="font-size:small">If you look at example #19 at:</div><div style="font-size:small"><br></div><div><a href="http://www.ncl.ucar.edu/Applications/ESMF.shtml#ex19">http://www.ncl.ucar.edu/Applications/ESMF.shtml#ex19</a><br></div><div><br></div><div>You will see that the regridding works with a destination grid that had a mask array for land and ocean. This was convenient because the data came with a separate mask array on the file with 0s and 1s.</div><div><br></div><div>Also look at example #28 at:</div><div><br></div><div><a href="http://www.ncl.ucar.edu/Applications/ESMF.shtml#ex28">http://www.ncl.ucar.edu/Applications/ESMF.shtml#ex28</a><br></div><div><br></div><div>This one creates a mask array simply by checking the variable for missing values:</div><div><br></div><div> Opt@DstMask2D = where(ismissing(POP_var),0,1)<br></div><div><br></div><div>Sometimes, if I have doubt that the missing values of my data are correct, I will use the gsn_coordinates procedure to add points at locations where my data is missing and not missing.</div><div><br></div><div>See the last frame of example 7 at:</div><div><br></div><div><a href="http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml#ex7">http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml#ex7</a><br></div><div><br></div><div>The way this works is you first create a contour plot of "hsic", for example:</div><div><br></div><div><pre> res = True
res@cnFillOn = True
res@gsnDraw = False
res@gsnFrame = False
plot = gsn_csm_contour_map(wks,hsic,res)</pre><pre>and then you can add points for the latitude/longitude locations, coloring
the missing and non-missing points differently:</pre><pre>;---Draw the lat/lon locations as markers
mkres = True
mkres@gsMarkerIndex = 16
mkres@gsMarkerSizeF = 3
mkres@gsnCoordsNonMissingColor = "Black"
mkres@gsnCoordsMissingColor = "red"
gsn_coordinates(wks,plot,hsic,mkres)</pre></div><div><br></div><div>--Mary</div><div><br></div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 20, 2016 at 2:39 AM, 林祥 <span dir="ltr"><<a href="mailto:xianglin72@icloud.com" target="_blank">xianglin72@icloud.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>Hi,Mary</div><div><br></div><div> I found the problem might be in the inconsistence between “hsic" and “hlat”</div><span class=""><div><br></div><div> <span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures"> fi = </span><span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures;color:rgb(52,187,199)">addfile</span><span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">(</span><span style="color:rgb(195,55,32);font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">"HadISST_ice.nc"</span><span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">,</span><span style="color:rgb(195,55,32);font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">"r”</span><span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures"><wbr>) </span></div></span><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> hsic = fi->sic </span>; it is global </div></div></blockquote></div></div></blockquote><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> hlon = fi->longitude</span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> hlat = fi->latitude(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(206,121,36)">{</span><span style="font-variant-ligatures:no-common-ligatures">-</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">90</span><span style="font-variant-ligatures:no-common-ligatures">.:-</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">50</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(206,121,36)">}</span><span style="font-variant-ligatures:no-common-ligatures">) ; it is regional</span></div></div></blockquote></div></div></blockquote><div><br></div> However, the same scripts with such error can not run in mac, while it run well in my Linux and output figure & nc files although error existed in masking.<div><div> <div> </div><div><br></div><div>Thank</div><div><br></div><div><br></div><div>Lin</div><div><br></div><br><div><blockquote type="cite"><span class=""><div>在 2016年12月20日,06:06,Mary Haley <<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>> 写道:</div><br class="m_-3490622176397403470Apple-interchange-newline"></span><div><div class="h5"><div><div dir="ltr"><div class="gmail_default" style="font-size:small">Lin,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I'm confused by the comment on this line:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><div class="gmail_default"> Opt@SrcGridMask = where(.not.ismissing(thetao(0,<wbr>:,:)),1,0) ; thetao is the source grids, with data zero in land, no missing </div><div><br></div><div>When you say "data zero in land, no missing", do you mean that the "thetao" variable is equal to 0 whenever it is over land, and that it contains no missing values? If so, then using "ismissing" on a variable that doesn't contain missing values is never going to return True.</div><div><br></div><div>Instead, you want something like this:</div><div><br></div><div><div style="font-size:12.8px"> Opt@SrcGridMask = where(thetao.ne.0,1,0)</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">This creates a mask array that is equal to 1 at locations where thetao is NOT equal to 0, and equal to 0 at locations where thetao is equal to 0. </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Just as an example, this line should produce the exact same mask array:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div style="font-size:small"><div style="font-size:12.8px"> Opt@SrcGridMask = where(thetao.eq.0,0,1)</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">--Mary</div><div style="font-size:12.8px"><br></div><div><br></div></div></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 19, 2016 at 11:53 AM, 林祥 <span dir="ltr"><<a href="mailto:xianglin72@icloud.com" target="_blank">xianglin72@icloud.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi, all<div><br></div><div> I have many CMIP5 sea ice concentration data and want to regrid them into the same grid coordinate as HadISST.</div><div><br></div><div> Since the land area own missing_value (_FillValue) in HadiSST, I also want the regridded data show missing values in land .</div><div><br></div><div>I use the following scripts:</div><div> </div><div> <span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures"> fi = </span><span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures;color:rgb(52,187,199)">addfile</span><span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">(</span><span style="color:rgb(195,55,32);font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">"HadISST_ice.nc"</span><span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">,</span><span style="color:rgb(195,55,32);font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">"r"</span><span style="font-family:Menlo;font-size:14px;font-variant-ligatures:no-common-ligatures">)</span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> hsic = fi->sic</span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> hlon = fi->longitude</span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> hlat = fi->latitude(</span><span style="font-variant-ligatures:no-common-ligatures;color:#ce7924">{</span><span style="font-variant-ligatures:no-common-ligatures">-</span><span style="font-variant-ligatures:no-common-ligatures;color:#c33720">90</span><span style="font-variant-ligatures:no-common-ligatures">.:-</span><span style="font-variant-ligatures:no-common-ligatures;color:#c33720">50</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#ce7924">}</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div><div> …….</div><div> </div><div> Opt@SrcGridMask = where(.not.ismissing(thetao(0,<wbr>:,:)),1,0) ; thetao is the source grids, with data zero in land, no missing </div><div> Opt@DstGridMask = where(.not.ismissing(hsic(0,:,<wbr>:)),1,0) ; hsic is the HadISST SIC data, with missing values in land</div><div> </div><div> <span style="font-family:Menlo;font-size:14px">Opt@DstGridLat </span><span style="font-family:Menlo;font-size:14px"> </span><span style="font-family:Menlo;font-size:14px">= hlat</span></div><div><span style="font-family:Menlo;font-size:14px"> </span><span style="font-family:Menlo;font-size:14px">Opt@DstGridLon </span><span style="font-family:Menlo;font-size:14px"> </span><span style="font-family:Menlo;font-size:14px">= hlon</span> </div><div>……..</div><div><br></div><div> <span style="font-family:Menlo;font-size:14px"> </span><span style="font-family:Menlo;font-size:14px">thetao_regrid = ESMF_regrid(thetao,Opt)</span></div><div><br></div><div>However, I found the regridded data “thetao_regrid" show zero values, not missing values in land.</div><div><br></div><div><br></div><div> How to make the regridded data have missing values for the same grids as HadISST?</div><div><br></div><div><br></div><div>Thank</div><div><br></div><div><br></div><div>Lin </div><div><br></div><div> </div><div><br></div></div><br>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</div></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div>