Re: avg of rainfall lying inside a basin boundary

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 21 2011 - 12:21:58 MST

Dear Abhishek,

I tried to run your script, but it has some other data sets that you didn't provide: d1.nc, d2.nc

I think you should be able to simply your code a bit by using wrf_user_ll_to_ij to get the indexes of the two corners of the basin, and then you can call "avg" on this subset of your data.

For example, instead of the "where" calls and the "do" loop, something like this might work (UNTESTED):

    latMin = min(lm_lat);-20
    latMax = max(lm_lat) ;60
    lonMin = min(lm_lon);110
    lonMax = max(lm_lon);270
    . . .

    ll_min_ij = wrf_user_ll_to_ij(a, lonMin, latMin, res) - 1
    ll_max_ij = wrf_user_ll_to_ij(a, lonMax, latMax, res) - 1

    prc_avg = avg(prc(ll_min_ij(1):ll_max_ij(1),ll_min_ij(0):ll_max_ij(0)))

--Mary

On Nov 17, 2011, at 11:59 PM, Abhishek Gupta wrote:

> i want to calculate avg of all values lying inside a basin boundary .I am little bit confuse for using where function. here I am attaching my ncl script & coordinate point of basin . boundary.plz help me
>
>
> --
> Abhishek Kumar Gupta,
> Junior Research Fellow,
> India Meteorological Department,
> Lodi Road ,New Delhi-110003,
> India
>
> <lm.dat><mh_wrf.ncl><um.dat>_______________________________________________
> 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 Nov 21 12:22:08 2011

This archive was generated by hypermail 2.1.8 : Tue Nov 22 2011 - 14:17:52 MST