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.0a6.tar.gz (110.6 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.0a6-cp314-cp314-manylinux_2_28_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.14macOS 15.0+ x86-64

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

Uploaded CPython 3.14macOS 14.0+ ARM64

arcae-0.4.0a6-cp313-cp313-manylinux_2_28_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 15.0+ x86-64

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

Uploaded CPython 3.13macOS 14.0+ ARM64

arcae-0.4.0a6-cp312-cp312-manylinux_2_28_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ x86-64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

arcae-0.4.0a6-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.0a6-cp311-cp311-manylinux_2_28_aarch64.whl (15.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ x86-64

arcae-0.4.0a6-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.0a6.tar.gz.

File metadata

  • Download URL: arcae-0.4.0a6.tar.gz
  • Upload date:
  • Size: 110.6 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.0a6.tar.gz
Algorithm Hash digest
SHA256 b24117f6872ba503a7273154eaf9d91a2a491aa4a2a7c9624fa3a81203140fff
MD5 8905660910eaf0f6d6044f4272d53ce7
BLAKE2b-256 66af09c21e3952534d286f2ec0d33fcde0d49739a3f919add3b235010c972f0f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 20b90cccb5b1408a5dc47df14c52df95af1c6f9621eb4eb6c526c4e91da03dc2
MD5 92ef3673c18acf329a2c710aeb71563d
BLAKE2b-256 d98f250417db4c2251d9b168e615f566fa9267ebd9195e5a5f4492e2eec2f3cc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f6a13966846a515dc4240538caa02fc33a326ad132b35a2287f5d3b17e9c2ad7
MD5 344c3e148700222b12a779f9e451e1bb
BLAKE2b-256 f915af7395047b7f86630a2a717ee3e47b1400c017e2e6f98e1dc68a8b3befd5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp314-cp314-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 0fe0caa91cda6bc2df3ec8c4ac3dfeded7ee77e9d3dca13c722ce5b9c98669e9
MD5 5acb57f0abd40b8dd2bf9d41e952dc43
BLAKE2b-256 0a904a54736e7cb91717248afa5b7d2e8ecf222498b7dea87eb7fce279405578

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 038908b14ce043c2d13c6929ecf5a10fad9962f122c56fddb92556d36ffa3878
MD5 0cb72edd4bed96846c7f019facd9909f
BLAKE2b-256 473927d19048e9ff7900537f80780ed6c0ac1953cc14280684ee559f7e9a8055

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6105fc41dee3ada954968358521eda14f459ba350d079dc4d0b9649accf66ea7
MD5 d1a57a662c3bfc4e75fba14f8c908da8
BLAKE2b-256 2389bb716c8203060cae34b643c0c96d1bae8ce5340a3912b33a88ff174ad308

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 efde9639ecefd63457e5bae3970128599033ee36edc8935379ef94f623292275
MD5 29e69d38f39b9ae2b1a040afd1a6cedf
BLAKE2b-256 df62b445f60b79035139b45c491c17357e4359791b75f579ed6b7fe893e95ec9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 9e95e2f6994c93f883f01b176c6eb7281fd29ae94a2851b2b98f22cf3ae5768b
MD5 8b748379961a8335118dbae7c19d20ab
BLAKE2b-256 3a3c80e9d1956832b3c5946e6388ad1c872e7217f5a37c95ab4a099805b7856e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0a017b7c3ff34a45afff2b33269fade96d56bbd14bc58e97c6a3f3281f7e5f2c
MD5 21bb79ba4ff8e6d524dee9e51e30452a
BLAKE2b-256 f10590c0482638334466829ec8c0fba572b6439a09f26bfe989d08e0d810f754

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c26754544747a99e8b15eec6c7d0d66723cc0cadeea3a57a03685472783a43f9
MD5 1b6588dfc66e9e461676e9f637a88620
BLAKE2b-256 25de07b5bd2dd3bf134436932fc8448d57344684406dd5736eb605a9f8519362

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5d29facfb84126c53ab917b3f7e01d0248c8cb5f6993a3d56ff55b8d5ea968b8
MD5 65173297c6ad4d74ff3d16a6c0d4523f
BLAKE2b-256 388fa066a6d1e2e1265eda06c434a20876e9d7888f77f4c67ba1daaaec25bfec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 fff6aefe86e88e0cbe6fa870ed45d26ea87066a3ca646981286c65dfee518151
MD5 7dab091d0b04f4a56995c2696e420bcf
BLAKE2b-256 89c10d71e6a4bf597176ebc86e8453f8e160023a5d2738bedd038362ed7e16ac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3dfbad7a3be852c468c45788e94e55349bc83ebf2b2894da32e165191ae5913e
MD5 5890cb94524f6381334f5ba2968ad1e1
BLAKE2b-256 2fe3a08c5d76feea10e215d1e97e6a98d06df73c82f05669cb52fc68162c608f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 67078933d24119e381e70f133f13f8ff3d1c47fa748b74996b51a94978853f00
MD5 91655fcfd60e29118f960457a573bcb1
BLAKE2b-256 b6a2656b9008c2e14765e2c26e7aa74f9e9a379226e752c15100ec2ea1f85a04

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e13e20a5b6b1bbf06ab44e9103db8fdb2b2c8c7fad5bc9a3873c119a26baaa92
MD5 7ec167e7960d2ff484c9d6df938585f4
BLAKE2b-256 0fc172d97f5dd541cb71dea01944bba28ca8bc8dd6db81bf48a7acbadc71e824

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 6073ab68d48a5cc0a0de344a19bfa2b0be03035fab4858f280b0a12b4dfecfa4
MD5 c467afeb5db3c9225fdefc21c965c3dd
BLAKE2b-256 0c4c52c54da2fbec60135e5065e2ebbd2330726aeabb457c865a92f7c51d00cb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arcae-0.4.0a6-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 36f616423bc774dac2c7672baa454416358b9a85db6d0c9abb1b9d1efbafef87
MD5 f53084c9748b85f6359920c915ea7cd1
BLAKE2b-256 336522c8f9beac31a0427ae681c2bbee456f73972d2226d4c913fc7939a4991e

See more details on using hashes here.

Provenance

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