Registry / data / castepxbin

castepxbin

JSON →
library0.3.1pypypi✓ verified 87d ago

castepxbin is a collection of Python readers for various binary output files generated by CASTEP, a first-principles quantum mechanics code. It enables parsing of data like projected density of states (.pdos_bin), checkpoint files (.castep_bin), optical matrix elements (.ome_bin, .ome_cst), and wave functions (.check). The current version is 0.3.1, with releases occurring irregularly, primarily driven by new feature additions and compatibility fixes.

pip install castepxbin
INSTALL
IMPORT
SIG · CASTEPXBIN
C
castepxbin
datapythonv0.3.1
Install
7.4s avg
Import
—
Disk
230MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 230.8MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 7.4s · import 0.000s · 222MB
230MB installed
● package 230MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

read_pdos_bin
✓ from castepxbin import read_pdos_bin
✗ from castepxbin.pdos_bin import PdosBinReader
read_castep_bin
✓ from castepxbin import read_castep_bin
read_ome_bin
✓ from castepxbin import read_ome_bin

This quickstart demonstrates how to instantiate a `PdosBinReader` to read a CASTEP `.pdos_bin` file and access common data such as eigenvalues and projected density of states (PDOS) weights. Remember to replace 'path_to_your_castep.pdos_bin' with the actual path to your CASTEP output file. Similar patterns apply to `CastepBinReader`, `OmeBinReader`, and `CheckReader` for their respective file types.

import numpy as np from castepxbin.pdos_bin import PdosBinReader # Assuming you have a castep.pdos_bin file generated by CASTEP # For demonstration, we'll create a dummy file. In a real scenario, # this path would point to your actual CASTEP output. dummy_pdos_data = { 'kpoints': np.random.rand(5, 3), # Dummy k-points 'num_spins': 1, 'num_bands': 10, 'num_species': 2, 'num_proj_per_species': 9, # s, p_x, p_y, p_z, d_xy, d_yz, d_zx, d_x2y2, d_z2 'eigenvalues': np.random.rand(1, 5, 10), # spin, kpoint, band 'weights': np.random.rand(1, 5, 10, 2, 9), # spin, kpoint, band, species, projection 'efermi': 0.0 } # In a real scenario, you'd have a pdos_bin file. # The library is for reading existing files, not creating them. # This part is just to make the example runnable without an actual file. # For a true quickstart, you'd replace 'path_to_your_file.pdos_bin' # with an actual file path. # Example usage with a placeholder path: file_path = 'path_to_your_castep.pdos_bin' try: reader = PdosBinReader(file_path) # Access data, e.g., eigenvalues, weights eigenvalues = reader.get_eigenvalues() pdos_weights = reader.get_total_weights() print(f"Successfully read {file_path}") print(f"Eigenvalues shape: {eigenvalues.shape}") print(f"PDOS weights shape: {pdos_weights.shape}") except FileNotFoundError: print(f"Error: The file '{file_path}' was not found. Please provide a valid CASTEP .pdos_bin file.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
gotchaOlder versions of `castepxbin` (pre-0.3.1) might encounter `DeprecationWarning` or unexpected behavior when used with NumPy versions 1.25.0 or newer due to changes in NumPy's C API.
fix
Upgrade to `castepxbin>=0.3.1` to ensure full compatibility with modern NumPy versions (`pip install --upgrade castepxbin`).
affects: <0.3.1
gotchaEach reader class (`PdosBinReader`, `CastepBinReader`, etc.) is specific to a particular CASTEP binary file format. Using the wrong reader for a given file will likely lead to parsing errors or incorrect data.
fix
Ensure you are using the correct reader class for the CASTEP binary file you are trying to parse (e.g., `PdosBinReader` for `.pdos_bin`, `CastepBinReader` for `.castep_bin`). Refer to the documentation for supported file types for each reader.
affects: All versions
gotchaFile paths must be exact and accessible. Relative paths are resolved from the current working directory.
fix
Always verify that the file path provided to the reader constructor is correct and that the file exists at that location. Use `os.path.exists()` for debugging if encountering `FileNotFoundError`.
affects: All versions
Upgrade
Version history
0.3.1latest on PyPI · released Oct 15, 2025
Audit
Dependencies
numpyrequiredCore dependency for array manipulation and data handling from binary files.
Agent activity
29 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
castepxbin — pip install castepxbin · libregistry