X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 03 Aug 2008 08:19 PM by  anon
GAUSSFIT Error
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
03 Aug 2008 08:19 PM
    Hello! I was attempting to fit gaussians to some spectral lines and found the procedure gaussfit. In the help file an example procedure is listed (ex_gaussfit.pro). When I ran the program expressly as written I received the following error: IlseDL> ex_gaussfit Expected: 4.00000 1.00000 2.00000 1.00000 0.250000 0.0100000 % Keyword parameters not allowed in call. % Execution halted at: EX_GAUSSFIT 25 C:\RSI\idl\Default\ex_gaussfit.pro % $MAIN$ In the example, gaussfit is called upon like this: yfit = GAUSSFIT(x, y, coeff, NTERMS=nterms) So I tried running it like this: yfit = GAUSSFIT(x, y, coeff) Since nterms was an optional input parameter. I then got the error: IlseDL> ex_gaussfit Expected: 4.00000 1.00000 2.00000 1.00000 0.250000 0.0100000 % Attempt to subscript A with is out of range. % Error occurred at: FUNCT 51 C:\RSI\idl\funct.pro % CURVEFIT 88 C:\RSI\idl\curvefit.pro % GAUSSFIT 62 C:\RSI\idl\gaussfit.pro % EX_GAUSSFIT 25 C:\RSI\idl\Default\ex_gaussfit.pro % $MAIN$ % Execution halted at: EX_GAUSSFIT 25 C:\RSI\idl\Default\ex_gaussfit.pro Does anybody have any ideas? I tried creating some random graphs and applying gaussfit to those via the command line but got similar errors. Is it something to do with my IDL? I have 7.0 Thank you. Ilse Cleeves pro ex_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, 'Expected: ', a z = (x - a[1])/a[2] ; Gaussian variable !P.MULTI = [0,2,2] ; set up 2x2 plot window 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: PLOT, x, y, TITLE='nterms='+STRTRIM(nterms,2) OPLOT, x, yfit, THICK=2 endfor end

    Deleted User



    New Member


    Posts:
    New Member


    --
    03 Aug 2008 08:19 PM
    I copied/pasted the example code from the Help page and it worked, using IDL 7.0. Idea 1: the call to GAUSSFIT appears on line 28 in my code; might you have missed a line or two when copying the example? Idea 2: IDL finds GAUSSFIT in C:\RSI\idl. This is not the default install location for this IDL library function. Are you using the IDL 7.0 version of GAUSSFIT, or some other version? (You can check line 1 of gaussfit.pro for the IDL version.) mp
    You are not authorized to post a reply.