<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lindoze.net &#187; Gnuplot</title>
	<atom:link href="http://blog.lindoze.net/tag/gnuplot/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lindoze.net</link>
	<description>Lindoze.net Weblog</description>
	<lastBuildDate>Sat, 02 Aug 2008 12:15:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Libiap: interactive plotting/fitting using Gnuplot</title>
		<link>http://blog.lindoze.net/software/gnuplot-libiap-fit-lorentzsum/</link>
		<comments>http://blog.lindoze.net/software/gnuplot-libiap-fit-lorentzsum/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 19:47:38 +0000</pubDate>
		<dc:creator>flo</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Gnuplot]]></category>
		<category><![CDATA[Physics]]></category>

		<guid isPermaLink="false">http://blog.lindoze.net/?p=32</guid>
		<description><![CDATA[Libiap is a set of Gnuplot (&#62;=4.2) scripts to provide a simple library to handle mouse input in Gnuplot. So far interactive fitting of a sum of several Lorentzian curves to some data has been implemented. But it can be easily adopted to fit e.g. Gaussians, exponential decay, etc. Interactive fitting is fitting a set [...]]]></description>
			<content:encoded><![CDATA[<p><em>Libiap</em> is a set of Gnuplot (&gt;=4.2) scripts to provide a simple library to handle mouse input in Gnuplot. So far interactive fitting of a sum of several Lorentzian curves to some data has been implemented. But it can be easily adopted to fit e.g. Gaussians, exponential decay, etc.</p>
<p>Interactive fitting is fitting a set of data by supplying the initial guess values just by clicking on the plot. You also can use <em>libiap</em> for completely different tasks in your own scripts. Just Have a look at the demonstration program of <em>libiap</em>&#8230;</p>
<p><span id="more-32"></span></p>
<h3>Demonstration</h3>
<p>Here is a step-by-step introduction of the demonstration program.</p>
<h4>Step 0</h4>
<p>Download <a href="http://blog.lindoze.net/wp-content/uploads/2008/06/libiap-20080628.zip">libiap-20080628.zip</a> (2008/06/28, cc-by-nc-sa licence) and extract the *.zip file. Run Gnuplot and type &#8220;load demo1.gnuplot&#8221;.</p>
<h4>Step 1</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen1.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen1" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen1-80x80.png" alt="Create some random peaks for demo" width="80" height="80" /></a>This screen only displays a superposition of four randomly generated Lorentz peaks. Press &#8220;y&#8221; on your keyboard if you want to generate a new set of data. Press &#8220;n&#8221; or just &#8220;return&#8221; to proceed. Hint: The default answer is always printed in capital letters. &#8220;return&#8221; accepts this default.</p>
<h4>Step 2</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen2.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen2" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen2-80x80.png" alt="Demo data with added noise" width="80" height="80" /></a>To make the fitting procedure more interesting a small amount of noise is added to the actual function. You can see the generated data in &#8220;demo1.dat&#8221;. Press any key on the keyboard to continue.</p>
<h4>Step 3</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen3.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen3" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen3-80x80.png" alt="Select minimum x value" width="80" height="80" /></a>Select the minimal x value you want to consider for the fit. You could use this feature to suppress peaks you don&#8217;t want to be fitted.</p>
<h4>Step 4</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen4.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen4" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen4-80x80.png" alt="Select maximum x value" width="80" height="80" /></a>Now select the maximum x value.</p>
<h4>Step 5</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen5.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen5" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen5-80x80.png" alt="Select baseline/offset" width="80" height="80" /></a>Click on the baseline of your spectrum (&#8220;offset&#8221;).</p>
<h4>Step 6</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen6.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen6" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen6-80x80.png" alt="Select first maximum" width="80" height="80" /></a>Select the first peak by clicking on its maximum. Actually you&#8217;d have to click slightly below, but the fit usually converges anyway.</p>
<h4>Step 7</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen7.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen7" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen7-80x80.png" alt="Select FWHM by mouse click" width="80" height="80" /></a>Select the full width at half maximum of your peak. The green line is right in the middle of the baseline and the maximum. So click somewhere on the intersection of the green line and your peak &#8211; or where you think the peak should intersect the green line.</p>
<h4>Step 8</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen8.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen8" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen8-80x80.png" alt="Do you want to add more peaks? Yes!" width="80" height="80" /></a>After selecting the FWHM you&#8217;ll be asked if you want to add more peaks. You can do so by pressing the &#8220;y&#8221; or &#8220;return&#8221; key. This will repeat step 7 until you have selected all peaks (four in the demonstration).</p>
<h4>Step 9</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen9.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen9" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen9-80x80.png" alt="Finally a guess for each peak has been made" width="80" height="80" /></a>If you have selected all peaks, press &#8220;n&#8221; in order to start the actual fitting procedure with the guesses you just made.</p>
<h4>Step 10</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen10.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen10" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen10-80x80.png" alt="See the initial values BEFORE the fitting procedure" width="80" height="80" /></a>This screen shows your initial guesses again. Should look quite good already.</p>
<h4>Step 11</h4>
<p><a href="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen11.png" rel="lightbox[32]"><img class="ngg-singlepic ngg-left ngg-clear" title="libiap-demo1-screen11" src="http://blog.lindoze.net/wp-content/uploads/2008/06/demo1-screen11-80x80.png" alt="...and the final result!" width="80" height="80" /></a></p>
<p>So now here&#8217;s the final result &#8211; without typing a single number! The fit results are written to &#8220;demo1_fit.gnuplot&#8221; as a Gnuplot script. You can easily load this file into your post-processing scripts and use all results there without having to fit the data again.</p>
<p>The screenshots have been made with Gnuplot from CVS and the wxWidgets terminal &#8220;wxt&#8221; (which looks much better than the usual x11 terminal).</p>
<h3>Pitfalls</h3>
<ul>
<li>The demonstration &#8220;demo1.gnuplot&#8221; needs write access to the current directory, because it stores the sample data in a file called &#8220;demo1.dat&#8221;. It also generates a file called &#8220;demo1_fit.gnuplot&#8221; with the fit results.</li>
<li>Don&#8217;t call &#8220;gnuplot demo1.gnuplot&#8221; directly. This wouldn&#8217;t give you an interactive gnuplot shell and close right after the last plot has been displayed.</li>
</ul>
<h3>Known bugs</h3>
<ul>
<li>No bugs know yet. If you find any please let me know (preferably already with a solution <img src='http://blog.lindoze.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ).</li>
</ul>
<h3>Downloads</h3>
<ul>
<li> <a href="http://blog.lindoze.net/wp-content/uploads/2008/06/libiap-20080628.zip">libiap-20080628.zip</a> (2008/06/28, cc-by-nc-sa licence)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.lindoze.net/software/gnuplot-libiap-fit-lorentzsum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

