Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CASA-based MS calibration tables #1391

Merged
merged 45 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c61892f
Initial commits of MSCal module stub out, test files.
kartographer Feb 9, 2024
8a74828
Adding MS utilities module to avoid duplicating things in both UVData…
kartographer Jan 26, 2024
e8c9fc9
Removing some bits from MS object following creation of common MS uti…
kartographer Jan 26, 2024
4a504ac
Adding unknown jones index for handling MS files
kartographer Jan 26, 2024
f428780
Migrating ms test over to new ms_cal test module
kartographer Jan 26, 2024
38d9b6d
CASA gains reader functional, passes UVCal check
kartographer Jan 26, 2024
801c53b
Minor clean-up and improvements for the MSCal class...
kartographer Feb 2, 2024
4b7fd9b
Making minor fix to UVBase.check method (allows req params to be allo…
kartographer Feb 4, 2024
141cc3b
Added MS gains writer, first successful loopback (now in tests)
kartographer Feb 4, 2024
6abe8c5
More re-org, pushing all table read/write functions into ms_utils
kartographer Feb 5, 2024
9b1cb46
Adding bandpass example file for ms_cal
kartographer Feb 5, 2024
9470581
Adding CASA delay-cal example file as well...
kartographer Feb 5, 2024
56a8282
Adding support for bandpass and delays read/write
kartographer Feb 5, 2024
0c898a9
Adding MS delay/bandpass loopback tests, fixing minor bugs/warnings
kartographer Feb 5, 2024
fa0e4a0
Fixing gain convention for CASA
kartographer Feb 7, 2024
7f269f9
Adding support for phase center handling in UVCal, moving some UVData…
kartographer Mar 3, 2024
e2f7490
Addressing subset of reviewer comments
kartographer Mar 3, 2024
59f4d21
Fixing incorrect comment
kartographer Mar 3, 2024
5c973d2
Updates due to user-discovered issues w/ ms_cal
kartographer Mar 4, 2024
03a5650
One more fix to ms_cal to resolve min_deps issue
kartographer Mar 4, 2024
9c80257
Adding support for CORRECTED_DATA, MODEL_DATA read/write to CASA MS
kartographer Mar 5, 2024
b7b2b6f
Minor updates and fixes based on SMA user testing.
kartographer Mar 19, 2024
9b9b092
Updating remove_flex_pol docstring in UVData (was missing parameters)
kartographer Mar 25, 2024
eb2a345
Adding flex-jones to UVCal
kartographer Mar 25, 2024
f34d3d8
Testing clean-up
kartographer Mar 26, 2024
c3b61a3
Adding flex-pol handling, first pass on general MS source table reader
kartographer Mar 26, 2024
1325d3c
Post-rebase clean-up
kartographer Mar 26, 2024
c835a1b
Patching tutorial after dropping one of the test files
kartographer Mar 26, 2024
204b514
Remaining test file cleanup
kartographer Mar 27, 2024
20259d7
More code re-organization, shifting common utils to ms_utils, clean-u…
kartographer Mar 27, 2024
ec2df23
More utility clean-up
kartographer Mar 27, 2024
921ff3b
Big slug of updates, responding to reviewer comments and enabling rou…
kartographer Mar 28, 2024
bd22424
Testing additions
kartographer Mar 29, 2024
3a4f0c6
More testing additions
kartographer Mar 29, 2024
47e7531
More testing updates, fixes to freq indexing in flex_spw add method
kartographer Mar 30, 2024
de4d3b7
More coverage/testing updates
kartographer Mar 31, 2024
e4bacc9
Adding last bit of test coverage
kartographer Mar 31, 2024
8c6566e
Fixing wrong error catch in ms_utils.read_ms_history
kartographer Mar 31, 2024
0836195
Add handling required for CASA when Njones==1 for cal solns
kartographer Mar 31, 2024
e723a21
Big push for docstring updates
kartographer Apr 1, 2024
ec2823e
Updating CHANGELOG
kartographer Apr 1, 2024
01543cd
Updating readme
kartographer Apr 1, 2024
5779003
Tutorial update to briefly highlight MS cal support
kartographer Apr 1, 2024
0234b5c
Addressing reviewer comments
kartographer Apr 18, 2024
70f7fed
One more set of updates to address reviewer comments.
kartographer Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
## [Unreleased]

### Added
- Support for writing "MODEL_DATA" and "CORRECTED_DATA" columns has been added to the
`UVData.write_ms` method.
- Support for "flexible-Jones" `UVCal` objects -- where different spectral windows can
contain different Jones vectors/polarization information -- has been added, along with
methods for converting `UVCal` objects to and from flex-Jones format (`remove_flex_jones`,
`_make_flex_jones`, and `convert_to_flex_jones`). Support for flex-Jones has been added
to `MSCal` and `CalH5` subclasses.
- A new class called `MSCal` has been added as a subclass of `UVCal`, which adds support
for reading and writing of CASA Measurement Set gains, bandpass, and delays tables. To
support this, several new optional parameters have been added to the `UVCal` class,
including `phase_center_catalog`, `phase_center_id_array`, `antenna_diameters`,
`scan_id_array`, and `ref_antenna_array` (which affords the ability to record a
different reference antenna per time-axis entry).
- A new HDF5 file format for calibration solutions called `calh5`, which supports
writing out all types of UVCal objects and supports partial reads (select on read).
- A `UVCal.get_lst_array` method similar to the `get_time_array` method that either
Expand Down Expand Up @@ -44,6 +57,12 @@ catalog entries resulted in an error.
- Bug in which `correct_cable_len` defaulted to `None` instead of `True`
for `read_mwa_corr_fits`.

### Fixed
- Fixed a bug in `UVBase` where `allowed_failures` was being ignored if a parameter had
`required=True` set.
- Fixed a bug where selection and addition/concat methods did not operate correctly on
flex-spw `UVCal` objects where `Nspws>1`.

kartographer marked this conversation as resolved.
Show resolved Hide resolved
## [2.4.3] - 2024-3-25

### Added
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ It is probably not compatible with other interferometric HDF5 files defined by o
* MWA correlator FITS files (read-only support, tested against Cotter outputs and FHD)

## UVCal file formats
* calfits: a new format defined in pyuvdata, details in the [calfits_memo](docs/references/calfits_memo.pdf).
* calh5: a new format defined in pyuvdata, details to come in a forthcoming memo.
* Measurement Set calibration files (read and write, gains/delay/bandpass supported, beta version).
Tested against a limited set of SMA, LWA, and VLA calibration files generated in CASA.
* calfits: a custom format defined in pyuvdata, details in the [calfits_memo](docs/references/calfits_memo.pdf).
Note that this format was recently defined and may change in coming versions,
based on user needs. Consider it to be a beta version, but we will strive to
make future versions backwards compatible with the current format.
Expand Down Expand Up @@ -253,6 +256,7 @@ pyuvdata is maintained by the RASG Managers, which currently include:

- Adam Beardsley (Winona State University)
- Bryna Hazelton (University of Washington)
- Garrett "Karto" Keating (Smithsonian Astrophysical Observatory)
- Daniel Jacobs (Arizona State University)
- Matt Kolopanis (Arizona State University)
- Paul La Plante (University of Nevada, Las Vegas)
Expand Down
2 changes: 1 addition & 1 deletion ci/pyuvdata_min_deps_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- pyerfa>=2.0
- pyyaml>=5.4.1
- coverage
- pytest>=6.2.0
- pytest>=6.2.5
- pytest-cases>=3.8.3
- pytest-cov
- pytest-xdist
Expand Down
15 changes: 15 additions & 0 deletions docs/uvcal_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ b) CalFITS to CalH5
>>> cal.write_calh5(os.path.join('.', 'tutorial_cal.calh5'), clobber=True)


c) MSCal to CalH5
*******************
.. code-block:: python

>>> import os
>>> from pyuvdata import UVCal
>>> from pyuvdata.data import DATA_PATH
>>> filename = os.path.join(DATA_PATH, 'sma.ms.amp.gcal')
>>> # Here we use the ``from_file`` class method, can also use the ``read`` method.
>>> # Can optionally specify the ``file_type`` to either method
>>> cal = UVCal.from_file(filename, use_future_array_shapes=True)

>>> cal.write_calh5(os.path.join('.', 'tutorial_cal.ms'), clobber=True)


UVCal: Initializing from a UVData object
----------------------------------------
The :meth:`pyuvdata.UVCal.initialize_from_uvdata` method allows you to initialize a UVCal
Expand Down
29 changes: 4 additions & 25 deletions docs/uvdata_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -922,15 +922,15 @@ Note: there is now support for reading in only part of a uvfits, uvh5 or miriad
>>> import matplotlib.pyplot as plt
>>> from pyuvdata import UVData
>>> from pyuvdata.data import DATA_PATH
>>> filename = os.path.join(DATA_PATH, 'day2_TDEM0003_10s_norx_1scan.uvfits')
>>> filename = os.path.join(DATA_PATH, 'day2_TDEM0003_10s_norx_1src_1spw.uvfits')
>>> uvd = UVData.from_file(filename, use_future_array_shapes=True)

>>> print(uvd.data_array.shape)
(1414, 128, 4)
(1360, 64, 4)
>>> print(uvd.Ntimes)
17
15
>>> print(uvd.Nfreqs)
128
64
>>> # get the data for a single baseline and polarization
>>> waterfall_data = uvd.get_data((1, 2, uvd.polarization_array[0]))
>>> # get the corresponding times for this waterfall
Expand All @@ -952,27 +952,6 @@ Note: there is now support for reading in only part of a uvfits, uvh5 or miriad
.. image:: Images/amplitude_waterfall.png
:width: 600

.. code-block:: python

>>> # The plot above has a discontinuity in the frequency axis because this
>>> # data set has spectral windows. Let's just plot the 0th one
>>> window_sel = uvd.flex_spw_id_array == 0
>>> freqs_use = uvd.freq_array[window_sel]
>>> fig, ax = plt.subplots(1, 1)
>>> _ = plt.imshow(np.abs(waterfall_data[:, window_sel]))
>>> _ = ax.set_yticks([0, waterfall_times.size - 1])
>>> _ = ax.set_yticklabels([waterfall_times[0], waterfall_times[1]])
>>> freq_tick_inds = np.concatenate((np.arange(0, freqs_use.size, 16), [freqs_use.size-1]))
>>> _ = ax.set_xticks(freq_tick_inds)
>>> _ = ax.set_xticklabels([f"{val:.3f}" for val in freqs_use[freq_tick_inds]*1e-9])
>>> _ = ax.set_xlabel("Frequency (GHz)")
>>> plt.show() # doctest: +SKIP
>>> plt.savefig("Images/amplitude_waterfall_spw0.png", bbox_inches='tight')
>>> plt.clf()

.. image:: Images/amplitude_waterfall_spw0.png
:width: 600


UVData: Location conversions
----------------------------
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed pyuvdata/data/day2_TDEM0003_10s_norx_1scan.ms/table.f2
Binary file not shown.
Binary file not shown.
Binary file removed pyuvdata/data/day2_TDEM0003_10s_norx_1scan.ms/table.f3
Binary file not shown.
Binary file not shown.
Binary file removed pyuvdata/data/day2_TDEM0003_10s_norx_1scan.ms/table.f4
Binary file not shown.
Binary file removed pyuvdata/data/day2_TDEM0003_10s_norx_1scan.ms/table.f5
Binary file not shown.
Binary file not shown.
Binary file removed pyuvdata/data/day2_TDEM0003_10s_norx_1scan.ms/table.f6
Binary file not shown.
Binary file not shown.
Binary file removed pyuvdata/data/day2_TDEM0003_10s_norx_1scan.ms/table.f7
Binary file not shown.
Binary file not shown.
Binary file removed pyuvdata/data/day2_TDEM0003_10s_norx_1scan.ms/table.f8
Binary file not shown.

This file was deleted.

5 changes: 0 additions & 5 deletions pyuvdata/data/day2_TDEM0003_10s_norx_1scan.ms/table.info

This file was deleted.

Binary file not shown.
Loading
Loading