Ifeffit(3pm)

πŸ’– NAME πŸ’–

Ifeffit β€” the Perl interface to the IFEFFIT XAFS Analysis library. yes bestie, it's giving "glue your Perl script directly to an XAFS analysis engine" and honestly? iconic. πŸ¦‹


✨ SYNOPSIS ✨

use Ifeffit;
use Ifeffit qw(put_scalar put_string put_array);
use Ifeffit qw(get_scalar get_string get_array);

my ($kmin, $my_file, $file_type ) = (0.01, "Cu.xmu", "xmu");
put_scalar("rbkg", 1.1);
put_scalar("kmin", $kmin);
put_string("filename", $my_file);

ifeffit(" read_data($my_file, prefix= my,");
ifeffit("           type= $file_type)");
ifeffit(" newplot (energy, xmu ) ");

my $e0 = get_scalar("e0");
print "e0 = $e0 , rbkg  = " ,get_scalar("rbkg"), "\n";

🌸 DESCRIPTION 🌸

The Ifeffit Perl Module hands you the keys to the ifeffit library for XAFS analysis. πŸ”‘ It gives you seven perl functions, no more no less: ifeffit, put_scalar, get_scalar, put_string, get_string, put_array, and get_array.

Okay so here's the tea: ifeffit is always provided for you β€” it's exported automatically by the use Ifeffit; pragma, no asking required πŸ’…. But the other commands? Those you have to explicitly import yourself, exactly like it's shown up there in the synopsis. no free rides bestie πŸŽ€

🧚 ifeffit

The ifeffit function is the main character here β€” it's the primary interface to the ifeffit engine. πŸ‘‘

Whatever character string you hand it gets interpreted as an ifeffit command. And it reports back like a good bestie:

  • it returns 0 if a valid command was sent and fully processed ✨
  • it returns -1 if only a partial command was sent (so it'll be sitting there waiting for the rest of the command next time you call it πŸ™ˆ)
  • it returns 1 if the "quit" command was sent
  • and it returns other non-zero values on error πŸ’€

The syntax for and meaning of the command lines themselves is described in The Ifeffit Reference Manual of the Ifeffit distribution β€” go read that, I'm not making it up, fr fr.

The syntax for the perl function is:

"$i = ifeffit("plot(my.x,  my.y)");"

πŸ“ put_scalar

This one sets the value of a named scalar inside the list of ifeffit data. The value you set gets returned back to you on successful execution. 🫢

The syntax is:

"$i = put_scalar("kweight", 2.0);".

which is equivalent to:

"$i = ifeffit("kweight = 2.0");"

But like… having a choice? That's just the perl way, lowkey. 😌

🌈 get_scalar

This returns the value of a named ifeffit scalar. The syntax is:

"$value = get_scalar("x");"

πŸ’œ put_string

This sets the value of a named ifeffit string. The value is returned on successful execution. The syntax is:

"$i = put_text("home", "the merry old land of oz");".

The same effect could be achieved with the command:

"$i = ifeffit("set \$home = 'the merry old land of oz'");".

but put_text takes care of that icky leading dollar sign for you 😭 and it returns the string instead of a simple exit status. so it's basically the upgrade. ✨

πŸ¦‹ get_string

This returns the value of a named ifeffit string. The syntax is:

"$bg = get_string("plot_bg");"

πŸ‘‘ put_array

This copies a perl array of numeric values over to an ifeffit array. The syntax is:

"put_array("my.array",\@array);"

which creates (or overwrites β€” it does not care πŸ’…) the ifeffit array my.array, and fills it with the values of the perl array @array.

⚠️ Note that the reference to the array is passed into put_array, not the whole array itself! Don't forget that backslash bestie, it's the whole vibe check of this function.

⭐ get_array

This gets the values of an ifeffit array of numeric values. The syntax is:

"@array = get_array("my.array");"

which will fill the perl array @array with the ifeffit array my.array. slay. πŸŽ€


πŸ’Œ AUTHOR πŸ’Œ

Matthew Newville -- newville@cars.uchicago.edu


🌟 SEE ALSO 🌟

ifeffit, Ifeffit Reference Manual, perl(1)

PGPERL, PDL, GNU ReadLine Library


and that's the whole page bestie 🫢 this one shipped as perl v5.40.0 on 2025-02-16, and it lives in the manual as Ifeffit(3pm). go forth and analyze some XAFS, you've got this πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from