comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to calculate the curve area?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: How to calculate the curve area? [message #44516] Tue, 21 June 2005 14:23
Julio[1] is currently offline  Julio[1]
Messages: 52
Registered: May 2005
Member
Now I'm using int_tabulated.pro (from IDL library). It's working
fine...

Best Regards!
Julio
Re: How to calculate the curve area? [message #44519 is a reply to message #44516] Tue, 21 June 2005 13:30 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Julio wrote:
> Hi Benjamin.
>
> The total command returns me returns the sum of the elements of an
> array. However, I need to find the area of the curve.
>
> I found the TSUM.PRO routine (see below), it calculates the integrated
> area of a curve. I think it is what I need,
> Thanks at any rate,
> Julio
>
> http://idlastro.gsfc.nasa.gov/ftp/pro/math/tsum.pro
>

You could use the INT_TABULATED IDL function.

Or use Simpson's rule. I have a integral.pro routine that does this. From the header:

; CALLING SEQUENCE:
; result = integral( x, y )
;
; INPUTS:
; x: Vector of abscissa points. Elements must be unique and monotonically
; increasing.
;
; y: Vector of corresponding ordinate points.
;
; EXAMPLE:
; Define 11 x-values on the closed interval [0.0 , 0.8].
;
; IDL> x = [ 0.0, .12, .22, .32, .36, .40, .44, .54, .64, .70, .80 ]
;
; Define 11 f-values corresponding to x(i).
;
; IDL> f = [ 0.200000, 1.30973, 1.30524, 1.74339, 2.07490, 2.45600, $
; IDL> 2.84299, 3.50730, 3.18194, 2.36302, 0.231964 ]
;
; Compute the integral:
;
; IDL> result = integral( x, f )
; IDL> HELP, result
; RESULT DOUBLE = 1.6274544
;
; In this example, the f-values are generated from a known function,
; (f = .2 + 25*x - 200*x^2 + 675*x^3 - 900*x^4 + 400*x^5)
;
; The Multiple Application Trapezoid Method yields; result = 1.5648
; The Multiple Application Simpson's Method yields; result = 1.6036
; IDL User Library INT_TABULATED.PRO yields; result = 1.6232
; INTEGRAL.PRO yields; result = 1.6274
; The Exact Solution (4 decimal accuracy) yields; result = 1.6405


paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: How to calculate the curve area? [message #44520 is a reply to message #44519] Tue, 21 June 2005 13:19 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
Julio wrote:
> Hi Benjamin.
>
> The total command returns me returns the sum of the elements of an
> array. However, I need to find the area of the curve.
>

Well, as long as the dataset is equally spaced on the X axis, the result
from TOTAL is proportional to the area under the curve. If it's not
equally spaced, you could interpolate. It's just a question of the units
on each axis. Or am I missing something?

Benjamin
Re: How to calculate the curve area? [message #44522 is a reply to message #44520] Tue, 21 June 2005 13:04 Go to previous message
Julio[1] is currently offline  Julio[1]
Messages: 52
Registered: May 2005
Member
Hi Benjamin.

The total command returns me returns the sum of the elements of an
array. However, I need to find the area of the curve.

I found the TSUM.PRO routine (see below), it calculates the integrated
area of a curve. I think it is what I need,
Thanks at any rate,
Julio

http://idlastro.gsfc.nasa.gov/ftp/pro/math/tsum.pro
Re: How to calculate the curve area? [message #44524 is a reply to message #44522] Tue, 21 June 2005 12:49 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
Julio wrote:
> Hello!
>
> Although my question is very simple, I haven't got it.
> I'm using PLOT command to plot curve from a 2D matrix. My problem is I
> need to calculate the area bellow the curve.
>

How about using TOTAL() on the dataset (if it is equally spaced)?

Benjamin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: data inside a circle
Next Topic: Re: Escaping Quotes

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:24:08 PDT 2025

Total time taken to generate the page: 0.00883 seconds