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

feat(ephemeris): Import functions moved to caput #72

Merged
merged 1 commit into from
Jul 16, 2024
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
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
Loading