Git Product home page Git Product logo

tschoonj / xraylib Goto Github PK

View Code? Open in Web Editor NEW
118.0 21.0 53.0 65.42 MB

A library for X-ray matter interaction cross sections for X-ray fluorescence applications

Home Page: https://github.com/tschoonj/xraylib/wiki

License: Other

Prolog 0.42% IDL 3.23% Perl 0.97% C 28.48% Ruby 0.91% PHP 0.95% Python 3.14% Fortran 14.78% C++ 8.79% Java 13.57% C# 1.09% Lua 4.85% Inno Setup 0.35% Pascal 5.13% Makefile 1.97% M4 2.60% Raku 0.08% SWIG 3.04% Meson 0.56% Cython 5.09%
c fortran python java idl lua pascal perl php ruby

xraylib's People

Contributors

adler-j avatar chatcannon avatar davidsagan avatar dependabot[bot] avatar lgtm-migrator avatar mschollmeier avatar nin17 avatar shirokobrod avatar tacaswell avatar tschoonj avatar wormy69 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xraylib's Issues

Missing Functions in Matlab?

Hi,
I would like to use xraylib with Matlab, but when I run the command

libfunctions('libxrl', '-full')

to get a list of available functions, I noticed, that the most interesting functions for me, namely the NIST Compound wrapper are missing. What am I doing wrong?
(I Installed xraylib using Port on my Mac and loaded the library with

loadlibrary('/opt/local/lib/libxrl',...
'/opt/local/include/xraylib/xraylib.h'))

Thanks,

Functions in library libxrl:
double AtomicLevelWidth(int32, int32)
double AtomicWeight(int32)
double AugerRate(int32, int32)
double AugerYield(int32, int32)
double CS_Compt(int32, double)
[double, cstring] CS_Compt_CP(cstring, double)
double CS_Energy(int32, double)
[double, cstring] CS_Energy_CP(cstring, double)
double CS_FluorLine(int32, int32, double)
double CS_FluorLine_Kissel(int32, int32, double)
double CS_FluorLine_Kissel_Cascade(int32, int32, double)
double CS_FluorLine_Kissel_Nonradiative_Cascade(int32, int32, double)
double CS_FluorLine_Kissel_Radiative_Cascade(int32, int32, double)
double CS_FluorLine_Kissel_no_Cascade(int32, int32, double)
double CS_KN(double)
double CS_Photo(int32, double)
[double, cstring] CS_Photo_CP(cstring, double)
double CS_Photo_Partial(int32, int32, double)
double CS_Photo_Total(int32, double)
[double, cstring] CS_Photo_Total_CP(cstring, double)
double CS_Rayl(int32, double)
[double, cstring] CS_Rayl_CP(cstring, double)
double CS_Total(int32, double)
[double, cstring] CS_Total_CP(cstring, double)
double CS_Total_Kissel(int32, double)
[double, cstring] CS_Total_Kissel_CP(cstring, double)
double CSb_Compt(int32, double)
[double, cstring] CSb_Compt_CP(cstring, double)
double CSb_FluorLine(int32, int32, double)
double CSb_FluorLine_Kissel(int32, int32, double)
double CSb_FluorLine_Kissel_Cascade(int32, int32, double)
double CSb_FluorLine_Kissel_Nonradiative_Cascade(int32, int32, double)
double CSb_FluorLine_Kissel_Radiative_Cascade(int32, int32, double)
double CSb_FluorLine_Kissel_no_Cascade(int32, int32, double)
double CSb_Photo(int32, double)
[double, cstring] CSb_Photo_CP(cstring, double)
double CSb_Photo_Partial(int32, int32, double)
double CSb_Photo_Total(int32, double)
[double, cstring] CSb_Photo_Total_CP(cstring, double)
double CSb_Rayl(int32, double)
[double, cstring] CSb_Rayl_CP(cstring, double)
double CSb_Total(int32, double)
[double, cstring] CSb_Total_CP(cstring, double)
double CSb_Total_Kissel(int32, double)
[double, cstring] CSb_Total_Kissel_CP(cstring, double)
double ComptonEnergy(double, double)
double ComptonProfile(int32, double)
double ComptonProfile_Partial(int32, int32, double)
double CosKronTransProb(int32, int32)
double DCSP_Compt(int32, double, double, double)
[double, cstring] DCSP_Compt_CP(cstring, double, double, double)
double DCSP_KN(double, double, double)
double DCSP_Rayl(int32, double, double, double)
[double, cstring] DCSP_Rayl_CP(cstring, double, double, double)
double DCSP_Thoms(double, double)
double DCSPb_Compt(int32, double, double, double)
[double, cstring] DCSPb_Compt_CP(cstring, double, double, double)
double DCSPb_Rayl(int32, double, double, double)
[double, cstring] DCSPb_Rayl_CP(cstring, double, double, double)
double DCS_Compt(int32, double, double)
[double, cstring] DCS_Compt_CP(cstring, double, double)
double DCS_KN(double, double)
double DCS_Rayl(int32, double, double)
[double, cstring] DCS_Rayl_CP(cstring, double, double)
double DCS_Thoms(double)
double DCSb_Compt(int32, double, double)
[double, cstring] DCSb_Compt_CP(cstring, double, double)
double DCSb_Rayl(int32, double, double)
[double, cstring] DCSb_Rayl_CP(cstring, double, double)
double EdgeEnergy(int32, int32)
double ElectronConfig(int32, int32)
double ElementDensity(int32)
double FF_Rayl(int32, double)
double Fi(int32, double)
double Fii(int32, double)
double FluorYield(int32, int32)
int32 GetErrorMessages
int32 GetExitStatus
double JumpFactor(int32, int32)
double LineEnergy(int32, int32)
double MomentTransf(double, double)
double RadRate(int32, int32)
[double, cstring] Refractive_Index_Im(cstring, double, double)
[double, cstring] Refractive_Index_Re(cstring, double, double)
double SF_Compt(int32, double)
SetErrorMessages(int32)
SetExitStatus(int32)
SetHardExit(int32)
XRayInit

Unit in x-ray fluorescence cross section

We often use cm2/g for the unit of x-ray fluorescence cross section. However, barn is also very popular for cross sections. Can I output fluorescence cross section in barn in xraylib? Thanks!

Suppress warning output from xraylib

Description

Is there any way to suppress warning output from xraylib, such as:

Shell not available in function JumpFactor
Line not allowed in function CS_FluorLine

I want to output results from multiple energy lines and shells by calling xraylib, but it is difficult to remove these warning messages.

IDL bindings Windows: CompoundParser fails

The CompoundParser function in the IDL bindings for Windows does not work and results in the following error message:

"Dynamically loadable module XRAYLIB failed to define routine: COMPOUNDPARSER"

This can be verified by running the IDL example xrlexample4.pro which can be found in the Example directory of xraylib.

Compile without using pkg-config on linux for C

Hi,

I'm trying to compile just with linking the static library "libxrl.a" with the following command line :
gcc test.c -L/usr/local/lib/ -lxrl
but I always have the same error :
test.c:1:21: fatal error: xraylib.h: Aucun fichier ou dossier de ce type
#include <xraylib.h>
^
compilation terminated.
There is something more to add at the command line to compile and linking the good .h ?

Thank you and best regards.

Anomalies in f' and f'' data

Hi,

While trying to plot the values of anomalous scattering factors f' and f'' in the energy range from 10 eV to 30 keV, I noticed some local instabilities in the output data of functions Fi and Fii (please refer to attached graphs). These anomalies fluctuate by several orders of magnitudes, but the overall shape of the curve agrees well with the Henke data.

For example,
Fi(14, 105.030000e-3)
returns -896.729846725145, while Henke data for this energy is -2.04570.

I wonder this issue is due to the inherent anomalies in Kissel data?

Thanks,
Ming
henke_kissel_comparison.pdf

Anomalous scattering factors: switch to EPDL97

The relationship between photoabsorption cross-section and form factor (see NIST:FFAST eq 7) has degraded numerically by commit d28f2ef which is in v3.3.0.

Code to test:

import xraylib

def mu_photo(element,energy):
    Z = xraylib.SymbolToAtomicNumber(element)
    M = xraylib.AtomicWeight(Z)
    f2 = xraylib.Fii(Z,energy)
    mu1 = xraylib.CS_Photo_Total(Z,energy)
    conv = -2*xraylib.R_E*xraylib.AVOGNUM*xraylib.KEV2ANGST/energy/M*1e18 # cm^2/g
    mu2 = conv*f2
    print ("Rel. Difference ({} @ {}keV): {}".format(element,energy,(mu2-mu1)/mu1))

mu_photo("Cl",30)
mu_photo("Fe",30)
mu_photo("Pb",30)

Version 3.2.0 (before change):
Rel. Difference (Cl @ 30keV): 3.7915729507e-06
Rel. Difference (Fe @ 30keV): 3.77828790713e-07
Rel. Difference (Pb @ 30keV): 1.24547963341e-06

Version 3.3.0 (after change):
Rel. Difference (Cl @ 30keV): 0.0064609625621
Rel. Difference (Fe @ 30keV): -0.000222803321302
Rel. Difference (Pb @ 30keV): 0.000661094705178

Not sure whether this is problematic but at least the data sources for CS_Photo_Total and Fii are less consistent than before.

int vs. np.int

Some methods requiring (python-native) int-inputs (e.g. AtomicNumberToSymbol) seem to be crashing in the case that a non-native int (e.g. numpy.int) is provided. Is perhaps good to know (perhaps the issue could be solved by envoking np.asscalar for numpy inputs, but I'm not sure if that covers all potential input-problems)

Error "No rule to make target 'xraylib.mod'" when building fortran bindings with parallel make

Dependency generation for xraylib.mod is dodgy

/bin/sh ../libtool  --tag=FC   --mode=compile gfortran -DHAVE_CONFIG_H -I. -I..     -g -O2 -c -o libxrlf03_la-xraylib_wrap.lo `test -f 'xraylib_wrap.F90' || echo './'`xraylib_wrap.F90
make: *** No rule to make target 'xraylib.mod', needed by 'all-am'.  Stop.
make: *** Waiting for unfinished jobs....
libtool: compile:  gfortran -DHAVE_CONFIG_H -I. -I.. -g -O2 -c xraylib_wrap.F90  -fPIC -o .libs/libxrlf03_la-xraylib_wrap.o
libtool: compile:  gfortran -DHAVE_CONFIG_H -I. -I.. -g -O2 -c xraylib_wrap.F90 -o libxrlf03_la-xraylib_wrap.o >/dev/null 2>&1

XRF production cs calculation

I am still a bit confused about xrf production cs. For instance:

In [42]: xraylib.CS_FluorLine_Kissel(82,xraylib.MA1_LINE,20.0)
Out[42]: 1.3438984155654907

In [43]: xraylib.CS_FluorLine(82,xraylib.MA1_LINE,20.0)
Out[43]: 0.0

When I compare the two methods for cs on K lines, the results are similar. So Kissel method is much accurate for M line calculation?

Cannot get xraylib version from python

When installing xraylib from apt-get there is no xraylib.__version__, as is standard for python. Due to this I cannot check what version I have running locally.

CS_FluorLine_Kissel: L-lines issue

In some cases the CS_FluorLine_Kissel function will return with an error even though a valid line was requested. To reproduce: use any line macro ranging from L2O1 to L2Q1 in CS_FluorLine_Kissel

Questions on fluorescence crosssection

I can get x-ray fluorescence cross section from either command line or online table http://ftp.esrf.eu/pub/scisoft/xraylib/xraylib_tables_v2.3.pdf.

However, I find the results are not the same for some elements. Take Ti as an example, I run the command line as

In [17]: xraylib.CSb_FluorLine_Kissel(22,xraylib.KA1_LINE,8)
Out[17]: 1832.0522750085834

From page 40 in the table, I can get Ti KA1 line at 8KeV as two values (1.71e+03 1.79e+03). So the value from command line is larger than the values in the table. I thus got the following 2 questions.

  1. Can you please recommend which value I should use? Why are there two values in the table, from different models?

  2. I also see from the table that the second column shows values for Ka2,1. I assume that means sum of Ka1 and Ka2. Just double check.

Thanks!

Fortran xrlexample3.f90 segfaults with Intel Fortran compiler

Description: when running "make check" after the compilation stage with the Intel Fortran compiler selected, a segmentation fault occurs at runtime. It appears to be associated with the DEALLOCATE call at line 50, most likely because the memory was allocated with malloc, but the Intel DEALLOCATE does not call the libc free.

Until a fix is written, if you intend to use the CompoundParser function, avoid using the Intel Fortran compiler. GFortran and g95 appear to have no problem with this function.

Windows installer kills path

It seems the current windows installer actually removes the PATH and sets it to PATH=C:\Program Files (x86)\xraylib\Bin. This is, for obvious reasons, not very good.

Question about KL1_LINE

Hello,

I have a question about KL1_LINE: according to transition selection rule, K-->L1, K-->M1, K-->N1 transitions are forbidden, which however are listed in the "X-ray fluorescence line macros". Also the corresponding energies could be given calling the "LineEnergy" function.

I am thinking if this fluorescence database is directly deviated from the absorption energies, by subtracting different energy levels, without considering whether the transition would really happen...?

Thanks!

CS_Photo, CS_compton, CS_Rayleigh with C++Builder 6 library give the wrong value

Hi,
I am using C++Builder6 and have recently added the library libxrl-7-bcc.lib.
The example xrlexample6.cpp runs properly.
Other xraylib functions that I want to use also run properly, like the attenuation coefficients amongst others.
The only problem I found is with the cubic splines cross sections, I get the wrong answers.

I duplicated the cubic splines from the source code and the data files and I get reasonable answers.Ssince the libxrl-7-bcc.lib is compiled it seems to me that something went wrong there.
Can you please advise?
I also noticed that the values of the log(keV) are not exactly the same as the one I compute for the same keV, they differ after the 4th or 5th digit, but is not the source of the problem.

My use is for simulation of x-ray measurements for thickness of materials and thickness of metal coatings.

Thanks a lot.

Roland.

pip install xraylib?

Hi,

A number of us at SLAC/Stanford and Brookhaven are hoping to use a portable python package "scikit-xray" for algorithms. xraylib is a dependency of that package. scikit-xray has an anaconda-based installation that automatically installs xraylib, but anaconda brings in a significant number of other packages that conflict with software at our lab (and presumably the same problem would occur at other labs). So we're looking into the possibility of using python's "pip install" to install scikit-xray, which doesn't bring in unneeded packages. That works for scikit-xray, and its dependencies, except for xraylib, since you use configure/make.

My question: do you have thoughts on the possibility of a "pip install" installation for xraylib? Perhaps I could try to do it (although I'm not sure yet how big a job it is).

Thought it wouldn't hurt to ask, and thanks for any thoughts,

chris

Possible problem about complex refractive index

Recently I've been using your refractive index to compute the absorption length for tissues and PMMA. I find that the numbers your functions gives is a factor away (to be specific, 0.5) from what can I find on the NIST website

My code to calculate the absorption length is

ri = Refractive_Index(argv[1], energy ,atof(argv[2]));//argv[1] is the compound formula, argv[2] is density
L = KEV2ANGST*1e-10/(2*PI*ri.im*energy);

The matlab code I used to calculate absorption length from NIST data is

nist(:,4) = 1./nist(:,2)/rho/100; % Calculate absorption length from absorption coefficient, which is the second column of the data table

I draw the energy-absorption length plot for both your data and the NIST data, here's what I got (the x-axis has the unit of keV, the y axis has the unit of m):

pmma

They are 0.5 times away. I tried several compounds, like PMMA, lung tissue and so on, the result hold the same.

CS_FluorLine L1 lines

Location: Jump_from_L1 function which is called from CS_FluorLine.

Effect: CS_FluorLine values are wrong if E > E_K, because they don't take into account the K shell Jump factor.

ENH: units in wiki API page

Would it be possible to give the units, where applicable, for the function variables on the API page? For example I was rather confused about whether to use q in inverse Angstroms or inverse nm for the FF_Rayl function.

Unable to locate libxr17 and libxr17-dev packages

Hello, I'm trying to install xraylib on ubuntu 14.04. I executed:

curl http://lvserver.ugent.be/apt/xmi.packages.key | sudo apt-key add -

then used: sudo gedit /etc/apt/sources.list

which opened the text file where I entered:

deb [arch=amd64] http://lvserver.ugent.be/apt/ubuntu trusty stable
deb-src http://lvserver.ugent.be/apt/ubuntu trusty stable

and then saved the file. After this I executed: sudo apt-get update

followed by: sudo apt-get install libxrl7 xraylib libxrl7-dev libxrlf03-7 libxrl-perl

at which point I get the error messages:
E: Unable to locate package libxr17
E: Unable to locate package libxr17-dev

Any help on figuring out why it can't seem to locate these packages would be amazing. One thing that does come up when I execute "sudo gedit /etc/apt/sources.list" is:
(gedit:4568)" IBUS-WARNING **: The owner of /home/saybrook/.config/ibus/bus is not root!

I'm not sure if this makes any difference. Thanks in advance for any help!

ComptonProfile produces negative values for high pz

A bug has been detected in the ComptonProfile and ComptonProfile_Partial functions which manifests itself by producing negative values (which are obviously incorrect) when requested for high pz.

Example: ComptonProfile(26,90.0) produces -0.000109986

RadRate problematic output

I found RadRate sometimes gives an error message (e.g. "Line not available in function RadRate") but returns a nonzero value.

For example, if you try RadRate(6, KB_LINE), it gives the error message, but also returns 1.0 instead of 0.0.

And RadRate(6, KA_LINE) does not equal RadRate(6, KA1_LINE)+RadRate(6, KA2_LINE)

Configure Lua error

I get the following message when running the configure script.

checking for lua... /usr/bin/lua
checking lua.h usability... no
checking lua.h presence... no
checking for lua.h... no
checking lualib.h usability... no
checking lualib.h presence... no
checking for lualib.h... no
checking for exp in -lm... (cached) yes
checking for dlopen in -ldl... (cached) yes
checking for lua_load in -llua... no
configure: WARNING: Cannot build lua bindings
./configure: line 25716: syntax error near unexpected token `else'
./configure: line 25716: `      else'

Do you know what the issue is, and if it is on my end what I can do to fix it?

How to get the list of crystals available in xraylib?

From the examples, I should get it with

crystals = xraylib.Crystal_GetCrystalsList()

but this function does not exist in my xraylib:

>>> import xraylib
>>> cryst = xraylib.Crystal_GetCrystal("Muscovite")
>>> xraylib.Bragg_angle (cryst, 10.0, 3, 3, 1)
0.431907830589977
>>> crystals = xraylib.Crystal_GetCrystalsList()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Crystal_GetCrystalsList'
>>> 

how to get molecular weight

Hello Tom,

I came to a problem: using the compound parser I cannot get the molecular weight of the compound. The compound information should have either the final molecular weight or the number of different elements (to be able to compute it). For example, with H2O:

In [106]: xraylib.CompoundParser("H2O")
Out[106]:
{'Elements': [1, 8],
'massFractions': [0.1120976692563818, 0.8879023307436182],
'nAtomsAll': 3.0,
'nElements': 2}

How I can get the molecular weight = 2_xraylib.AtomicWeight(1) + 1_xraylib.AtomicWeight(8) ?

If it is not possible, please consider it for a future version!!

Thanks a lot,

Manolo

xraylib_np on windows

It seems the xraylib_np version is missing in the windows installer, could this perhaps be added?

How to edit or add crystal structures in the crystal list for OASYS?

In XOP, the "Crystal.dat" file in "my XOP directory\data\dabax" can be editted. Then I can change the lattice constant of the crystals.
I failed to figure out a way to edit the structure in OASYS.
Would you please suggest how to edit or add crystal structures in the crystal list for OASYS-XOPPY, or SHADOW?
Thanks,

About compiling with gcc

In wiki it is suggested to compile a C program like this

gcc `pkg-config --cflags libxrl` program.c `pkg-config --libs libxrl`

which makes I view this wiki or use history command literally everytime I compile my program. I think containing this sort of shell script could be helpful for those who compile their program with gcc:

#!/bin/bash
PARAMETERS=""
FILES=""
while [[ $# -gt 0 ]]; do
    if [[ $1 =~ ".c" ]]; then
        FILES=$(echo $FILES $1)
    elif [[ $1 == -o ]]; then
        PARAMETERS=$(echo $PARAMETERS $1)
        shift
        PARAMETERS=$(echo $PARAMETERS $1)
    else
        PARAMETERS=$(echo $PARAMETERS $1)
    fi
    shift
done
#gcc -L /usr/local/lib -I /usr/local/include/xraylib $FILES $PARAMETERS -lxrl
gcc `pkg-config --cflags libxrl` $FILES `pkg-config --libs libxrl` $PARAMETERS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.