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

Home » Public Forums » archive » mpfit questions /strange behavior
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
mpfit questions /strange behavior [message #72729] Fri, 01 October 2010 03:32
sirvival is currently offline  sirvival
Messages: 18
Registered: August 2010
Junior Member
Hi,
I just started getting used to mpfit.

My question is:
I call mpfit2Dfun as mentioned in the description
I have a function (extra pro).
If I use return, functionname inside the function I get a different
result than when I leave the return blank.
What am I doing wrong?
Also when the return is blank it runs much faster.
For demonstration here I reduced the size of my arrays.


My pro is:

if keyword_set(fspec1) eq 0 then begin
rstar = 10
nx = 1000
ny = 400
rotvel = 0.25
x = findgen(nx)
y = findgen(ny)
xpos = nx/2.
xprof = sqrt(1- (((x-xpos)/rstar)^2 <1))
ypos = ny/2
yprof = 1.-0.5*exp(-0.5*((y-ypos)/16)^2)
spec0 = xprof#yprof
sspec0 = spec0
rstar = 100
For j = fix(xpos)-fix(rstar),fix(xpos)+fix(rstar-1) do begin ;
(linien breite?)
sh = (j-fix(xpos))*rotvel ; 1 km/sec rot vel
sspec0(j,*) = shift(spec0(j,*),sh)
Endfor
fspec0 = sspec0
xprof = indgen(1000)
yprof = indgen(400)
psfx0 = exp(-.5/20^2*((findgen(21)-10))^2)
psfy0 = exp(-.5/10^2*(findgen(11)-5)^2)
psf0 = psfx0#psfy0
psf0 = psf0/total(psf0)
fspec0 = convol(sspec0,psf0,/edge_truncate)
fspec1 = fspec0 > 0.00005D
sqrt0 = sqrt(fspec0*100000000D)/100000000D
sqrt0 = sqrt0 > 0.0000005D

endif else begin
if keyword_set(fspec1) ne 0 then fspec1=fspec1
endelse
window,0
window,1
wset,0
shade_surf,fspec1,charsize=2.5
wset,1
print,'starting mpfit'

parinfo=replicate({value:0D,step:0D,relstep:0D},5)
parinfo[*].value = [10D,20D,10D,100D,0.25D]
parinfo[*].step = [0,0,0,0,0]
parinfo[*].relstep = [0.05D,0.05D,0.05D,0.05D,0.005D]
test =
mpfit2Dfun('specfunc',xprof,yprof,fspec1,sqrt0,parinfo=parin fo)

end


The Function:


Function specfunc,x,y,p

x = dindgen(1000)
y = dindgen(400)
xprof = sqrt(1- (((x-500)/p[0])^2 <1))
yprof = 1.-0.5*exp(-0.5*((y-200)/16)^2)
spec = xprof#yprof
rotvel = p[4]
xpos = 500
For j = fix(xpos)-fix(p[3]),fix(xpos)+fix(p[3]-1) do begin ; (linien
breite?)
sh = (j-fix(xpos))*rotvel ; 1 km/sec rot vel
spec(j,*) = shift(spec(j,*),sh)
Endfor
specfunc = spec
xdim = dindgen(21)
ydim = dindgen(11)
psfx = exp(-.5/p[1]^2*(xdim-10)^2)
psfy = exp(-.5/p[2]^2*(ydim-5)^2)
psf = psfx#psfy
psf = psf/total(psf)
print,'starting convolution (MPFIT)'
specfunc = convol(spec,psf,/edge_truncate)
specfunc = specfunc > 0.00005D
shade_surf,specfunc,charsize=2.5
return,specfunc

end


Thanks.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: while running mdefringe.pro
Next Topic: Color the points with different colors

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

Current Time: Wed Oct 08 15:16:49 PDT 2025

Total time taken to generate the page: 0.06114 seconds