ndarray support
Date: 2018-04-02
The latest feature has been added to the master branch. fitsio
now
supports reading image data into ndarray
arrays.
Replicating some of the functionality of the Python numpy library, where an array object can be treated like a simple scalar variable.
For example:
# #![allow(unused_variables)] #fn main() { let filename = "../testdata/full_example.fits"; let mut fptr = FitsFile::open(filename)?; let phdu = fptr.primary_hdu()?; let image: ArrayD<f32> = phdu.read_image(&mut fptr)?; let new_image = (image * 4.0) / 5.2; assert_eq!(new_image.ndim(), 2); #}
Currently, only reading images is supported. I do see writing Array
objects coming in the future, but it is not currently supported.
I hope to be adding ndarray
support to a formal versioned release
soon.
Contributions
- astrojghu for seeding the idea in this thread