sigproc_filterbank

Crates.iosigproc_filterbank
lib.rssigproc_filterbank
version0.4.0
sourcesrc
created_at2022-08-11 18:07:08.049098
updated_at2024-04-05 22:50:38.866868
descriptionA parser and serializer for SIGPROC pulsar filterbank files
homepagehttps://github.com/kiranshila/sigproc_filterbank
repositoryhttps://github.com/kiranshila/sigproc_filterbank
max_upload_size
id643479
size72,535
Kiran Shila (kiranshila)

documentation

README

sigproc_filterbank

license docs rustc build status Codecov

This crate provides a simple, fast, and robust interface to the SIGPROC filterbank binary format. This format contains dynamic spectra, used commonly in pulsar and radio transient science in radio astronomy. This implementation is pure-rust with few dependencies and denies any unsafe code.

Description

There are two main interfaces to filterbank files, reading and writing. These exists as separate data structures as the way you interact with them is fundamentally different.

Reading

To read from a filterbank file, you simply need a slice of bytes. This can come from a memory-mapped file, an incoming stream, etc. Then, there are getter methods for the header data and a single get method for accessing points in the dynamic spectra. Every filterbank will return f32s as the largest integer value supported by the format (u16) fits losslessly in an f32. get indexes as IF channel, Sample number, frequency channel.

use std::{fs::File, io::Read};

use sigproc_filterbank::read::ReadFilterbank;

let mut file = File::open("tests/small.fil").unwrap();
let mut bytes = vec![];
file.read_to_end(&mut bytes).unwrap();
let fb = ReadFilterbank::from_bytes(&bytes).unwrap();
let my_spec_val = fb.get(0,0,0);

Writing

To build a filterbank file, you push time-series data, just as you would receive them in a live telescope. You must declare the number of IFs and number of channels, and then the sample number is implied by how much data you write. Additionally, the number of bits of the filterbank is implied by the type of data you push. You get a compile error if you try to push different types. For data less than 8 bits, use the ux crate. We support, u1, u2, and u4.

Then to write the file, you simply dump the bytes and write to a file, stream, etc.

use sigproc_filterbank::write::WriteFilterbank;

// Two frequency channels, one IF
let mut fb = WriteFilterbank::new(2, 1);
fb.push(&[1u8, 2u8]);
fb.push(&[3u8, 4u8]);
// Serialize to bytes
let bytes = fb.bytes();

License

sigproc_filterbank is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Commit count: 23

cargo fmt