[Thread Prev][Thread Next][Index]

Re: [ferret_users] computation of derivatives



Dear Saurabh

On Tue, Dec 6, 2022 at 7:48 AM saurabh rathore <rohitsrb2020@xxxxxxxxx> wrote:

here is the problem that I am having variables var1(time,lev,lat,lon) and var2(time,lev,lat,lon) and I want to differentiate var1 w.r.t. var2 i.e. d(var1)/d(var2).


Before discussing how to implement it in Ferret, we need to make it clear what you mean by d(var1)/d(var2) in a multidimensional space.

To illustrate the problem, let's consider 2D variables var1(x,y) and var2(x,y). Along a zonal section at a fixed latitude y0, we observe how these variables change:

var1(x + dx, y0) = var1(x, y0) + [∂(var1)/∂x] dx,
var2(x + dx, y0) = var1(x, y0) + [∂(var2)/∂x] dx.

So the changes are

d(var1) = [∂(var1)/∂x] dx,
d(var2) = [∂(var2)/∂x] dx.

Along this zonal section, therefore,

d(var1)/d(var2)
= {[∂(var1)/∂x] dx} / {[∂(var2)/∂x] dx}
= [∂(var1)/∂x] / [∂(var2)/∂x]

This result is the same as a 1D case.  You can easily implement this in Ferret using the partial derivative operator(s) in the x direction.

Similarly, along a meridional, you get d(var1)/d(var2) =  [∂(var1)/∂y] / [∂(var2)/∂y].

Along an arbitrary section, we move from point (x,y) to point (x + dx, y + dy) and observe

var1(x+dx, y+dy)
= var1(x, y) + [∂(var1)/∂x] dx +  [∂(var1)/∂y] dy
= var1(x,y) + {[∂(var1)/∂x] cos θ +  [∂(var1)/∂y] sin θ} dl,

where dl = sqrt(dx^2 + dy^2) is the length of the (dx,dy) vector and θ is the angle that the vector makes from due east.  So,

d(var1) =  {[∂(var1)/∂x] cos θ +  [∂(var1)/∂y] sin θ} dl.

Likewise for d(var2).  Therefore,

d(var1)/d(var2) =  {[∂(var1)/∂x] cos θ +  [∂(var1)/∂y] sin θ} /  {[∂(var2)/∂x] cos θ +  [∂(var2)/∂y] sin θ}

in the direction θ.

In the 4D space (x,y,z,t), you specify the direction (dx, dy, dz, dt) and do the same as the above.

Cheers,

Ryo


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement