[ncl-talk] Is there a where statement for this?
Will Hobbs
will.hobbs at utas.edu.au
Fri Sep 6 08:44:07 MDT 2019
Hi Barry
It’s a bit difficult to tell what you’re trying to do from that code snippet. I *think* you have 3 arrays : dcsi(Npod, Nsr), pod_7 (Npod * Nsr) and sr_7 (Npod*Nsr). You’re trying to replace values of pod_7 and sr_7 , where dcsi=700, with monotically increasing numbers with a stride of 0.001. If so, then the following will do that eliminating the loop; I don’t think the where() function will help here though
This is assuming I’ve understood what you’re trying to do (and I’m not sure about that)….
Will
;---------------------
dcsi1D = ndtooned(dcsi) ;1-d array, same shape as pod_7 and sr_7
ii = ind(dcsi1D.eq.700.)
N = dimsizes(ii)
newval = fspan(0., (N-1)*0.001, N) ; new array of replacement values
pod_7(ii) = newval
sr_7(ii) = newval
;------------------
From: ncl-talk <ncl-talk-bounces at ucar.edu> on behalf of Barry Lynn via ncl-talk <ncl-talk at ucar.edu>
Reply-To: Barry Lynn <barry.h.lynn at gmail.com>
Date: Friday, 6 September 2019 at 6:51 AM
To: ncl-talk <ncl-talk at ucar.edu>
Subject: [ncl-talk] Is there a where statement for this?
Hello:
I am wondering if there is someway to speed up a loop like this.
do i_pod = 1,n_pod-1
do i_sr = 1,n_sr-1
if (dcsi(i_pod,i_sr).eq.700)then
pod_7(i_val) = tofloat(i_pod)*.001
sr_7(i_val) = tofloat(i_sr)*.001
i_val = i_val + 1
end if
end do
end do
--
Barry H. Lynn, Ph.D
Senior Associate Scientist, Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581
C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com<http://weather-it-is.com>
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
University of Tasmania Electronic Communications Policy (December, 2014).
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190906/6648738c/attachment.html>
More information about the ncl-talk
mailing list