# [ncl-talk] Calculating d/dx and d/dy of a variable

Dennis Shea shea at ucar.edu
Thu Aug 16 12:21:43 MDT 2018

```I forgot that I had a library of functions that use gradients. Maybe these
will be useful for you.
See attached.

These were originally developed some time ago. I updated them to uses 6.5.0
new language feature:

*elseif*I'm sure the 1st four functions work. I *think* the Q-vector
functions work.
These functions could be quite useful for  investigating (say) cyclogenesis/
frontogenesis.

All require *rectilinear *(global or regional) grids. Documentation is
embedded within the functions

*advect_variable_cfd  *           : regional grid; centered finite
difference
; This is a function that
should have been in 6.5.0. My bad.

*shear_stretch_deform*         ; kinematic; global; spherical harmonics
*shear_stretch_deform_cfd*  ;     "                     ; regional;
centered finite differences

*beta_dfdy_rossby*                ; important in the studying the
generation of Rossby waves.

*qvector_isobaric*                    ; Q-Vector on isobaric levels; global
grid; spherical harmonics
*qvector_isobaric_cfd*             ; Q-Vector on isobaric levels; regional
grid; centered finite differences

Cheers

On Thu, Aug 16, 2018 at 7:58 AM, Dennis Shea <shea at ucar.edu> wrote:

> Gradients: zonal [ d()/dx ] and meridional [ d()/dy ]
>
> [1]
> WRF data are on a *regional * *curvilinear* grid.
>
> [2]
> NCL's *gradient calculation functions* require data to be on a
> *rectilinear* grid.
>
> [3]
> Different functions should be used for global and regional rectilinear
> grids.
>
> For global grids, NCL's gradient calculation functions use *highly
> accurate* spherical harmonics to calculate gradients
> For regional grids, NCL's gradient calculation functions use centered
> finite differences
>
> [4]
> NCL has no single function to directly calculate the zonal and meridional
> gradients on a curvilinear grid.
>
> [5]
> You must (a) interpolate the WRF data to a rectilinear grid of about the
> same resolution or, ?better? slightly higher resolution; (b) calculate the
> (c) reinterpolate from the rectilinear grid back onto the original WRF grid.
>
> [6] See:
> http://www.ncl.ucar.edu/Applications/ESMF.shtml
> Examples 29 and 37
> Here, the divergence was calculated [ *uv2dv_cfd ]
> <http://www.ncl.ucar.edu/Document/Functions/Built-in/uv2dv_cfd.shtml>*but
> you can use the* grad_latlon_cfd *function
> *.*
> ===================================================================
>
> shtml
>
>
> FYI only: global
>
> HTH
>
> On Thu, Aug 16, 2018 at 6:28 AM, Ty Buckingham <
> ty.buckingham at manchester.ac.uk> wrote:
>
>> Hi all,
>>
>> I'm probably overthinking this, but I'm struggling isolating the d/dx and
>> d/dy of a variable (in my case, absolute vorticity from WRF output).
>>
>> Is there an easy way to compute this?
>>
>> Thanks
>> Ty
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180816/88e98db1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...