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

Home » Public Forums » archive » How to use mpfitfun.pro for fitting?
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
How to use mpfitfun.pro for fitting? [message #93364] Sun, 26 June 2016 22:14 Go to next message
Sonu Tabitha is currently offline  Sonu Tabitha
Messages: 29
Registered: April 2016
Junior Member
I went through the documentation but I didn't understand it much. Can anyone of you please give me a sample mpfitfun.pro (with the definition of function)?

PS:Infact I am having a set of flux values(measured) for 4 sources at 5 frequency bands. I know the expression of flux and it's a function of 5 parameters.
Re: How to use mpfitfun.pro for fitting? [message #93365 is a reply to message #93364] Mon, 27 June 2016 04:00 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Monday, June 27, 2016 at 6:14:40 AM UTC+1, Meegle_Jade wrote:
> I went through the documentation but I didn't understand it much. Can anyone of you please give me a sample mpfitfun.pro (with the definition of function)?
>
> PS:Infact I am having a set of flux values(measured) for 4 sources at 5 frequency bands. I know the expression of flux and it's a function of 5 parameters.

Hi,
I'm not sure what the problem with the function definition is. In the instructions I found this:
; FUNCTION MYFUNCT, X, P
; ; The independent variable is X
; ; Parameter values are passed in "P"
; YMOD = ... computed model values at X ...
; return, YMOD
; END

And it worked for me. But anyhow, below is an example that works well for me (adapted from something that I use):

function mySineFunction, x, p
return, p[0] + p[1] * sin(x * p[2] /!radeg + p[3])
end

pro doTheFit, angles, xPos
;************* fit x ****************
xSineFit = double(angles)
ySineFit = double(xPos)
yerr = 1
starty = [-800d, 1000d, 1d, -90d]
xResult = mpfitfun('mySineFunction', xSineFit, ySineFit, yerr, startY)
print, xResult
end

I hope this helps.

Cheers,
Helder
Re: How to use mpfitfun.pro for fitting? [message #93372 is a reply to message #93364] Mon, 27 June 2016 08:49 Go to previous messageGo to next message
Sonu Tabitha is currently offline  Sonu Tabitha
Messages: 29
Registered: April 2016
Junior Member
On Monday, June 27, 2016 at 10:44:40 AM UTC+5:30, Meegle_Jade wrote:
> I went through the documentation but I didn't understand it much. Can anyone of you please give me a sample mpfitfun.pro (with the definition of function)?
>
> PS:Infact I am having a set of flux values(measured) for 4 sources at 5 frequency bands. I know the expression of flux and it's a function of 5 parameters.

Thanks a lot for the reply.
Re: How to use mpfitfun.pro for fitting? [message #93373 is a reply to message #93364] Mon, 27 June 2016 08:54 Go to previous messageGo to next message
Sonu Tabitha is currently offline  Sonu Tabitha
Messages: 29
Registered: April 2016
Junior Member
On Monday, June 27, 2016 at 10:44:40 AM UTC+5:30, Meegle_Jade wrote:
> I went through the documentation but I didn't understand it much. Can anyone of you please give me a sample mpfitfun.pro (with the definition of function)?
>
> PS:Infact I am having a set of flux values(measured) for 4 sources at 5 frequency bands. I know the expression of flux and it's a function of 5 parameters.

So where should I write the function? Should I save in the dothefit.pro textfile or should I save the function seperately in another text file?
Re: How to use mpfitfun.pro for fitting? [message #93374 is a reply to message #93373] Mon, 27 June 2016 14:23 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Monday, June 27, 2016 at 11:54:16 AM UTC-4, Meegle_Jade wrote:
> So where should I write the function? Should I save in the dothefit.pro textfile or should I save the function seperately in another text file?

Maybe it's worth starting with the tutorial.
https://www.physics.wisc.edu/~craigm/idl/mpfittut.html
See if you can master that first before going to your more complicated problem.

But yes, *typically* one writes the user fitting function as a stand-alone file. David Fanning's tips can help:
http://www.idlcoyote.com/tips/namefiles.html

It's also possible to put everything in an IDL "script" file that you can use ".RUN" with. The only trick is that the fitting function has to be at the top, and then the executable statements appear last. I do this all the time.

Craig
Re: How to use mpfitfun.pro for fitting? [message #93375 is a reply to message #93364] Mon, 27 June 2016 18:57 Go to previous message
Sonu Tabitha is currently offline  Sonu Tabitha
Messages: 29
Registered: April 2016
Junior Member
On Monday, June 27, 2016 at 10:44:40 AM UTC+5:30, Meegle_Jade wrote:
> I went through the documentation but I didn't understand it much. Can anyone of you please give me a sample mpfitfun.pro (with the definition of function)?
>
> PS:Infact I am having a set of flux values(measured) for 4 sources at 5 frequency bands. I know the expression of flux and it's a function of 5 parameters.

Thanks a lot!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How reload (re-import) a modified Python module through the IDL to Python bridge ?
Next Topic: Bug in legend() for horizontal orientations

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

Current Time: Wed Oct 08 09:20:44 PDT 2025

Total time taken to generate the page: 0.00415 seconds