print fit parameters and errors

695 views
Skip to first unread message

Andres Cimmarusti

unread,
Apr 12, 2011, 9:50:48 PM4/12/11
to fityk...@googlegroups.com
Hi,

I've been using fityk 0.9.7 in Debian testing, to fit gaussian peaks
(plus lines) to dozens of spectra files.
First of all, is there a way to do for loops in a cfityk script? or
does it have to be done by a bash script externally? I basically want
to process all these spectra "semi-automatically". I couldn't find
anything in the documentation.

I know I can load multiple data sets, but I don't know how to loop over them...

Second question, one I fit my gaussian, I want to extract the fit
parameters (height, center and hwhm) with their errors. The only way I
know is using 'info errors' and then copying each individual number
elsewhere....this is really time consuming... how can I export them to
a file?

I tried doing (as in the documentation):

print all: $_1, $_2, $_3 > fit_data1.tsv
Syntax error: at 27, near `_2, $_3 > ': unexpected token or end of expression

I also tried without the $ signs and got an error saying 'unknown name _1'

Ideally I would like to export something in this format:

fit_par1 (tab, space or comma) error_fit_par1 (tab, space or comma)
fit_par2 (tab,space or comma) error_fit_par2 .....and so on

and then a new line for a different spectrum...

Any help is appreciated!

Thanks

Andres

Marcin Wojdyr

unread,
Apr 13, 2011, 8:29:11 AM4/13/11
to fityk...@googlegroups.com, Andres Cimmarusti
Hi Andres,

> First of all, is there a way to do for loops in a cfityk script? or

[...]


> I know I can load multiple data sets, but I don't know how to loop over them...

@*: ... # this makes a loop

see http://fityk.nieto.pl/lang.html

> I tried doing (as in the documentation):
>
> print all: $_1, $_2, $_3 > fit_data1.tsv
> Syntax error: at 27, near `_2, $_3 > ': unexpected token or end of expression

I probably corrected the manual after 0.9.7. You can see it online:
http://fityk.nieto.pl/ref.html#print


> Ideally I would like to export something in this format:
>
> fit_par1 (tab, space or comma) error_fit_par1 (tab, space or comma)
> fit_par2 (tab,space or comma) error_fit_par2 .....and so on
>
> and then a new line for a different spectrum...

It's possible. This should work:
@*: print F[0].height, F[0].height.error, F[0].center, F[0].center.error >> file

Marcin

Pablo Bianucci

unread,
Apr 16, 2011, 10:44:11 PM4/16/11
to fityk...@googlegroups.com
Hi Marcin!

On Wed, Apr 13, 2011 at 08:29:11AM -0400, Marcin Wojdyr wrote:

> > fit_par1 (tab, space or comma) error_fit_par1 (tab, space or comma)
> > fit_par2 (tab,space or comma) error_fit_par2 .....and so on
> >
> > and then a new line for a different spectrum...
>
> It's possible. This should work:
> @*: print F[0].height, F[0].height.error, F[0].center, F[0].center.error >> file

Would it be possible to do the same, but for all peaks in each dataset (where
each dataset can have a different number of peaks)?

I've tried with "print F[*].area" (for instance), but I get a syntax error
(using 0.9.7).

Is there any other way to reproduce the behaviour of "info+ peaks" from older
versions?

Thanks a lot!

Pablo B.

Marcin Wojdyr

unread,
Apr 17, 2011, 10:55:58 AM4/17/11
to fityk...@googlegroups.com, Pablo Bianucci
Hi Pablo,


> Is there any other way to reproduce the behaviour of "info+ peaks" from older
> versions?

info peaks_err

Best,
Marcin

Marcin Wojdyr

unread,
Apr 18, 2011, 5:05:59 AM4/18/11
to Pablo Bianucci, fityk...@googlegroups.com
>> info peaks_err
>
> I should really look up the source, but is there a way to put the title of
> each peaks dataset in the output of "info peaks_err" [...]

You can do:
=-> @*: i filename, peaks_err

or:
=-> @*: i title, peaks_err

It prints, for each dataset, filename/title before the output from peaks_err.
If it's not what you'd like to get, you can propose a new format for
listing of peak parameters.

Cheers,
Marcin

Pablo Bianucci

unread,
Apr 18, 2011, 7:52:18 AM4/18/11
to fityk...@googlegroups.com
Hi Marcin!

On Mon, Apr 18, 2011 at 11:05:59AM +0200, Marcin Wojdyr wrote:

> =-> @*: i title, peaks_err
>
> It prints, for each dataset, filename/title before the output from peaks_err.
> If it's not what you'd like to get, you can propose a new format for
> listing of peak parameters.

That works well for me, I can now go back to using the little script I wrote
to extract results from multi-dataset fits.

Soren Eustis

unread,
Apr 21, 2011, 2:06:39 PM4/21/11
to fityk...@googlegroups.com
Greetings,

The new release is a significant improvement over the beta versions, I am especially pleased with the availability of a new MacOS app.  For a working research scientist, this program is really a great tool.

I have some questions/ideas regarding the program:

  • Is there a way to print not only the fitted peaks, but the fit information and a header line with the filename or a user defined header?  RIght now I stopped printing the outputs because I have so many different spectra to print that I would need to grab each one off the printer and hand tag it with the fit parameters and the experiment details in order for it to be of use.
  • Can I define the default directory for the data files?  It defaults to the /Applications directory (Mac) and I have to go through many folder levels to get to my data directory.

Regards,

Soren



Soren N. Eustis, Ph.D.
ETH – Zürich
Environmental Organic Chemistry Group
Institute for Biogeochemistry and Pollutant Dynamics
Universitatstrasse 16
CHN F33
8092 Zürich
SWITZERLAND

+41 44 632 93 48 (office)
+41 44 632 14 38 (fax)

Marcin Wojdyr

unread,
Apr 21, 2011, 2:57:55 PM4/21/11
to fityk...@googlegroups.com
Hi Soren,
I'm glad you like the program.

> Is there a way to print not only the fitted peaks, but the fit information
> and a header line with the filename or a user defined header?

Unfortunately not. Printing has been neglected for a long time.
Adding some text to the graph is definitely a good idea.

> Can I define the default directory for the data files?  It defaults to the
> /Applications directory (Mac) and I have to go through many folder levels to
> get to my data directory.

I assumed that this option is rarely used and I removed it some time
ago, to simplify the GUI.
But it's still possible to set the default data directory.
On Mac, open the file ~/Library/Application Support/fityk/wxoptions
(on Linux it is ~/.fityk/wxoptions, on Windows C:\Documents and
Settings\username\Application Data\fityk\wxoptions)
If there is a line starting with "loadDataDir=" modify it, otherwise
add such line, at the beginning of file:
loadDataDir=/path/to/dir

On Mac it should be also possible to open files that have popular
extensions by right clicking on them (open with > fityk)

Marcin

Soren Eustis

unread,
Apr 21, 2011, 3:12:29 PM4/21/11
to fityk...@googlegroups.com
Martin,

I normally use quick load but I often compare several Y values with
the same X, so the load data file is useful. Perhaps the first line header
could be imported into the dataset to be used for printing and tagging?

(i.e. X-header, Y-header1, Y-header 2, Y-header-3
X-data, Y-data-1, Y-data-2, Y-data-3)

A fit to page printout with the datapoints, fitsum, individual components,
fit parameters (and individual function x,y values), and modifiable
headers would be perfect for archival purposes.

I will try the default directory trick. The open with command would
probably only work for a quick load file. If I have one X and several Y
it would likely only load the first Y.

Best,

Soren

Soren N. Eustis, Ph.D.
ETH ­ Zürich
Environmental Organic Chemistry Group
Institute for Biogeochemistry and Pollutant Dynamics
Universitatstrasse 16
CHN F33
8092 ZürichSWITZERLAND

so...@env.ethz.ch

>--
>http://groups.google.com/group/fityk-users


Marcin Wojdyr

unread,
Apr 22, 2011, 7:36:35 AM4/22/11
to fityk...@googlegroups.com
On Thu, Apr 21, 2011 at 21:12, Soren Eustis <soren...@gmail.com> wrote:

>    I normally use quick load but I often compare several Y values with
> the same X, so the load data file is useful. Perhaps the first line header
> could be imported into the dataset to be used for printing and tagging?

The problem here is how to detect if the first line contains column
headers or something else. It would be possible to add it as an option
to the open data dialog, but this would make this dialog even more
complicated.
BTW after 1.0.1 I started changing this dialog, to allow opening of
multiple files, blocks and/or columns at the same time. I haven't
finished it yet.

> I will try the default directory trick.  The open with command would
> probably only work for a quick load file.  If I have one X and several Y
> it would likely only load the first Y.

yes, that's what it does.

Cheers,
Marcin

Christian Weikusat

unread,
Apr 26, 2011, 7:31:26 AM4/26/11
to fityk...@googlegroups.com
> You can do:
> =-> @*: i filename, peaks_err
>
> or:
> =-> @*: i title, peaks_err

Just a small note on this:
When trying to output to a file, e.g.

@*: i title, peaks_err > datafile

the file only contains the data from the last dataset. To get all the
data one has to do

@*: i title, peaks_err >> datafile

While this is probably expected behaviour (separate output for each
dataset), it still took me some time to figure out, so I just want to
mention it in case anyone else is wondering.

Cheers,
Christian

Bernd Maier

unread,
Apr 26, 2011, 10:21:56 AM4/26/11
to fityk-users
Dear Marcen,

I suggest printing the peaks with errors in a table format so that it
can be read into a plotting software (e.g. origin) directly without
the need for a rearranging script.

Best wishes,
Bernd

Marcin Wojdyr

unread,
Sep 14, 2011, 2:57:48 PM9/14/11
to fityk...@googlegroups.com
FTR, in version 1.1.0 I added an option to print header, for example
filename and fit statistics on the plot:
http://img856.imageshack.us/img856/1683/fitykplotdescription.png
The header is customizable, it is an output of the info command with
any arguments.
Marcin

> --
> http://groups.google.com/group/fityk-users

Reply all
Reply to author
Forward
0 new messages