Skip to content

Commit

Permalink
Remove deprecated code, update changelog for version 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bhazelton committed Mar 14, 2023
1 parent 77abeca commit 31554b6
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 137 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [2.3.0] - 2023-03-13

### Added
- A new `interpolation_function` parameter to `UVBeam.interp` and `UVBeam.to_healpix`
to allow the function name to be passed into the methods, with sensible defaulting.
Expand All @@ -19,6 +21,7 @@ they are converted between types using UVData and UVCalobjects.
to set several of these new parameters.

### Changed
- Increases the h5py minimum version to 3.1.
- Increase the minimum compatible version for lunarsky to 0.2.1 to fix astropy
deprecation warnings.

Expand Down Expand Up @@ -60,6 +63,10 @@ non-wide-band UVCal objects in version 3.0.
of the `phase_center_catalog`. The older phase attributes will be removed in version 3.0.
- The `lst_from_uv` function in the uvflag module.

### Removed
- Removed deprecated handling for UVCal objects without `telescope_location`,
`antenna_positions` and `lst_array` parameters defined.

## [2.2.12] - 2022-12-07

### Changed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ Note that as of v2.2, `pyuvdata` is only supported on python 3.7+.
Required:

* astropy >= 5.0.4
* h5py >= 3.0
* h5py >= 3.1
* numpy >= 1.19
* pyerfa >= 2.0
* scipy >= 1.3
* setuptools_scm
* setuptools_scm <7.0|>=7.0.3

Optional:

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 @@ -5,7 +5,7 @@ dependencies:
- astropy>=5.0.4
- numpy>=1.19.*
- scipy>=1.3
- h5py>=3.0
- h5py>=3.1
- pyerfa>=2.0
- coverage
- pytest>=6.2.0
Expand Down
2 changes: 1 addition & 1 deletion ci/pyuvdata_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- astropy>=5.0.4
- numpy>=1.19.*
- scipy>=1.3
- h5py>=3.0
- h5py>=3.1
- pyerfa>=2.0
- cython
- setuptools_scm<7.0|>=7.0.3
Expand Down
2 changes: 1 addition & 1 deletion ci/pyuvdata_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- astropy>=5.0.4
- astropy-healpix>=0.6
- astroquery>=0.4.4
- h5py>=3.0
- h5py>=3.1
- hdf5plugin>=3.1.0
- numpy>=1.19.*
- pyerfa>=2.0
Expand Down
2 changes: 1 addition & 1 deletion ci/pyuvdata_tests_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- astropy>=5.0.4
- astropy-healpix>=0.6
- astroquery>=0.4.4
- h5py>=3.0
- h5py>=3.1
- hdf5>=1.12.0
- hdf5plugin>=3.1.0
- numpy>=1.19.*
Expand Down
2 changes: 1 addition & 1 deletion ci/pyuvdata_warning_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- astropy>=5.0.4
- astropy-healpix>=0.6
- astroquery>=0.4.4
- h5py>=3.0
- h5py>=3.1
- hdf5plugin>=3.1.0
- numpy>=1.19.*
- pyerfa>=2.0
Expand Down
2 changes: 1 addition & 1 deletion environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- astroquery>=0.4.4
- coverage
- cython>=0.23
- h5py>=3.0
- h5py>=3.1
- hdf5plugin>=3.1.0
- numpy>=1.19
- pip
Expand Down
20 changes: 8 additions & 12 deletions pyuvdata/uvcal/calfits.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,12 @@ def write_calfits(
# Conforming to fits format
prihdr["SIMPLE"] = True
prihdr["TELESCOP"] = self.telescope_name
if self.telescope_location is not None:
prihdr["ARRAYX"] = self.telescope_location[0]
prihdr["ARRAYY"] = self.telescope_location[1]
prihdr["ARRAYZ"] = self.telescope_location[2]
prihdr["LAT"] = self.telescope_location_lat_lon_alt_degrees[0]
prihdr["LON"] = self.telescope_location_lat_lon_alt_degrees[1]
prihdr["ALT"] = self.telescope_location_lat_lon_alt[2]
prihdr["ARRAYX"] = self.telescope_location[0]
prihdr["ARRAYY"] = self.telescope_location[1]
prihdr["ARRAYZ"] = self.telescope_location[2]
prihdr["LAT"] = self.telescope_location_lat_lon_alt_degrees[0]
prihdr["LON"] = self.telescope_location_lat_lon_alt_degrees[1]
prihdr["ALT"] = self.telescope_location_lat_lon_alt[2]
prihdr["GNCONVEN"] = self.gain_convention
prihdr["CALTYPE"] = self.cal_type
prihdr["CALSTYLE"] = self.cal_style
Expand Down Expand Up @@ -491,11 +490,8 @@ def write_calfits(
self.ant_array, np.zeros(nants_add, dtype=np.int64) - 1
)
col3 = fits.Column(name="ANTARR", format="D", array=ant_array_use)
if self.antenna_positions is not None:
col4 = fits.Column(name="ANTXYZ", format="3D", array=self.antenna_positions)
cols = fits.ColDefs([col1, col2, col3, col4])
else:
cols = fits.ColDefs([col1, col2, col3])
col4 = fits.Column(name="ANTXYZ", format="3D", array=self.antenna_positions)
cols = fits.ColDefs([col1, col2, col3, col4])
ant_hdu = fits.BinTableHDU.from_columns(cols)
ant_hdu.header["EXTNAME"] = "ANTENNAS"

Expand Down
36 changes: 14 additions & 22 deletions pyuvdata/uvcal/tests/test_fhd_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,29 +292,21 @@ def test_break_read_fhdcal(cal_file, obs_file, layout_file, settings_file, nfile
expected_history += " Combined data along time axis using pyuvdata."
assert fhd_cal.history == expected_history

message_list = (
["No layout file, antenna_postions will not be defined."] * nfiles
+ ["UVParameter diffuse_model does not match"] * (nfiles - 1)
+ [
"The antenna_positions parameter is not set. It will be a required "
"parameter starting in pyuvdata version 2.3"
]
* (4 * nfiles - 3)
)

warning_list = [UserWarning] * (2 * nfiles - 1) + [DeprecationWarning] * (
4 * nfiles - 3
)
with uvtest.check_warnings(warning_list, message_list):
fhd_cal.read_fhd_cal(
cal_file,
obs_file,
settings_file=settings_file,
use_future_array_shapes=True,
)
message_list = [
"No layout file, antenna_postions will not be defined."
] * nfiles + ["UVParameter diffuse_model does not match"] * (nfiles - 1)

# Check no antenna_positions
assert fhd_cal.antenna_positions is None
warning_list = [UserWarning] * (2 * nfiles - 1)
with pytest.raises(
ValueError, match="Required UVParameter _antenna_positions has not been set."
):
with uvtest.check_warnings(warning_list, message_list):
fhd_cal.read_fhd_cal(
cal_file,
obs_file,
settings_file=settings_file,
use_future_array_shapes=True,
)


def test_read_multi(tmp_path):
Expand Down
151 changes: 89 additions & 62 deletions pyuvdata/uvcal/tests/test_uvcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import numpy as np
import pytest
from astropy.io import fits
from astropy.table import Table

import pyuvdata.tests as uvtest
import pyuvdata.utils as uvutils
Expand Down Expand Up @@ -313,26 +315,6 @@ def test_check(gain_data):
assert gain_data.check()


def test_check_warnings(gain_data):
"""Test that parameter checks run properly"""
gain_data.telescope_location = None
gain_data.lst_array = None
gain_data.antenna_positions = None

with uvtest.check_warnings(
DeprecationWarning,
[
"The telescope_location is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
"The antenna_positions parameter is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
"The lst_array is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
],
):
assert gain_data.check()


def test_check_flag_array(gain_data):
gain_data.flag_array = np.ones((gain_data.flag_array.shape), dtype=int)

Expand Down Expand Up @@ -492,30 +474,47 @@ def test_future_array_shape_errors(

def test_unknown_telescopes(gain_data, tmp_path):
calobj = gain_data
calobj.telescope_name = "foo"
calobj.telescope_location = None
calobj.lst_array = None
calobj.antenna_positions = None

write_file_calfits = str(tmp_path / "test.calfits")
deprecation_messages = [
"The telescope_location is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
"The antenna_positions parameter is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
"The lst_array is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
]

with uvtest.check_warnings(DeprecationWarning, match=deprecation_messages):
calobj.write_calfits(write_file_calfits, clobber=True)
write_file = str(tmp_path / "test.calfits")
write_file2 = str(tmp_path / "test2.calfits")
calobj.write_calfits(write_file)
with fits.open(write_file, memmap=True) as hdu_list:
hdunames = uvutils._fits_indexhdus(hdu_list)
primary_hdu = hdu_list[0]
primary_hdr = primary_hdu.header.copy()
del primary_hdr["ARRAYX"]
del primary_hdr["ARRAYY"]
del primary_hdr["ARRAYZ"]
del primary_hdr["LAT"]
del primary_hdr["LON"]
del primary_hdr["ALT"]
primary_hdr["TELESCOP"] = "foo"
primary_hdu.header = primary_hdr

ant_hdu = hdu_list[hdunames["ANTENNAS"]]

table = Table(ant_hdu.data)
del table["ANTXYZ"]
ant_hdu = fits.BinTableHDU(table)
ant_hdu.header["EXTNAME"] = "ANTENNAS"

hdulist = fits.HDUList([primary_hdu, ant_hdu])

hdulist.writeto(write_file2)
hdulist.close()

calobj2 = UVCal()
with pytest.raises(
ValueError, match="Required UVParameter _antenna_positions has not been set."
):
with uvtest.check_warnings(
[UserWarning], match=["Telescope foo is not in known_telescopes"]
):
calobj2.read_calfits(write_file2, use_future_array_shapes=True)
with uvtest.check_warnings(
[UserWarning] + [DeprecationWarning] * 3,
match=["Telescope foo is not in known_telescopes"] + deprecation_messages,
[UserWarning], match=["Telescope foo is not in known_telescopes"]
):
calobj2.read_calfits(write_file_calfits, use_future_array_shapes=True)
calobj2.read_calfits(write_file2, use_future_array_shapes=True, run_check=False)


def test_nants_data_telescope_larger(gain_data):
Expand Down Expand Up @@ -3348,21 +3347,29 @@ def test_match_antpos_antname(gain_data, antnamefix, tmp_path):
]

# remove the antenna_positions to test matching them on read
gain_data2 = gain_data.copy()
gain_data2.antenna_positions = None
write_file = str(tmp_path / "test.calfits")
write_file2 = str(tmp_path / "test2.calfits")
gain_data.write_calfits(write_file)
with fits.open(write_file, memmap=True) as hdu_list:
hdunames = uvutils._fits_indexhdus(hdu_list)
primary_hdu = hdu_list[0]
ant_hdu = hdu_list[hdunames["ANTENNAS"]]

write_file_calfits = str(tmp_path / "test.calfits")
with uvtest.check_warnings(
DeprecationWarning,
match="The antenna_positions parameter is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
):
gain_data2.write_calfits(write_file_calfits)
table = Table(ant_hdu.data)
del table["ANTXYZ"]
ant_hdu = fits.BinTableHDU(table)
ant_hdu.header["EXTNAME"] = "ANTENNAS"

hdulist = fits.HDUList([primary_hdu, ant_hdu])

hdulist.writeto(write_file2)
hdulist.close()

gain_data2 = UVCal()
with uvtest.check_warnings(
UserWarning, "antenna_positions is not set. Using known values for HERA."
):
gain_data2.read_calfits(write_file_calfits, use_future_array_shapes=True)
gain_data2.read_calfits(write_file2, use_future_array_shapes=True)

assert gain_data2.antenna_positions is not None
assert gain_data == gain_data2
Expand Down Expand Up @@ -3391,27 +3398,47 @@ def test_set_antpos_from_telescope_errors(gain_data, modtype, tmp_path):
gain_data.antenna_numbers[1] = orig_num

# remove the antenna_positions to test matching them on read
gain_data2 = gain_data.copy()
gain_data2.antenna_positions = None
write_file = str(tmp_path / "test.calfits")
write_file2 = str(tmp_path / "test2.calfits")
gain_data.write_calfits(write_file)
with fits.open(write_file, memmap=True) as hdu_list:
hdunames = uvutils._fits_indexhdus(hdu_list)
primary_hdu = hdu_list[0]
ant_hdu = hdu_list[hdunames["ANTENNAS"]]

write_file_calfits = str(tmp_path / "test.calfits")
with uvtest.check_warnings(
DeprecationWarning,
match="The antenna_positions parameter is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
table = Table(ant_hdu.data)
del table["ANTXYZ"]
ant_hdu = fits.BinTableHDU(table)
ant_hdu.header["EXTNAME"] = "ANTENNAS"

hdulist = fits.HDUList([primary_hdu, ant_hdu])

hdulist.writeto(write_file2)
hdulist.close()

gain_data2 = UVCal()
with pytest.raises(
ValueError, match="Required UVParameter _antenna_positions has not been set."
):
gain_data2.write_calfits(write_file_calfits)
with uvtest.check_warnings(
[UserWarning],
match=[
"Not all antennas have positions in the telescope object. "
"Not setting antenna_positions."
],
):
gain_data2.read_calfits(write_file2, use_future_array_shapes=True)

with uvtest.check_warnings(
[UserWarning, DeprecationWarning],
UserWarning,
match=[
"Not all antennas have positions in the telescope object. "
"Not setting antenna_positions.",
"The antenna_positions parameter is not set. It will be a required "
"parameter starting in pyuvdata version 2.3",
"Not setting antenna_positions."
],
):
gain_data2.read_calfits(write_file_calfits, use_future_array_shapes=True)
gain_data2.read_calfits(
write_file2, use_future_array_shapes=True, run_check=False
)

assert gain_data2.antenna_positions is None

Expand Down
Loading

0 comments on commit 31554b6

Please sign in to comment.