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
MPFITFUN error -- only reading the first data value [message #90708] Tue, 31 March 2015 15:45 Go to previous message
graham kerr is currently offline  graham kerr
Messages: 5
Registered: March 2015
Junior Member
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
[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 11:33:24 PDT 2025

Total time taken to generate the page: 0.00396 seconds