Freeze or remove all peaks centered outside active data range

64 views
Skip to first unread message

Robert Koch

unread,
Mar 2, 2017, 4:06:07 AM3/2/17
to fityk-users
Hello,

I've built some fit templates based on data over a given x range. Later, I collected data over a narrower x range. Is it possible to automatically remove or freeze all peaks located (centered) outside the active data range through a command or script?

This would save me a lot of time.

Thanks.
Rob Koch

Marcin Wojdyr

unread,
Mar 2, 2017, 6:18:35 AM3/2/17
to fityk...@googlegroups.com
Functions > Auto-Freeze was meant for a similar situation, but it
works differently: if you check Auto-Freeze and then disactivate an x
range peaks in this range are frozen. So it won't work for you.

Here is a Lua script that removes all PseudoVoigt functions outside of
the active range (assuming that the active range has no gaps).

m = F:calculate_expr("min(x if a)")
M = F:calculate_expr("max(x if a)")
for i,f in F:get_components() do
if f:get_template_name() == "PseudoVoigt" then
c = f:get_param_value("center")
if c < m or c > M then
F:execute("del %" .. f.name)
end
end
end


And below is a similar script that removes all functions that have
Center defined.
pcall() in Lua is so-called protected call. Here it catches errors
from getting Center of a function (such as Linear) that has no Center
defined.

m = F:calculate_expr("min(x if a)")
M = F:calculate_expr("max(x if a)")
for i,f in F:get_components() do
pcall(function()
c = f:get_param_value("Center")
if c < m or c > M then
F:execute("del %" .. f.name)
end
end)
end


Best,
Marcin
> --
> http://groups.google.com/group/fityk-users
> ---
> You received this message because you are subscribed to the Google Groups
> "fityk-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to fityk-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Robert Koch

unread,
Mar 2, 2017, 4:30:31 PM3/2/17
to fityk-users
That's excellent thanks Marcin
Reply all
Reply to author
Forward
0 new messages