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.2.tar.gz (95.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.2-cp314-cp314-manylinux_2_28_x86_64.whl (15.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

arcae-0.5.2-cp314-cp314-manylinux_2_28_aarch64.whl (15.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.14macOS 15.0+ x86-64

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

Uploaded CPython 3.14macOS 14.0+ ARM64

arcae-0.5.2-cp313-cp313-manylinux_2_28_x86_64.whl (15.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

arcae-0.5.2-cp313-cp313-manylinux_2_28_aarch64.whl (15.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 15.0+ x86-64

arcae-0.5.2-cp313-cp313-macosx_14_0_arm64.whl (3.9 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

arcae-0.5.2-cp312-cp312-manylinux_2_28_x86_64.whl (15.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

arcae-0.5.2-cp312-cp312-manylinux_2_28_aarch64.whl (15.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ x86-64

arcae-0.5.2-cp312-cp312-macosx_14_0_arm64.whl (3.9 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

arcae-0.5.2-cp311-cp311-manylinux_2_28_x86_64.whl (15.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

arcae-0.5.2-cp311-cp311-manylinux_2_28_aarch64.whl (15.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ x86-64

arcae-0.5.2-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.5.2.tar.gz.

File metadata

  • Download URL: arcae-0.5.2.tar.gz
  • Upload date:
  • Size: 95.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.2.tar.gz
Algorithm Hash digest
SHA256 534102b422ffdc515270e6c9f6b7f112e15470dbdc9e3907d20d94ad8826bc4f
MD5 5f0b289ed6d91430deee04af7b99142a
BLAKE2b-256 52eb136946699aff957dc8f8e9601466da8e8f5247f7c2bd5b33d3a3e79458df

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c179abb292ab765756ecf6f3864bd2376769167e7793e80030586a0d1d41e83
MD5 a2148cc111810e3f2e4b20644e6a781c
BLAKE2b-256 3ee4d814f9d34df3070810064dae3597b051f2ae3ed43c4e23fee3b94697b80f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b643a976de592d0574d74e632fa50fc35410efbfcbb926a66bcfedc615ddce94
MD5 aedb333b9b8787bc8be4d2fcb2ce315c
BLAKE2b-256 79c681be7c7a1a8ff3cf6d0105321a0744dbad994c1f67f45eca8b44c56636c8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp314-cp314-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 a68c439acba8e985b1841fcae91291c815d32952bf09adfdd1f9ca7dd225606d
MD5 66ba7b3e2536ac0293b95b9997496cd3
BLAKE2b-256 e40008870b8d474e97401d3bbdf718c62018452def21bbbce2f06d8eff7745af

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e608a93fe973ba337c29a067e3bbfc263dff20c041c7be1b0fb3818ab0363d33
MD5 82090b5e28be7c0e6234b269bebf2b96
BLAKE2b-256 3a5e664c86029436e3d4b65482e4e285e066f5d2c7485fad0a4c4a22f63bbc73

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7752c4329c6f8755b1a6942022ea5cd1981fe915966cb29ef22b79a62a4481f9
MD5 852f4f7d13a8a5f28e138c0136f576da
BLAKE2b-256 3647a78266623b038d0cfbae6ea94c012b5df5785096a3fe73085c90fbf6b35a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b092ab3707400c16f5a65ea9116b0ea851105f0088d5f999e53a675006b5d1de
MD5 1c5a423f9ab5c27857f6f66ef61eab80
BLAKE2b-256 ba8ea80c0b0b640a9a5419896dcc4643da76dff9b06777508281179791c190a6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 188845751000710ee55d766a696fec3bb705a4b8bdc510255dc994f8a5ecd4ee
MD5 a110548b858f0f0f73f0df46c8460d1a
BLAKE2b-256 92fb93984f6d2df19fabdac138358b2504b141953f980ff1224099a6bcda7fb8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2987df1f5a4042ee4d70898209447fddd0e5323ad1675393d8b7b604bb621ad5
MD5 e21d88ab06f9235e70d63f428678e87d
BLAKE2b-256 07d1a69f8abe4733244756c0f1fc96e95dca5022e4bd906c76d25430067ca7ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d0792f00893eb3ebf0ac39a4f8fa542d525c3b244f7de2c291c226df8d13658
MD5 9c7fda4d530cd757649a3c5736bd6318
BLAKE2b-256 97fc07ba2e57441764a904ee55657ccb8f6cbcdb7e26ab355196728e62446920

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4248b252baa10de70db5a9604aadad6202eedbb8ad2d664c1ef776714e97dec2
MD5 432953c446bfa8cac54854e82311e960
BLAKE2b-256 0fcd001b945db0e93a0e74d61b73a8d156a8af090f5a13d9e88b82195072dbc8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 81834372680c64e6546f7ddbb8c11896fb85696f2a4737d0ad14c1fc1ab72044
MD5 ee403fc8229dc5ee13e77ff20fb257dc
BLAKE2b-256 1c4ea9ad5b22e079f5a334787bd8440d506f39beef738e80df692bf8ac59ac68

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e4aa31b9d40eec682753cce4c6997c2b4f143383f66d17ea6833e6f7e9dcd65a
MD5 80414b2bc21046cb85ee809ee62d5619
BLAKE2b-256 dd7d4a582cbd5c39ed75639eff8470bb91b9cebf0c8f00752cea796bbc58c4c8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5cb50658a25eb98f5e7053cc344619d4e0ea33b26ca3b58d0ce03709f53a1e99
MD5 df32371904181a084c1dca3b0809586b
BLAKE2b-256 c63490d54a431fdbb77a44ace70898b920ab29a439a616f18c8f3e4b89de3911

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1531bb6abc2fbaf40e6bc8f02821e1247eaa69c65f6ba6bdcd0f0605e89170cf
MD5 803d03a4ee7872a92983670b443699ba
BLAKE2b-256 aa490f8fcb8092ee54fb41f11c41c5f6e14b2ef256a276e4f95cb856ae03e35c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 502bf6b87d7c7881744262f42207bb3fed16055fa916a4e2733cb7082cd04ff7
MD5 c7a82a9af65382cfb757f24daac8bd28
BLAKE2b-256 bd73f85ef0fb7c6802be50183e18222148fc8d03f6c09d2189f5947d6861df30

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.5.2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 63b2f91037df371f49681e679814fbe66c9c9a83e055b22db0b40aa8cc0aa538
MD5 c028bcf71a87c431a35fee6ca41d3d87
BLAKE2b-256 f9aefba0ebfea6242ce875a27ed82b666589b4203f2ed5c63f4775a3fa23f108

See more details on using hashes here.

Provenance

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