[Thread Prev][Thread Next][Index]

Finding average value over desired grids



Dear all,
It seems my last mail went unnoticed so i am sending it again. May be  there were some ambiguty in my prevous mail. so let me rewrite what i am looking for:
I want to average value of a variable over a number of grid. This is preety simple if we want to  average over all the grid within a rectangular box. but i want to find average value from a number of grids that have shapes other than a rectangular box( when we consider their outer boundry.) I have seen examples where masking is used for such cases. Now what is the solution if its difficult to define a mask  just valid for the grids of my concern and false for other neighbouring grids.
Hope i made myself clear this time 
Regards
jagadish
jagadish karmacharya <j_karmacharya@yahoo.com> wrote:
Dear Jaison and all,
 
Regriding the variable to a regular longitude axis and then use the new variable as the source data for sampling helps .ie it give the average value (but doesn't Bail out of external function "samplexy").
but i am actually looking for a way to calculate average value over a number of scattered grids. I think what i got with Regriding  is average of  the scattered x-y coordinates(points).or am i getting it wrong?
Please suggest me a way find the arial average over non-rectangular( irregular) grids.
thanking in advance 
jagadish     
 

Jaison Kurian <jaison@caos.iisc.ernet.in> wrote:
Hi Jagadish,
External function SAMPLEXY needs the "MODULO" axis of the
variable (if any) to be a "regular" one (ie. uniformly spaced). For
example your script will work for Levitus climatology, using "show axis"
command to know the axis properties....

yes? use levitus_climatology
yes? show axis XAXLEVITR ! longitude (x) axis for variables temp &
salt
name axis # pts start end
XAXLEVITR LONGITUDE 360mr 20.5E 19.5E(379.5)
Axis span (to cell edges) = 360 (modulo length = axis span)
yes?

pts is given as 360mr : here m ==> modulo & r ==> regular

For your dataset, it will be "***mi".

You can regrid the variable to a regular longitude axis and then use
the new variable as the source data for sampling (see the example below).

Hope this helps

With regards

Jaison

Example :
---------

! create an "irregular" & MODULO longitude axis

let xdata = XSEQUENCE({0,5,10,15,20,25,30,40,50,60,70,80,90,100})
define axis/x/units=longitudes/MODULO/from_data xax=xdata
show axis xax

! create some data defined over this axis

define axis/y=-30:30:1/units=latitudes yax
define axis/z=0:500:25/units=meters/DEPTH zax
let var = sin(x[gx=xax]/100 + y[gy=yax]/100 + z[gz=zax]/50)

! do the sampling

LET xlon = 34.5 + I[I=1:50] ! define the slant line
LET dely = 24./49
LET ylat = 24.5 - dely*i[i=1:50] + dely
! IF we do the sampling now ..it will fail...try it out by
! uncommenting the following line..
! LET slantsalt = samplexy(var,xlon,ylat) ; fill slantsalt

! So let us regrid the variable to a regular axis

define axis/x=0:100:10/units=longitudes/MODULO xregular
show axis xregular

let var_reg = var[gx=xregular]
LET slantsalt = samplexy(var_reg[y=-10:10,x=10:40],xlon,ylat)
fill slantsalt
!----------------------------------


On Sun, 17 Oct 2004, jagadish karmacharya wrote:

> Dear Ansley,
> SAMPLEXY funtion works fine for the examples you mentioned but it did not work with my data. I used following commands which generate the following error:
>
> yes? LET xlon=82+I[I=1:6]
> yes? LET dely = 24./49
> yes? LET ylat = 24.5 - dely*i[i=1:6] + dely
> yes? PLOT/VS/LINE/SYM=27 xlon,ylat ! gives slanted line
>
> yes? LET slanttk = samplexy(tk[x=80:90,y=20:25,L=1],xlon,ylat)
> yes? FILL slanttk
> Bailing out of external function "samplexy":
> cannot handle MODULO axis that is not regular
> **ERROR: : error in external function
>
> I wonder what caused the error.
>
> thanking you in advance
>
> jagadish
>
> ps : my dataset
>
> yes? show data
> ; ; currently SET data sets:
> 1> ./ATMJJAS-DAILYAVG.CDF (default)
> name title I J K L
> U Zonal Wind 1:63 1:66 1:18 1:122
> V Meridional Wind 1:63 1:66 1:18 1:122
> TK Temperature 1:63 1:66 1:18 1:122
> QD Mixing Ratio 1:63 1:66 1:18 1:122
> QC Cloud Mixing Ratio 1:63 1:66 1:18 1:122
> MSE Moist Static Energy 1:63 1:66 1:18 1:122
> RH Relative Humidity 1:63 1:66 1:18 1:122
> HGT Geopotential Height 1:63 1:66 1:18 1:122
> PS Surface Pressure 1:63 1:66 ... 1:122
> RT Total Precip 1:63 1:66 ... 1:122
> TGRND Ground Temperature 1:63 1:66 ... 1:122
> SMT Total Soil Water 1:63 1:66 ... 1:122
> RB Base Flow 1:63 1:66 ... 1:122
>
>
> Ansley Manke wrote: Hello Jagadish,
> There is an example which does this kind of thing in the
> Users Guide. Look up "SAMPLEXY, function definition".
> The X axis of the plot that is made has just a count of points,
> 1 for the first point, 2 for the second point and so on. Here
> is the example from the Users Guide, which shows how to define
> a set of points along a line. You could also define them as lists as I
> did in the previous email. This example has depth vs location; time
> vs location would be analogous.
>
> USE ocean_atlas_annual
> LET xlon = 234.5 + I[I=1:50] ! define the slant line
> LET dely = 24./49
> LET ylat = 24.5 - dely*i[i=1:50] + dely
>
> LET slantsalt = samplexy(salt[x=200:300,y=0:30],xlon,ylat)
> FILL/LEVELS=(33.2,35.2,0.1)/VLIMITS=0:4000 slantsalt
>
> Ansley
>
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> vote.yahoo.com - Register online to vote today!

--
___________________________________________________

Jaison Kurian
Centre for Atmospheric and Oceanic Sciences
I ndian Institute of Science
B A N G A L O R E 560 012
Ph: +91-80-3942505
+91-80-3600450
Fax:+91-80-3600865
___________________________________________________


Do you Yahoo!?
Check out the new Yahoo! Front Page. www.yahoo.com


Do you Yahoo!?
Discover all that’s new in My Yahoo!
[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement