Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']
python-version: ['3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
Expand All @@ -27,7 +27,7 @@ jobs:
python -m pip install -U pip setuptools wheel
python -m pip install .[tests] -v
- name: Lint with Ruff
uses: chartboost/ruff-action@v1
uses: astral-sh/ruff-action@v3
with:
args: "check"
continue-on-error: true
Expand All @@ -40,9 +40,9 @@ jobs:
pytest --cov=./ --cov-report=xml
continue-on-error: false
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
files: ./coverage.xml
name: codecov-umbrella
fail_ci_if_error: true
env:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[![Docs](https://readthedocs.org/projects/sigpyproc3/badge/?version=latest)](https://sigpyproc3.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/FRBs/sigpyproc3/branch/main/graph/badge.svg)](https://codecov.io/gh/FRBs/sigpyproc3)
[![License](https://img.shields.io/github/license/FRBs/sigpyproc3)](https://github.com/FRBs/sigpyproc3/blob/main/LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![SPEC 0 — Minimum Supported Dependencies](https://img.shields.io/badge/SPEC-0-green?labelColor=%23004811&color=%235CA038)](https://scientific-python.org/specs/spec-0000/)

`sigpyproc` is a pulsar and FRB data analysis library for python. It provides an OOP approach to pulsar data handling through the use of
objects representing different data types (e.g. [SIGPROC filterbank](http://sigproc.sourceforge.net),
Expand All @@ -20,7 +21,7 @@ The quickest way to install the package is to use [pip](https://pip.pypa.io):
pip install -U git+https://github.com/FRBs/sigpyproc3
```

Note that you will need Python (>=3.8) installed to use `sigpyproc`.
Note that you will need Python (>=3.11) installed to use `sigpyproc`.
Also check out the [installation documentation page](https://sigpyproc3.readthedocs.io/en/latest/install.html) for more options.

## Legacy Version
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Configuration file for the Sphinx documentation builder.

Check failure on line 1 in docs/conf.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.13)

docs/conf.py:1:1: INP001 File `docs/conf.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in docs/conf.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

docs/conf.py:1:1: INP001 File `docs/conf.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in docs/conf.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

docs/conf.py:1:1: INP001 File `docs/conf.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in docs/conf.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

docs/conf.py:1:1: INP001 File `docs/conf.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in docs/conf.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

docs/conf.py:1:1: INP001 File `docs/conf.py` is part of an implicit namespace package. Add an `__init__.py`.

Check failure on line 1 in docs/conf.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.13)

docs/conf.py:1:1: INP001 File `docs/conf.py` is part of an implicit namespace package. Add an `__init__.py`.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
Expand Down Expand Up @@ -26,7 +26,7 @@

project = "sigpyproc3"
author = "Fast Radio Burst Software"
year = datetime.datetime.now(tz=datetime.timezone.utc).date().year
year = datetime.datetime.now(tz=datetime.UTC).date().year
copyright = f"{year}, {author}" # noqa: A001
version = meta_version("sigpyproc")
release = version
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ environment, with a simple plug-and-play system with new modules and extensions.
[![Docs](https://readthedocs.org/projects/sigpyproc3/badge/?version=latest)](https://sigpyproc3.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/FRBs/sigpyproc3/branch/main/graph/badge.svg)](https://codecov.io/gh/FRBs/sigpyproc3)
[![License](https://img.shields.io/github/license/FRBs/sigpyproc3)](https://github.com/FRBs/sigpyproc3/blob/main/LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![SPEC 0 — Minimum Supported Dependencies](https://img.shields.io/badge/SPEC-0-green?labelColor=%23004811&color=%235CA038)](https://scientific-python.org/specs/spec-0000/)

## Contents

Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Installation

:::{note}
`sigpyproc` requires Python 3.8 and later.
`sigpyproc` requires Python 3.11 and later.
:::

## Using pip
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[project]
name = "sigpyproc"
version = "1.2.0"
version = "2.0.0"
description = "Python FRB/pulsar data toolbox"
readme = "README.md"
authors = [{ name = "Ewan Barr", email = "[email protected]" }]
maintainers = [{ name = "Pravir Kumar", email = "[email protected]" }]
requires-python = ">=3.10"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand All @@ -32,7 +31,10 @@ dependencies = [
"click",
"rich",
"rich-click",
"rocket-fft",
#"rocket-fft",
# The following line is a workaround for Py 3.13 compatibility
# until the issue is resolved in rocket-fft
"rocket-fft @ git+https://github.com/styfenschaer/rocket-fft.git",
"bidict",
"typing_extensions",
]
Expand Down Expand Up @@ -84,7 +86,7 @@ exclude = ["sigpyproc/apps/spp_digifil.py"]

line-length = 88
indent-width = 4
target-version = "py310"
target-version = "py311"

[tool.ruff.format]
quote-style = "double"
Expand Down Expand Up @@ -126,7 +128,6 @@ exclude_lines = [
]

[tool.mypy]
enable_incomplete_feature = ["Unpack"]
ignore_missing_imports = true
plugins = ["numpy.typing.mypy_plugin"]

Expand Down
7 changes: 6 additions & 1 deletion sigpyproc/apps/spp_clean.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import rich_click as click

from sigpyproc.readers import FilReader

if TYPE_CHECKING:
from sigpyproc.core.custom_types import MaskMethods


@click.command(
context_settings={"help_option_names": ["-h", "--help"], "show_default": True},
Expand Down Expand Up @@ -46,7 +51,7 @@
)
def main(
filfile: str,
method: str,
method: MaskMethods,
threshold: float,
outfile: str | None,
maskfile: str | None,
Expand Down
3 changes: 1 addition & 2 deletions sigpyproc/block.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Self

import numpy as np
from numpy import typing as npt
from typing_extensions import Self

from sigpyproc.core import kernels, stats
from sigpyproc.header import Header
Expand Down
1 change: 1 addition & 0 deletions sigpyproc/core/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
"gaussian_blobs",
"random",
]
MatchFilterMethods = Literal["boxcar", "gaussian", "lorentzian"]
4 changes: 2 additions & 2 deletions sigpyproc/core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)

if TYPE_CHECKING:
from sigpyproc.core.custom_types import LocMethods, ScaleMethods
from sigpyproc.core.custom_types import LocMethods, MatchFilterMethods, ScaleMethods


class MatchedFilter:
Expand Down Expand Up @@ -99,7 +99,7 @@ def __init__(
data: np.ndarray,
loc_method: LocMethods | Literal["norm"] = "median",
scale_method: ScaleMethods | Literal["norm"] = "iqr",
temp_kind: Literal["boxcar", "gaussian", "lorentzian"] = "boxcar",
temp_kind: MatchFilterMethods = "boxcar",
nbins_max: int = 32,
spacing_factor: float = 1.5,
) -> None:
Expand Down
7 changes: 6 additions & 1 deletion sigpyproc/foldedcube.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import numpy as np
from numpy import typing as npt

from sigpyproc import params
from sigpyproc.core.filters import MatchedFilter
from sigpyproc.header import Header

if TYPE_CHECKING:
from sigpyproc.core.custom_types import MatchFilterMethods


class Profile:
"""An array class to handle a 1-D pulse profile.
Expand Down Expand Up @@ -38,7 +43,7 @@ def tsamp(self) -> float:

def compute_mf(
self,
temp_kind: str = "boxcar",
temp_kind: MatchFilterMethods = "boxcar",
nbins_max: int = 32,
spacing_factor: float = 1.5,
) -> MatchedFilter:
Expand Down
2 changes: 1 addition & 1 deletion sigpyproc/fourierseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def deredden(
FourierSeries
Whitened fourier series.
"""
end_freq_bin = int(round(end_freq / self.binwidth))
end_freq_bin = round(end_freq / self.binwidth)
out_ar = kernels.fs_running_median(
self.data,
start_width,
Expand Down
8 changes: 5 additions & 3 deletions sigpyproc/header.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from pathlib import Path
from typing import Any
from typing import TYPE_CHECKING, Any

import attrs
import numpy as np
Expand All @@ -14,6 +14,8 @@
from sigpyproc.io.bits import BitsInfo
from sigpyproc.io.fileio import FileWriter

if TYPE_CHECKING:
from collections.abc import Sequence

@attrs.frozen(auto_attribs=True, kw_only=True)
class Header:
Expand Down Expand Up @@ -687,15 +689,15 @@ def from_inffile(cls, filename: str | Path) -> Header:
@classmethod
def from_sigproc(
cls,
filenames: str | Path | list[str | Path],
filenames: str | Path | Sequence[str | Path],
*,
check_contiguity: bool = True,
) -> Header:
"""Parse the metadata from Sigproc-style files.

Parameters
----------
filenames : str | Path | list[str | Path]
filenames : str | Path | Sequence[str | Path]
Sigproc filterbank files containing the header.
check_contiguity : bool, optional
Check if the files are contiguous, by default True.
Expand Down
33 changes: 17 additions & 16 deletions sigpyproc/io/bits.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
from __future__ import annotations

from typing import ClassVar
from typing import Any, ClassVar

import attrs
import numpy as np
import numpy.typing as npt

from sigpyproc.core import kernels

nbits_to_dtype = {1: "<u1", 2: "<u1", 4: "<u1", 8: "<u1", 16: "<u2", 32: "<f4"}


def unpack(
array: np.ndarray,
array: npt.NDArray[np.uint8],
nbits: int,
unpacked: np.ndarray | None = None,
unpacked: npt.NDArray[np.uint8] | None = None,
*,
bitorder: str = "big",
) -> np.ndarray:
) -> npt.NDArray[np.uint8]:
"""Unpack 1, 2 and 4-bit data packed as 8-bit numpy array.

Parameters
----------
array : numpy.ndarray
array : NDArray[np.uint8]
Array to unpack.
nbits : int
Number of bits of the packed data.
unpacked : numpy.ndarray, optional
unpacked : NDArray[np.uint8], optional
Array to unpack into.
bitorder : str, optional
Bit order of the packed data.

Returns
-------
numpy.ndarray
NDArray[np.uint8]
Unpacked array.

Raises
Expand Down Expand Up @@ -65,28 +66,28 @@ def unpack(


def pack(
array: np.ndarray,
array: npt.NDArray[np.uint8],
nbits: int,
packed: np.ndarray | None = None,
packed: npt.NDArray[np.uint8] | None = None,
*,
bitorder: str = "big",
) -> np.ndarray:
) -> npt.NDArray[np.uint8]:
"""Pack 1, 2 and 4-bit data into 8-bit numpy array.

Parameters
----------
array : numpy.ndarray
array : NDArray[np.uint8]
Array to pack.
nbits : int
Number of bits of the unpacked data.
packed : numpy.ndarray, optional
packed : NDArray[np.uint8], optional
Array to pack into.
bitorder : str, optional
Bit order in which to pack the data.

Returns
-------
numpy.ndarray
NDArray[np.uint8]
Packed array.

Raises
Expand Down Expand Up @@ -174,7 +175,7 @@ def _set_digi_sigma(self) -> float:
return self.default_sigma[self.nbits]

@property
def dtype(self) -> np.dtype:
def dtype(self) -> np.dtype[Any]:
"""Type of the data.

Returns
Expand Down Expand Up @@ -272,7 +273,7 @@ def digi_scale(self) -> float:
"""
return self.digi_mean / self.digi_sigma

def to_dict(self) -> dict[str, int | float | np.dtype]:
def to_dict(self) -> dict[str, int | float | np.dtype[Any]]:
"""Get a dict of all property attributes.

Returns
Expand All @@ -289,7 +290,7 @@ def to_dict(self) -> dict[str, int | float | np.dtype]:
attributes.update(prop)
return attributes

def quantize(self, arr_norm: np.ndarray) -> np.ndarray:
def quantize(self, arr_norm: npt.NDArray[np.float32]) -> npt.NDArray[np.uint8]:
"""Quantize normalized data to given nbit-dependent mean and sigma.

Parameters
Expand Down
3 changes: 1 addition & 2 deletions sigpyproc/io/fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

if TYPE_CHECKING:
from collections.abc import Callable

from typing_extensions import Self
from typing import Self

from sigpyproc.io.sigproc import StreamInfo

Expand Down
3 changes: 2 additions & 1 deletion sigpyproc/io/pfits.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

from typing import Self

import attrs
import numpy as np
from astropy import units
from astropy.coordinates import Angle, EarthLocation, SkyCoord
from astropy.io import fits
from astropy.time import Time, TimeDelta
from typing_extensions import Self

from sigpyproc.io.bits import BitsInfo, unpack
from sigpyproc.utils import FrequencyChannels
Expand Down
Loading
Loading