-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Being able to calculate the differential operators Laplacian, div (divergence of a vector of fields), grad (vector derivative of a scalar field), and curl on field constructs would be useful, preserving metadata through the operations and setting the correct units.
The current use case (towards calculating the baroclinic geostrophic part of ocean dynamic sea level from the density field) is for calculating these quantities on the horizontal X-Y plane, either in Cartesian coordinates (e.g. plane projections), or in spherical polar coordinates. In the latter case the plane is the theta-phi plane for a constant radial distance to the origin.
I propose the following methods and syntax:
>>> f = cf.example_field(0)
>>> lp = f.laplacian_xy()
>>> fx, fy = f.grad_xy()
>>> d = cf.div_xy(fx, fy)
>>> c = cf.curl_xy(fx, fy)
In the spherical polar case, it will be assumed that the inferred or provided radius is applicable at all horizontal locations, and to all vertical levels. An extension to allow for varying Z on each X-Y plane should be possible, if desired.