pyref_core::loader

Struct FitsLoader

Source
pub struct FitsLoader {
    pub path: String,
    pub hdul: HDUList,
}

Fields§

§path: String§hdul: HDUList

Implementations§

Source§

impl FitsLoader

FitsLoader struct for loading and accessing FITS file data.

The FitsLoader struct provides methods for loading and accessing data from a FITS file. It supports retrieving individual card values, all card values, image data, and converting the data to a Polars DataFrame.

§Example

extern crate pyref_core;
use pyref_core::loader::FitsLoader;

let fits_loader = FitsLoader::new("/path/to/file.fits").unwrap();

// Get a specific card value
let card_value = fits_loader.get_value("CARD_NAME");

// Get all card values
let all_cards = fits_loader.get_all_cards();

// Get image data
let image_data = fits_loader.get_image();

// Convert data to Polars DataFrame
let keys = ["KEY1", "KEY2"];
let polars_df = fits_loader.to_polars(&keys);

A struct representing a FITS loader.

Source

pub fn new(path: &str) -> Result<Self, Box<dyn Error + Send + Sync>>

Creates a new FitsLoader instance.

§Arguments
  • path - The path to the FITS file.
§Returns

A Result containing the FitsLoader instance if successful, or a boxed dyn std::error::Error if an error occurred.

Source

pub fn get_card(&self, card_name: &str) -> Option<Card>

Retrieves a specific card from the FITS file.

§Arguments
  • card_name - The name of the card to retrieve.
§Returns

An Option containing the requested card::Card if found, or None if not found.

Source

pub fn get_value(&self, card_name: &str) -> Option<f64>

Retrieves the value of a specific card from the FITS file.

§Arguments
  • card_name - The name of the card to retrieve the value from.
§Returns

An Option containing the value of the requested card as a f64 if found, or None if not found.

Source

pub fn value_from_hdu(&self, card_name: &str) -> Option<f64>

Source

pub fn get_scan_num(&self) -> i32

Source

pub fn get_all_cards(&self) -> Vec<Card>

Retrieves all cards from the FITS file.

§Returns

A Vec containing all the cards as card::Card instances.

Source

pub fn get_image( &self, ) -> Result<(Vec<u32>, Vec<u32>), Box<dyn Error + Send + Sync>>

Retrieves the image data from the FITS file as an Array2<u32>.

§Returns

A Result containing the image data as a Array2<u32> if successful, or a boxed dyn std::error::Error if an error occurred.

Source

pub fn to_polars( &self, keys: &Vec<HeaderValue>, ) -> Result<DataFrame, Box<dyn Error + Send + Sync>>

Converts the FITS file data to a polars::prelude::DataFrame.

§Arguments
  • keys - The keys of the cards to include in the DataFrame. If empty, all cards will be included.
§Returns

A Result containing the converted DataFrame if successful, or a boxed dyn std::error::Error if an error occurred.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Ungil for T
where T: Send,