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

refactor(ephemeris): Use ch_ephem #77

Merged
merged 1 commit into from
Aug 1, 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
23 changes: 13 additions & 10 deletions ch_util/cal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
from scipy.linalg import lstsq, inv

from caput import memh5, time as ctime

from chimedb import dataset as ds
from chimedb.dataset.utils import state_id_of_type, unique_unmasked_entry
from ch_util import ephemeris, tools

from ch_ephem.observers import chime
import ch_ephem.sources

from ch_util import tools

# Set up logging
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -2474,13 +2479,13 @@ def thermal_amplitude(delta_T, freq):
def _el_to_dec(el):
"""Convert from el = sin(zenith angle) to declination in degrees."""

return np.degrees(np.arcsin(el)) + ephemeris.CHIMELATITUDE
return np.degrees(np.arcsin(el)) + chime.latitude


def _dec_to_el(dec):
"""Convert from declination in degrees to el = sin(zenith angle)."""

return np.sin(np.radians(dec - ephemeris.CHIMELATITUDE))
return np.sin(np.radians(dec - chime.latitude))


def get_reference_times_file(
Expand Down Expand Up @@ -2691,10 +2696,10 @@ def get_reference_times_dataset_id(

# The CHIME calibration sources
_source_dict = {
"cyga": ephemeris.CygA,
"casa": ephemeris.CasA,
"taua": ephemeris.TauA,
"vira": ephemeris.VirA,
"cyga": ch_ephem.sources.CygA,
"casa": ch_ephem.sources.CasA,
"taua": ch_ephem.sources.TauA,
"vira": ch_ephem.sources.VirA,
}

# Get the set of gain IDs for each time stamp
Expand Down Expand Up @@ -2728,9 +2733,7 @@ def get_reference_times_dataset_id(

# Calculate the source transit time, and sanity check it
source = _source_dict[d["source_name"]]
d["source_transit"] = ephemeris.transit_times(
source, d["gen_time"] - 24 * 3600.0
)
d["source_transit"] = chime.transit_times(source, d["gen_time"] - 24 * 3600.0)
cal_diff_hours = (d["gen_time"] - d["source_transit"]) / 3600
if cal_diff_hours > 3:
logger.warn(
Expand Down
Loading