Pulsarbat#

Release

0.0.9

Date

Feb 27, 2023

Pulsarbat (PULSAR Baseband Analysis Tools) is a Python package for analysis of radio baseband signals. Although this package has a special focus on radio pulsar astronomy, it can also be used to work with other types of radio astronomical observations (such as fast radio bursts, quasars, and so on) or any time-frequency data, in general. Pulsarbat provides:

  • Signals: Standardized containers for signal data.

  • Functions/Transforms for manipulating signals.

  • Easy integration with Dask for lazily executed workflows or managing large workloads in an “embarassingly parallel” manner.

The source code can be found on GitHub: theXYZT/pulsarbat

Quickstart#

Install the latest version of Pulsarbat:

$ pip install pulsarbat

To use Pulsarbat in a project:

import pulsarbat as pb

Citing#

Pulsarbat has a DOI via Zenodo: https://doi.org/10.5281/zenodo.6934355

This DOI link represents all versions, and will always resolve to the latest one. Use the following Bibtex entry to cite this work:

@software{pulsarbat,
  author       = {Nikhil Mahajan and Rebecca Lin},
  title        = {pulsarbat: PULSAR Baseband Analysis Tools},
  year         = {2023},
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.6934355},
  url          = {https://doi.org/10.5281/zenodo.6934355}
}

License#

Pulsarbat is licensed under the GNU General Public License v3.

Installation#

Pulsarbat has the following dependencies:

  • Python 3.9 or later

  • Astropy 5.2 or later

  • Numpy 1.23 or later

  • Scipy 1.10 or later

  • Baseband 4.1.1 or later

  • Dask 2023.2.1 or later: with Dask Array.

Released version#

To install the latest released version of Pulsarbat with pip, run:

$ pip install pulsarbat

If you don’t have pip installed, this Python installation guide can guide you through the process.

Development version#

To install the latest development version of Pulsarbat, you can clone the public repository and install the package:

$ git clone git://github.com/theXYZT/pulsarbat
$ cd pulsarbat
$ pip install -e .

The -e flag installs the package in editable mode which allows you to update the package at any time via:

$ git pull

Testing#

Pulsarbat uses pytest for testing. You can test the development version of the package from the source directory with:

$ pytest

User Guide#

Note

This section is under construction.

To use Pulsarbat in a project:

import pulsarbat as pb

API Reference#

Release

0.0.9

Date

Feb 27, 2023

Signals#

Signal(z, /, *, sample_rate[, start_time, meta])

Base class for all signals.

RadioSignal(z, /, *, sample_rate[, ...])

Class for heterodyned radio signals.

IntensitySignal(z, /, *, sample_rate[, ...])

Class for intensity signals.

FullStokesSignal(z, /, *, sample_rate[, ...])

Class for full Stokes (I, Q, U, V) signals.

BasebandSignal(z, /, *, sample_rate[, ...])

Class for complex baseband signals.

DualPolarizationSignal(z, /, *, sample_rate)

Class for dual-polarization complex baseband signals.

Readers#

BaseReader(*, shape, dtype[, signal_type, ...])

Base class for readers.

BasebandReader(name, /, *[, signal_type, ...])

Wrapper around StreamReader from the baseband package.

GUPPIRawReader(name, /)

Baseband reader for GUPPI raw voltage data format.

DADAStokesReader(name, /)

Reader for full Stokes data in DADA format.

Transforms#

signal_transform(func)

Wraps an array function and returns a signal transform.

concatenate(signals, /[, axis])

Concatenates multiple signals along given axis.

snippet(z, /, t, n)

Extracts a snippet of a signal in time.

time_shift(z, /, shift[, crop])

Shift signal data by given number of samples or time.

freq_shift(z, /, shift)

Shift signal data in frequency by given amount.

fast_len(z, /)

Crops signal to an efficient length for FFTs.

Dedispersion#

DispersionMeasure(value[, unit, dtype, ...])

Dispersion Measure class (with default units of pc / cm^3).

coherent_dedispersion(z, DM, /, *[, ...])

Coherently dedisperses a baseband signal.

incoherent_dedispersion(z, DM, /, *[, ref_freq])

Incoherently dedisperses a signal by a given dispersion measure.

Pulsar#

PolycoEntry(psr, obs, freq, tmid, span, ...)

Entry for polynomial-based pulsar phase prediction.

PhasePredictor([data])

Pulsar phase predictor.

Phase(phase1[, phase2, copy, subok])

Represent two-part phase.

FractionalPhase(angle[, unit, wrap_angle])

Phase without the cycle count, i.e., with a range of 1 cycle.

Contrib#

stft(z, /[, window, nperseg, noverlap, nfft])

Performs a short-time Fourier transform on a baseband signal.

istft(z, /[, window, nperseg, noverlap, nfft])

Performs an inverse short-time Fourier transform.

Development#

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. This page assumes the reader has some familiarity with contributing to open-source Python projects using GitHub.

Pulsarbat could always use more documentation, especially in the form of worked examples.

For bug reports and feature requests, create an issue on GitHub here: theXYZT/pulsarbat#issues

Developer Workflow#

To contribute changes (fixing bugs, adding features), we follow a typical GitHub workflow:

  • Create a personal fork of the repository.

  • Create a branch (preferrably, with an informative name).

  • Make changes, test your contributions and document them!

  • Open a pull request.

  • Iterate until changes pass various linters and checks.

  • Work through code review until your PR is accepted and merged.

Deploying#

A reminder for the maintainers on how to deploy a release:

  • Make sure all changes are committed.

  • Update changelog in HISTORY.rst.

  • Update package version in pulsarbat/__init__.py either manually or using bump2version.

  • Create a tagged commit with tag: vX.Y.Z and push tags to origin. A tagged commit should automatically publish the package to PyPI via Github Actions.

  • Create a release on Github on the tagged commit (this will trigger Zenodo).

Useful Things#

This section is an informal reference for contributors and maintainers on how to do some development-related things.

Testing and Coverage#

From the root directory of the repository, run:

$ pytest --cov-report=html --cov=pulsarbat

Then open htmlcov/index.html in your browser to look at test coverage.

Building Docs#

From docs/, run:

$ make clean
$ make html && python -m http.server --directory _build/html 9000

Then open http://localhost:9000/ in your browser to access the built docs.

Release Notes#

0.0.9 (2022-10-??)#

  • Added a frequency-shift function pulsarbat.freq_shift (PR #52)

  • Added a snippet function pulsarbat.snippet (PR #54)

  • pulsarbat.time_shift can now support multiple shifts (PR #58)