# Re: How to calculate the weighted average of Relative humidity?

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 23 2011 - 08:06:10 MST

You are not clear on what you want to do.

running average? eg a band-pass filter over 'time'
http://www.ncl.ucar.edu/Document/Functions/Contributed/dim_avg_wgt_n_Wrap.shtml

monthly mean ...
this is *not* a weighted average ... n refers to the 'time' dimension
Since you have just 31 days
RHAvg=dim_avg_n(RH,n)

If you want a vertical average .... data in vertical weighted
by layer thickness [weights], then see

On 11/23/11 7:24 AM, brownrig@ucar.edu wrote:
> Hi,
>
> Line 17 is:
>
> RHAvg=dim_avg_wgt_n(RH,wgt,1,0)
>
> The "wgt" array must be the same length as the "nth" dimension. In
> your case, length of wgt is 4; I'm not sure what the "0"th dimension
> of RH is (check your print(RH) output), but I bet its not 4.
>
> Check out the docs at:
>
> http://ncl.ucar.edu/Document/Functions/Built-in/dim_avg_wgt_n.shtml
>
> I hope that helps...
> Rick
>
> On Wed, 23 Nov 2011 15:26:31 +0530
> manaswini sreekar<manaswinikolluru@gmail.com> wrote:
>> Hi
>>
>> How to calculate the weighted average of the relative humidity?
>>
>> attached is my ncl script and here is my PrintVarSummary.
>>
>> I am getting the min and max of Relative humidity as
>> min(RH)=-20.4056 max(RH)=213.099.
>> so I wanted the values are right or wrong.
>>
>> the data is july 1st 2008 to july 31st 2008
>>
>> Variable: RH_TL_AVG
>> Type: float
>> Total Size: 317440000 bytes
>> 79360000 values
>> Number of Dimensions: 4
>> Dimensions and sizes: [g50_lat_3 | 800] x [g50_lon_4 | 800] x
>> [initial_time0_hours | 31] x [lv_ISBL1 | 4]
>> Coordinates:
>> initial_time0_hours: [1827654..1828374]
>> lv_ISBL1: [700..900]
>> Number Of Attributes: 10
>> center : European Center for Medium-Range Weather Forecasts
>> (RSMC)
>> long_name : Relative humidity
>> units : %
>> _FillValue : 1e+20
>> level_indicator : 100
>> gds_grid_type : 50
>> parameter_table_version : 128
>> parameter_number : 157
>> forecast_time : 0
>> forecast_time_units : hours
>> (0) min(RH)=-20.4056 max(RH)=213.099
>> fatal:dim_avg_wgt_n: w must be length nx
>> fatal:Execute: Error occurred at or near line 17 in file CFRHC.ncl
>>
>>
>> Can anyone give me some hint to resolve the error?
>
> _______________________________________________
> 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 Nov 23 08:06:16 2011

This archive was generated by hypermail 2.1.8 : Wed Nov 23 2011 - 16:46:19 MST