Skip to main content

A package allowing simple interfacing with typical Astronomical data (FITS, numpy) in polars

Project description

polars_astro

A package adding support for common astronomy data files in Polars.

DOI

Installing

pip install polars_astro

Usage

FITS Files

scan_fits adds support for reading in FITS files as a LazyFrame including predicate pushdown and column projection. The python package fitsio (built around CFITSIO) is used internally for efficient row/column access.

import polars as pl
import polars_astro as pla

pla.scan_fits("astro_catalog.fits").filter(
    pl.col("parallax") > 0.1,
    pl.col("parallax_err") < 0.01
).select(
    pl.col("ID"),
    pl.col("pm_ra"),
    pl.col("pm_dec"),
    pl.col("B_mag"),
    pl.col("V_mag")
)

Numpy Arrays

The np namespace makes it easy to retrieve numpy arrays from a DataFrame

import polars as pl
import polars_astro as pla

pmra, pmdec, distance = pla.read_fits("astro_catalog.fits").filter(
    pl.col("parallax") > 0.1,
    pl.col("parallax_err") < 0.01
).np.select(
    "pm_ra",
    "pm_dec",
    1/pl.col("parallax")
)

pmra, pmdec and distance will all be one-dimensional numpy arrays of the appropriate type. Nulls are handled as described in the polars documentation for Series.to_numpy. This may involve casting integers to floats.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polars_astro-0.2.2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polars_astro-0.2.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file polars_astro-0.2.2.tar.gz.

File metadata

  • Download URL: polars_astro-0.2.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for polars_astro-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1a62406249fb89eabbea6f8dd362d27ef1944bae535e9a08eb4f2aac67413d4d
MD5 c4649303db3d6846a4c2f9a28ddfcd69
BLAKE2b-256 e55ae29fe6355f073e2a8b1f8605acc21d13669aafab2cc40a9a73e5161c98fd

See more details on using hashes here.

File details

Details for the file polars_astro-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: polars_astro-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for polars_astro-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0aef718d8df56ac62fd019755c7e4f05bc3342bb8c969dbb93cc7b8e6a12ab4
MD5 1d1abdef8a1344031a4fdcf8db6cfd68
BLAKE2b-256 7dea8cbb80be7d3e84870479964629e85c5ff5dff6ad5e61efbc58f91f2657f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page