<div dir="ltr"><div>Please mentions these issues (eg: missing_values, _FillValue) in a post to ncl-talk</div><div>=======================================<br></div><div>[1] Same input part as previous script<br></div><div>[2] Use <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/uv2dv_cfd.shtml"><b>uv2vr_cfd</b></a> and <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/grad_latlon_cfd.shtml"><b>grad_latlon_cfd</b></a><br></div><div>[3] CFD -> centered finite differences<br></div><div><br>;************************************************<br>; calculate vorticity on a rectilinear grid with missing values via CFD<br>;************************************************ <br> vr = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/uv2dv_cfd.shtml"><b>uv2vr_cfd</b> </a>(u,v,u&lat,u&lon, 2)<br> copy_VarMeta(u,vr)<br> vr@long_name = "vorticity"<br> vr@units = "per second"<br> printVarSummary(vr)<br> printMinMax(vr,0)<br> print("-------------")<br><br>;************************************************<br>; calculate gradients on a rectilinear grid with missing values via CFD<br>;************************************************ <br><br> u_gradLatLon = <b>grad_latlon_cfd </b>(u, u&lat, u&lon, True, False)<br> dUdY = u_gradLatLon[0] ; for clarity; explicitly extract variables from returned 'list' <br> dUdX = u_gradLatLon[1]<br> delete(u_gradLatLon)<br><br> dUdX@long_name = "longitudinal gradient of zonal wind U"<br> dUdX@units = "1/m" ; ; (m/s)*(1/m) = 1/m <br> dUdY@long_name = "latitudinal gradient of zonal wind U"<br> dUdY@units = "1/m"<br> printVarSummary(dUdX)<br> printMinMax(dUdX,0)<br> print("-------------")<br> printVarSummary(dUdY)<br> printMinMax(dUdY,0)<br> print("-------------")<br><br> v_gradLatLon = <b>grad_latlon_cfd </b>(v, v&lat, v&lon, True, False)<br> dVdY = v_gradLatLon[0] ; for clarity; explicitly extract variables from returned 'list' <br> dVdX = v_gradLatLon[1]<br> delete(v_gradLatLon)<br><br> dVdX@long_name = "longitudinal gradient of meridional wind V"<br> dVdX@units = "1/m" ; (m/s)*(1/m) = 1/m<br> dVdY@long_name = "latitudinal gradient of meridional wind V"<br> dVdY@units = "1/m"<br> printVarSummary(dVdX)<br> printMinMax(dVdX,0)<br> print("-------------")<br> printVarSummary(dVdY)<br> printMinMax(dVdY,0)<br> print("-------------")<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 3, 2021 at 7:15 PM Lyndz <<a href="mailto:olagueralyndonmark429@gmail.com">olagueralyndonmark429@gmail.com</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 Sir Dennis,<div><br></div><div>Thank you for this. </div><div>My data has missing values, that's why I used cfd.</div><div><br></div><div>Sincerely,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 4, 2021 at 7:28 AM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@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"><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" target="_blank">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" target="_blank">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>
</blockquote></div>
</blockquote></div>