<div dir="ltr"><div><br></div><div>Given the dimension sizes (73x144), I am sure the data are global. <br></div><div>In fact, a 2.5 degree grid. I speculate, it is ordered North-to-South.</div><div><br></div><div><div>I am not sure why you used centered finite differences (cfd). <br></div><div>Of course, it can be done. However, it is recommended to use the "highly" accurate spherical harmonic functions.</div><div>===</div><div>Based on your script, try the following. **If ** your source grid is ordered South-to-North, no reordering is needed. Skip that part.<br></div></div><div>====</div><div><br></div><div> ufile = addfile("<a href="http://uwnd_2008.nc">uwnd_2008.nc</a>","r") ; open netcdf file<br> u = short2flt(ufile->uwnd(:,{925},:,:)) ; pull u off file<br><br> vfile = addfile("<a href="http://vwnd_2008.nc">vwnd_2008.nc</a>","r")<br> v = short2flt(vfile->vwnd(:,{925},:,:)) ; pull v off file</div><div><div><br></div><div>;*******************************************************************<br>; Spherical harmonics require the data to be South-to-North</div><div>; Skip this step if source data are already South-to-North<br></div><div>;******************************************************************<br></div> <br> u = u(:,::-1,:) ; make grid South-to-North<br> printVarSummary(u)<br> printMinMax(u,0)<br> print("-------------")</div><div><br> v = v(:,::-1,:) ; make grid South-to-North<br> printVarSummary(v)<br> printMinMax(v,0)</div><div><br></div><div>;*******************************************************************<br>; calculate vorticity on a Global Fixed Grid via spherical harmonics<br>;*******************************************************************<br><br> vr = uv2vrF_Wrap (u,v) <br> printVarSummary(vr)<br> printMinMax(vr,0)<br> print("-------------")<br><br>;**********************************************************************************<br>; calculate wind component gradients on a Global Fixed Grid via spherical harmonics<br>;**********************************************************************************<br><br> u_grad_lon = u ; create arrays to hold output, same size and type as input<br> u_grad_lat = u <br> gradsf (u, u_grad_lon, u_grad_lat) <br> u_grad_lon@long_name = "U longitudinal gradient: dUdX"<br> u_grad_lon@units = "1/m" <br> u_grad_lat@long_name = "U latitudinal gradient: dUdY"<br> u_grad_lat@units = "1/m" ; (m/s)*(1/m) = 1/m<br> printVarSummary(u_grad_lon)<br> printMinMax(u_grad_lon,0)<br> print("-------------")<br> printVarSummary(u_grad_lat)<br> printMinMax(u_grad_lat,0)<br> print("-------------")<br><br> v_grad_lon = v ; create arrays to hold output, same size and type as input<br> v_grad_lat = v <br> gradsf (v, v_grad_lon, v_grad_lat) <br> v_grad_lon@long_name = "V longitudinal gradient: dVdX" <br> v_grad_lon@units = "1/m" <br> v_grad_lat@long_name = "V latitudinal gradient: dVdY"<br> v_grad_lat@units = "1/m" <br> printVarSummary(v_grad_lon)<br> printMinMax(v_grad_lon,0)<br> print("-------------")<br> printVarSummary(v_grad_lat)<br> printMinMax(v_grad_lat,0)<br> print("-------------")<br><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 3, 2021 at 10:35 AM Lyndz via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">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 dir="ltr">Dear. NCL-experts,<div><br></div><div>I want to get the dV/dx and dU/dy when calculating the relative vorticity.</div><div><br></div><div>I tried using the <b>center_finite_diff_n</b> but encountered this error:</div><div><br></div><div>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><i>fatal:center_finite_diff_n: r must either be a scalar, a 1D array the same length as the dim-th dimemsion of q, or the same size as q</i></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><i>fatal:["Execute.c":8637]:Execute: Error occurred at or near line 39 in file orig_vort.ncl</i></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p></div><div>Attached file is the script that I am using.</div><div><br></div><div>The input file has the following dimension:</div><div>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><b>Dimensions and sizes:<span style="white-space:pre-wrap"> </span>[time | 4] x [lat | 73] x [lon | 144]</b></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p></div><div>I am using the lat and lon for dY and dX, respectively.</div><div><br></div><div>I'll appreciate any help on this matter.</div><div><br></div><div><br></div><div>Sincerely,</div><div>Lyndz</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>