# [ferret_users] Re: Ferret - masking based on altitude

Dear Andre/ ferret users,

(the journal file and the errors & warnings are listed below:
I could not much understand the errors.
kindly help.

Regards
Simon

!====================================================================
!topo-rf.jnl
!====================================================================
use spi-rf.nc     ! Rainfall data on .25x.25 grid - variable name 'rainfall'
set region/x=74E:81E/y=8N:15N/l=1:365     ! selected 365 days data from ~ 100 years data

use elev.0.25-deg.nc      ! elevation on .25x.25 grid - variable name 'data'
set region/x=74E:81E/y=8N:15N/l=1

let mask1 = IF (data GE 0 AND data LT 100) THEN 1 else 1/0

let rf_100 = rainfall[D=1] * mask1

plot rf_100[x=@ave,y=@ave,l=1:365]    ! plotting 365 days xy spacially averaged data

!====================================================================

Error

yes? go topo-rf.jnl
use spi-rf.nc     ! Rainfall data on .25x.25 grid
set region/x=74E:81E/y=8N:15N/l=1:365     ! selected 365 days data from ~ 100 years data

use elev.0.25-deg.nc      ! elevation on .25x.25 grid - variable name 'data' - got dataset from site.

*** NOTE: Axis coordinates are decreasing-ordered. Reversing ordering for axis lat
set region/x=74E:81E/y=8N:15N/l=1

let mask1 = IF (data GE 0 AND data LT 100) THEN 1 else 1/0
!let mask2 = IF (data GE 100 AND data LT 500) THEN 1 else 1/0

let rf_100 = rainfall[D=1] * mask1
!let rain_500 = rainfall * mask2

plot rf_100[x=@ave,y=@ave,l=1:365]

*** NOTE: Ambiguous coordinates on X axis: RAINFALL[D=1] * MASK1
*** NOTE: Ambiguous coordinates on Y axis: RAINFALL[D=1] * MASK1
*** NOTE: Ambiguous coordinates on T axis: RAINFALL[D=1] * MASK1
**ERROR: inconsistent sizes of data regions: X axis
_expression_ has 29 points (I=31:59)

plot rf_100[x=@ave,y=@ave,l=1:365]
Command file, command group, or REPEAT execution aborted
yes?
=================================================================

On Sat, Oct 17, 2015 at 9:58 AM, simon EK wrote:
Dear Andre,
I saw the mail of Jorg and got the background information. Now I have to regrid the topo data to 1/4deg as in the rain data and proceed with the masking as clearly given in your mail.

Can you please help me in regridding 1 minute grid to 1/4 (0.25) deg as in rainfall data.
(The rainfall data is on 1/4 deg xy grid with daily data for about 100 years).

Thanking you so much,
Regards
Simon

On Fri, Oct 16, 2015 at 10:04 PM, Andre Paim wrote:
Did you see Joerg's answer in you other e-mail? If you manage to have both data sets on the same grid, this should be easy enough to go from there.

(assuming you have topography variable called "topo")

let mask1 = IF (topo GE 0 AND topo LT 100) THEN 1 else 1/0
let mask2 = IF (topo GE 100 AND topo LT 500) THEN 1 else 1/0

Then you need to create a new variable containing only the data in the level you want:
(assuming a variable called "rain")

let rain_100 = rain * mask1
let rain_500 = rain * mask2

Now all you need to do is compute your average anyway you want.

Let me know if you have more questions.

Best regards,
Andre

On 16 October 2015 at 05:38, simon EK wrote:
Dear Ferret users,

I have a daily rainfall dataset on .25x.25 grid and
I have a topography dataset with 1 minute resolution.

I would like to study the impact of altitude on rainfall.  Hence I would like to get spacial averages of rainfall over different altitude regions, say
0 to 100 meters
100 to 500 meters
500 to 1000 meters
and above 1000 meters.
I have seen certain ferret scripts  using masking, etc.

Can you pl. help me?

Regards
Simon