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.5.3.tar.gz (94.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.5.3-cp314-cp314-manylinux_2_28_x86_64.whl (16.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

arcae-0.5.3-cp314-cp314-manylinux_2_28_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

arcae-0.5.3-cp314-cp314-macosx_15_0_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.14macOS 15.0+ x86-64

arcae-0.5.3-cp314-cp314-macosx_14_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

arcae-0.5.3-cp313-cp313-manylinux_2_28_x86_64.whl (16.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

arcae-0.5.3-cp313-cp313-manylinux_2_28_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

arcae-0.5.3-cp313-cp313-macosx_15_0_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

arcae-0.5.3-cp313-cp313-macosx_14_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

arcae-0.5.3-cp312-cp312-manylinux_2_28_x86_64.whl (16.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

arcae-0.5.3-cp312-cp312-manylinux_2_28_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

arcae-0.5.3-cp312-cp312-macosx_15_0_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

arcae-0.5.3-cp312-cp312-macosx_14_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

arcae-0.5.3-cp311-cp311-manylinux_2_28_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

arcae-0.5.3-cp311-cp311-manylinux_2_28_aarch64.whl (15.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

arcae-0.5.3-cp311-cp311-macosx_15_0_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

arcae-0.5.3-cp311-cp311-macosx_14_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

File details

Details for the file arcae-0.5.3.tar.gz.

File metadata

  • Download URL: arcae-0.5.3.tar.gz
  • Upload date:
  • Size: 94.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.5.3.tar.gz
Algorithm Hash digest
SHA256 4f1307d878990690510dcd57e7b9b39406cd0aebf91ce2eea5642eadff647803
MD5 12f8e2dad079be158231b8f1ed17dfb1
BLAKE2b-256 7b0e07a3a5dfb3d7eac259a9026da425131e25ba19b9b382c493892d9861ec4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3.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.5.3-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c423a29dfde3dfb07a968b1956d76c28d028090476b09bfabdd37d1ca5ec8604
MD5 0620a9a26d257534b86a502afe0162e3
BLAKE2b-256 0a9ceab37a472f9f6b54cf1cf07a1346c05d8e84ea81e8b63ea71dcf1c513642

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e2378d97524e8d9287011a40963f71e2b7a029b0d8b7ff8291f6d700bd15bde4
MD5 4f3c0717c64e3de2da60147815050c67
BLAKE2b-256 e569ad96da16f46690e765643990c9bf72528e069f48fa22e2384ec6d031b6c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp314-cp314-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp314-cp314-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 883ea3982c21e93ced430ba7cc1621fcb65aaaeb8dfc745d614407a17783e826
MD5 fe697a89f80f935fc7d71538df60c096
BLAKE2b-256 32d53e56b7edea5b7e1b882423ffa08306c37bf14d6efdbbe475828e2fced4d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2e793e815bc24069d39951ee063b7eedfe671d381c6d01d476ee99656ab1d861
MD5 5b3eda1a84829a3da0fd04a230c5bc02
BLAKE2b-256 02fe79f32b0e6784e311ee00ecf84cd74bf67d3985316ec40a11d12a12a45b39

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c9631c046c9bad9012999d5bfe0bf23b00f79992bf282f2f3a838a764c098b78
MD5 1b19ba28a95e0ebf650eabfa840d015f
BLAKE2b-256 3bc2a92bc155fae782f02bed46f615ff5325f69a75f7005a3891d625683ea072

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 00ec2992d1cdefd78d6cb4b1f4deea1d35ad73f6f726afa4b11f318fcdfe95da
MD5 e676d01f83139ab76aae8cb5eb7c8913
BLAKE2b-256 0481eec9df5746c31ac1662d5426b19f201f5a62ff7e2d55568b73ba84d94ecd

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 d13adac3dfa0c0879dad10eb4f891c73af67f4b2c6e4206ee472c23d61ea12c5
MD5 39bd4515d8c0bee4cf363a58f2de284d
BLAKE2b-256 774f81dc521379a3d45d35af3db78db8b04f4a6de76edf1b8f0610e966afad6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 bf00cbdda940e697c5069021bbf9951bcaa9fcd387b52efd392596ddc32ecc18
MD5 d18cd79e4c97be765a8a52870586a9a4
BLAKE2b-256 95cba826d5ddd53c0c9289b43484390a463e6f9748d932dc9b49e12798cde511

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bdd1857b238f48ff30864f4a9da8d9fa9a2f2e81be635561c8cd10cf6cfb6c19
MD5 7bc792bfa92d6c4be3f860cfea6a9f58
BLAKE2b-256 4063d93d8b832919adbc3e0ca3bac6eff1f97b7c71e78a62afe91f03405b6866

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 83d145e62ab68740a46ad0fd1887e0b395b3e6b4b9f0939fdd0fcc90819d3762
MD5 d7f35034ea7e6a17dcfec66faafaab07
BLAKE2b-256 7ef80fb02b2af8f1ef127d91bbb8f824ad7a795ca22bbf925a3205cf32543757

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 ad559287bb8f5290fba7c902d2b17068b35e181b0dbc4b3df0f4ccd2d776fd0d
MD5 295904f2025a7c56d2f70032e82e15eb
BLAKE2b-256 2d378a4fe38b47b3cdd0da848a57f3a9e9320d32e4e90c9210bd62da7e6e616a

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 174e0883f34f728ac4a00faa5a94526f10334c9c58e2634ed66bb793f9d3b9e2
MD5 0b3dcf8d28e27da1b5bc01398c202713
BLAKE2b-256 baf428e939fe61b81f0e9925b571e84e0a167e4b158d7941698970ac3a2bae77

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4bdb114f40fc144a4977e4040f697272572bc1e5c9d77934c736b809e16adea8
MD5 7478a2fb1c301e3af388b4be75b0f8d4
BLAKE2b-256 d0882a71b96de35e5d5a4eff75277df93abcbcc00e40bb4c8c9997cd74e1ee99

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ccee1be8d90095b2e315fe71f450790a961151887d382d0e6af5bd680d659903
MD5 d687e921ef77e02a90b2f996cfc40182
BLAKE2b-256 98a4e405fb9232e4c04bf188515b9090dd427024f7d2dc5b4bed754b4cd934a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 ee59050d33662075edb6bec766035bca42284c4d28e5225ba245c8a4c78d1136
MD5 99656581147d4f6a7638b823eddf87a9
BLAKE2b-256 a8642503e1094b2331dfc9d56688faca66e658091106563b5b3ef7ccac9aea79

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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.5.3-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for arcae-0.5.3-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d520fd13ff52c9ef8844ab97e551f9621cdc42c13cc9ecc3b2033a75c48d94be
MD5 b5a47a6d43ef62b13d4ff1c838a75733
BLAKE2b-256 67796dd5effe9cf32ea83a65b8d2f5c0deb3522bd32153e84158a99c5ca84659

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcae-0.5.3-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