; ; AC 22/03/2007 ; ; put in one file basic tests for MPFIT ; FUNCTION MYGAUSS, X, P RETURN, P[0] + GAUSS1(X, P[1:3]) END ; pro test_mpfit ; print, 'You must have MPfit Library in your IDL/GDL PATH' print, 'This procedure only helps to quickly run the tutorial' print, 'http://cow.physics.wisc.edu/~craigm/idl/mpfittut.html' ; ; we don't know where is the data file ; chemin=file_which('fakedata.sav') if (STRLEN(chemin) EQ 0) then begin print, 'data file not found. It should have be found' print, 'if the GDL_PATH includes the path to MPFIT library' return endif ; ; obviously, the CMSVlib must be present ! ; restore, chemin ; start = [950.D, 2.5, 1., 1000.] ; expr = 'P[0] + GAUSS1(X, P[1:3])' result1 = MPFITEXPR(expr, t, r, rerr, start,/quiet) ; result2 = MPFITFUN('MYGAUSS', t, r, rerr, start, /quiet) ; ; tabulated value of reference run ; ref_res=[997.61864, 2.1550703, 1.4488421, 3040.2411] ; format='(a,4(" ",g8.7))' print, 'Output of basic test' print, format=format, 'Expected result : ', ref_res print, format=format, 'Computed result (v1 exp): ', result1 print, format=format, 'Computed result (v2 fun): ', result2 ; ; --------- second part of tests ; pi = replicate({fixed:0, limited:[0,0], limits:[0.D,0.D]},4) pi(0).fixed = 1 start(0) = 1000. ; nref_res=[1000.0 ,2.154962, 1.442753, 3021.817] ; nresult1 = MPFITEXPR(expr, t, r, rerr, start, PARINFO=pi,/quiet) nresult2 = MPFITFUN('MYGAUSS', t, r, rerr, start, PARINFO=pi,/quiet) ; print, 'Output of test under constrain' print, format=format, 'Expected result : ', nref_res print, format=format, 'Computed result (v1 exp): ', nresult1 print, format=format, 'Computed result (v2 fun): ', nresult2 ; end