Hi Jingmin,
As Dennis indicated, your syntax is incorrect. You've provided the
conditional expression, but you have not told the function what to
do when the condition is true, and what to do when the condition is
false.
Please carefully study the documentation for the where function,
as it provides several examples that nicely illustrate proper use
of that function.
http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml
Good luck!
Daran
Daran Rife
Head of Mesoscale Modeling
GL Garrad Hassan
9665 Chesapeake Drive, Suite 435, San Diego, CA 92123, USA
Tel: +1 303 271 1450 / Fax: +1 303 271 1450 / Mobile: +1 303 968 6821
www.gl-garradhassan.com
This email is issued on behalf of Garrad Hassan America, Inc. (trading
as GL Garrad Hassan) and is subject to the GL Garrad Hassan email
disclaimer (http://www.gl-garradhassan.com/emaildisclaimer). Garrad
Hassan America, Inc. is registered in America No. 94-3402236 Registered
Office: 45 Main Street, Suite 302, Peterborough, NH 03458, USA
-- [1] The syntax you used is incorrect. Further, the shapes of the arrays in your statement are inconsistent. [2] If the sst array has one-dimensional coordinate variables, use sst(:,{latS:latN},{lonW:lonE}) = 0 If you are new to NCL, please read the mini-language manual at http://www.ncl.ucar.edu/Document/Manuals/ Good Luck On 4/11/12 1:51 AM, Jingmin Li wrote: > Hello, Here is me again. > > My code below at the line with where function should be : > > sst= where( (sst@lat.ge.latS .and. sst@lat.le.latN .and. \ > sst@lon.ge.lonW .and. sst@lon.le.lonE),0,sst) > > Sorry for my mistake. Please have a look what is the problem! > Thanks. > Jingmin > > ----- Forwarded message from jingmin.li@uni-tuebingen.de ----- > Date: Wed, 11 Apr 2012 09:26:00 +0200 > From: Jingmin Li<jingmin.li@uni-tuebingen.de> > Subject: Error from using "where" function > To: ncl-talk@ucar.edu > > Hello, > > I have a 3-dimensional array coordinate arrays time*lon*lat. I want to > set all values outside a domain region to 0. > > I copied one example of "where" function from NCL home. But I got > always error message like: > -------------------- > fatal:And: Dimension size, for dimension number 0, of operands does > not match, can't continue) > fatal:where: condition variable (parameter 1) dimension mismatch with > parameter 2. > ----------------------- > > Does anyone know what is the problem? Thanks! > Jingmin > > Here is my code: > --------------------- > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" > > begin > > data_dir = "/home/jingmin/echam_plot" > cdf_file = addfile(data_dir + "/T21_amip2sst_2000_copy.nc","r") > > sst = cdf_file->sst ; files to local variables. > sst@time = cdf_file->time > sst@lat = cdf_file->lat ; Create coordinate variables > sst@lon = cdf_file->lon ; for sst and store the sizes > > latS = 30.00 > latN = 40.00 > lonW = 70.00 > lonE = 140.00 > > sst= where( (sst@lat.ge.latS .and. sst@lat.le.latN .and. \ > sst@lon.ge.lonW .and. sst@lonE),0,sst) > end > ---------------------------------- _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Wed Apr 11 12:10:14 2012
This archive was generated by hypermail 2.1.8 : Fri Apr 13 2012 - 13:37:52 MDT