<div dir="ltr"><div>For global data with no missing values, NCL uses spherical harmonic based functions. These are not applicable for your problem. <br></div><div><br></div><div>There are gradient functions that can 'handle' missing values. These use centered finite differences (_cfd). <br></div><div><br></div><div><pre> gradLatLon = <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/grad_latlon_cfd.shtml"><strong>grad_latlon_cfd</strong></a> (SST, SST&lat SST&lon, True, False)
SS_grad_lat = gradLatLon<b>[0]</b> ; for clarity; explicitly extract variables from returned 'list'
SS_grad_lon = gradLatLon<b>[1]</b>
<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/delete.shtml"><strong>delete</strong></a>(gradLatLon)
; replace the generic attributes with more specific attributes
SST_grad_lon@long_name = "longitudinal gradient"
SST_grad_lat@long_name = "latitudinal gradient"
if (<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/isatt.shtml"><strong>isatt</strong></a>(SST,"units")) then
SST_grad_lat@units = SST@units+"/m"
else
SST_grad_lat@units = "C/m"
end if <br> <b>printVarSummary</b>(SS_grad_lat)<br> <b>printVarSummary</b>(SST_grad_lon)</pre></div><div><br></div><div>===============================================</div><div>Of course, deriving gradients near 'land' is limited due to missing values.</div><div>One approach: if the land areas (missing values) are small, the use of <a href="http://www.ncl.ucar.edu/Applications/grid_fill.shtml"><b>poisson_grid_fill</b></a></div><div> prior to using the above may be appropriate. None of the original SST values is changed. <br></div><div>I think this is much better than using (say) bilinear interpolation to fill in gaps. <br></div><div>For smaller regions, I'd say it is shape preserving interpolation.<br></div><div><br></div><div> SST</div><div><pre> guess = 1 ; use zonal means
is_cyclic = False ; non-cyclic
nscan = 1000 ; usually MUCH than this
eps = 1.e-2 ; variable dependent
relc = 0.6 ; relaxation coefficient
opt = 0 ; not used
<strong>poisson_grid_fill</strong>( SST, is_cyclic, guess, nscan, eps, relc, opt)
;;<strong>poisson_grid_fill</strong>( SST, True, 1, 1500, 1e-2, 0.6, 0)<br>Then use <br> gradLatLon = <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/grad_latlon_cfd.shtml"><strong>grad_latlon_cfd</strong></a> (SST, SST&lat SST&lon, True, False) <br></pre></div><div><br></div><div>You might save the original grid</div><div> SST_SAVE = SST</div><div><br></div><div>then use it to restore the original missing value locations</div><div><br></div><div> SST = where(ismissing(SST_SAVE), SST@_FillValue,SST)<br></div><div><br></div><div><br></div><div><a href="http://www.ncl.ucar.edu/Applications/gradients.shtml"><b>Some Gradient Examples</b></a></div><div>Some grid filling examples: <a href="http://www.ncl.ucar.edu/Applications/grid_fill.shtml"><b>Grid Fill</b></a></div><div><b></b><a href="http://www.ncl.ucar.edu/Applications/wind.shtml"><b>Some Spherical Harmonic Examples</b></a>: These include some gradient examples: Calculate various divergence and moisture quantities including
Vertically Integrated Moisture Flux Convergence (<b>VIMFC</b>).
</div><div><br></div><div>Functions where gradients are returned as a byproduct:<a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/advect_variable_cfd.shtml"><b> advect_variable_cfd</b></a></div><div><br></div><div>Good Luck</div><div>Happy New Year</div><div>Stay Healthy<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 20, 2021 at 1:36 AM Sam McClatchie via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p><font face="TeX Gyre Adventor">Colleagues</font></p>
<p><font face="TeX Gyre Adventor">I have a general question where I
suspect the answer is "no".<br>
</font></p>
<p>Problem:</p>
<p>I would like to calculate temperature gradients from satellite
measured SST in ocean areas around a land mass (see <a href="http://u.pc.cd/K62rtalK" target="_blank"><http://u.pc.cd/K62rtalK></a> for a
plot of the SST data). The SST data matrix has missing values.
Using the landsea_mask and mask functions, I have confirmed that
the missing data (data@_FillValue) are at grid points over land.
If I remove the missing values, I destroy the regular grid.</p>
<p>Question: Does NCL have a function for calculating gradients in
ocean areas with land? Or are the various functions designed to
calculate gradients in the atmosphere?</p>
<p>Best fishes</p>
<p>Sam<br>
</p>
<div>-- <br>
Sam McClatchie (fisheries oceanographer)<br>
& Elena Turin (accounting & auditing)<br>
FishOcean Enterprises <span style="text-decoration:underline"><a href="http://www.fishocean.info" target="_blank">www.fishocean.info</a></span><br>
38 Upland Rd, Huia, Auckland 0604, New Zealand<br>
cell: 027 752 8495<br>
<img style="width: 150px; height: 149px;" alt="" src="cid:1772040ebc2b74f45fb1"><br>
<br>
“The three great elemental sounds in nature are the sound of rain,<br>
the sound of wind in a primeval wood, and the sound of outer ocean
on a beach.<br>
I have heard them all, and of the three elemental voices, <br>
that of ocean is the most awesome, beautiful and varied.”<br>
<br>
― Henry Beston, The Outermost House: A Year of Life on the Great
Beach of Cape Cod </div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>