This gem provides a Ruby interface to xraylib for the interaction of X-rays with matter, using Fiddle instead of SWIG.
Instal xraylib once you have agreed to its license. If you’re using Homebrew, the installation procedure is as follows:
brew install tschoonj/tap/xraylib
Add this line to your application’s Gemfile:
gem 'xrayfid'
And then execute:
bundle install
Or install it yourself as:
gem install xrayfid
require 'xrayfid'
include Xrayfid
# Atomic weights (z = 6)
atomic_weight(6)
# => 32.07
# Cross sections [cm2/g] (z = 10, energy = 10.0 [keV])
cs_total(10, 10.0)
# => 11.967284888387404
Note: if you receive an error message of
image not found (Fiddle::DLError)
, set an environment variable
XRAYLIB_DIR
to specify the location of lib/libxrl.(so|dylib)
, e.g.
export XRAYLIB_DIR=/opt/homebrew/opt/xraylib
After checking out the repo, run bin/setup
to install dependencies.
Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install
. To release a new version, update the version
number in version.rb
, and then run bundle exec rake release
, which
will create a git tag for the version, push git commits and the created
tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/zalt50/xrayfid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Note: The use of xraylib is subject to its license.
Everyone interacting in the Xrayfid project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
- Support for all APIs in the official documentation of xraylib
- Proper error handling
- A library for X-ray–matter interaction cross sections for X-ray fluorescence applications, Spectrochimica Acta Part B: Atomic Spectroscopy, Volume 59, Issues 10-11, 2004, pp. 1725-1731