Skip to content

Conversation

@sjperkins
Copy link
Member

@sjperkins sjperkins commented Oct 13, 2025

Currently, the measures code for both the MAIN table and sub-table targets specific columns when extracting measures data from the MSv2 dataset.

For e.g. MAIN::TIME, SPECTRAL_WINDOW::CHAN_FREQ and SPECTRAL_WINDOW::REF_FREQUENCY, or ANTENNA::POSITIONS columns are hard-coded to have epoch, frequency and location measures handlers associated with them.

This can be improved in the case of subtables as they are loaded into memory as arrow Tables and the VarRefCol, if present for a target column, can be read directly from this table.

This PR reworks the measures handling code to automatically derive a Measures coder in the case of an arrow Table. The MAIN table columns for which it is assumed

  1. they are too large too fit in memory
  2. they contain no VarRefCol measures references

will still need to be somewhat manually specified

Thanks for contributing to xarray-ms.

We would appreciate it if you could add:

  • Test Cases covering your PR.
  • Documentation.
  • A Changelog entry in doc/source/changelog.rst.

@sjperkins
Copy link
Member Author

@JSKenyon If you want to take a look, I'd appreciate it. The main takeaway is that MSv4 measures attributes can now be extracted seamlessly from underlying the MEASINFO in the CASA column keywords, rather than assuming a specific type of measures and the associated hard-coding.

Don't feel obliged though and I may just merge.

@sjperkins sjperkins changed the title Rework of Measures Handling Formalise Measures Handling Oct 16, 2025
@sjperkins
Copy link
Member Author

sjperkins commented Oct 17, 2025

In measures_adapter.py the Adapter pattern has been used to provide the same interface for cases where there is indirection in the Measures definition (i.e. MEASINFO contains VarRefCol or RefOff* keywords that refer to other columns that are used to resolve the Measure frame and values) and no indirection.

  1. If no indirection is present, the Measures can be resolved from the table descriptor.
  2. If indirection is present, other table columns are required to resolve the Measures.

Possibly this could be reworked with a Facade

@JSKenyon
Copy link

Thanks for the review request; no need to wait on me but I will take a look a little later.

Copy link

@JSKenyon JSKenyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that my approval is needed but looks good to me! Left one comment about a docstring.

@sjperkins sjperkins merged commit bad5256 into main Oct 17, 2025
6 checks passed
@sjperkins sjperkins deleted the rework-measures branch October 17, 2025 12:05
@sjperkins
Copy link
Member Author

Thanks for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formalise Measures handling

3 participants