X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 28 Jul 2015 03:53 PM by  anon
GAUSSFIT error
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
28 Jul 2015 03:53 PM
    Hi all, I'm trying to use the built-in IDL function gaussfit.pro, and every time I try, I get the following error % Keyword parameters not allowed in call. % Execution halted at: $MAIN$ I'm only trying to get the function to work right now, so I'm just running the sample code from the gaussfit help file, which calls the function like so: yfit = GAUSSFIT(x, y, coeff) This call doesn't even include a keyword parameter, so I'm baffled. I've also tried calling it with keywords set, and I get the same error. I have IDL version 8.3.0, if that make a difference. If anyone could help, I would really appreciate it!

    Deleted User



    New Member


    Posts:81
    New Member


    --
    29 Jul 2015 09:39 AM
    From the error message shown, I wonder if you have a syntax error elsewhere in your program, causing the error that you are seeing. Another possibility is that your IDL session is using an unexpected custom version the GAUSSFIT function that is being loaded from an unexpected source. To test the first idea, are you able to get the example code provided in the IDL Help for GAUSSFIT to work if you create a new program file in your IDL Workbench editor with the following contents: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Example for GAUSSFIT from IDL Help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pro test_gaussfit ; Define the independent variable. n = 101 x = (FINDGEN(n)-(n/2))/4 ; Define the coefficients. a = [4.0, 1.0, 2.0, 1.0, 0.25, 0.01] print, 'Expect: ', a z = (x - a[1])/a[2] ; Gaussian variable seed = 123321 ; Pick a starting seed value for nterms=3,6 do begin ; Define the dependent variables. Start with random noise. y = 0.4*RANDOMN(seed, n) ; Use a switch statement so we fall through to each term. switch nterms of 6: y = y + a[5]*x^2 5: y = y + a[4]*x 4: y = y + a[3] 3: y = y + a[0]*exp(-z^2/2) endswitch ; Fit the data to the function, storing coefficients in ; coeff: yfit = GAUSSFIT(x, y, coeff, NTERMS=nterms) print, 'Result: ', coeff[0:nterms-1] ; Plot the original data and the fitted curve: p1 = PLOT(x, y, TITLE='nterms='+STRTRIM(nterms,2), $ LAYOUT=[4,1,nterms-2], CURRENT=(nterms gt 3), $ DIMENSIONS=[800,200], MARGIN=[0.1,0.2,0.1,0.2]) p2 = PLOT(x, yfit, THICK=2, /OVERPLOT) endfor end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Save to a file named, "test_gaussfit.pro", and then compile and run the program. If this works correctly it may indicate that there is a syntax error in your original program. ------ However, if the GAUSSFIT call in the above program causes the same compile error as before, what do you get if you then issue the following IDL command: print, routine_info('gaussfit', /SOURCE, /FUNCTIONS) ----- I hope this can help. Regards,

    Deleted User



    New Member


    Posts:
    New Member


    --
    29 Jul 2015 09:59 AM
    Hi Jim, thank you for responding! Running the sample code you provided, I get the same error. I've also tried calling the function without the NTERMS keyword included in the call and still receive the error. ------- Using print, routine_info('gaussfit', /SOURCE, /FUNCTIONS) gives the following: { GAUSSFIT C:\Program Files\Exelis\IDL83\lib\gaussfit.pro} I've searched the system and don't see another copy of GAUSSFIT. ------ I should also mention that I have successfully used GAUSSFIT in the past with no issue. Since the last time I used it successfully, I haven't installed any new libraries or modified the GAUSSFIT code in any way. This error just started popping about a few days ago.

    Deleted User



    New Member


    Posts:
    New Member


    --
    31 Jul 2015 10:52 AM
    I resolved the issue, and figured I'd update in case anyone else ever has a similar problem. I had the correct copy of GAUSSFIT compiled, but GAUSSFIT calls another function, CURVEFIT, and the copy of CURVEFIT that was compiling was from a third party library. The error message made it seem as though the problem was with the call to GAUSSFIT itself, thus the confusion. Deleting the extraneous copy of CURVEFIT and recompiling solved the problem.

    Deleted User



    New Member


    Posts:81
    New Member


    --
    31 Jul 2015 01:41 PM
    Thanks for posting your solution, Joshua. I'll keep this in mind for the future.
    You are not authorized to post a reply.