[Thread Prev][Thread Next][Index]

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



Dear Russ,
Thanks a lot for pointing out the vulnerabilities/mistakes and bringing more clarity in the code. 

Regards
Simon

On Mon, Oct 19, 2015 at 6:25 AM, Russ Fiedler <russell.fiedler@xxxxxxxx> wrote:

Hi Simon,

The problem is that you aren't mapping the variables between grids explicitly. Ferret is making its best guess (hence the warning about ambiguous grids) but not making the right choice. The repeated changing of regions is also confusing, especially the time index. The region is only evaluated when making the plot so your first set/region does precisely nothing.

When defining variables from a combination of sources make sure that the grids are compatible.

So rather than

let rf_100 = rainfall[d=1] * mask1

you should use (assuming the mask is time invariant)

let rf_100 = rainfall[d=1,gxy=mask1]*mask1[l=1] ! put on the topography grid

or

let rf_100 = rainfall[d=1]*mask1[gxy=rainfall[d=1],l=1]  ! put on the rainfall grid.

If the grids are aligned but of different sizes then the @NRST regridding is possibly the most appropriate transform.

I'd also omit the set region statements and plot things explicitly. Setting regions when you have mixed grids often leads to problems and it's
probably best not to get into the habit of automatically setting regions unless you are sure that it's safe and that you cancel the region as soon as it's not needed.

plot/x=74E:81E/y=8N:15N/l=1:365 rf_100[x=@ave,y=@ave]


Cheers,
Russ


On 17/10/15 22:10, simon EK wrote:
Dear Andre/ ferret users,

I downloaded .25x.25 grid topography dataset and tried with one mask as adviced by you::
(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
          MASK1 has 28 points (I=297:324)
          _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 <simonambat@xxxxxxxxx> 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 <paim.oceano@xxxxxxxxx> 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.

About the masking, you would need to do something like:
(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 <simonambat@xxxxxxxxx> 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







[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement