{"id":148,"date":"2022-05-31T13:39:54","date_gmt":"2022-05-31T13:39:54","guid":{"rendered":"http:\/\/musruser.psi.ch\/wordpress\/?page_id=148"},"modified":"2024-05-15T15:29:21","modified_gmt":"2024-05-15T15:29:21","slug":"musrfit-doc","status":"publish","type":"page","link":"https:\/\/musruser.psi.ch\/?page_id=148","title":{"rendered":"MuSRFit"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Plot\/Fit PSI \u03bcSR data<\/h2>\n\n\n\n<p>The musrfit.cgi script is a web based graphical user interface for plotting and fitting PSI \u00b5SR data. The interface acts as a wrapper to the <a href=\"https:\/\/bitbucket.org\/zaher-salman\/musrfit\">musrfit software<\/a> and uses many of its capabilities in a user friendly way. However, to utilize the full power of musrfit for we recommend that you either install musrfit locally on your computer or use the software installed on the PSI local computers.<\/p>\n\n\n\n<p>Thank you for using this script. Please contact Zaher Salman &lt;zaher.salman \u201cat\u201d psi.ch&gt; if you have any problems, suggestions or comments.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Setting up the fit<\/h3>\n\n\n\n<p>The musrfit.cgi script can be reached using any web browser, also from outside PSI, by following this link<\/p>\n\n\n\n<p><a href=\"http:\/\/musruser.psi.ch\/cgi-bin\/musrfit.cgi\">http:\/\/musruser.psi.ch\/cgi-bin\/musrfit.cgi<\/a><\/p>\n\n\n\n<p>You will then see the following html form:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"458\" src=\"http:\/\/lmu-user-dmz-01.psi.ch\/wp-content\/uploads\/2024\/05\/musrfit-doc_html_52f975d16e91a61a.jpg\" alt=\"\" class=\"wp-image-342\"\/><\/figure>\n\n\n\n<p><br>You may initially ignore the \u201cExtra options\u201d. We will return to these later on. To start with you should type the run numbers that you wish to fit. For multiple runs you can use the following (msr2data) notation:<\/p>\n\n\n\n<ul>\n<li>comma separated run numbers: 3232,3235,3237<\/li>\n\n\n\n<li>hyphen denotes a series, from-to, i.e. 3232-3234 means 3232,3233,3234<\/li>\n\n\n\n<li>colon denotes a loop with a step, from:to:step, i.e. 3232:3238:2 means 3232,3234,3236,3238<\/li>\n<\/ul>\n\n\n\n<p>The script allows you to fit the data to a sum of unlimited number of components. These components can be one of the standard functions already available in musrfit<\/p>\n\n\n\n<ul>\n<li><strong>Constant Background<\/strong> \u2013 Non-relaxing asymmetry<\/li>\n\n\n\n<li><strong>Exponential<\/strong> \u2013 Exponential relaxation function<\/li>\n\n\n\n<li><strong>Gaussian<\/strong> \u2013 Gaussian relaxation function<\/li>\n\n\n\n<li><strong>Stretch Exponential<\/strong> \u2013 Stretched exponential relaxation function<\/li>\n\n\n\n<li><strong>Exponential Cosine<\/strong> \u2013 Exponentially damped oscillation<\/li>\n\n\n\n<li><strong>Gaussian Cosine<\/strong> \u2013 Guassian damped oscillation<\/li>\n\n\n\n<li><strong>Stretch Cosine <\/strong>\u2013 Stretched exponentially damped oscillation<\/li>\n\n\n\n<li><strong>Lorentzian Dynamic Kubo-Toyabe LF<\/strong><\/li>\n\n\n\n<li><strong>Gaussian Dynamic Kubo-Toyabe LF<\/strong><\/li>\n\n\n\n<li><strong>Lorentzian Kubo-Toyabe LF x Exp<\/strong> &#8211; Lorentzian Kubo-Toyabe LF multiplied by an exponential function<\/li>\n\n\n\n<li><strong>Gaussian Kubo-Toyabe LF x Exp<\/strong> &#8211; Gaussian Kubo-Toyabe LF multiplied by an exponential function<\/li>\n\n\n\n<li><strong>Lorentzian Kubo-Toyabe LF x Str Exp<\/strong> &#8211; Lorentzian Kubo-Toyabe LF multiplied by a stretched exponential function<\/li>\n\n\n\n<li><strong>Gaussian Kubo-Toyabe LF x Str Exp<\/strong> &#8211; Gaussian Kubo-Toyabe LF multiplied by a stretched exponential function<\/li>\n<\/ul>\n\n\n\n<p>Simply chose the number of components in your fit function and then select a suitable standard function from the corresponding drop-down menu. Components with \u201c<strong>None<\/strong>\u201d selected will be simply ignored, however, try to avoid doing that by reducing the number of components.<\/p>\n\n\n\n<p>Next, select the time range for fitting; \u201ct<sub>i<\/sub>\u201d and \u201ct<sub>f<\/sub>\u201d are the initial and final time, respectively. You may also change the binning factor for the fit. Typically for LEM data one should use 100-200 and for bulk data 10-50.<\/p>\n\n\n\n<p>The \u201cFit type\u201d drop-down menu allows you to choose the type of fit you are performing, either \u201cAsymmetry\u201d\/\u201dAsymmetry GLB\u201d or \u201cSingle Hist\u201d fits.<\/p>\n\n\n\n<p>For an \u201c<strong>Asymmetry<\/strong>\u201d\/\u201d<strong>Asymmetry GLB<\/strong>\u201d fit, you must provide only two comma separated histogram numbers in the \u201cHistograms\u201d field. These numbers denote the order of the histograms in the data file and will be used to calculate the asymmetry between them. One very useful option is addition of histograms before calculating the asymmetry. For example, in recent LEM data files the histograms 1 and 5 are the upstream and downstream parts of the left detector respectively, while 3 and 7 are the upstream and downstream parts of the right detector. Therefore, to calculate the asymmetry between left\/right detectors one should use \u201c1 5,3 7\u201d, which indicates that the asymmetry will be calculated between the sums of 1+5 and 3+7.<\/p>\n\n\n\n<p>For a \u201c<strong>Single Hist<\/strong>\u201d fit, you may put in the \u201cHistograms\u201d field as many comma separated histograms (valid numbers) as you wish. These will be fit assuming that the asymmetry in all these histograms follows the same function, with the exception of the phase if present. The same histogram summation rule above (space separated) applies also here.<\/p>\n\n\n\n<p>What is the difference between \u201c<strong>Asymmetry<\/strong>\u201dand \u201d<strong>Asymmetry GLB<\/strong>\u201d? Generally, I would suggest using \u201d<strong>Asymmetry GLB<\/strong>\u201d which utilizes the \u201cglobal\u201d option built into msr2data in a smart way. Therefore, msr files generated this way will be usable also on your computer for further analysis. The \u201c<strong>Asymmetry<\/strong>\u201d produces non-standard msr files created according to Zaher\u2019s warped logic. They can be more flexible, but if you do not miss this flexibility do not even go there.<\/p>\n\n\n\n<p>Now, we return to the \u201cExtra option\u201d, which allow the user to change the title which will be included in the msr file and the name of the generated msr file. Both are optional, if left empty, the script will use the title of the first run and a standard file name RUN_BEAMLINE_YEAR, where RUN is the first run number, BEAMLINE and YEAR are the values from the corresponding drop-down menus.<\/p>\n\n\n\n<p>Finally, you may proceed to the next fitting stage by clicking the \u201cNext&gt;\u201d.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Shared fit parameters<\/strong><\/h3>\n\n\n\n<p>This stage will be available only when you are performing a fit which includes multiple runs, i.e. you had more than one run number in the \u201cRUN numbers\u201d field. Here, you will be able to tell musrfit which parameters are to be shared among all runs by selecting the corresponding check box of the parameter (see figure below). Then you may proceed to the next step by clicking \u201cNext&gt;\u201d.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"430\" height=\"309\" src=\"http:\/\/lmu-user-dmz-01.psi.ch\/wp-content\/uploads\/2024\/05\/musrfit-doc_html_141666a6a95d8e92.jpg\" alt=\"\" class=\"wp-image-346\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Plot\/fit iterations<\/strong><\/h3>\n\n\n\n<p>Finally, you reach the most important stage in the fitting procedure. Initially, using default parameters, the script will plot the requested data. You will be able to see how good you initial guess is and adjust it before you try to properly fit the data. This can be done in the editable parameters table shown below the plot (see figure below).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1065\" height=\"862\" src=\"http:\/\/lmu-user-dmz-01.psi.ch\/wp-content\/uploads\/2024\/05\/musrfit-doc_html_e954cf1af347b52f.jpg\" alt=\"\" class=\"wp-image-340\"\/><\/figure>\n\n\n\n<p>At this stage you can also change or fix the value of fit parameters. The musrfit.cgi script typically starts with reasonable default value for various parameters which will usually be a good enough guess for simple fits. However, care should be taken when performing a more complex fit, since a bad starting guess may lead to the fit not converging at all. For each fit parameter you can give an initial value, error, minimum and maximum values:<\/p>\n\n\n\n<ul>\n<li>the value determines the initial guess<\/li>\n\n\n\n<li>the error determines the initial step in the fitting procedure. If the error is set to zero \u201c0\u201d, then musrfit will assume that the corresponding fit parameter is fixed at the given value<\/li>\n\n\n\n<li>the minimum and maximum values provide the boundaries that will be imposed on the corresponding fit parameter.<\/li>\n<\/ul>\n\n\n\n<p>Once all parameters have been adjusted (or if you are happy with the defaults) click on \u201cPLOT\u201d to plot without running the minimization of \u201cFIT\u201d to run the fitting and minimization before plotting the result.<\/p>\n\n\n\n<p>On this page you may also change many of the fields that you set in previous stages on the fit. Just below the figure you will be able to change the run numbers that you are fitting, add additional runs to the fit or remove runs from the fit. You may even change the order or number of histograms that were used from the fit in the \u201cHistograms\u201d field. You can also change the fitting time range by changing \u201ct<sub>i<\/sub>\u201d and \u201ct<sub>f<\/sub>\u201d.<\/p>\n\n\n\n<p>On the right hand side you will be able to change various aspects of the plot. These will only change the displayed figure, but will not change the actual fit itself. You can inspect the FFT of the plot.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1071\" height=\"676\" src=\"http:\/\/lmu-user-dmz-01.psi.ch\/wp-content\/uploads\/2024\/05\/musrfit-doc_html_499b3f2e6be4e4d9.jpg\" alt=\"\" class=\"wp-image-343\"\/><\/figure>\n\n\n\n<p>You may toggle between log and linear x or y scales using the appropriate check box. \u201ct cor.\u201d can be used to correct for the muon lifetime in single histogram fits. The \u201cx,y range\u201d can be used to change the x and y scales.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1035\" height=\"569\" src=\"http:\/\/lmu-user-dmz-01.psi.ch\/wp-content\/uploads\/2024\/05\/musrfit-doc_html_334b6577bd82f0e8.jpg\" alt=\"\" class=\"wp-image-344\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1036\" height=\"570\" src=\"http:\/\/lmu-user-dmz-01.psi.ch\/wp-content\/uploads\/2024\/05\/musrfit-doc_html_202998feafdc6a8b.jpg\" alt=\"\" class=\"wp-image-345\"\/><\/figure>\n\n\n\n<p>\u201cView Bin\u201d can be used to re-plot the same fit using a different binning factor from that used for the fit, which can be sometimes very useful to more clearly inspect the quality of the fits. Any change in these fields will not take effect until you press the \u201cPLOT\u201d button (or the \u201cFIT\u201d button on the right hand side, see below)<\/p>\n\n\n\n<p>On the left hand side you will be able to control the minimization for the fit. For the minimization you can choose between \u201cMIGRAD\u201d, \u201cMINIMIZE\u201d or \u201cSIMPLEX\u201d which indicate different minimization routines used by minuit. For the error calculation you can choose either \u201cHESSE\u201d or \u201cMINOS\u201d. The first is fast but less accurate than the latter. Once these are selected you can press on the \u201cFIT\u201d button which will run the requested minimization and error estimate. The results of the fit are displayed in the same page and the values and errors in the fit parameters are updated. This stage can take some minutes so be patient and avoid using this script for fitting many (more than 20) runs and\/or for very complex fits.<\/p>\n\n\n\n<p>An extremely useful aspect of this script is that all fit results can be downloaded and used immediately to generate quick plots of the parameters. At the bottom of the page you will find links to five different files:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"917\" height=\"139\" src=\"http:\/\/lmu-user-dmz-01.psi.ch\/wp-content\/uploads\/2024\/05\/musrfit-doc_html_dcba02ed052df8ee.jpg\" alt=\"\" class=\"wp-image-341\"\/><\/figure>\n\n\n\n<ol>\n<li>FileName.msr \u2013 is the musrfit input file which can be downloaded, edited and used as a starting input file for more complex fits or as a template for different fits.<\/li>\n\n\n\n<li>FileName.dat.gz \u2013 is an archive that includes ASCII files which contain the data points with error bars as well as the fit curves. This can be easily used to generate plots of the displayed figure in your favorite plotting software.<\/li>\n\n\n\n<li>FileName_par.dat \u2013 is and ASCII file which contains the values of the fit parameters in a table format. This can be easily used to plot the dependencies of the various fit parameters on temperature, field etc.<\/li>\n\n\n\n<li>FileName.out and debug.txt \u2013 Are files for debugging information. If you have a problem, it would be best if you send usthese files by email.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Plot\/Fit PSI \u03bcSR data The musrfit.cgi script is a web based graphical user interface for plotting and fitting PSI \u00b5SR data. The interface acts as a wrapper to the musrfit software and uses many of its capabilities in a user friendly way. However, to utilize the full power of musrfit for we recommend that you &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/musruser.psi.ch\/?page_id=148\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MuSRFit&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/musruser.psi.ch\/index.php?rest_route=\/wp\/v2\/pages\/148"}],"collection":[{"href":"https:\/\/musruser.psi.ch\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/musruser.psi.ch\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/musruser.psi.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/musruser.psi.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=148"}],"version-history":[{"count":1,"href":"https:\/\/musruser.psi.ch\/index.php?rest_route=\/wp\/v2\/pages\/148\/revisions"}],"predecessor-version":[{"id":347,"href":"https:\/\/musruser.psi.ch\/index.php?rest_route=\/wp\/v2\/pages\/148\/revisions\/347"}],"wp:attachment":[{"href":"https:\/\/musruser.psi.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}