Skip to content

A Rust XRD pattern parser with Python and Node.js bindings

Notifications You must be signed in to change notification settings

jcwang587/geddes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

119 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geddes

Crates.io PyPI npm

A Rust XRD pattern parser with Python and Node.js bindings. Supports:

  • .raw (GSAS text or Bruker binary)
  • .rasx (Rigaku Zip archive)
  • .xrdml (Panalytical XML)
  • .xy / .xye (Space-separated ASCII)
  • .csv (Comma-separated values)

Rust Usage

Load from a file path:

use geddes::read;

fn main() {
    let pattern = read("tests/data/xy/sample.xy").unwrap();
    println!("{} {}", pattern.x.len(), pattern.y.len());
}

Load from in-memory bytes (filename is used to infer the format):

use std::fs;

use geddes::read_bytes;

fn main() {
    let data = fs::read("tests/data/xy/sample.xy").unwrap();
    let pattern = read_bytes(&data, "sample.xy").unwrap();
    println!("{} {}", pattern.x.len(), pattern.y.len());
}

Python Usage

Load from a file path:

import geddes

pattern = geddes.read("tests/data/xy/sample.xy")
print(len(pattern.x), len(pattern.y))

Load from in-memory bytes (filename is used to infer the format):

import geddes

with open("tests/data/xy/sample.xy", "rb") as f:
    data = f.read()

pattern = geddes.read_bytes(data, "sample.xy")
print(len(pattern.x), len(pattern.y))

Node.js Usage

Load from a file path:

const geddes = require('@jcwang587/geddes')

const pattern = geddes.read('tests/data/xy/sample.xy')
console.log(pattern.x.length, pattern.y.length)

Load from in-memory bytes (filename is used to infer the format):

const fs = require('node:fs')
const geddes = require('@jcwang587/geddes')

const bytes = fs.readFileSync('tests/data/xy/sample.xy')
const pattern = geddes.readBytes(bytes, 'sample.xy')
console.log(pattern.x.length, pattern.y.length)

License

MIT

About

A Rust XRD pattern parser with Python and Node.js bindings

Topics

Resources

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •