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

Home » Public Forums » archive » MPFITFUN error -- only reading the first data value
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: MPFITFUN error -- only reading the first data value [message #90711 is a reply to message #90708] Wed, 01 April 2015 11:14 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Tuesday, March 31, 2015 at 5:45:03 PM UTC-5, graham kerr wrote:
> Hello everyone,
>
> I am trying to use mpfitfun to fit data observed at multiple wavelengths to a blackbody function, with temperature as the only variable; so I'm trying to find the best fit temperature.
>
> My function is called planck_fit_sot.pro, and is below. When I use mpfitfun the output has clearly only tried to fit the first data point. For a few test runs where I simulated blackbody intensities at multiple wavelengths (100 in total), the fitting routine returns the temperature that I set the first data point to. Also, yfit has only one value (the first), with all the rest '0'.
>
> Does anyone know what (presumably silly) mistake I've made here, and why mpfitfun is not using all the data to fit the function?
>
> cheers,
> Graham
> _____________________________
>
> mpfitfun procedure where wave_rgb & data_rgb are input and temp_range and start_temp are included as optional input :-
>
> if n_elements(start_temp) eq 0 then start_temp = double(6000.0)
> parinfo = {value:0.0, fixed:0, limited:[0,0], limits:[0.0,0.0]}
> parinfo[0].value = start_temp
> parinfo[0].fixed = 0
> if n_elements(temp_range) eq 0 then begin
> parinfo[0].limited(*) = 0
> endif else begin
> parinfo[0].limited(*) = 1
> parinfo[0].limits[0] = temp_range[0]
> parinfo[0].limits[1] = temp_range[1]
> endelse
>
> fit_fn = mpfitfun('planck_fit_sot', wave_rgb, data_rgb, err, $
> parinfo = parinfo, double = double,$
> maxiter = 2000, bestnorm = bestnorm,$
> yfit = yfit, perror = perror, dof = dof,$
> status = status, errmsg=errmsg)
> _____________________________
>
> planck_fit_sot.pro :-
>
> FUNCTION planck_fit_sot, wave, temp
>
> ;Some constants
> cc = 2.99792458d10 ;cm/s
> hh = 6.62606957d-27 ;erg s
> kb = 1.3806488d-16 ;erg/K
>
> wave_cm = wave/1.e8 ;cm
>
> bb_fn = dblarr(n_elements(wave))
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;
> ;;;;;;;;;;; DEFINE THE FUNCTION ;;;;;;;;;
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;
>
> ;2*h*c^2.0
> const1 = double(2*hh*cc*cc)
>
> ;h*c/k
> const2 = double(hh*cc/kb)/wave_cm
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;
>
> bb_fn = const1 / ( wave_cm^5.0 * ( exp( const2]/temp)-1. ) )
>
> bb_fn = bb_fn*1.d-8 ;ergs/s/cm^2/sr/Ang
>
> bb_fn_watts = bb_fn/1.e7 ;W/cm^2/sr/Ang
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;
>
> return, bb_fn_watts
>
> end


As written it won't compile -- I'm guessing the "]" isn't supposed to be here:

bb_fn = const1 / ( wave_cm^5.0 * ( exp( const2]/temp)-1. ) )

Assuming that's fixed, I would speculate that your start_temp variable coming into the function is an array (possibly a 1-element array) instead of a scalar. Try "help, start_temp" to check.

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Keep getting a transparent background on a composite image
Next Topic: Function call string

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

Current Time: Wed Oct 08 13:46:59 PDT 2025

Total time taken to generate the page: 0.00442 seconds