Re: area weighted average

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 17 2013 - 08:55:59 MDT

This is confusing.

It indicates below that 'tp' has attributes lat2d, lon2d and lat

tp@lat
tp@lat2d
tp@lon2d

On the surface of it I'd say there is something incorrect with
what you are doing. However, you have not sent enough information.

The lat2d/lon2d imply a curvilinear grid with
2-dimensional lat/lon arrays.

Then you use

  latwgt = latRegWgt(tp@lat, "float", 0)

which has a one dimensional array of latitudes.

Something is inconsistent and, likely, wrong here.

=================================================
The following might be more appropriate.
==================================================

undef("Atlantic")
functionn Atlantic(tp:numeric,nbin:integer)
begin

   print("Setuping Atlantic region arrays....")

   latMin = -7
   latMax = 25
   lonMin = 310
   lonMax = 350

   tp = mask (tp, conform(tp, (tp@lat2d.ge.latMin .and. \
                               tp@lat2d.le.latMax .and. \
                               tp@lon2d.ge.lonMin .and. \
                               tp@lon2d.le.lonMax), (/1,2/)), True)
   printVarSummary(tp)

   rad = 0.01745329
   latwgt = cos(lat2d*rad) ; (:,:)

; http://www.ncl.ucar.edu/Document/Functions/Built-in/wgt_areaave2.shtml
   areaAve = wgt_areaave2(tp, latwgt, 1)
   print("Area Average "+areaAve)

   pdf = pdfx(atlantic,nbin,False)
;;pdf = where(pdf.ne.0,pdf,pdf@_FillValue) ; ???

   return(pdf)
end

On 6/16/13 4:43 AM, Marston Johnston wrote:
> Hi,
>
> Just want to update this problem.
>
> I've changed the call to mask and tried to mask the correct region:
>
> function Atlantic(tp:numeric,nbin:integer)
>
>
> begin
>
>
> print("Setuping Atlantic region arrays....")
>
>
> latMin = -7
>
>
> latMax = 25
>
>
> lonMin = 310
>
>
> lonMax = 350
>
>
> tp = mask (tp, conform(tp, (tp@lat2d.ge.latMin .and. \
>
>
> tp@lat2d.le.latMax .and. \
>
>
> tp@lon2d.ge.lonMin .and. \
>
>
> tp@lon2d.le.lonMax), (/1,2/)), True)
>
>
> printVarSummary(tp)
>
>
> latwgt = latRegWgt(tp@lat, "float", 0)
>
>
> atlantic = ndtooned(tp) ; convert to 1D
>
>
> areaAve = wgt_areaave(tp, latwgt, 1.0, 1)
>
>
> ;print("Area Average "+areaAve)
>
>
> exit
>
>
> pdf = pdfx(atlantic,nbin,False)
>
>
> pdf = where(pdf.ne.0,pdf,pdf@_FillValue)
>
>
> return(pdf)
>
>
> end
>
> resulted in:
> ncl total_rr_stats_regions.ncl
> Copyright (C) 1995-2012 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.1.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0) Extracting the total precip arrays...
> (0) Opening file ECHAM6_regridded_1x1_2007-2008.nc...
> (0)
> (0) min=4.71418e-15 max=25.8996
>
> Variable: tp
> Type: float
> Total Size: 682110720 bytes
> 170527680 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 5848] x [lat | 81] x [lon | 360]
> Coordinates:
> Number Of Attributes: 2
> zAvgTime : <ARRAY of 29160 elements>
> _FillValue : 9.96921e+36
> (0) Setuping Atlantic region arrays....
>
> Variable: tp (parameter)
> Type: float
> Total Size: 682110720 bytes
> 170527680 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 5848] x [lat | 81] x [lon | 360]
> Coordinates:
> Number Of Attributes: 6
> _FillValue : 9.96921e+36
> zAvgTime : <ARRAY of 29160 elements>
> lat : <ARRAY of 81 elements>
> lon : <ARRAY of 360 elements>
> lat2d : <ARRAY of 29160 elements>
> lon2d : <ARRAY of 29160 elements>
> warning:Dimension (0) has not been defined
> .
> .
> .5835) Area Average 9.96921e+36
> (5836) Area Average 9.96921e+36
> (5837) Area Average 9.96921e+36
> (5838) Area Average 9.96921e+36
> (5839) Area Average 9.96921e+36
> (5840) Area Average 9.96921e+36
> (5841) Area Average 9.96921e+36
> (5842) Area Average 9.96921e+36
> (5843) Area Average 9.96921e+36
> (5844) Area Average 9.96921e+36
> (5845) Area Average 9.96921e+36
> (5846) Area Average 9.96921e+36
> (5847) Area Average 9.96921e+36
> [sm_marst@a6 ncl_codes]$
>
> /M
>
>
>
> _______________________________________________
> 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 Mon Jun 17 08:56:01 2013

This archive was generated by hypermail 2.1.8 : Mon Jun 24 2013 - 11:46:47 MDT