| Crates.io | pyref-core |
| lib.rs | pyref-core |
| version | 0.5.8 |
| created_at | 2024-08-29 00:37:55.941721+00 |
| updated_at | 2025-06-24 15:04:05.061277+00 |
| description | Core of the pyref project |
| homepage | |
| repository | https://github.com/WSU-Carbon-Lab/pyref-ccd |
| max_upload_size | |
| id | 1355484 |
| size | 122,199 |
This crate is a light wrapper over the astrors-fork crate. It provides a simple interface to access CCD data in FITS files and convert them to Polars DataFrames.
use pyref_core::*;
use std::path::Path;
fn main() {
// Read a single FITS file
let path = "path/to/fits/file.fits";
let df = read_fits_file(path, ExperimentType::Xrr).unwrap();
println!("{:?}", df);
// Load all FITS files in a directory
let dir_path = "path/to/directory";
let all_df = read_experiment_dir(dir_path, ExperimentType::Xrr).unwrap();
println!("{:?}", all_df);
}
use pyref_core::*;
use std::path::PathBuf;
fn main() {
// Read files matching a pattern
let pattern_df = read_fits_with_pattern(
"path/to/directory",
"Y6_refl_*.fits",
ExperimentType::Xrr
).unwrap();
// Read specific files
let file_paths = vec![
PathBuf::from("path/to/file1.fits"),
PathBuf::from("path/to/file2.fits"),
PathBuf::from("path/to/file3.fits"),
];
let selected_df = read_multiple_fits_files(file_paths, ExperimentType::Xrr).unwrap();
// Work with the DataFrames
let combined = selected_df.vstack(&pattern_df).unwrap();
println!("Combined shape: {:?}", combined.shape());
}
ExperimentType::Xrr - X-ray ReflectivityExperimentType::Xrs - X-ray SpectroscopyExperimentType::Other - Generic FITS filesEach experiment type automatically extracts the relevant header values, plus standard headers:
// XRR headers
ExperimentType::Xrr => vec![
"Sample Theta [deg]",
"CCD Theta [deg]",
"Beamline Energy [eV]",
"Beam Current [mA]",
"EPU Polarization [deg]",
"Horizontal Exit Slit Size [um]",
"Higher Order Suppressor [mm]",
"EXPOSURE [s]",
]
// Standard headers always included for all experiment types
"DATE" // Date/time information from the FITS header
The library now extracts only the base file name from the path without parsing frame numbers or scan IDs. This simplifies file handling and makes it more robust.
The library automatically calculates:
Output DataFrames are automatically sorted by: