[ncl-talk] Error when using center_finite_diff_n

Dennis Shea shea at ucar.edu
Wed Mar 3 16:28:12 MST 2021


Given the dimension sizes (73x144), I am sure the data are global.
In fact, a 2.5 degree grid. I speculate, it is ordered North-to-South.

I am not sure why you used centered finite differences (cfd).
Of course, it can be done. However, it is recommended to use the "highly"
accurate spherical harmonic functions.
===
Based on your script, try the following. **If ** your source grid is
ordered South-to-North, no reordering is needed. Skip that part.
====

  ufile  = addfile("uwnd_2008.nc","r")       ; open netcdf file
  u   = short2flt(ufile->uwnd(:,{925},:,:))                             ;
pull u off file

  vfile  = addfile("vwnd_2008.nc","r")
  v   = short2flt(vfile->vwnd(:,{925},:,:))                             ;
pull v off file

;*******************************************************************
; Spherical harmonics require the data to be South-to-North
; Skip this step if source data are already South-to-North
;******************************************************************

  u = u(:,::-1,:)                  ; make grid South-to-North
  printVarSummary(u)
  printMinMax(u,0)
  print("-------------")

  v = v(:,::-1,:)                  ; make grid South-to-North
  printVarSummary(v)
  printMinMax(v,0)

;*******************************************************************
; calculate vorticity on a Global Fixed Grid via spherical harmonics
;*******************************************************************

  vr = uv2vrF_Wrap (u,v)
  printVarSummary(vr)
  printMinMax(vr,0)
  print("-------------")

;**********************************************************************************
; calculate wind component gradients on a Global Fixed Grid via spherical
harmonics
;**********************************************************************************

  u_grad_lon = u                ; create arrays to hold output, same size
and type as input
  u_grad_lat = u
  gradsf (u, u_grad_lon, u_grad_lat)
  u_grad_lon at long_name = "U longitudinal gradient: dUdX"
  u_grad_lon at units     = "1/m"
  u_grad_lat at long_name = "U latitudinal gradient: dUdY"
  u_grad_lat at units     = "1/m"                        ; (m/s)*(1/m) = 1/m
  printVarSummary(u_grad_lon)
  printMinMax(u_grad_lon,0)
  print("-------------")
  printVarSummary(u_grad_lat)
  printMinMax(u_grad_lat,0)
  print("-------------")

  v_grad_lon = v                ; create arrays to hold output, same size
and type as input
  v_grad_lat = v
  gradsf (v, v_grad_lon, v_grad_lat)
  v_grad_lon at long_name = "V longitudinal gradient: dVdX"
  v_grad_lon at units     = "1/m"
  v_grad_lat at long_name = "V latitudinal gradient: dVdY"
  v_grad_lat at units     = "1/m"
  printVarSummary(v_grad_lon)
  printMinMax(v_grad_lon,0)
  print("-------------")
  printVarSummary(v_grad_lat)
  printMinMax(v_grad_lat,0)
  print("-------------")


On Wed, Mar 3, 2021 at 10:35 AM Lyndz via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Dear. NCL-experts,
>
> I want to get the dV/dx and dU/dy when calculating the relative vorticity.
>
> I tried using the *center_finite_diff_n* but encountered this error:
>
> *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*
>
> *fatal:["Execute.c":8637]:Execute: Error occurred at or near line 39 in
> file orig_vort.ncl*
>
>
> Attached file is the script that I am using.
>
> The input file has the following dimension:
>
> *Dimensions and sizes: [time | 4] x [lat | 73] x [lon | 144]*
>
>
>
> I am using the lat and lon for dY and dX, respectively.
>
> I'll appreciate any help on this matter.
>
>
> Sincerely,
> Lyndz
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210303/cbfafb14/attachment.html>


More information about the ncl-talk mailing list