# Re: center_finite_diff_n missing values

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Dec 01 2011 - 16:39:24 MST

I think Example 6 may have a documentation error.

The following

dTdX(:,:,nl,:) = center_finite_diff_n (T(:,:,nl,:), dX , True,0,0)

should be

dTdX(:,:,nl:nl,:) = center_finite_diff_n (T(:,:,nl:nl,:), dX , True,0,3)

```----
dTdX(:,:,nl:nl,:)
0 1   2   3    <== dimension number
the nl:nl forces the array to remain 4D so the dimension numbering
stays the same.
---
Let us know if this is the issue.
+++++
Below ... if hus is already (time,lev,lat,lon) there would be no need
to do this: hus(time|:,plev|:,lat|:,lon|:)
On 12/1/11 4:17 PM, Nicole Schiffer wrote:
> My goal is to calculate the 1-D moisture flux (mfu, mfv)and then use
> that to figure moisture convergence.
>
> I was trying to follow Example 6 from the documentation
> (http://www.ncl.ucar.edu/Document/Functions/Built-in/center_finite_diff_n.shtml).
> I switched the dimension of n1,n2 because I want to look at divergence
> rather than vorticity, as in an earlier post
> (http://www.ncl.ucar.edu/Support/talk_archives/2010/2835.html).
>
> I also tried it using lat and lon without the looping or conversion from
> degrees to distance just to get the function to work (see code below).
> NCL still sees missing values in the u data and not in the v data (and
> hence tries to calculate the gradient between real values and 1e+20).
>
> mfu(:,:,:,n2) =
> center_finite_diff_n((hus(time|:,plev|:,lat|:,lon|:)/g)*ua(:,:,:,:),lon,False,0,2)
> mfv(:,:,:,:) =
> center_finite_diff_n((hus(time|:,plev|:,lat|:,lon|:)/g)*va(:,:,:,:),lat,False,0,2)
>
> -Nicole
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> *     Nicole Schiffer
> *     Graduate Research Fellow (Dept. of Energy)
> *     Department of Atmospheric Sciences
> *     University of Illinois, Urbana-Champaign
> *     Email: nschiff2 [at] illinois [dot] edu
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> On 12/1/11 4:56 PM, Mary Haley wrote:
>> Hi Nicole,
>>
>> Why are dx and dy calculated the way they are?
>>
>>> dx = 6378388*cos(0.0174533*lat(n2))*dlon
>>>    dy = 6378388.*0.0174533*dlon
>>
>>
>>
>> Did you mean to subscript "lat" with n2?  You use "n2" as a longitude
>> subscript
>> in the center_finite_diff_n call, so I'm wondering if there's an error
>> there...
>>
>> Something doesn't look quite right with the above code. I'm guessing
>> one or
>> both of dx or dy are incorrect.
>>
>> --Mary
>>
>> On Dec 1, 2011, at 10:31 AM, Nicole Schiffer wrote:
>>
>>> I'm using center_finite_diff_n on two 4D array (time, pressure, lat,
>>> lon) with missing values. With one array, the u-wind, it handles missing
>>> values fine. With the v-wind array, it doesn't. Both arrays have the
>>> same metadata (missing and fill values). Any ideas why v-wind is a
>>> problem?
>>>
>>> Code snippet:
>>> dlat = 2.5*0.0174533
>>>    dlon = dlat
>>>    do n2=0,nlon-1
>>>      dx = 6378388*cos(0.0174533*lat(n2))*dlon
>>>      mfu(:,:,:,n2) =
>>> center_finite_diff_n((hus(time|:,plev|:,lat|:,lon|n2)/g)*ua(:,:,:,n2),dx,False,0,2)
>>>
>>>    end do
>>>    dlon = 2.5*0.0174533
>>>    do n1=0,nlat-1
>>>      dy = 6378388.*0.0174533*dlon
>>>      mfv(:,:,n1,:) =
>>> center_finite_diff_n((hus(time|:,plev|:,lat|n1,lon|:)/g)*va(:,:,n1,:),dy,False,0,2)
>>>
>>>    end do
>>>
>>> Thanks,
>>> Nicole
>>>
>>> --
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> *     Nicole Schiffer
>>> *     Graduate Research Fellow (Dept. of Energy)
>>> *     Department of Atmospheric Sciences
>>> *     University of Illinois, Urbana-Champaign
>>> *     Email: nschiff2 [at] illinois [dot] edu
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
```
Received on Thu Dec 1 16:39:28 2011

This archive was generated by hypermail 2.1.8 : Fri Dec 02 2011 - 16:10:18 MST