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.0a7.tar.gz (111.2 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.0a7-cp314-cp314-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

arcae-0.4.0a7-cp314-cp314-manylinux_2_28_aarch64.whl (15.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.14macOS 15.0+ x86-64

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

Uploaded CPython 3.14macOS 14.0+ ARM64

arcae-0.4.0a7-cp313-cp313-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

arcae-0.4.0a7-cp313-cp313-manylinux_2_28_aarch64.whl (15.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 15.0+ x86-64

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

Uploaded CPython 3.13macOS 14.0+ ARM64

arcae-0.4.0a7-cp312-cp312-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

arcae-0.4.0a7-cp312-cp312-manylinux_2_28_aarch64.whl (15.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ x86-64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

arcae-0.4.0a7-cp311-cp311-manylinux_2_28_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

arcae-0.4.0a7-cp311-cp311-manylinux_2_28_aarch64.whl (15.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ x86-64

arcae-0.4.0a7-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.4.0a7.tar.gz.

File metadata

  • Download URL: arcae-0.4.0a7.tar.gz
  • Upload date:
  • Size: 111.2 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.0a7.tar.gz
Algorithm Hash digest
SHA256 d78925efee4218ab9d487eca869673066fbcad531af7eefb26f54d3fdfae43f7
MD5 61351fd6eb3e6100647f8428bb030113
BLAKE2b-256 fed0c33a48109eedfd800faa8248f5873516d7cc3b4fac3530524207bbc2a12f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 968e0d97313446b49c057298dfc9c32a3c125a381768057182f1c3f07ef74e42
MD5 bfb30dd76f183c59f4d947bcdf7437d1
BLAKE2b-256 4ed6a05d6d65449c2a17e5175077cc8f0d2946f5b76772bc42296b046450f5ce

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 65c1175bd903e87794dad2471fb1e8d7cea47a5806542032faf68cf2ea764ad5
MD5 25a963de271f8721fadae652b28ce198
BLAKE2b-256 f090081712a0e07eb8aa4f2fdfd73cf98fa10ee5f11b6e944e312000c72545b6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp314-cp314-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 fd51f86158dc696a4a3f2a404838f7428d30d7faaec916fcdfb2b24a16c367c4
MD5 fed0e702b2cd77df7040ec668dc5310c
BLAKE2b-256 2472e7466719b92e09419df982da1f780b2c79518f9e63f11d10c0341131b3d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e00f6bc5cea91acf27dfdb55696735166e20d3a424a0aa1238488dcb51e8c38a
MD5 221db5705bac070d093b42b34feb6bbc
BLAKE2b-256 167c46c9dcc5f9ebf701158832b23c390cfb46de806f3ab61a7388b800490a9c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c8cd025ba3d6f96c3ef828d0dae2b7f75335a63d7ba8d88fffbb60332da3ef5
MD5 e5caf7ea9e16eb3bdeefa33a66700fb0
BLAKE2b-256 62274c33d376436ed215e97cce9bea148002b93e89909938eecd7ed42899db53

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 396dbe723e795938b580c4d7b2b8632d3302bcb1fc03565da5b44ac8b7d277d1
MD5 3b0db29074d4e268ed82c3dde12d09fa
BLAKE2b-256 7a60a2b62c05d75388db51f75ba98cb01e513e4a1623f26561337a45786f78f0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 61a85ef310a428024b30fc53db125cdeeb90563f54233ae1533453b1d680f9e2
MD5 b841e69ae0ae3fcde15e25259802cc18
BLAKE2b-256 95bd4fcc18a522649ae3fa980b47c6b1fffd66aeaff9945a2e75db82da24218c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3e0eec72f68481c6b29b7f065cbfe42ac1a3a49f5ebb251f96a9c80e944341e0
MD5 7a7977fc29fe6e68749042ca869d55a6
BLAKE2b-256 b6fe8da64672419302ac537330b21e97bb5dbd3400dbdf1ece5c993a3f03ce17

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a4312ccbdfafb5c7dc8c2bafe440b5c5cdb07d6ba598c4301bee0ce19ec3e7f2
MD5 8dfa4513cb870e5cc5b56e17f19c42cd
BLAKE2b-256 437610b418b3ecc58c3dcb39bd6b53cddd63924d4f60ac0b48791fee69170fac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 eb36b56e9b0299c49776dae9cfd04a6d04786d9b6c307be5f109680f02f2c79c
MD5 5e0aac4e82c57092aaa4ea492f6d570f
BLAKE2b-256 c60372ea994abfbdbe4c4b75a63e6fa626b521467ad42c347f353b57f00e845e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 1ae55d7e3e5d25e389c1c0960d32121a66051ce4a214ea2a8fa2d8a07e8719f6
MD5 3247db35f348b90a79a345cea2d5d811
BLAKE2b-256 97df199f53aa880908dbfb4905cc34ef8ac9bd803b6dc300b8c2ee0c9aaf0247

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ff14e9a55134a444f04e8c70f09c337734cc6cd70d65b1928eb0d1db36bc8228
MD5 f07e99a8b93cd533e40e9d8a9dd4b5b2
BLAKE2b-256 15ff324985550b166957cf17ebb0b61dbb96cc1b9ed48ba3d8bf9b62ee35ec93

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a4e4f8c19ea696dc4fe17c18a623125a087db10b055b90b257777c8eea930490
MD5 36825dcdab836ea18c89f9a303427f56
BLAKE2b-256 29b8bfc9524a8cc63455ea0222005fe38e77d8164a582e7bb362a481447d4233

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 048101dc183177caeecef318cf9a10e1c0c555aea58a5e99be9a22fec64d6b36
MD5 241819901af17c1e533b80086117eb01
BLAKE2b-256 230777bb7851de905bdab0b9ba83eaedc7728e4c50a076ad06fbbf81c4893fbf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 3480248438145b42abbfd132594b12f8e5f97ee2f49ac3caa032360abd24ca63
MD5 6243b2938c5181bd5dbff87e4f85bd92
BLAKE2b-256 269748e284937497b9d77a24116df49d41d67e1d3c079cb122c5615137420729

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a7-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9f39cfcaa50896d4f35fb7c1a2fba66a1f87637a4ee2a028265bfc5a4bb09d96
MD5 bc69e3759e656d1e1696bf68513004dc
BLAKE2b-256 760df76ab1803850a5f5682ae1adae7132b2fc87ce3c62b2ae86f5930836da5f

See more details on using hashes here.

Provenance

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