diff --git a/CHANGELOG.md b/CHANGELOG.md index d64557d3..7812f32b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +### Changed +- Use the new pyuvdata analytic short dipole beam for polarized source testing. +- Updated minimum dependency versions: pyuvdata>=3.1.0 +- Updated minimum optional dependency versions: lunarsky>=0.2.5 + ## [1.0.1] - 2024-07-01 ### Changed diff --git a/README.md b/README.md index 0c4ee591..c0aa3381 100644 --- a/README.md +++ b/README.md @@ -69,14 +69,14 @@ Required: * h5py>=3.4 * numpy>=1.23 * scipy>=1.8 -* pyuvdata>=2.4.3 +* pyuvdata>=3.1.0 * setuptools_scm>=8.1 Optional: * astropy-healpix>=1.0.2 (for working with beams in HEALPix formats) * astroquery>=0.4.4 (for downloading GLEAM and other VizieR catalogs) -* lunarsky>=0.2.2 (for supporting telescope locations on the moon) +* lunarsky>=0.2.5 (for supporting telescope locations on the moon) We suggest using conda to install all the dependencies. To install pyuvdata, astropy-healpix and astroquery, you'll need to add conda-forge as a channel diff --git a/ci/full_deps.yaml b/ci/full_deps.yaml index 4eeee761..2f9175eb 100644 --- a/ci/full_deps.yaml +++ b/ci/full_deps.yaml @@ -11,8 +11,8 @@ dependencies: - numpy>=1.23 - pip - pytest-cov - - pyuvdata>=2.4.3 + - pyuvdata>=3.1.0 - scipy>=1.8 - setuptools_scm>=8.1 - pip: - - lunarsky>=0.2.2 + - lunarsky>=0.2.5 diff --git a/ci/min_deps.yaml b/ci/min_deps.yaml index 462fbddf..14abde52 100644 --- a/ci/min_deps.yaml +++ b/ci/min_deps.yaml @@ -8,7 +8,7 @@ dependencies: - numpy>=1.23 - pytest - pytest-cov - - pyuvdata>=2.4.3 + - pyuvdata>=3.1.0 - scipy>=1.8 - setuptools_scm>=8.1 - pip diff --git a/ci/min_versions.yaml b/ci/min_versions.yaml index 9e5ba400..dc9301be 100644 --- a/ci/min_versions.yaml +++ b/ci/min_versions.yaml @@ -11,7 +11,7 @@ dependencies: - coverage - pytest-cov - setuptools_scm==8.1 - - pyuvdata==2.4.3 + - pyuvdata==3.1.1 # 3.1.0 is not available on conda - pip - pip: - - lunarsky==0.2.2 + - lunarsky==0.2.5 diff --git a/ci/publish.yaml b/ci/publish.yaml index 29860788..431f404f 100644 --- a/ci/publish.yaml +++ b/ci/publish.yaml @@ -6,7 +6,7 @@ dependencies: - h5py>=3.4 - numpy>=1.23 - pip - - pyuvdata>=2.4.3 + - pyuvdata>=3.1.0 - scipy>=1.8 - setuptools_scm>=8.1 - pip: diff --git a/docs/references/skyh5_memo.tex b/docs/references/skyh5_memo.tex index 9fa22510..346f7e68 100644 --- a/docs/references/skyh5_memo.tex +++ b/docs/references/skyh5_memo.tex @@ -35,7 +35,7 @@ \section{Introduction} We assume that the user has a working knowledge of HDF5 and the associated python bindings in the package \texttt{h5py}\footnote{\url{https://www.h5py.org/}}, as well as \texttt{SkyModel} objects in \texttt{pyradiosky}. For more information about -HDF5, pleasevisit \url{https://portal.hdfgroup.org/display/HDF5/HDF5}. For more +HDF5, please visit \url{https://portal.hdfgroup.org/display/HDF5/HDF5}. For more information about the parameters present in a \texttt{SkyModel} object, please visit \url{https://pyradiosky.readthedocs.io/en/latest/skymodel.html}. Examples of how to interact with \texttt{SkyModel} objects in \texttt{pyradiosky} are diff --git a/environment.yaml b/environment.yaml index 46724c75..a982981c 100644 --- a/environment.yaml +++ b/environment.yaml @@ -13,9 +13,9 @@ dependencies: - pre-commit - pypandoc - pytest-cov - - pyuvdata>=2.4.3 + - pyuvdata>=3.1.0 - scipy>=1.8 - setuptools_scm>=8.1 - sphinx - pip: - - lunarsky>=0.2.2 + - lunarsky>=0.2.5 diff --git a/pyproject.toml b/pyproject.toml index 41880f38..b99d963d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ "astropy>=6.0", "h5py>=3.4", "numpy>=1.23", - "pyuvdata>=2.4.3", + "pyuvdata>=3.1.0", "scipy>=1.8", "setuptools>=64", "setuptools_scm>=8.1", @@ -42,7 +42,7 @@ classifiers = [ [project.optional-dependencies] healpix = ["astropy-healpix>=1.0.2"] astroquery = ["astroquery>=0.4.4"] -lunarsky = ["lunarsky>=0.2.2"] +lunarsky = ["lunarsky>=0.2.5"] all = ["pyradiosky[healpix,astroquery,lunarsky]"] test = ["coverage", "pre-commit", "pytest", "pytest-cov"] doc = ["matplotlib", "pypandoc", "sphinx"] diff --git a/src/pyradiosky/skymodel.py b/src/pyradiosky/skymodel.py index fb4fcf44..d3eba53c 100644 --- a/src/pyradiosky/skymodel.py +++ b/src/pyradiosky/skymodel.py @@ -9,6 +9,8 @@ import astropy.units as units import h5py import numpy as np +import pyuvdata.utils.history as history_utils +import pyuvdata.utils.tools as uvutils import scipy.io from astropy.coordinates import ( AltAz, @@ -30,15 +32,6 @@ from . import __version__, spherical_coords_transforms as sct, utils as skyutils -try: # pragma: no cover # This pragma can be removed once pyuvdata v3 is released. - import pyuvdata.utils.history as history_utils - import pyuvdata.utils.tools as uvutils -except ImportError: - # this can be removed once we require pyuvdata >= v3.0 - import pyuvdata.utils as history_utils - import pyuvdata.utils as uvutils - - __all__ = ["hasmoon", "SkyModel"] try: diff --git a/tests/test_skymodel.py b/tests/test_skymodel.py index 654deb5b..d0cd95be 100644 --- a/tests/test_skymodel.py +++ b/tests/test_skymodel.py @@ -10,15 +10,7 @@ import h5py import numpy as np import pytest - -try: - import pyuvdata.utils.history as history_utils - from pyuvdata.testing import check_warnings -except ImportError: - # this can be removed once we require pyuvdata >= v3.0 - import pyuvdata.utils as history_utils - from pyuvdata.tests import check_warnings - +import pyuvdata.utils.history as history_utils import scipy.io from astropy import units from astropy.coordinates import ( @@ -32,6 +24,8 @@ ) from astropy.time import Time, TimeDelta from astropy.units import Quantity +from pyuvdata import ShortDipoleBeam +from pyuvdata.testing import check_warnings from pyradiosky import SkyModel, skymodel, utils as skyutils from pyradiosky.data import DATA_PATH as SKY_DATA_PATH @@ -1355,22 +1349,6 @@ def test_pol_rotator(time_location, spectral_type, unpolarized, below_horizon): ) -def analytic_beam_jones(za, az, sigma=0.3): - """ - Analytic beam with sensible polarization response. - - Required for testing polarized sources. - """ - # B = np.exp(-np.tan(za/2.)**2. / 2. / sigma**2.) - B = 1 - # J alone gives you the dipole beam. - # B can be used to add another envelope in addition. - J = np.array( - [[np.cos(za) * np.sin(az), np.cos(az)], [np.cos(az) * np.cos(za), -np.sin(az)]] - ) - return B * J - - def test_polarized_source_visibilities(time_location): """Test that visibilities of a polarized source match prior calculations.""" time0, array_location = time_location @@ -1428,7 +1406,25 @@ def test_polarized_source_visibilities(time_location): coherency_matrix_local[:, :, ti] = coherency_tmp zas = np.pi / 2.0 - alts - Jbeam = analytic_beam_jones(zas, azs) + + # use pyuvdata ShortDipoleBeam for a sensible polarized response + dipole_beam = ShortDipoleBeam() + Jbeam = dipole_beam.efield_eval( + az_array=np.asarray(azs), + za_array=np.asarray(zas), + freq_array=np.asarray([150e6]), + ) + + # swap axes to put feed axis first then basis vector axis to match what is + # done in pyuvsim + Jbeam = np.transpose(Jbeam[:, :, 0].real, axes=[1, 0, 2]) + + # put ZA response first, then Az response to match what is done in pyuvsim + Jbeam = np.flip(Jbeam, axis=1) + + # put north dipole first, then east to match test data + Jbeam = np.flip(Jbeam, axis=0) + coherency_instr_local = np.einsum( "ab...,bc...,dc...->ad...", Jbeam, coherency_matrix_local, np.conj(Jbeam) ) @@ -1538,7 +1534,25 @@ def test_polarized_source_smooth_visibilities( coherency_matrix_local[:, :, ti] = coherency_tmp zas = np.pi / 2.0 - alts - Jbeam = analytic_beam_jones(zas, azs) + + # use pyuvdata ShortDipoleBeam for a sensible polarized response + dipole_beam = ShortDipoleBeam() + Jbeam = dipole_beam.efield_eval( + az_array=np.asarray(azs), + za_array=np.asarray(zas), + freq_array=np.asarray([150e6]), + ) + + # swap axes to put feed axis first then basis vector axis to match what is + # done in pyuvsim + Jbeam = np.transpose(Jbeam[:, :, 0].real, axes=[1, 0, 2]) + + # put ZA response first, then Az response to match what is done in pyuvsim + Jbeam = np.flip(Jbeam, axis=1) + + # put north dipole first, then east to match test data + Jbeam = np.flip(Jbeam, axis=0) + coherency_instr_local = np.einsum( "ab...,bc...,dc...->ad...", Jbeam, coherency_matrix_local, np.conj(Jbeam) )