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

Support multiple spws in UVData.frequency_average #1307

Merged
merged 4 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
command: |
source ./ci/_activate_current_env.sh
cd docs
python -m pytest -n 2 --doctest-glob="*.rst" -W "error::DeprecationWarning"
python -m pytest -n auto --doctest-glob="*.rst" -W "error::DeprecationWarning"
cd ..
- save_cache:
key: deps-{{ .Branch }}-{{ checksum "ci/pyuvdata_tests.yml" }}
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
## [Unreleased]

### Added
- Support for multiple spectral windows in `UVData.frequency_average`, including a new
parameter `respect_spws` for controlling whether averaging crosses spectral window
boundaries.
- Better handling in `UVData.frequency_average` when averaging by a number of channels
that does not divide evenly into the number of channels in each spectral window.
- Compatibility with Python 3.11

### Changed
Expand All @@ -20,7 +25,8 @@ All notable changes to this project will be documented in this file.
methods that mostly wrap other methods.
- A new `UVCal.new()` method (based on new function `new_uvcal`) that creates a new,
self-consistent `UVCal` object from scratch from a set of flexible input parameters.
- A new `UVData.new()` method (based on new function `new_uvdata`) that creates a new, self-consistent `UVData` object from scratch from a set of flexible input parameters.
- A new `UVData.new()` method (based on new function `new_uvdata`) that creates a new,
self-consistent `UVData` object from scratch from a set of flexible input parameters.
- A new `fast_concat` method on `UVCal`.
- A new generic `read` method on `UVCal` that, like the `read` methods on our other
objects, supports all file types and a new `from_file` class method to allow one-line
Expand Down
12 changes: 8 additions & 4 deletions docs/uvdata_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,12 @@ c) Resampling a BDA dataset in time

d) Averaging in frequency
*************************
The :meth:`pyuvdata.UVData.frequency_average` method takes a number of channels to
average together. Use the `keep_ragged` parameter to control the handling if the
number of frequencies in each spectral window does not divide evenly by the number of
channels to be averaged together. Use the `respect_spws` parameter to control whether
averaging will be done over spectral window boundaries.

.. code-block:: python

>>> import os
Expand All @@ -780,7 +786,7 @@ d) Averaging in frequency
Channel width: [122070.3125 122070.3125 122070.3125 122070.3125]

>>> # Average by a factor of 2 in frequency
>>> uvd.frequency_average(2)
>>> uvd.frequency_average(n_chan_to_avg=2, keep_ragged=True)
>>> print("Channel width after frequency averaging: ", uvd.channel_width)
Channel width after frequency averaging: [244140.625 244140.625]

Expand All @@ -789,8 +795,7 @@ UVData: Plotting
Making a simple waterfall plot.

Note: there is now support for reading in only part of a uvfits, uvh5 or miriad file
(see :ref:`large_files`), so you need not read in the
entire file to plot one waterfall.
(see :ref:`large_files`), so you need not read in the entire file to plot one waterfall.

.. code-block:: python

Expand All @@ -802,7 +807,6 @@ entire file to plot one waterfall.
>>> filename = os.path.join(DATA_PATH, 'day2_TDEM0003_10s_norx_1src_1spw.uvfits')
>>> uvd = UVData.from_file(filename, use_future_array_shapes=True)

>>> # Note that the length of the array along axis=1 is always 1.
>>> print(uvd.data_array.shape)
(1360, 64, 4)
>>> print(uvd.Ntimes)
Expand Down
18 changes: 7 additions & 11 deletions pyuvdata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,20 +544,16 @@ def _check_freq_spacing(
chanwidth_error = True
if raise_errors and spacing_error:
raise ValueError(
"The frequencies are not evenly spaced (probably "
"because of a select operation) or has differing "
"values of channel widths. Some file formats "
"(e.g. uvfits, miriad) and methods (frequency_average) "
"do not support unevenly spaced frequencies."
"The frequencies are not evenly spaced (probably because of a select "
"operation) or has differing values of channel widths. Some file formats "
"(e.g. uvfits, miriad) do not support unevenly spaced frequencies."
)
if raise_errors and chanwidth_error:
raise ValueError(
"The frequencies are separated by more than their "
"channel width (probably because of a select operation). "
"Some file formats (e.g. uvfits, miriad) and "
"methods (frequency_average) do not support "
"frequencies that are spaced by more than their "
"channel width."
"The frequencies are separated by more than their channel width (probably "
"because of a select operation). Some file formats (e.g. uvfits, miriad) "
"do not support frequencies that are spaced by more than their channel "
"width."
)

return spacing_error, chanwidth_error
Expand Down
Loading