[Thread Prev][Thread Next][Index]

Calls of an external function to evaluate Ferret expressions



Hello Ferreters,
	I'm doing scatter plot between two variables (varx vs. vary).
One of these variables are calculated using an external function.
Next, both these variables are used to 'bin' the data and plot line
graph over the previous view itself. So the sequence of commands
are something like this:

...

let varx = ... ! uses ferret expressions and file variables
               ! (without a function call).

let vary1 = extfun1(v1,v2,v3,...) ! v1, v2, v3 are file variables.
! Now there's a condition to get final vary
let vary = if vary1 gt 0 then vary1
! and plot it
plot/vs varx, vary
! The regions are not specified explicitly but given in []'s while
!  defining the variables.
! At this point, a single write(*,*) statement from extfun1()
! displays:
Hi from extfun1
Hi from extfun1
! which means extfun1() is being called twice. This is most probably
! due to the definition of vary which involves vary1 twice. (A simple
! check with let vary = if vary1 gt 0 then (vary1 + vary1)*0.5 prints
! the message 3 times.)

! Now I try to bin this variables:
 let binxy = bin_1d(varx,vary,xi,xf,xw) ! This is another external
             ! function which returns 2D result along abstract axes.
! and plot
 plot/vs/over/line=8 binxy[j=1],binxy[j=2]
! but again those messages appear:
Hi from extfun1
Hi from extfun1
! which shows that extfun1() was called again two times.

Since everything remains same (data and region) between the scatter
and bin-ed line plots, there is not need to call extfun1() again.
If the variable (from external function) is being calculated every
time it appears in an expression, then it may become time consuming
especially if the external function does a huge set of computations.

Is there any way I can reduce these 4 calls of extfun1() by a
single call? Or any tricks in re-arranging these statements
(commands) to reduce the time taken by the whole procedure?


Many thanks in advance,

arindam chakraborty
------------------------------------------
 ARINDAM CHAKRABORTY
 Centre for Atmospheric & Oceanic Sciences
 Indian Institute of Science
 Bangalore 560 012; INDIA
 Tel: +91-80-2932505, +91-80-3600450
 Fax: +91-80-3600865
__________________________________________



[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement