Git Product home page Git Product logo

sim-xrf's Introduction

sim-xrf

This is a python/C++ program for simulating X-Ray Fluorescence (XRF) spectrum acquired at a synchrotron radiation beamline.

  1. Installation ======= The source files need to be compiled with C++11 (tested with g++ version 4.7 and mingw-w64 x86_64-4.9.1-posix-seh-rt_v3-rev1).

Xraylib with python bindings is also needed at compiling.

Xraylib is available at https://github.com/tschoonj/xraylib.

1.1. Compiling Xraylib

Instructions on compiling XrayLib can be found at https://github.com/tschoonj/xraylib/wiki.

After compilation of XrayLib, change the "XRL_PATH" in "variables.mk" to the actual installation directory of XrayLib.

1.2. Compiling sim-xrf

In the top directory do "make". If your C++ compiler is not called with "g++", modify the variable "g++" in "variables.mk" according to your actual compiler.

1.3. Initialization

Initialize the program by running ". init.sh" before running the program.

  1. Running sim-xrf ======= Sim-xrf can be run in C++ mode and Python mode. In both modes, an input file defining the parameters needed in the calculation is required. The output of the C++ mode is a text file; the Python mode can in addition plot the spectrum or read the output files and plot them.

2.1. Input file

The input file is a text file defining the parameters needed in the calculation. See the example "input.txt" file for instructions.

2.2. Running in C++ mode

On linux:

./main.out [input file name] [output file name]

On windows:

main.exe [input file name] [output file name]

2.3. Running in Python mode

2.3.1. Direct run in command line

Calculation + plotting:

python simpy.py [input file name] [output file name]

Reading output file + plotting:

python read.py [input file name] [output file name]

2.3.2. Import as a module:

Calculate spectrum

from python.pyapi import calc

nout = 3000, 30, 500, 500  # N of channels, N of Z, N of lines, N of thetas
xlim = 0, 11
ylim = 1e-14, 1e-4

spec = calc(input_file="input.txt", output_file="output.txt")
spec.show(xlim=xlim, ylim=ylim)

Read/plot output files

from read import read, plot
    
fname = "output.txt"
xlim = 0, 11
ylim = 1e-14, 1e-4

# Read data file
ev, a, labels = read(fname)

# Plot spectrum
plt.figure()
plt.title('Spectrum read from %s' % fname)
plot(ev, a, labels, xlim=xlim, ylim=ylim)

sim-xrf's People

Contributors

gromitsun avatar

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.