[ncl-talk] How to get second partial derivative of a variable

Dennis Shea shea at ucar.edu
Thu Apr 15 18:38:07 MDT 2021


The following is long the same line as Gus' suggestion but using spherical
harmonics. Data must be global and must not contain missing values.

----


NOTE: Arrays must be ordered South-to-North for spherical harmonic functions

----


If data are ordered, N->S  ... reorder.



 f = addfile("...","r")
 p = f->slp           ; ordered North-to-South

 p = p(:,::-1,:)      ; reorder to South-to-North [required by spherical
harmonics]


 nmsg = num(ismissing(p))   ; # of missing values

 if (nmsg.gt.0) then

     print("missing values encountered: nmsg="+nmsg)

     exit

 end if

========================



See attached:   NOTE: I don't have your file. Minor changes may be needed.



%> ncl lyndz.ncl_dx2dy2

On Thu, Apr 15, 2021 at 3:14 PM Gus Correa via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> This maybe?
>
>
>
>   gradp  = grad_latlon_cfd (p, p&lat, p&lon, True, False)
>
>
>
>   dpdX  = gradp[0]
>
>   dpdY  = gradp[1]
>
>
>
>   graddpdX  = grad_latlon_cfd (dpdX, p&lat, p&lon, True, False)
>
>   d2pdX2 = graddpdX[0]
>
>   d2pdXdY = graddpdX[1]
>
>
>   graddpdY  = grad_latlon_cfd (dpdY, p&lat, p&lon, True, False)
>
>   d2pdYdX = graddpdY[0]
>
>   d2pdY2 = graddpdX[1]
>
>
>   myvar = d2pdX2 * d2pdY2
>
> On Thu, Apr 15, 2021 at 3:56 PM Lyndz via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
>> Dear NCL-experts,
>>
>> *Details:*
>> I have mean sea level pressure data from NCEP-DOE reanalysis with the
>> following dimensions and sizes.
>>
>> Dimensions and sizes: [time | 124] x [lat | 73] x [lon | 144]
>>
>>
>> *Problems*:
>> (a) I would like to get the second partial derivative of the mslp
>> separately for the lon and lat.
>> I would like to get their products later and save as a variable such as
>> the below image:
>> [image: image.png]
>>
>> a gradient of a gradient or components of a laplacian?
>>
>> *What I have so far:*
>>
>> I have the following initial script but only for getting the first
>> partial derivative using CFD.
>>
>>    diri = "."
>>
>>    fp   = addfile ("mslp_jan_2017.nc", "r")
>>
>>    p = fp->mslp(:,:,:)
>>
>> ;****************************************
>>
>> ; calculate pressure gradients via CFD
>>
>> ;****************************************
>>
>>
>>   p_gradLatLon  = grad_latlon_cfd (p, p&lat, p&lon, True, False)
>>
>>   dpdY  = u_gradLatLon[0]
>>
>>   dpdX  = u_gradLatLon[1]
>>
>>   delete(p_gradLatLon)
>>
>>
>>   dpdX at long_name = "longitudinal gradient of MSLP"
>>
>>   dpdX at units     = "P/m"                                         ;(Pa)*(1/m)
>> = Pa/m
>>
>>   dpdY at long_name = "latitudinal gradient of MSLP"
>>
>>   dpdY at units     = "Pa/m"
>>
>>   printVarSummary(dpdX)
>>
>>   printMinMax(dpdX,0)
>>
>>   print("-------------")
>>
>>   printVarSummary(dpdY)
>>
>>   printMinMax(dpdY,0)
>>
>>   print("-------------")
>>
>>
>>
>> I'll appreciate any help on this.
>>
>> 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
>
> _______________________________________________
> 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/20210415/99ac196d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 3964 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210415/99ac196d/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lyndz.ncl_dx2dy2
Type: application/octet-stream
Size: 1785 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210415/99ac196d/attachment.obj>


More information about the ncl-talk mailing list