Re: about the blackbody radiation curve [message #72373] |
Fri, 03 September 2010 06:52 |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Wox wrote:
>
> Do something like
>
> y=a/(exp((h*c)/(k*x*t))-1)
> ind=where(x eq 0,ct)
> if ct ne 0 then y[ind]=0
I would recommend checking stuff before the calculation is done:
; Check values
loc = WHERE(x LT Tolerance OR FINITE(x) EQ 0, count)
IF ( count GT 0 ) THEN $
MESSAGE, 'Input X-values < or = 0.0, NaN, or Inf found.'
where "Tolerance" is the eps output from MACHAR. One should avoid floating point equality tests.
cheers,
paulv
|
|
|
Re: about the blackbody radiation curve [message #72375 is a reply to message #72373] |
Fri, 03 September 2010 05:36  |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Thu, 2 Sep 2010 20:37:29 -0700 (PDT), panshu Zhao
<rochesterzhao@gmail.com> wrote:
> PRO radiation
>
>
> h=6.626068e-27;
> k=1.38066e-16;
> c=2.997925e+10;
> t=6000;
> x=findgen(100)*0.0000001;
> a=2*h*(c^2)*(x^(-5));
>
> if x=0 then begin
> y=0
> endif else begin
> y=(a)/ (exp((h*c)/(k*x*t))-1)
> endelse
> plot,x,y
>
> END
Do something like
y=a/(exp((h*c)/(k*x*t))-1)
ind=where(x eq 0,ct)
if ct ne 0 then y[ind]=0
|
|
|
|