tart-msv4 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tart_msv4-0.1.1/LICENSE +21 -0
- tart_msv4-0.1.1/PKG-INFO +183 -0
- tart_msv4-0.1.1/README.md +165 -0
- tart_msv4-0.1.1/pyproject.toml +78 -0
- tart_msv4-0.1.1/pyproject.toml.orig +61 -0
- tart_msv4-0.1.1/src/tart_msv4/__init__.py +22 -0
- tart_msv4-0.1.1/src/tart_msv4/backend.py +287 -0
- tart_msv4-0.1.1/src/tart_msv4/geometry.py +173 -0
- tart_msv4-0.1.1/src/tart_msv4/lazy.py +80 -0
- tart_msv4-0.1.1/src/tart_msv4/schema.py +296 -0
tart_msv4-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Landman Bester
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tart_msv4-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tart-msv4
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: xarray backend exposing TART visibility HDF5 files as Measurement Set v4 DataTrees
|
|
5
|
+
Author: Landman Bester
|
|
6
|
+
Author-email: Landman Bester <lbester@sarao.ac.za>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
11
|
+
Requires-Dist: numpy>=1.26
|
|
12
|
+
Requires-Dist: xarray>=2025.1
|
|
13
|
+
Requires-Dist: h5py>=3.10
|
|
14
|
+
Requires-Dist: pyerfa>=2.0.1
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Project-URL: Repository, https://github.com/landmanbester/tart-msv4
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# tart-msv4
|
|
20
|
+
|
|
21
|
+
An [xarray](https://xarray.dev) backend that opens [TART](https://tart.elec.ac.nz) (Transient Array Radio
|
|
22
|
+
Telescope) visibility HDF5 files as Measurement Set v4 (MSv4) `xarray.DataTree`s. Its output passes
|
|
23
|
+
`xradio.schema.check.check_datatree`, and it follows the conventions of
|
|
24
|
+
[xarray-ms](https://github.com/ratt-ru/xarray-ms).
|
|
25
|
+
|
|
26
|
+
The only runtime dependencies are numpy, xarray, h5py and pyerfa. It needs no astropy, no network and no
|
|
27
|
+
dask (dask is supported when installed).
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install tart-msv4
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import xarray as xr
|
|
39
|
+
|
|
40
|
+
dt = xr.open_datatree("vis_2026-06-09_08_11_43.476804.hdf", engine="tart")
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`xr.open_dataset(path, engine="tart")` returns just the visibility partition. `engine="tart"` accepts a
|
|
44
|
+
single file only. Always pass `engine="tart"`. The backend's guessing claims only HDF5 files that carry the TART
|
|
45
|
+
signature (`vis`, `baselines`, `timestamp`, and a JSON `config` with `num_antenna`), but xarray tries its
|
|
46
|
+
netCDF engines first, and h5netcdf or netCDF4, when installed, claim every HDF5 file.
|
|
47
|
+
|
|
48
|
+
Every array on the (time, baseline) grid is lazy: VISIBILITY is read from the file, and FLAG, WEIGHT, UVW,
|
|
49
|
+
TIME_CENTROID and EFFECTIVE_INTEGRATION_TIME are computed on read from small per-file tables. Opening a file
|
|
50
|
+
reads only its metadata, and the opened tree pickles small. xarray's CF decoding keywords (`decode_times`
|
|
51
|
+
etc.) are accepted and ignored.
|
|
52
|
+
|
|
53
|
+
### Several files
|
|
54
|
+
|
|
55
|
+
TART writes one file per minute or so. To open the files of one observation as a single partition, lazily
|
|
56
|
+
concatenated along `time`:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from pathlib import Path
|
|
60
|
+
import tart_msv4
|
|
61
|
+
|
|
62
|
+
paths = sorted(Path("data").glob("vis_*.hdf"))
|
|
63
|
+
dt = tart_msv4.open_tart(paths) # lazy, no dask
|
|
64
|
+
dt = tart_msv4.open_tart(paths, chunks={}) # dask, one chunk per file
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- **Inputs:** `open_tart` takes one path or a sequence of paths. You expand globs and directories
|
|
68
|
+
yourself.
|
|
69
|
+
- **Ordering:** files are sorted by timestamp. Files that overlap in time, or repeat, raise `ValueError`.
|
|
70
|
+
- **Compatibility:** `config` and `baselines` must be identical. `antenna_positions` may differ by up to
|
|
71
|
+
`position_tolerance` (default 1 cm), because TART recalibrates them along with its gains. Any other
|
|
72
|
+
mismatch raises `ValueError`.
|
|
73
|
+
|
|
74
|
+
### Keyword arguments
|
|
75
|
+
|
|
76
|
+
The keywords below work with both `xr.open_datatree` and `open_tart`:
|
|
77
|
+
|
|
78
|
+
| kwarg | default | meaning |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `partition_name` | `<first file stem>_partition_000` | partition node name |
|
|
81
|
+
| `creation_date` | last snapshot time (UTC ISO) | `creation_date` and data-group `date`. The default is deterministic ([ADR 3](docs/adr/0003-deterministic-dates.md)) |
|
|
82
|
+
| `dut1` | `0.0` | UT1 − UTC in seconds (see Conventions) |
|
|
83
|
+
| `drop_variables` | `None` | variables to drop from every group |
|
|
84
|
+
| `position_tolerance` | `0.01` | `open_tart` only: allowed antenna-position change between files (m) |
|
|
85
|
+
|
|
86
|
+
## Schema
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
/
|
|
90
|
+
└── <partition> visibility (time, baseline_id, frequency, polarization, uvw_label)
|
|
91
|
+
├── antenna_xds antenna (antenna_name, cartesian_pos_label, receptor_label)
|
|
92
|
+
├── field_and_source_base_xds field_and_source (field_name, sky_dir_label)
|
|
93
|
+
└── gain_xds TART extension (gain_time, antenna_name, enu_label)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| Node | Variable | Notes |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| partition | `VISIBILITY` | complex64, `units="dimensionless"` (normalised correlation coefficients, uncalibrated). Lazy |
|
|
99
|
+
| | `FLAG`, `WEIGHT` | uint8 / float32. Baselines of a dead antenna (gain 0 in that file) have FLAG=1, WEIGHT=0. Otherwise 0 / 1 |
|
|
100
|
+
| | `UVW` | float64 m, `frame="fk5"`, toward each snapshot's own zenith |
|
|
101
|
+
| | `TIME_CENTROID`, `EFFECTIVE_INTEGRATION_TIME` | equal to `time` and the median snapshot spacing |
|
|
102
|
+
| | coords | `time` (unix s, UTC), `baseline_id`, `baseline_antenna{1,2}_name` (`ant00…`), `frequency` (one L1 channel, `channel_width` = bandwidth), `polarization` = `["RR"]`, `field_name(time)`, `scan_name(time)` |
|
|
103
|
+
| antenna_xds | `ANTENNA_POSITION` | geocentric ITRS (m), from the first file's ENU positions on the exact WGS84 tangent plane |
|
|
104
|
+
| | `ANTENNA_DISH_DIAMETER`, `ANTENNA_EFFECTIVE_DISH_DIAMETER`, `ANTENNA_RECEPTOR_ANGLE` | 0.025 m, 0.025 m, 0 rad |
|
|
105
|
+
| field_and_source_base_xds | `FIELD_PHASE_CENTER_DIRECTION` | ICRS (ra, dec) in rad of the zenith at each snapshot, one field per snapshot |
|
|
106
|
+
| gain_xds (**extension**) | `GAIN`, `GAIN_AMPLITUDE`, `GAIN_PHASE`, `ANTENNA_FLAG` | TART's per-file gain snapshot, **not** applied to VISIBILITY |
|
|
107
|
+
| | `ANTENNA_POSITION_ENU` | each file's East/North/Up positions (m) |
|
|
108
|
+
|
|
109
|
+
`gain_xds` has `type="extension:gain.tart_msv4"` and `tart_msv4_extension=True`. `check_datatree` skips it
|
|
110
|
+
with an `ExtensionTypeWarning`.
|
|
111
|
+
|
|
112
|
+
## Conventions
|
|
113
|
+
|
|
114
|
+
- **Fields.** TART points at the zenith and does not fringe-stop, so every snapshot is its own field. Fields
|
|
115
|
+
are named `zenith_<UTC ISO µs>` (e.g. `zenith_2026-06-09T08:10:42.993515`), which keeps names unique
|
|
116
|
+
across files. All fields share one partition, as in xradio and xarray-ms. Each file is one scan
|
|
117
|
+
(`scan_<first snapshot ISO>`). See [ADR 1](docs/adr/0001-one-field-per-snapshot.md).
|
|
118
|
+
- **Visibilities need no rephasing.** They are already phased to each snapshot's zenith. They are passed
|
|
119
|
+
through unconjugated, and are identical to the tart2ms MS DATA at a shared phase centre.
|
|
120
|
+
- **UVW = pos(ant1) − pos(ant2)**, the sign tart2ms writes. It is checked against the reference MS
|
|
121
|
+
([ADR 2](docs/adr/0002-uvw-sign-ant1-minus-ant2.md)). Each ITRS baseline is rotated into the celestial
|
|
122
|
+
frame at its snapshot (IAU 2006/2000A, `erfa.c2t06a`) and projected onto the (u, v, w) basis of that
|
|
123
|
+
snapshot's phase centre.
|
|
124
|
+
- **Phase centres** come from `erfa.atoc13`, which converts observed (az, zd) = (0, 0) to ICRS with
|
|
125
|
+
aberration and no refraction. They match astropy to under 0.5″; the difference is polar motion, which is
|
|
126
|
+
neglected. They match casacore/tart2ms to about 0.25″.
|
|
127
|
+
- **Time.** Timestamps are parsed as ISO 8601. Timestamps without a timezone are UTC, never machine-local.
|
|
128
|
+
`time` is the TART timestamp exactly, as tart2ms writes it.
|
|
129
|
+
- **UT1.** No IERS data is used, so by default UT1 = UTC. An error of Δ seconds shifts right ascensions by
|
|
130
|
+
about 15Δ″ (|Δ| < 0.9 s), which is negligible against TART's ~7° resolution. Pass `dut1=` for better.
|
|
131
|
+
- **Antenna positions.** ENU offsets are placed on the exact WGS84 tangent plane. tart2ms uses a spherical
|
|
132
|
+
approximation, so its u and v differ by up to about 2 cm.
|
|
133
|
+
|
|
134
|
+
## Out of scope (TODO)
|
|
135
|
+
|
|
136
|
+
- Rephasing all snapshots to one common phase centre. That is a processing step and belongs in the consumer
|
|
137
|
+
(e.g. kremetart). Its result should be a separate `field_and_source` data group.
|
|
138
|
+
- Applying gains.
|
|
139
|
+
- Satellite catalogues.
|
|
140
|
+
- IERS-based UT1 and polar motion.
|
|
141
|
+
- Writing back to HDF5.
|
|
142
|
+
|
|
143
|
+
## Development
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
uv sync # dev + test groups
|
|
147
|
+
uv run ruff format . && uv run ruff check .
|
|
148
|
+
uv run pytest # downloads the real-data bundle once into tests/data
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The real-data bundle is the kremetart test bundle (nine TART files and tart2ms reference MSs). Set
|
|
152
|
+
`TART_MSV4_OFFLINE=1` to skip the download, or `TART_MSV4_DATA=<dir>` to use an existing copy. Tests marked
|
|
153
|
+
`integration` skip without it. Domain terms are defined in [GLOSSARY.md](GLOSSARY.md).
|
|
154
|
+
|
|
155
|
+
### Pre-commit hooks
|
|
156
|
+
|
|
157
|
+
Install the hooks once per clone:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
uv sync
|
|
161
|
+
uv run pre-commit install # installs the pre-commit and commit-msg hooks
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| Stage | Hook | What it does |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| commit | ruff, pre-commit-hooks | `ruff check --fix`, `ruff format`, whitespace/EOF/YAML/TOML/large-file checks |
|
|
167
|
+
| commit message | conventional-pre-commit | requires a [Conventional Commit](https://www.conventionalcommits.org/) message: `feat:`, `fix:`, `refactor:`, `perf:`, `docs:`, `deps:`, `chore:`, `ci:`, `style:`, `test:` or `build:` |
|
|
168
|
+
|
|
169
|
+
If a hook modifies files, the commit is aborted so you can review the changes. Run
|
|
170
|
+
`git add -u && git commit` again. Run all hooks on demand with `uv run pre-commit run --all-files`.
|
|
171
|
+
|
|
172
|
+
### Releasing
|
|
173
|
+
|
|
174
|
+
Commit messages are the changelog. `CHANGELOG.md` is generated from them by [git-cliff](https://git-cliff.org)
|
|
175
|
+
(`cliff.toml`) at release time, so don't edit it by hand. Releases use [tbump](https://github.com/your-tools/tbump):
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
uv run tbump 0.2.0
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
tbump updates the version in `pyproject.toml` and `src/tart_msv4/__init__.py`, generates `CHANGELOG.md`,
|
|
182
|
+
refreshes `uv.lock`, commits `chore(release): bump version to 0.2.0`, tags `v0.2.0` and pushes. Pushing the
|
|
183
|
+
tag publishes the package to PyPI.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# tart-msv4
|
|
2
|
+
|
|
3
|
+
An [xarray](https://xarray.dev) backend that opens [TART](https://tart.elec.ac.nz) (Transient Array Radio
|
|
4
|
+
Telescope) visibility HDF5 files as Measurement Set v4 (MSv4) `xarray.DataTree`s. Its output passes
|
|
5
|
+
`xradio.schema.check.check_datatree`, and it follows the conventions of
|
|
6
|
+
[xarray-ms](https://github.com/ratt-ru/xarray-ms).
|
|
7
|
+
|
|
8
|
+
The only runtime dependencies are numpy, xarray, h5py and pyerfa. It needs no astropy, no network and no
|
|
9
|
+
dask (dask is supported when installed).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install tart-msv4
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import xarray as xr
|
|
21
|
+
|
|
22
|
+
dt = xr.open_datatree("vis_2026-06-09_08_11_43.476804.hdf", engine="tart")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`xr.open_dataset(path, engine="tart")` returns just the visibility partition. `engine="tart"` accepts a
|
|
26
|
+
single file only. Always pass `engine="tart"`. The backend's guessing claims only HDF5 files that carry the TART
|
|
27
|
+
signature (`vis`, `baselines`, `timestamp`, and a JSON `config` with `num_antenna`), but xarray tries its
|
|
28
|
+
netCDF engines first, and h5netcdf or netCDF4, when installed, claim every HDF5 file.
|
|
29
|
+
|
|
30
|
+
Every array on the (time, baseline) grid is lazy: VISIBILITY is read from the file, and FLAG, WEIGHT, UVW,
|
|
31
|
+
TIME_CENTROID and EFFECTIVE_INTEGRATION_TIME are computed on read from small per-file tables. Opening a file
|
|
32
|
+
reads only its metadata, and the opened tree pickles small. xarray's CF decoding keywords (`decode_times`
|
|
33
|
+
etc.) are accepted and ignored.
|
|
34
|
+
|
|
35
|
+
### Several files
|
|
36
|
+
|
|
37
|
+
TART writes one file per minute or so. To open the files of one observation as a single partition, lazily
|
|
38
|
+
concatenated along `time`:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from pathlib import Path
|
|
42
|
+
import tart_msv4
|
|
43
|
+
|
|
44
|
+
paths = sorted(Path("data").glob("vis_*.hdf"))
|
|
45
|
+
dt = tart_msv4.open_tart(paths) # lazy, no dask
|
|
46
|
+
dt = tart_msv4.open_tart(paths, chunks={}) # dask, one chunk per file
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- **Inputs:** `open_tart` takes one path or a sequence of paths. You expand globs and directories
|
|
50
|
+
yourself.
|
|
51
|
+
- **Ordering:** files are sorted by timestamp. Files that overlap in time, or repeat, raise `ValueError`.
|
|
52
|
+
- **Compatibility:** `config` and `baselines` must be identical. `antenna_positions` may differ by up to
|
|
53
|
+
`position_tolerance` (default 1 cm), because TART recalibrates them along with its gains. Any other
|
|
54
|
+
mismatch raises `ValueError`.
|
|
55
|
+
|
|
56
|
+
### Keyword arguments
|
|
57
|
+
|
|
58
|
+
The keywords below work with both `xr.open_datatree` and `open_tart`:
|
|
59
|
+
|
|
60
|
+
| kwarg | default | meaning |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| `partition_name` | `<first file stem>_partition_000` | partition node name |
|
|
63
|
+
| `creation_date` | last snapshot time (UTC ISO) | `creation_date` and data-group `date`. The default is deterministic ([ADR 3](docs/adr/0003-deterministic-dates.md)) |
|
|
64
|
+
| `dut1` | `0.0` | UT1 − UTC in seconds (see Conventions) |
|
|
65
|
+
| `drop_variables` | `None` | variables to drop from every group |
|
|
66
|
+
| `position_tolerance` | `0.01` | `open_tart` only: allowed antenna-position change between files (m) |
|
|
67
|
+
|
|
68
|
+
## Schema
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
/
|
|
72
|
+
└── <partition> visibility (time, baseline_id, frequency, polarization, uvw_label)
|
|
73
|
+
├── antenna_xds antenna (antenna_name, cartesian_pos_label, receptor_label)
|
|
74
|
+
├── field_and_source_base_xds field_and_source (field_name, sky_dir_label)
|
|
75
|
+
└── gain_xds TART extension (gain_time, antenna_name, enu_label)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| Node | Variable | Notes |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| partition | `VISIBILITY` | complex64, `units="dimensionless"` (normalised correlation coefficients, uncalibrated). Lazy |
|
|
81
|
+
| | `FLAG`, `WEIGHT` | uint8 / float32. Baselines of a dead antenna (gain 0 in that file) have FLAG=1, WEIGHT=0. Otherwise 0 / 1 |
|
|
82
|
+
| | `UVW` | float64 m, `frame="fk5"`, toward each snapshot's own zenith |
|
|
83
|
+
| | `TIME_CENTROID`, `EFFECTIVE_INTEGRATION_TIME` | equal to `time` and the median snapshot spacing |
|
|
84
|
+
| | coords | `time` (unix s, UTC), `baseline_id`, `baseline_antenna{1,2}_name` (`ant00…`), `frequency` (one L1 channel, `channel_width` = bandwidth), `polarization` = `["RR"]`, `field_name(time)`, `scan_name(time)` |
|
|
85
|
+
| antenna_xds | `ANTENNA_POSITION` | geocentric ITRS (m), from the first file's ENU positions on the exact WGS84 tangent plane |
|
|
86
|
+
| | `ANTENNA_DISH_DIAMETER`, `ANTENNA_EFFECTIVE_DISH_DIAMETER`, `ANTENNA_RECEPTOR_ANGLE` | 0.025 m, 0.025 m, 0 rad |
|
|
87
|
+
| field_and_source_base_xds | `FIELD_PHASE_CENTER_DIRECTION` | ICRS (ra, dec) in rad of the zenith at each snapshot, one field per snapshot |
|
|
88
|
+
| gain_xds (**extension**) | `GAIN`, `GAIN_AMPLITUDE`, `GAIN_PHASE`, `ANTENNA_FLAG` | TART's per-file gain snapshot, **not** applied to VISIBILITY |
|
|
89
|
+
| | `ANTENNA_POSITION_ENU` | each file's East/North/Up positions (m) |
|
|
90
|
+
|
|
91
|
+
`gain_xds` has `type="extension:gain.tart_msv4"` and `tart_msv4_extension=True`. `check_datatree` skips it
|
|
92
|
+
with an `ExtensionTypeWarning`.
|
|
93
|
+
|
|
94
|
+
## Conventions
|
|
95
|
+
|
|
96
|
+
- **Fields.** TART points at the zenith and does not fringe-stop, so every snapshot is its own field. Fields
|
|
97
|
+
are named `zenith_<UTC ISO µs>` (e.g. `zenith_2026-06-09T08:10:42.993515`), which keeps names unique
|
|
98
|
+
across files. All fields share one partition, as in xradio and xarray-ms. Each file is one scan
|
|
99
|
+
(`scan_<first snapshot ISO>`). See [ADR 1](docs/adr/0001-one-field-per-snapshot.md).
|
|
100
|
+
- **Visibilities need no rephasing.** They are already phased to each snapshot's zenith. They are passed
|
|
101
|
+
through unconjugated, and are identical to the tart2ms MS DATA at a shared phase centre.
|
|
102
|
+
- **UVW = pos(ant1) − pos(ant2)**, the sign tart2ms writes. It is checked against the reference MS
|
|
103
|
+
([ADR 2](docs/adr/0002-uvw-sign-ant1-minus-ant2.md)). Each ITRS baseline is rotated into the celestial
|
|
104
|
+
frame at its snapshot (IAU 2006/2000A, `erfa.c2t06a`) and projected onto the (u, v, w) basis of that
|
|
105
|
+
snapshot's phase centre.
|
|
106
|
+
- **Phase centres** come from `erfa.atoc13`, which converts observed (az, zd) = (0, 0) to ICRS with
|
|
107
|
+
aberration and no refraction. They match astropy to under 0.5″; the difference is polar motion, which is
|
|
108
|
+
neglected. They match casacore/tart2ms to about 0.25″.
|
|
109
|
+
- **Time.** Timestamps are parsed as ISO 8601. Timestamps without a timezone are UTC, never machine-local.
|
|
110
|
+
`time` is the TART timestamp exactly, as tart2ms writes it.
|
|
111
|
+
- **UT1.** No IERS data is used, so by default UT1 = UTC. An error of Δ seconds shifts right ascensions by
|
|
112
|
+
about 15Δ″ (|Δ| < 0.9 s), which is negligible against TART's ~7° resolution. Pass `dut1=` for better.
|
|
113
|
+
- **Antenna positions.** ENU offsets are placed on the exact WGS84 tangent plane. tart2ms uses a spherical
|
|
114
|
+
approximation, so its u and v differ by up to about 2 cm.
|
|
115
|
+
|
|
116
|
+
## Out of scope (TODO)
|
|
117
|
+
|
|
118
|
+
- Rephasing all snapshots to one common phase centre. That is a processing step and belongs in the consumer
|
|
119
|
+
(e.g. kremetart). Its result should be a separate `field_and_source` data group.
|
|
120
|
+
- Applying gains.
|
|
121
|
+
- Satellite catalogues.
|
|
122
|
+
- IERS-based UT1 and polar motion.
|
|
123
|
+
- Writing back to HDF5.
|
|
124
|
+
|
|
125
|
+
## Development
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
uv sync # dev + test groups
|
|
129
|
+
uv run ruff format . && uv run ruff check .
|
|
130
|
+
uv run pytest # downloads the real-data bundle once into tests/data
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The real-data bundle is the kremetart test bundle (nine TART files and tart2ms reference MSs). Set
|
|
134
|
+
`TART_MSV4_OFFLINE=1` to skip the download, or `TART_MSV4_DATA=<dir>` to use an existing copy. Tests marked
|
|
135
|
+
`integration` skip without it. Domain terms are defined in [GLOSSARY.md](GLOSSARY.md).
|
|
136
|
+
|
|
137
|
+
### Pre-commit hooks
|
|
138
|
+
|
|
139
|
+
Install the hooks once per clone:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
uv sync
|
|
143
|
+
uv run pre-commit install # installs the pre-commit and commit-msg hooks
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
| Stage | Hook | What it does |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| commit | ruff, pre-commit-hooks | `ruff check --fix`, `ruff format`, whitespace/EOF/YAML/TOML/large-file checks |
|
|
149
|
+
| commit message | conventional-pre-commit | requires a [Conventional Commit](https://www.conventionalcommits.org/) message: `feat:`, `fix:`, `refactor:`, `perf:`, `docs:`, `deps:`, `chore:`, `ci:`, `style:`, `test:` or `build:` |
|
|
150
|
+
|
|
151
|
+
If a hook modifies files, the commit is aborted so you can review the changes. Run
|
|
152
|
+
`git add -u && git commit` again. Run all hooks on demand with `uv run pre-commit run --all-files`.
|
|
153
|
+
|
|
154
|
+
### Releasing
|
|
155
|
+
|
|
156
|
+
Commit messages are the changelog. `CHANGELOG.md` is generated from them by [git-cliff](https://git-cliff.org)
|
|
157
|
+
(`cliff.toml`) at release time, so don't edit it by hand. Releases use [tbump](https://github.com/your-tools/tbump):
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
uv run tbump 0.2.0
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
tbump updates the version in `pyproject.toml` and `src/tart_msv4/__init__.py`, generates `CHANGELOG.md`,
|
|
164
|
+
refreshes `uv.lock`, commits `chore(release): bump version to 0.2.0`, tags `v0.2.0` and pushes. Pushing the
|
|
165
|
+
tag publishes the package to PyPI.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tart-msv4"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
description = "xarray backend exposing TART visibility HDF5 files as Measurement Set v4 DataTrees"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"numpy>=1.26",
|
|
11
|
+
"xarray>=2025.1",
|
|
12
|
+
"h5py>=3.10",
|
|
13
|
+
"pyerfa>=2.0.1",
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Topic :: Scientific/Engineering :: Astronomy",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[[project.authors]]
|
|
21
|
+
name = "Landman Bester"
|
|
22
|
+
email = "lbester@sarao.ac.za"
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Repository = "https://github.com/landmanbester/tart-msv4"
|
|
26
|
+
|
|
27
|
+
[project.entry-points."xarray.backends"]
|
|
28
|
+
tart = "tart_msv4.backend:TartBackendEntrypoint"
|
|
29
|
+
|
|
30
|
+
[dependency-groups]
|
|
31
|
+
dev = [
|
|
32
|
+
"ruff>=0.6",
|
|
33
|
+
"pytest>=8",
|
|
34
|
+
"pre-commit>=4",
|
|
35
|
+
"tbump>=6.11.0",
|
|
36
|
+
]
|
|
37
|
+
test = [
|
|
38
|
+
"pytest>=8",
|
|
39
|
+
"gdown>=5",
|
|
40
|
+
"xradio>=1.3",
|
|
41
|
+
"xarray-ms>=0.5.13",
|
|
42
|
+
"arcae>=0.5.8",
|
|
43
|
+
"dask[array]",
|
|
44
|
+
"astropy>=6",
|
|
45
|
+
"trove-classifiers",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[build-system]
|
|
49
|
+
requires = ["uv_build>=0.11.6,<0.12.0"]
|
|
50
|
+
build-backend = "uv_build"
|
|
51
|
+
|
|
52
|
+
[tool.uv]
|
|
53
|
+
default-groups = [
|
|
54
|
+
"dev",
|
|
55
|
+
"test",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 120
|
|
60
|
+
target-version = "py311"
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = [
|
|
64
|
+
"E",
|
|
65
|
+
"F",
|
|
66
|
+
"I",
|
|
67
|
+
"N",
|
|
68
|
+
"W",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[tool.pytest.ini_options]
|
|
72
|
+
testpaths = ["tests"]
|
|
73
|
+
addopts = "--strict-markers"
|
|
74
|
+
filterwarnings = ["ignore:Skipping schema check of .*gain_xds"]
|
|
75
|
+
markers = [
|
|
76
|
+
"unit: fast tests on synthetic data",
|
|
77
|
+
"integration: tests against the real TART test-data bundle",
|
|
78
|
+
]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tart-msv4"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
description = "xarray backend exposing TART visibility HDF5 files as Measurement Set v4 DataTrees"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Landman Bester", email = "lbester@sarao.ac.za" }]
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"numpy>=1.26",
|
|
12
|
+
"xarray>=2025.1",
|
|
13
|
+
"h5py>=3.10",
|
|
14
|
+
"pyerfa>=2.0.1",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Astronomy",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Repository = "https://github.com/landmanbester/tart-msv4"
|
|
23
|
+
|
|
24
|
+
[project.entry-points."xarray.backends"]
|
|
25
|
+
tart = "tart_msv4.backend:TartBackendEntrypoint"
|
|
26
|
+
|
|
27
|
+
[dependency-groups]
|
|
28
|
+
dev = ["ruff>=0.6", "pytest>=8", "pre-commit>=4", "tbump>=6.11.0"]
|
|
29
|
+
test = [
|
|
30
|
+
"pytest>=8",
|
|
31
|
+
"gdown>=5",
|
|
32
|
+
"xradio>=1.3",
|
|
33
|
+
"xarray-ms>=0.5.13",
|
|
34
|
+
"arcae>=0.5.8",
|
|
35
|
+
"dask[array]",
|
|
36
|
+
"astropy>=6",
|
|
37
|
+
"trove-classifiers",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[build-system]
|
|
41
|
+
requires = ["uv_build>=0.11.6,<0.12.0"]
|
|
42
|
+
build-backend = "uv_build"
|
|
43
|
+
|
|
44
|
+
[tool.uv]
|
|
45
|
+
default-groups = ["dev", "test"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 120
|
|
49
|
+
target-version = "py311"
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint]
|
|
52
|
+
select = ["E", "F", "I", "N", "W"]
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
testpaths = ["tests"]
|
|
56
|
+
addopts = "--strict-markers"
|
|
57
|
+
filterwarnings = ["ignore:Skipping schema check of .*gain_xds"]
|
|
58
|
+
markers = [
|
|
59
|
+
"unit: fast tests on synthetic data",
|
|
60
|
+
"integration: tests against the real TART test-data bundle",
|
|
61
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""TART visibility HDF5 files as Measurement Set v4 xarray DataTrees.
|
|
2
|
+
|
|
3
|
+
>>> import xarray as xr
|
|
4
|
+
>>> dt = xr.open_datatree("vis_2026-06-09_08_11_43.476804.hdf", engine="tart")
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.1"
|
|
10
|
+
|
|
11
|
+
from tart_msv4.backend import open_tart # noqa: E402 (backend reads __version__ lazily)
|
|
12
|
+
|
|
13
|
+
__all__ = ["__version__", "build_msv4_groups", "open_tart"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def __getattr__(name: str) -> Any:
|
|
17
|
+
# Lazy: xarray imports this package whenever it resolves any engine, and the schema pulls in pyerfa.
|
|
18
|
+
if name == "build_msv4_groups":
|
|
19
|
+
from tart_msv4.schema import build_msv4_groups
|
|
20
|
+
|
|
21
|
+
return build_msv4_groups
|
|
22
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|