[Thread Prev][Thread Next][Index]
[las_users] Using Define Symbol Cause Custom Script to Fail
Hi All,
I am using a custom script, curvi_region_subset.jnl, to plot a
variable. I'm trying to mask our the portion of the plot for which
there is no data. When I do that I get a title for the plot that
includes the mask logic "if ( mask eq 1 ) then $1". So I have created a
symbol to create a title as follows:
def sym newTitle = `$1,return=title`
The inclusion of this line in the script at the bottom of this e-mail
causes the LAS to complain about bad illegal limits on the x axis.
Any ideas on what is going wrong? This strategy worked in another
script I an using so its failure is somewhat baffling.
Regards,
John
\cancel mode verify
! curvi_region_subset.jnl
! 9/12/05 ACM
! 11/2/05 version to call curv_range rather than curv_to_rect_map
! Description: plot a subset of a variable on a curvilinear grid, using
the region
! that has been set. Overlay a shade plot of the appropriate land mask
! This script assumes
! 1) The curvilinear data set has been opened
! 2) Any desired region has been set in X, Y, Z, and T
! 3) Variables dat_lon and dat_lat have been defined pointing to the
curvilinear
! coordinate variables including their units and title
! usage: arg1
! GO curvi_region_subset varname
! arguments:
! arg1 variable to shade using dat_lon and dat_lat
! Example:
! USE "/home/ja8/ansley/hazmat/TGLO-his-05-09-12-00-06.nc"
! LET/TITLE="`lon,RETURN=title`"/UNITS="`lon,RETURN=units`" dat_lon = lon
! LET/TITLE="`lat,RETURN=title`"/UNITS="`lat,RETURN=units`" dat_lat = lat
! SET REGION/X=97W:90W/Y=25N:30N/K=1/T="21-sep-2005:08:00"
!
! GO curvi_region_subset v
define region/default save
! Make a dummy plot to get the values of the region settings, modulo in x
use etopo120; shade/noax/nolab/nokey/pal=white rose; can data etopo120
let xmin = `($xaxis_min)`
let xmax = `($xaxis_max)`
let ymin = `($yaxis_min)`
let ymax = `($yaxis_max)`
! Save the time index corresponding to the region.
let timeindex = `l[gt=$1]`
! See if a region had indeed been set. If not use the range from the
! lon and lat curvlinear variables.
can region
IF `xmin eq 20` THEN
IF `xmax eq 380` THEN
LET xmin = `dat_lon[x=@min,y=@min]`
LET xmax = `dat_lon[x=@max,y=@max]`
ENDIF
ENDIF
IF `ymin eq -90` THEN
IF `ymax eq 90` THEN
LET ymin = `dat_lat[x=@min,y=@min]`
LET ymax = `dat_lat[x=@max,y=@max]`
ENDIF
ENDIF
set region save
can region/t
!
! Define a mapping from the curvilinear data to a rectangle bounded by the
! desired output range.
!
!! def axis/x=`xmin`:`xmax`/npoints=2/modulo/units=degrees xax
!! def axis/y=`ymin`:`ymax`/npoints=2/units=degrees yax
!!
!! let lonlatout = y[gy=yax] + x[gx=xax]
!!
!! ! Compute weights for the mapping
!! let map = curv_to_rect_map ( dat_lon, dat_lat, lonlatout, 10)
!! let map = curv_to_rect_map ( dat_lon, dat_lat, lonlatout, 10)
!! load map
!!
!! ! map includes the lon and lat indices from the source grid
!! ! which correspond to coordinates in the dest grid.
!!
!! let llon = map[i=1,j=@min,l=2,k=@min]
!! let llat = map[i=@min,j=1,l=3,k=@min]
!! let ulon = map[i=2,j=@max,l=2,k=@max]
!! let ulat = map[i=@max,j=2,l=3,k=@max]
!!
! Call curv_range to get the corresponding I and J range, in variable rr
let rr = curv_range (lon, lat, `xmin`, `xmax`, `ymin`, `ymax`, 0)
let llon = `rr[i=1]`
let ulon = `rr[i=2]`
let llat = `rr[i=3]`
let ulat = `rr[i=4]`
! say "lon index range `llon`:`ulon`"
! say "lat index range `llat`:`ulat`"
set region save
can region/t
def sym newTitle = `$1,return=title`
let masked_var1 = if ( mask eq 1 ) then $1
shade \
masked_var1[i=`llon`:`ulon`,j=`llat`:`ulat`,L=`timeindex`], \
dat_lon[i=`llon`:`ulon`,j=`llat`:`ulat`], \
dat_lat[i=`llon`:`ulon`,j=`llat`:`ulat`]
! SHADE the land mask
can region/x/y
! SHADE/OVER/NOLAB/LEV=(0,0,1)/PAL=grey \
! mask[i=`llon`:`ulon`,j=`llat`:`ulat`], \
! dat_lon[i=`llon`:`ulon`,j=`llat`:`ulat`], \
! dat_lat[i=`llon`:`ulon`,j=`llat`:`ulat`]
go land red
set region save
set mode/last verify
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement