Skip to main content

Electron Diffraction Refinement Engine - SHELXL-compatible crystallographic refinement for 3D ED/microED

Project description

EDref v3

Pipeline Status Coverage PyPI version Python versions License: MIT

Electron Diffraction Refinement Engine - A Python library for crystallographic structure refinement compatible with SHELXL.

Overview

EDref is a modular implementation of least-squares crystallographic refinement on F². It can reproduce SHELXL's kinematic refinement workflow and supports both X-ray and electron diffraction data.

Installation

# Development installation
cd EDref_v3
pip install -e .

# With development dependencies
pip install -e ".[dev]"

Quick Start

from edref import (
    InsFileReader, HklFileReader,
    SpaceGroup,
    calculate_reciprocal_cell,
    calculate_structure_factor,
    merge_reflections,
    calculate_R1,
)

# Load structure
ins = InsFileReader("structure.ins").read()
hkl = HklFileReader("structure.hkl").read()

# Setup
reciprocal = calculate_reciprocal_cell(ins.cell)
spacegroup = SpaceGroup(ins.latt, ins.symm)

# Merge reflections
merged = merge_reflections(hkl.reflections, spacegroup)

# Calculate structure factors
for refl in merged[:5]:
    Fc = calculate_structure_factor(
        refl.h, refl.k, refl.l,
        ins.atoms, ins.sfac,
        spacegroup, reciprocal,
        ins.wavelength
    )
    print(f"({refl.h},{refl.k},{refl.l}): |Fc|² = {abs(Fc)**2:.2f}")

Package Structure

src/edref/
├── core/           # Crystallographic fundamentals
│   ├── crystallography.py   # Unit cell, d-spacing
│   ├── symmetry.py          # Space group operations
│   ├── scattering.py        # Atomic scattering factors
│   └── structure_factors.py # F(hkl) calculation
├── io/             # File I/O
│   ├── formats.py          # Data classes
│   └── shelxl.py           # SHELXL file readers
├── refinement/     # Least-squares refinement
│   ├── weighting.py        # SHELXL weighting scheme
│   └── statistics.py       # R-factors, GooF
└── analysis/       # Data processing
    └── merging.py          # Reflection merging

Key Features

  • SHELXL-compatible: Reproduces SHELXL kinematic refinement
  • Type hints: Full type annotations for better IDE support
  • Modular design: Use only the components you need
  • No hard-coded paths: All paths are parameters
  • Electron diffraction: Supports custom SFAC coefficients

Validated Against SHELXL

  • Aspirin (P2₁/c, 21 atoms): R1 within 0.32% of SHELXL
  • Structure factors: Correlation > 0.9999 with SHELXL .fcf

Command-Line Interface

EDref includes a CLI for running refinements:

# Run EDref refinement
edref structure.ins --edref

# Run SHELXL for comparison
edref structure.ins --shelxl

# Run both and compare results
edref structure.ins --compare

# With resolution cutoff
edref structure.ins --compare --resolution 99 0.8

Requirements

  • Python >= 3.10
  • NumPy >= 1.21
  • SciPy >= 1.7
  • Matplotlib >= 3.5

Documentation

License

MIT License - see LICENSE for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edref-3.5.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edref-3.5.0-py3-none-any.whl (159.2 kB view details)

Uploaded Python 3

File details

Details for the file edref-3.5.0.tar.gz.

File metadata

  • Download URL: edref-3.5.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for edref-3.5.0.tar.gz
Algorithm Hash digest
SHA256 52c6be237aee0c67b6d7937b6eb684a6db04cc8e5308b0bd8be4aca87c1d9a7f
MD5 f96beacc47b7a40371849adfd7303966
BLAKE2b-256 ea2fa9780315747e8da0b55e0d1441a930c4c3c561b7aead9b1ace9400b82283

See more details on using hashes here.

File details

Details for the file edref-3.5.0-py3-none-any.whl.

File metadata

  • Download URL: edref-3.5.0-py3-none-any.whl
  • Upload date:
  • Size: 159.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for edref-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1f13d34d283299d475415cb1c07059e46a9f83f4ba776c14f20fd1948de833c
MD5 01e8c8a55d40b747446a5963e6ac5f22
BLAKE2b-256 f785796e3ea8863f6a5d9d0abf8155b45511d6dc99a8cc64bbd567293f74e4d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page