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

Home » Public Forums » archive » Re: Error detected while calling MPFIT_FDJAC2
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
Re: Error detected while calling MPFIT_FDJAC2 [message #71481] Wed, 23 June 2010 17:16 Go to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Jun 23, 4:39 am, Fermiona Fermiona <fermion...@gmail.com> wrote:
> It works now after I found the "transpose" of the subarrays:
>
> args = {X:transpose(x_n), Y:transpose(y_n), ERR:transpose(yerr)}
>
> It would have been really nice if we could get an error about the
> wrong type of structure MPFIT accepts.
>
> Thaaanks!!!

Quoting the documentation...
; In general there are no restrictions on the number of dimensions in
; X, Y or ERR. However the deviates *must* be returned in a
; one-dimensional array, and must have the same type (float or
; double) as the input arrays.

CM
Re: Error detected while calling MPFIT_FDJAC2 [message #71487 is a reply to message #71481] Wed, 23 June 2010 01:39 Go to previous messageGo to next message
Fermiona Fermiona is currently offline  Fermiona Fermiona
Messages: 17
Registered: June 2010
Junior Member
It works now after I found the "transpose" of the subarrays:

args = {X:transpose(x_n), Y:transpose(y_n), ERR:transpose(yerr)}

It would have been really nice if we could get an error about the
wrong type of structure MPFIT accepts.

Thaaanks!!!
Re: Error detected while calling MPFIT_FDJAC2 [message #71488 is a reply to message #71487] Tue, 22 June 2010 23:35 Go to previous messageGo to next message
Fermiona Fermiona is currently offline  Fermiona Fermiona
Messages: 17
Registered: June 2010
Junior Member
The first time I called MPFIT was to fit an entire set of data (30
points), i.e. no need for a loop


The second time I called MPFIT was to fit a subset of the entire set
(6 points at a time, hence the need for a loop)--> this fails

Thank you!!
Re: Error detected while calling MPFIT_FDJAC2 [message #71489 is a reply to message #71488] Tue, 22 June 2010 21:47 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Jun 22, 5:40 am, Fermiona Fermiona <fermion...@gmail.com> wrote:
> Hello Dr. Craige,
>
> I didn't compute the derivatives. The user function returnes the
> residual:
>
> FUNCTION LinearFit, p, X=x, Y=y, ERR=err, $
>                     perror=perror, bestnorm=bestnorm, dof=dof
>
>     model = p[0]+p[1]*x
>     resid = (y-model)/err
>
>     return, resid
> END
>
> and inside the procedure, I had:
>
> p0 = [51.0,-0.5]
> args = {X:x_n, Y:y_n, ERR:yerr}
> fit_res = mpfit('LinearFit', p0, functargs=args,perror=perror,
> bestnorm=bestnorm, dof=dof)
>
> The first time I called mpfit outside of the loop, there was no
> error.
> When mpfit was called again, from inside the loop this time, I got the
> error I mentioned.
>

I'm guessing what "inside" and "outside" of a loop might mean.

Forgetting a loop, does your experience mean that you can call MPFIT
with some arguments a first time, and it works; and then you do it
again with *exactly* the same arguments and it fails? That would be
odd.

Or, do you mean you are calling MPFIT recursively?

Craig
Re: Error detected while calling MPFIT_FDJAC2 [message #71503 is a reply to message #71489] Tue, 22 June 2010 02:40 Go to previous messageGo to next message
Fermiona Fermiona is currently offline  Fermiona Fermiona
Messages: 17
Registered: June 2010
Junior Member
Hello Dr. Craige,

I didn't compute the derivatives. The user function returnes the
residual:

FUNCTION LinearFit, p, X=x, Y=y, ERR=err, $
perror=perror, bestnorm=bestnorm, dof=dof

model = p[0]+p[1]*x
resid = (y-model)/err

return, resid
END


and inside the procedure, I had:

p0 = [51.0,-0.5]
args = {X:x_n, Y:y_n, ERR:yerr}
fit_res = mpfit('LinearFit', p0, functargs=args,perror=perror,
bestnorm=bestnorm, dof=dof)

The first time I called mpfit outside of the loop, there was no
error.
When mpfit was called again, from inside the loop this time, I got the
error I mentioned.

Many thanks!
Re: Error detected while calling MPFIT_FDJAC2 [message #71506 is a reply to message #71503] Tue, 22 June 2010 00:48 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Jun 21, 3:15 pm, Fermiona Fermiona <fermion...@gmail.com> wrote:
> Hello,
>
> I used MPFIT within a loop and I got the following errors:
>
> % MPFIT: Error detected while calling MPFIT_FDJAC2:
> % MPFIT: Out of range subscript encountered: FJAC.
> % MPFIT: Error condition detected. Returning to MAIN level.
>
> The function carried out "Iter      1", calculated "CHI-SQUARE" and
> "DOF" then found the value of the parameters P(0), P(1), etc ..
> After that, it reported the above errors, and increased the dof by 1
> (and consequently skipped finding the value of one of the Params),
> then carried out the rest of iterations.
>
> What could be wrong?

Well the obvious answer is that there was an error while calling
MPFIT_FDJAC2! That is where the user function and its derivatives are
evaluated.

I suspect you are attempting to compute your own explicit derivatives
and not returning an array with the right dimensions and/or sizes.

Regards,
Craig Markwardt
Re: Error detected while calling MPFIT_FDJAC2 [message #88478 is a reply to message #71481] Thu, 01 May 2014 07:28 Go to previous messageGo to next message
pete.petrus is currently offline  pete.petrus
Messages: 1
Registered: May 2014
Junior Member
On Wednesday, June 23, 2010 8:16:17 PM UTC-4, Craig Markwardt wrote:
> On Jun 23, 4:39 am, Fermiona Fermiona <fermion...@gmail.com> wrote:
>> It works now after I found the "transpose" of the subarrays:
>>
>> args = {X:transpose(x_n), Y:transpose(y_n), ERR:transpose(yerr)}
>>
>> It would have been really nice if we could get an error about the
>> wrong type of structure MPFIT accepts.
>>
>> Thaaanks!!!
>
> Quoting the documentation...
> ; In general there are no restrictions on the number of dimensions in
> ; X, Y or ERR. However the deviates *must* be returned in a
> ; one-dimensional array, and must have the same type (float or
> ; double) as the input arrays.
>
> CM

Ha ha bit me too.

"However the deviates *must* be returned in a
; one-dimensional array"

A error code for this (when the residuals are not 1-D) with something like STATUS "-19 Hey dumb-ass read the documentation" would be helpful

Cheers

-- Pete
Re: Error detected while calling MPFIT_FDJAC2 [message #88480 is a reply to message #88478] Thu, 01 May 2014 10:34 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Thursday, May 1, 2014 10:28:01 AM UTC-4, pete....@gmail.com wrote:
> On Wednesday, June 23, 2010 8:16:17 PM UTC-4, Craig Markwardt wrote:
>
>> On Jun 23, 4:39 am, Fermiona Fermiona <fermion...@gmail.com> wrote:
>
>>> It works now after I found the "transpose" of the subarrays:
>
>>>
>
>>> args = {X:transpose(x_n), Y:transpose(y_n), ERR:transpose(yerr)}
>
>>>
>
>>> It would have been really nice if we could get an error about the
>
>>> wrong type of structure MPFIT accepts.
>
>>>
>
>>> Thaaanks!!!
>
>>
>
>> Quoting the documentation...
>
>> ; In general there are no restrictions on the number of dimensions in
>
>> ; X, Y or ERR. However the deviates *must* be returned in a
>
>> ; one-dimensional array, and must have the same type (float or
>
>> ; double) as the input arrays.
>
>>
>
>> CM
>
>
>
> Ha ha bit me too.
>
>
>
> "However the deviates *must* be returned in a
>
> ; one-dimensional array"
>
>
>
> A error code for this (when the residuals are not 1-D) with something like STATUS "-19 Hey dumb-ass read the documentation" would be helpful

Good point. Could you run MPFIT with /NOCATCH set, to find out where it crashes specifically?

Thanks,
Craig
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: linear interpolation to form a deformation field
Next Topic: IDLDoc + HTML

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

Current Time: Wed Oct 08 09:18:19 PDT 2025

Total time taken to generate the page: 0.00535 seconds