Skip to main content

Arrow bindings for casacore

Project description

arcae implements a limited subset of functionality from the more mature python-casacore package. It bypasses some existing limitations in python-casacore to provide safe, multi-threaded access to CASA formats, thereby enabling export into newer cloud native formats such as Apache Arrow and Zarr.

Rationale

casacore and the python-casacore Python bindings provide access to the CASA Table Data System (CTDS) and Measurement Sets created within this system. The CTDS, as of casacore 3.5.0 is subject to the following limitations:

Resolving these concerns is potentially a major effort, involving invasive changes across the CTDS system.

In the time since the CTDS was developed, newer, open-source formats such as Apache Arrow and Zarr have been developed that are suitable for representing Radio Astronomy data.

  • The Apache Arrow project defines a programming language portable in-memory columnar storage format.

  • Translating CTDS data to Arrow is relatively simple, with some limitations mentioned below.

  • It’s easy to convert Arrow Tables between many different languages

  • Once in Apache Arrow format, it is easy to store data in modern, cloud-native disk formats such as parquet and Zarr.

  • Converting CASA Tables to Arrow in the C++ layer avoids the GIL

  • Access to non thread-safe CASA Tables is constrained to a ThreadPool containing a single thread

  • It also allows us to write astrometry routines in C++, potentially side-stepping thread-safety and GIL issues with the CASA Measures server.

Limitations

Arrow supports both 1D arrays and nested structures:

  1. Fixed shape multi-dimensional data (i.e. visibility data) is currently represented as nested FixedSizeListArrays .

  2. Variably-shaped multi-dimensional (i.e. subtable data) is currently represented as nested ListArrays.

  3. Complex values are represented as an extra FixedSizeListArray nesting of two floats.

  4. Currently, it is not trivially trivial (repetition intended here) to convert between the above and numpy via to_numpy calls on Arrow Arrays, but it is relatively trivial to reinterpret the underlying data buffers from either API. This is done transparently in getcol and putcol functions (see usage below).

Going forward, FixedShapeTensorArray and VariableShapeTensorArray will provide more ergonomic structures for representing multi-dimensional data. First class support for complex values in Apache Arrow will require implementing a C++ extension type within Arrow itself:

Some other edge cases have not yet been implemented, but could be with some thought.

  • Columns with unconstrained rank (ndim == -1) whose rows, in practice, have differing dimensions. Unconstrained rank columns whose rows actually have the same rank are catered for.

  • Not yet able to handle TpRecord columns. Probably simplest to convert these rows to json and store as a string.

  • Not yet able to handle TpQuantity columns. Possible to represent as a run-time parametric Arrow DataType.

Installation

Binary wheels are providing for Linux and MacOSX for both x86_64 and arm64 architectures

$ pip install arcae

Usage

Example usage with Arrow Tables:

import json
from pprint import pprint

import arcae
import pyarrow as pa
import pyarrow.parquet as pq

# Obtain (partial) Apache Arrow Table from a CASA Table
casa_table = arcae.table("/path/to/measurementset.ms")
arrow_table = casa_table.to_arrow()        # read entire table
arrow_table = casa_table.to_arrow(index=(slice(10, 20),)
assert isinstance(arrow_table, pa.Table)

# Print JSON-encoded Table and Column keywords
pprint(json.loads(arrow_table.schema.metadata[b"__arcae_metadata__"]))
pprint(json.loads(arrow_table.schema.field("DATA").metadata[b"__arcae_metadata__"]))

pq.write_table(arrow_table, "measurementset.parquet")

Some reading and writing functionality from python-casacore is replicated, with added support for some NumPy Advanced Indexing.

casa_table = arcae.table("/path/to/measurementset.ms", readonly=False)
# Get rows 10 and 2, and channels 16 to 32, and all correlations
data = casa_table.getcol("DATA", index=([10, 2], slice(16, 32), None))
# Write some modified data back
casa_table.putcol("DATA", data + 1*1j, index=([10, 2], slice(16, 32), None))

See the test cases for further use cases.

Multi-threaded read support

When opening a CASA table, arcae can open multiple instances of the table in separate threads and multiplex read operations over them. This mode of operation is intended to saturate the number of I/O requests in-flight by submitting read operations from multiple threads:

import concurrent.futures as cf

table = arcae.table("/path/to/measurementset.ms", ninstances=8, readonly=True)
with cf.ThreadPoolExecutor(max_workers=8) as pool:
  nrow = table.nrow()
  futures = []
  for start_row in range(0, nrow, 10_000):
  nrow = min(10_000, nrow - start_row)
    futures.append(pool.submit(table.getcol, "DATA", startrow=start_row, nrow=nrow))

  with cf.as_completed(futures):
    ...

Multi-threaded write support

arcae only supports writing when a single instance of the table is opened (ninstances=1). Writing to a table when multiple instances are opened is an unsafe operation and arcae will error if this is attempted. Future versions of arcae may support this. In the meantime, the support for this ability can be inspected via the arcae.safe_multithread_writes function:

assert not arcae.safe_multithreaded_writes()

table = arcae.table("/path/to/measurementset.ms", ninstances=8, readonly=False)
table.putcol("DATA", ...)  # Fails, ninstances > 1

Exporting Measurement Sets to Arrow Parquet Datasets

Install the applications optional extra.

pip install arcae[applications]

Then, an export script is available:

$ arcae export /path/to/the.ms --nrow 50000
$ tree output.arrow/
output.arrow/
├── ANTENNA
   └── data0.parquet
├── DATA_DESCRIPTION
   └── data0.parquet
├── FEED
   └── data0.parquet
├── FIELD
   └── data0.parquet
├── MAIN
   └── FIELD_ID=0
       └── PROCESSOR_ID=0
           ├── DATA_DESC_ID=0
              ├── data0.parquet
              ├── data1.parquet
              ├── data2.parquet
              └── data3.parquet
           ├── DATA_DESC_ID=1
              ├── data0.parquet
              ├── data1.parquet
              ├── data2.parquet
              └── data3.parquet
           ├── DATA_DESC_ID=2
              ├── data0.parquet
              ├── data1.parquet
              ├── data2.parquet
              └── data3.parquet
           └── DATA_DESC_ID=3
               ├── data0.parquet
               ├── data1.parquet
               ├── data2.parquet
               └── data3.parquet
├── OBSERVATION
   └── data0.parquet

This data can be loaded into an Arrow Dataset:

>>> import pyarrow as pa
>>> import pyarrow.dataset as pad
>>> main_ds = pad.dataset("output.arrow/MAIN")
>>> spw_ds = pad.dataset("output.arrow/SPECTRAL_WINDOW")

Etymology

Noun: arca f (genitive arcae); first declension A chest, box, coffer, safe (safe place for storing items, or anything of a similar shape)

Pronounced: ar-ki.

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

arcae-0.4.0a5.tar.gz (102.5 kB view details)

Uploaded Source

Built Distributions

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

arcae-0.4.0a5-cp314-cp314-manylinux_2_28_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

arcae-0.4.0a5-cp314-cp314-manylinux_2_28_aarch64.whl (15.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

arcae-0.4.0a5-cp314-cp314-macosx_15_0_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.14macOS 15.0+ x86-64

arcae-0.4.0a5-cp314-cp314-macosx_14_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

arcae-0.4.0a5-cp313-cp313-manylinux_2_28_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

arcae-0.4.0a5-cp313-cp313-manylinux_2_28_aarch64.whl (15.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

arcae-0.4.0a5-cp313-cp313-macosx_15_0_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

arcae-0.4.0a5-cp313-cp313-macosx_14_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

arcae-0.4.0a5-cp312-cp312-manylinux_2_28_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

arcae-0.4.0a5-cp312-cp312-manylinux_2_28_aarch64.whl (15.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

arcae-0.4.0a5-cp312-cp312-macosx_15_0_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

arcae-0.4.0a5-cp312-cp312-macosx_14_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

arcae-0.4.0a5-cp311-cp311-manylinux_2_28_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

arcae-0.4.0a5-cp311-cp311-manylinux_2_28_aarch64.whl (15.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

arcae-0.4.0a5-cp311-cp311-macosx_15_0_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

arcae-0.4.0a5-cp311-cp311-macosx_14_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

File details

Details for the file arcae-0.4.0a5.tar.gz.

File metadata

  • Download URL: arcae-0.4.0a5.tar.gz
  • Upload date:
  • Size: 102.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arcae-0.4.0a5.tar.gz
Algorithm Hash digest
SHA256 4649cf47eaee44e7ac421fae12a3b3a6ef2d65a1836312ef88e359649bceb15d
MD5 0f3ae676cbed888d50ebf82ff7919dc6
BLAKE2b-256 8b6197e17776b20db702216be9d0357827eac419fac311c08c9e79a24d21efd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5.tar.gz:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7a8eb5fb5fa13a4313f7af3f5ae05cfbfb7d132a8a6d76f63f12e23cec3deb5f
MD5 6bb1bbb8f2b1d2ed608a9c31181c5f4c
BLAKE2b-256 0b22bc9f1ed0bad5cc1a2f5cbc12d9294f0270987a424be43b43eb2d1fbe6072

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp314-cp314-manylinux_2_28_x86_64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b9eac5c9bf5bf9b2648f0902cebf615659b071bf5800511106e7e6fe6298d62d
MD5 1ea93ca737529449225af2ffaedf7d37
BLAKE2b-256 390bc39d03ba0d4c5b9a0931623545f4f00ee8fc1ea38c44a84370d42bc75da5

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp314-cp314-manylinux_2_28_aarch64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp314-cp314-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp314-cp314-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 a967439b85631167e6b2b951f82f1d4a76f485a9c98d51c233b50af919342594
MD5 1b7fb4bf85568cb7c027f8693e7045af
BLAKE2b-256 d9493fad76712558c1c609295e965f56a5501847ae5e0480c4b5a3214b85cadb

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp314-cp314-macosx_15_0_x86_64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8d9073acf2654efe7edc0178ecbbaaaa421b35923b16c979722153045376c5dc
MD5 d648311f902e682b00ff56f326bb215f
BLAKE2b-256 b6ef3a2833a42dfb3342febc31ce518840705f58e3d5828f1372c61a3703a82c

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp314-cp314-macosx_14_0_arm64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dc56cc767394de8c5f6fe07fc6df592963233c629cebe6e77d52948bd8648d32
MD5 234d33e03b53602281ba5f0ff7e0887c
BLAKE2b-256 083718dd52b3742b09f1d8b0dd5dc8d19b58cb67fcc145f29c497a2e87a6493a

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 126211887c446a4dc361a91e9ee575f8c9eb8d9b2064692b1ca207394fb617a0
MD5 79d4d6eb1a0391c27850ba04a7a12d38
BLAKE2b-256 611b80a8aaa6d5897f6efd09bece138361f6ae423d4eb286039dd847738a2b86

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp313-cp313-manylinux_2_28_aarch64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 6cee28b080622f7f21c39eaec57d66b18af2d34bff6c689f8f9487190d18cd31
MD5 95f0b2fa1f6d2e89f5cd4c31cc668cb0
BLAKE2b-256 d3698063e4ff2ae19763b8619087a2ba723d46410fc050baa6e354fadfc77741

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp313-cp313-macosx_15_0_x86_64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 528efe73c246284726fed517a68766b029376465c713b85caf913b1ec5bb0577
MD5 b4149a535ade567bbfd8904f70c97cc9
BLAKE2b-256 37ae84f08062344645ef590c597483cd8ea0665496ee6e830c660bc20eea9fd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0a703b939cd2a8fe6024ff698061730da2b6c5d82c3c758a33f986c2bb335159
MD5 2d0f7b4cf8d460fe08368b33e04a54b7
BLAKE2b-256 b511152d2c42a63853327a788360584e8d743c9527be10d50654ac6ad725027c

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 da1bb717c0c7c4c93c299c7a265f63f1acd33265a0569b96f04ecf02907f4240
MD5 d522afa240af372bfaf55b4bb89be4a3
BLAKE2b-256 80857c6d86e77421dae3fbcc6a59dd7b4b4a6dd57a39caf6f621ce83ca17313d

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp312-cp312-manylinux_2_28_aarch64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 240c31c9f6a0111c9ba8acd0b9a5c2a05c2097047f2173abd295b2281d5c2ee9
MD5 58e9cf79cefaca0e1f9c6ea02566c529
BLAKE2b-256 cf75f37bdcbe9f53bcc65a14085b046a56210f441d4015f20b54f11c3b9c22d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp312-cp312-macosx_15_0_x86_64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f88ec2cdce0db0e66982cfc165126fb57bff00bafd2c92ab5f53d1b8b0c550da
MD5 6aed96b59e89b79e50cf4fdb9b04e4cf
BLAKE2b-256 2de627e79f3ba1d72e4f467567a70a04d3c69de9304fd2bfdc50eb146e557c4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fcdb1db16ecadbaf1b56af9b0bed73763c9b4b0e49f615ea37947f01a2780654
MD5 78e7d855f85f2bffc8b0cd89c86d360a
BLAKE2b-256 ac99b014d1b7d5895b65cc74101fe37d1dfbce397180e0c21697f67b030d9346

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fb6299adce63c2a027cae494be2cf9fdd4a64e521bbb6c91067a97cf43a766b9
MD5 a7ef52a859a71c36cf1595b1ac7d1cce
BLAKE2b-256 5cc0ea95430906f2c48debfc2702fc7ef57ad8fd859a8ea6f3df5ffa28b15570

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp311-cp311-manylinux_2_28_aarch64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 8a0fa08bb6b23b04cd8b717480a3464c758d8bf93f75d5259a265f88e481e993
MD5 909963651a82e4ff8ce4a2195c62b3b2
BLAKE2b-256 7d89517efa36fa0bb5a863a848f56f1b39960a2d4378f50411efb7f4b19c253d

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp311-cp311-macosx_15_0_x86_64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcae-0.4.0a5-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for arcae-0.4.0a5-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 30dac5533ab112a12ea000d17edc83c68ea332d60699f5ea2c0b6c20b40ef090
MD5 962694bcd2cd606efaea9c6098dd9608
BLAKE2b-256 e1f938b1a5483d9eac81abc9c36611e78d3d9abeccedc0e670a64f2629470a30

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.4.0a5-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: ci.yml on ratt-ru/arcae

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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