Skip to content

Commit

Permalink
feat(ephemeris): Import functions moved to caput (#72)
Browse files Browse the repository at this point in the history
In radiocosmology/caput#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.
  • Loading branch information
ketiltrout authored Jul 16, 2024
1 parent c460b37 commit 5db74ef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 45 deletions.
46 changes: 3 additions & 43 deletions ch_util/ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
- :py:meth:`galt_pointing_model_ha`
- :py:meth:`galt_pointing_model_dec`
- :py:meth:`sphdist`
"""

from datetime import datetime
Expand All @@ -108,6 +107,7 @@

import numpy as np

from caput.interferometry import sphdist
from caput.time import (
unix_to_datetime,
datetime_to_unix,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ch_util/holography.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5db74ef

Please sign in to comment.