Re: [fityk-users] Exporting a lot of data at once

332 views
Skip to first unread message

Dan Parshall

unread,
Oct 5, 2012, 1:59:22 PM10/5/12
to fityk...@googlegroups.com
@* info peaks >> filename

On Fri, Oct 5, 2012 at 11:49 AM, ohshitgorillas <atom.go...@gmail.com> wrote:
Hi,

I'm very new to this program, but love it already as I can reduce all of my data at once, and use my own computer to do it! I actually have the newest version installed on Linux at home, and am SSH forwarding the full version to my windows computer...which I think is really cool on its own... but I digress.

I'm looking to export all of my peak data at once. Is there a way to do this for multiple files? I am working with large datasets, sometimes 50 files or more, and it would be nice to be able to export all peak parameters to individual files, named after the dataset. Is there a way to do this or do I have to use the GUI to export the peak parameters one by one?

Thanks!

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



--
Dan Parshall
Shorty George Productions
Boulder, CO

ohshitgorillas

unread,
Oct 5, 2012, 4:10:36 PM10/5/12
to fityk...@googlegroups.com
if I remember correctly, this only outputs every file to "filename" so that it is overwritten every time it goes to the next data set. i'm trying to confirm this, but right now it's only crashing the program.

ohshitgorillas

unread,
Oct 5, 2012, 4:38:55 PM10/5/12
to fityk...@googlegroups.com
Ah, now I see a post from a while ago which mentions that two >'s will do what I want it to. I will mention, however, that this function is not capable of outputting peaks_err... which is very unfortunate. Still, thank you!

Dan Parshall

unread,
Oct 5, 2012, 4:41:01 PM10/5/12
to fityk...@googlegroups.com
that command will output the peak data (and any other functions such as linear) to a file called "filename".  You can actually make it a complete path, such as:
@*: info peaks >> /home/dan/filename

Note that I forgot the colon (:) last time- that's actually required.  This command appends to "filename", so you may or may not want to delete that file before doing the output. If you use a single >, it overwrites/replaces.  If you use a double >>, it appends.

Dan Parshall

unread,
Oct 5, 2012, 4:42:17 PM10/5/12
to fityk...@googlegroups.com
@* info errors >> filename
if you're using 1.2.  There's a bug in the earlier versions, and you have to list each dataset individually (i.e., @0 @1 @2, etc).

Marcin Wojdyr

unread,
Oct 6, 2012, 9:02:04 AM10/6/12
to fityk...@googlegroups.com
On 5 October 2012 18:49, ohshitgorillas <atom.go...@gmail.com> wrote:

> I'm looking to export all of my peak data at once. Is there a way to do this
> for multiple files? I am working with large datasets, sometimes 50 files or
> more, and it would be nice to be able to export all peak parameters to
> individual files, named after the dataset. Is there a way to do this or do I

I remember similar question some time ago. I think it was not possible
at that time.
It's possible using Lua, unfortunately switching between Lua and fityk
script makes it a bit complicated.
Fityk 'lua' command interprets the rest of the line in Lua. (It's also
possible to write whole script in lua and then run it using "exec
myscript.lua".)

=-> lua F:out('hello')
hello
(hello is printed in the output panel.)

=-> lua F:out(F:get_info('filename', 0))
/home/wojdyr/local/share/fityk/samples/enso.dat
=-> lua F:out(F:get_info('filename', 1))
/home/wojdyr/fityk/samples/nacl01.dat
=-> @*: lua F:out(F:get_info('filename', F:get_default_dataset()))
/home/wojdyr/local/share/fityk/samples/enso.dat
/home/wojdyr/fityk/samples/nacl01.dat

let's remove extension .dat (if this is the extension) and add .out:
=-> lua F:out(F:get_info('filename', 0):gsub('.dat$', '') .. ".out")
/home/wojdyr/local/share/fityk/samples/enso.out

the final command is:
@*: lua F:execute("info peaks
>'"..F:get_info('filename',F:get_default_dataset()):gsub('.dat$','')..".out'")

I must add some syntactic sugar to make it simpler.

M

Marcin Wojdyr

unread,
Oct 21, 2012, 11:00:08 PM10/21/12
to fityk...@googlegroups.com
I was thinking about the syntax for a while and I've changed a few things:
- API functions that take dataset number as argument have now default
value set to current dataset (as set by "use" or by @n:)
- In the GUI, Lua print is redefined to show output in the GUI (not in stdout)
- like in Lua interpreter (the one included with Lua), "=" prints returned value
- adding 'exec' before the '=', i.e. command exec = ... will interpret
the rest of line in Lua and execute it as fityk command

Examples should explain it better:

=-> = os.date()
Sat Oct 20 21:31:16 2012
=-> @*: = F:get_info('filename')
../samples/nacl01.dat
../samples/SiC_Zn.dat
=-> = F:get_info('filename'):sub(0,-4) .. "out"
../samples/nacl01.out
=-> @*: = F:get_info('filename'):sub(0,-4) .. "out"
../samples/nacl01.out
../samples/SiC_Zn.out

to make it more readable, let's first create a helper function:
=-> lua function ip(f) return string.format("info peaks >'%s'", f) end
=-> @*: = ip(F:get_info('filename'):sub(0,-4) .. "out")
info peaks >'../samples/nacl01.out'
info peaks >'../samples/SiC_Zn.out'

and adding "exec" will execute these commands and export peaks for all files:
@*: exec= ip(F:get_info('filename'):sub(0,-4) .. "out")
Reply all
Reply to author
Forward
0 new messages