Skip to content

πŸ”πŸ” SAXS diffraction pattern indexing the easy way

License

Notifications You must be signed in to change notification settings

jowch/Himalaya.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

77 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Himalaya.jl

SAXS diffraction pattern indexing the easy way.

Installation

Once you have started Julia, enter Pkg mode by typing ] and run add Himalaya command. You will see something like this

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.0-beta3 (2022-03-29)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.8) pkg> add Himalaya

And that's it!

Usage

The following code is an example of how to use Himalaya to index the integration of a diffraction pattern.

using DelimitedFiles
using Himalaya

load_integration(path) = readdlm(path, ' ', Float64, '\n')

# `integration` contains the values in a tot_file
integration = load_integration("my-high-impact-sample_tot.dat")
qs, logIs = integration[:, 1], log10.(integration[:, 2])

# indices of peaks in the integration array
peak_locations, peak_proms = findpeaks(logIs)
peak_qs = qs[peak_locations]

# compute phases matching identified peaks
indices = indexpeaks(peak_qs, peak_proms)

# Example `indices`
# 3-element Vector{Index}:
#  Index(::Pn3m, 0.05344, [0.05344 0.06556 0.07508 0.09239 0.10668 0.11317 β‹… 0.12486]
#  Index(::Im3m, 0.05344, [0.05344 0.07508 0.09239 0.10668 β‹… 0.13049 β‹… β‹… β‹…]
#  Index(::Pn3m, 0.07508, [0.07508 0.09239 0.10668 0.13049 β‹… β‹… β‹… β‹…]

index = first(indices)

score(index) # => 6.4996...
d, RΒ² = fit(index) # => d = 117.8585...Γ…; RΒ² = 0.9999...

You can also get Indexs for a specific phase as follows

indexpeaks(Hexagonal, peak_qs, peak_proms)
# 6-element Vector{Index}:
#  Index(::Hexagonal, 0.06426, [0.06426 0.11144 0.12876 0.16771 0.19368 β‹… β‹…])
#  Index(::Hexagonal, 0.07855, [0.07855 0.13655 0.15732 β‹… β‹… β‹… β‹…])
#  Index(::Hexagonal, 0.09673, [0.09673 0.16771 0.19368 0.25645 0.29107 β‹… β‹…])
#  ...

You can use ?Phase to see the list of available phases (? enters help mode).

About

πŸ”πŸ” SAXS diffraction pattern indexing the easy way

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages