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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a62406249fb89eabbea6f8dd362d27ef1944bae535e9a08eb4f2aac67413d4d
|
|
| MD5 |
c4649303db3d6846a4c2f9a28ddfcd69
|
|
| BLAKE2b-256 |
e55ae29fe6355f073e2a8b1f8605acc21d13669aafab2cc40a9a73e5161c98fd
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0aef718d8df56ac62fd019755c7e4f05bc3342bb8c969dbb93cc7b8e6a12ab4
|
|
| MD5 |
1d1abdef8a1344031a4fdcf8db6cfd68
|
|
| BLAKE2b-256 |
7dea8cbb80be7d3e84870479964629e85c5ff5dff6ad5e61efbc58f91f2657f2
|