Re: The error from "dim_avg_n".

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 29 2010 - 16:38:09 MDT

The reason the function was designed for performance.

    q = f->Q ; (a,b,c) => 0,1,2

There is a work around. As with most 'work arounds' it is
not elegant but it 'does the job'.

    qAvg_abc = avg(q) ; average of all elements

    qAvg_a = dim_avg_n(q, 0)
    qAvg_b = dim_avg_n(q, 1)
    qAvg_c = dim_avg_n(q, 2)

    qAvg_ab = dim_avg_n(q, (/0,1/))
    qAvg_bc = dim_avg_n(q, (/1,2/))

    qAvg_ac = dim_avg_n(q(b|:,a|:,c|:), (/1,2/)) ; use reordering
                            0 1 2
Cheers

On 9/29/10 8:36 AM, HUANG, Ping wrote:
> Dear Hoffman,
> Thanks for your explanation. That's true.
> The dimensional sizes of input array must be larger than the averaging
> dimensional sizes.
> Actually, I have met another error: "fatal:dim_avg_n: Input dimension
> sizes must be monotonically increasing, can't continue " when i tried to
> perform averaging for a 4d array on its first (0) and third (2)
> dimensions. And that's due to that averaging dimensions must be close
> each other.
> Anyway, these usages of dim_avg_n are limited.
> Best Regards,
> Huang Ping
> ------------------------------------------------------------------------
> *发件人:* Hoffman Cheung
> *发送时间:* 2010-09-29 21:00:19
> *收件人:* HUANG, Ping
> *抄送:*
> *主题:* Re: [ncl-talk] The error from "dim_avg_n".
> Dear Huang Ping,
>
> The fourth example of this function illustrates the case when the
> function performs averaging on the first and second dimensions
> (subscripts 0 and 1) of a four-dimensional variable. But the variable in
> your trail contains two dimensions only, that's why it does not work.
>
>
> Best Regards,
> Hoffman
>
> 2010/9/29 HUANG, Ping <ph0007@ustc.edu <mailto:ph0007@ustc.edu>>
>
> Hi all,
> Here I report a error from the function "dim_avg_n".
> In the online document
> http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_avg_n.shtml,
> dim_avg_n can perform average in multi-dimension as in example 4:
>
> *Example 4*
>
> Let z be defined as z(time,lev,lat,lon). Compute the time average at
> each latitude/longitude grid point.
>
> zAvg =*dim_avg_n*(z, (/0,1/)) ; ==> zAvg(nlat,nlon)
>
> If metadata is desired use:
>
> zAvg =*dim_avg_n_Wrap* <http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_avg_n_Wrap.shtml>(z, (/0,1/)) ; ==> zAvg(nlat,nlon)
>
> However, the error occurs when I try to use the multi-dimension
> average as above. And I test a simple example as following.
> NCAR Command Language Version 5.1.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> ncl 0> a = (/ (/1,2,3/),(/4,5,6/) /)
> ncl 1> print(a)
> Variable: a
> Type: integer
> Total Size: 24 bytes
> 6 values
> Number of Dimensions: 2
> Dimensions and sizes: [2] x [3]
> Coordinates:
> (0,0) 1
> (0,1) 2
> (0,2) 3
> (1,0) 4
> (1,1) 5
> (1,2) 6
> ncl 2> temp = dim_avg_n( a , (/0,1/) )
> fatal:NclReturnValue: Incomplete information to create return value
> from builtin function
> fatal:Execute: Error occurred at or near line 2
> ncl 3> print (dim_avg_n( a , 1 ))
> (0) 2
> (1) 5
> What's the correct usage of multi-dimension average in dim_avg_n?
> Best Regards,
> Thanks
> Huang Ping
>
> _______________________________________________
> 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
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 29 16:38:33 2010

This archive was generated by hypermail 2.1.8 : Mon Oct 04 2010 - 08:55:54 MDT