area weighted average

From: Marston Johnston <shejo284_at_nyahnyahspammersnyahnyah>
Date: Sun Jun 16 2013 - 02:58:24 MDT

Hi,

I'm trying to take a large array dimensioned: time,lat,lon and take a slice
out of it and calculate the area-weighted mean and other stats but I I seem
to misunderstand how to get a slice from the array. Here is my function and
the results:

function Atlantic(tp:numeric,nbin:integer)

  begin

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

  latMin = -7

  latMax = 25

  lonMin = 310

  lonMax = 350

  ;x = where((tp@lat2d.ge.latMin .and. tp@lat2d.le.latMax .and. \

  ; tp@lon2d.ge.lonMin .and. tp@lon2d.le.lonMax), \

  ; tp,tp@_FillValue)

  x = mask(tp,(tp@lat2d.le.latMin .or. tp@lat2d.ge.latMax .or. \

               tp@lon2d.le.lonMin .or. tp@lon2d.ge.lonMax), True)

  printVarSummary(x)

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

  atlantic = ndtooned(x) ; convert to 1D

  areaAve = wgt_areaave(x, latwgt, 1.0, 1)

  print("Area Average "+areaAve)

  print(x)

  exit
.
.
.
end

gives:

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

which is the FillValue. It is as if the function is not using the mask or
the mask is not working as I think it should. I have even tried where but
with the same results.

Any help here would be appreciated.

/M

-- 
Only the fruitful thing is true!

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Jun 16 02:58:36 2013

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