[gradsusr] use 'const' only over a specific region

pr romero619 at hotmail.com
Sat Jan 15 16:06:08 EST 2011


Everyone,

I found a work-around for my problem.

I ended up modifying the grads source code and enabling 'set clip' for the
'display' command.

(by default, 'set clip' only works for 'draw' commands, but not for
'display' commands)

This allowed me to define a clipping region using 'set clip', display a
variable, and have the resulting contour plot be drawn only within the
clipping region.

 

'set clip x1 x2 y1 y2'

'display const(A,0,-u)'

 

. and const(A) will only be drawn within the clipping regioned defined by
'x1 x2 y1 y2'.

 

Regards,

Pablo

 

From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org]
On Behalf Of pr
Sent: Friday, January 14, 2011 11:28 PM
To: 'GrADS Users Forum'
Subject: [gradsusr] use 'const' only over a specific region

 

Hi,

I don't know if the following is possible, and I need help.

I need to use the 'const' function for a variable, but ONLY over a specific
region.

 

Here's the problem:

I have two variables, A & B

Variable A is from a dataset with a global 0.5x0.5 grid, yet it has all
undefined values over the region covering the Mediterranean Sea.

Variable B is from a separate dataset with a 0.167x0.167 resolution that
covers the Med. Sea area and also a small portion of the Atlantic (over the
Bay of Biscay near France).

What I want to do is:

1)      First plot variable A from the global dataset using const to fill in
all undefined areas

'd const(A,0,-u)'

2)      Overlay variable B from the regional dataset onto the global plot of
A & ALSO use const to fill in areas with undefined values.

'd const(B,0,-u)' , plot 'const(B) only over the Mediterranean region

 

The problem is that the 2nd display command, 'd const(B,0,-u)', overwrites
the plotting from the first display command, so everything outside variable
B's region is set to a value of '0'.

I thought about trying to somehow 'merge' or 'add' the two variables, such
as 'display const(A+B,0,-u)', but this doesn't work since the datasets have
different sized grids & different resolutions.

(I'd really like to avoid having to over-complicate things by having to use
regrid and create new grids  or merge datasets.)

 

.Although I know that this is currently not supported, ideally, I'd like to
do something like the following:

* plot const(A) over entire grid (i.e.,globally)

'display const(A,0,-u)'

 

* now display const(B), overlaying onto previous plot of 'const(A)' 

* cropping results of 'const(B)' so that it ONLY covers the Med. Sea region

'display const(B,0,-u,lon1=-5.6,lat1=30,lon2=42,lat2=47)

 

* Now, handle 'Bay of Biscay' region, since it was overwritten by 'const(B)'

* So, re-plot const(A) over this small region

'display const(A,0,-u,lon1=-5.6,lat1=43,lon2=0,lat2=47)

 

Would it be feasible to modify the source code for 'const' in order to
achieve the 'regional cropping' of const that Ive shown in the example
above?

Or, Can my goal be achieved using some combination of 'const', 'maskout',
'set clip', or some other function(s)?

 

Please help,

Thanks,

Pablo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110115/73c7ea95/attachment-0003.html 


More information about the gradsusr mailing list