[Thread Prev][Thread Next][Index]

Re: irregular box from ij grid to xy grid ...



Hi Emilie,

	How to illustrate the domain of a second grid on a graphic
of a field from another grid is fairly easy if you remove the
restriction of not writing to/reading from a file. You use something
similar to the method of your second mail - i.e. creating a polygon.
How to mask one grid to reflect the extent of another has not come
to me yet.
   Here is a demo of overlaying a polygon:

! Demo: overlay polygon to illustrate domain of another grid
use etopo5
shade/x=350:370/y=40:50 rose ! this is the "first" grid

! now define a 5x4 grid of points to represent the "other" grid
def axis/x=1:5:1 xax ; def axis/y=1:4:1 yax
def grid/x=xax/y=yax grd
! and define lon,lat so it is a rotated parallelogram
let d2r=atan(1.)/45 ; let alfa=30
let cs=cos(d2r*alfa) ; let sn=sin(d2r*alfa)
let lon=360+x[g=grd]*cs+y[g=grd]*sn
let lat=45-x[g=grd]*sn+y[g=grd]*cs

! output the lon,lat coords of the outer strip of the grid
sp rm box.data    ! remove any previous version of the temporary file
sp touch box.data ! and prepare to append values to it
! "first" edge : j=1, i=1,2,3,4,5
repeat/k=1:5 (list/nohead/file=box.data/app/form=(2f8.3) \
              lon[i=`k`,j=1],lat[i=`k`,j=1])
! "second" edge : i=5, j=2,3,4
repeat/k=2:4 (list/nohead/file=box.data/app/form=(2f8.3) \
              lon[i=5,j=`k`],lat[i=5,j=`k`])
! "third" edge : j=4, i=4,3,2,1
repeat/k=2:5 (list/nohead/file=box.data/app/form=(2f8.3) \
              lon[i=`6-k`,j=4],lat[i=`6-k`,j=4])
! "last" edge : i=1, j=3,2
repeat/k=2:4 (list/nohead/file=box.data/app/form=(2f8.3) \
              lon[i=1,j=`5-k`],lat[i=1,j=`5-k`])
! actually it wouldn't matter if you duplicated the corners

! read back the polygon box
file/form=free/var=bx,by box.data
polygon/o/nolab/line=1 bx,by        ! to surround region with a box, OR
! polygon/o/pat=lite_vertical bx,by ! to shade region with a pattern
!----------------------------------------------------------------------

Good luck,
Mick

|!!! Mick.Spillane@noaa.gov !!!|
|__Room 2070 Bldg#3 NOAA/PMEL__|
|____Phone_:_(206)526-6780_____|




[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement