From 5db74efecb12e77dc8716daf79e4d3f124fc19c7 Mon Sep 17 00:00:00 2001 From: ketiltrout Date: Tue, 16 Jul 2024 10:55:33 -0700 Subject: [PATCH] feat(ephemeris): Import functions moved to caput (#72) In https://github.com/radiocosmology/caput/pull/269: * `ch_util.ephemeris.sphdist` has been moved to `caput.interferometry.sphdist` * `drift.telescope.cylbeam.rotate_ypr` has been moved to `caput.interferometry.rotate_ypr` Updated `ch_util/holography.py` to use the caput version of `sphdist` directly. This removes the `driftscan` dependency. --- ch_util/ephemeris.py | 46 +++---------------------------------------- ch_util/holography.py | 2 +- requirements.txt | 1 - 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/ch_util/ephemeris.py b/ch_util/ephemeris.py index c8203a74..35e886b8 100644 --- a/ch_util/ephemeris.py +++ b/ch_util/ephemeris.py @@ -96,7 +96,6 @@ - :py:meth:`galt_pointing_model_ha` - :py:meth:`galt_pointing_model_dec` -- :py:meth:`sphdist` """ from datetime import datetime @@ -108,6 +107,7 @@ import numpy as np +from caput.interferometry import sphdist from caput.time import ( unix_to_datetime, datetime_to_unix, @@ -355,42 +355,6 @@ def utc_lst_to_mjd(datestring, lst, obs=chime): ) -def sphdist(long1, lat1, long2, lat2): - """ - Return the angular distance between two coordinates. - - Parameters - ---------- - - long1, lat1 : Skyfield Angle objects - longitude and latitude of the first coordinate. Each should be the - same length; can be one or longer. - - long2, lat2 : Skyfield Angle objects - longitude and latitude of the second coordinate. Each should be the - same length. If long1, lat1 have length longer than 1, long2 and - lat2 should either have the same length as coordinate 1 or length 1. - - Returns - ------- - dist : Skyfield Angle object - angle between the two coordinates - """ - from skyfield.positionlib import Angle - - dsinb = np.sin((lat1.radians - lat2.radians) / 2.0) ** 2 - - dsinl = ( - np.cos(lat1.radians) - * np.cos(lat2.radians) - * (np.sin((long1.radians - long2.radians) / 2.0)) ** 2 - ) - - dist = np.arcsin(np.sqrt(dsinl + dsinb)) - - return Angle(radians=2 * dist) - - def solar_transit(start_time, end_time=None, obs=chime): """Find the Solar transits between two times for CHIME. @@ -715,12 +679,10 @@ def hadec_to_bmxy(ha_cirs, dec_cirs): https://chime-frb-open-data.github.io/beam-model/#coordinate-conventions """ - from caput.interferometry import sph_to_ground + from caput.interferometry import rotate_ypr, sph_to_ground from ch_util.tools import _CHIME_ROT - from drift.telescope.cylbeam import rotate_ypr - # Convert CIRS coordinates to CHIME "ground fixed" XYZ coordinates, # which constitute a unit vector pointing towards the point of interest, # i.e., telescope cartesian unit-sphere coordinates. @@ -773,12 +735,10 @@ def bmxy_to_hadec(bmx, bmy): """ import warnings - from caput.interferometry import ground_to_sph + from caput.interferometry import rotate_ypr, ground_to_sph from ch_util.tools import _CHIME_ROT - from drift.telescope.cylbeam import rotate_ypr - # Convert CHIME/FRB beam model XY position to spherical polar coordinates # with the pole towards almost-North and using CHIME's meridian as the prime # meridian. Note that the CHIME/FRB beam model X coordinate increases westward diff --git a/ch_util/holography.py b/ch_util/holography.py index 1b1a49b7..c74bfc5f 100644 --- a/ch_util/holography.py +++ b/ch_util/holography.py @@ -257,7 +257,7 @@ def create_from_ant_logs( none """ - from ch_util.ephemeris import sphdist + from caput.interferometry import sphdist from skyfield.positionlib import Angle ts = ephemeris.skyfield_wrapper.timescale diff --git a/requirements.txt b/requirements.txt index a1589199..b75f68e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,3 @@ bitshuffle caput[compression] @ git+https://github.com/radiocosmology/caput.git skyfield >= 1.10 mpi4py -driftscan @ git+https://github.com/radiocosmology/driftscan.git