Skip to content

Commit

Permalink
Merge pull request #438 from lsst/tickets/SP-1035
Browse files Browse the repository at this point in the history
SP-1305: Remove openorb dependency
  • Loading branch information
rhiannonlynne authored Jan 18, 2025
2 parents 238cf10 + bc4b218 commit ab59ca0
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test_and_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
python-version: ["3.11"]
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
miniforge-variant: Miniforge3
channels: conda-forge,defaults
channels: conda-forge
use-mamba: true
channel-priority: strict
show-channel-urls: true
Expand Down
2 changes: 2 additions & 0 deletions optional-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
openorb
openorb-data-de405
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Astronomy",
]
urls = {documentation = "https://rubin-sim.lsst.io", repository = "https://github.com/lsst/rubin_sim" }
Expand All @@ -38,7 +39,6 @@ dependencies = [
"shapely",
"skyfield",
"skyproj",
"pyoorb",
"tqdm",
"rubin-scheduler",
"pyarrow",
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ sqlalchemy
astropy
pytables
h5py
openorb
openorb-data-de405
astroplan
colorcet
cycler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(
self.amplitude = amplitude
self.time_interval = time_interval
if random_phase:
self.phase = np.NaN
self.phase = np.nan
else:
self.phase = phase
self.n_monte = n_monte
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/base_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(
):
# Turn cols into numpy array so we know
# we can iterate over the columns.
self.col_name_arr = np.array(col, copy=False, ndmin=1)
self.col_name_arr = np.array(col, copy=None, ndmin=1)
# To support simple metrics operating on a single column,
# set self.colname
if len(self.col_name_arr) == 1:
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/sn_cadence_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
def run(self, data_slice, slice_point=None):
# Cut down to only include filters in correct wave range.

good_filters = np.in1d(data_slice["filter"], self.filter_names)
good_filters = np.isin(data_slice["filter"], self.filter_names)
data_slice = data_slice[good_filters]
if data_slice.size == 0:
return None
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/sn_n_sn_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def run(self, data_slice, slice_point):
data_slice[self.m5_col] = new_m5

# select observations filter
good_filters = np.in1d(data_slice[self.filter_col], list(self.bands))
good_filters = np.isin(data_slice[self.filter_col], list(self.bands))
data_slice = data_slice[good_filters]

# coaddition per night and per band (if requested by the user)
Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/maf/metrics/sn_snr_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def run(self, data_slice, slice_point=None):
-------
detection rate : `float`
"""
good_filters = np.in1d(data_slice["filter"], self.filter_names)
good_filters = np.isin(data_slice["filter"], self.filter_names)
data_slice = data_slice[good_filters]
if data_slice.size == 0:
return None
Expand All @@ -134,7 +134,7 @@ def run(self, data_slice, slice_point=None):
if self.info_season is None:
return 0.0

sel = data_slice[np.in1d(data_slice["season"], np.array(seasons))]
sel = data_slice[np.isin(data_slice["season"], np.array(seasons))]

detect_frac = None
if len(sel) >= 5:
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/weak_lensing_systematics_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def run(self, data_slice, slice_point):
# find all entries where exposure time is long enough and
# in the detection bands
exptime_msk = data_slice[self.exp_time_col] > self.min_exp_time
filter_msk = np.in1d(data_slice[self.filter_col], self.det_bands)
filter_msk = np.isin(data_slice[self.filter_col], self.det_bands)
tot_msk = exptime_msk & filter_msk

res = np.sum(data_slice[self.exp_time_col][tot_msk])
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/slicers/healpix_subset_slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def make_wfd_subset_slicer(nside=64, use_cache=True, wfd_labels=None):
if wfd_labels is None:
wfd_labels = ["lowdust", "euclid_overlap", "virgo", "bulgy", "LMC_SMC"]
footprints, labels = get_current_footprint(nside=nside)
wfdpix = np.where(np.in1d(labels, wfd_labels))[0]
wfdpix = np.where(np.isin(labels, wfd_labels))[0]
slicer = HealpixSubsetSlicer(nside=nside, hpid=wfdpix, use_cache=use_cache)
return slicer

Expand Down
6 changes: 3 additions & 3 deletions rubin_sim/maf/slicers/time_interval_slicers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(
self,
interval_seconds=90,
mjd_column_name="observationStartMJD",
badval=np.NaN,
badval=np.nan,
verbose=False,
):
super().__init__(verbose=verbose, badval=badval)
Expand Down Expand Up @@ -148,7 +148,7 @@ def __init__(
mjd_column_name="observationStartMJD",
duration_column_name="visitTime",
note_column_name="scheduler_note",
badval=np.NaN,
badval=np.nan,
verbose=False,
):
super().__init__(verbose=verbose, badval=badval)
Expand Down Expand Up @@ -242,7 +242,7 @@ def __init__(
mjd_column_name="observationStartMJD",
duration_column_name="visitTime",
extra_column_names=tuple(),
badval=np.NaN,
badval=np.nan,
verbose=False,
):
super().__init__(verbose=verbose, badval=badval)
Expand Down
16 changes: 8 additions & 8 deletions rubin_sim/maf/web/maf_run_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def metric_ids_to_metrics(self, metric_ids, metrics=None):
"""
if metrics is None:
metrics = self.metrics
metrics = metrics[np.in1d(metrics["metric_id"], metric_ids)]
metrics = metrics[np.isin(metrics["metric_id"], metric_ids)]
return metrics

def metrics_to_metric_ids(self, metrics):
Expand Down Expand Up @@ -267,7 +267,7 @@ def metrics_with_plot_type(self, plot_type="SkyMap", metrics=None):
if metrics is None:
metrics = self.metrics
# Identify the plots with the right plot_type, get their IDs.
plot_match = self.plots[np.in1d(self.plots["plot_type"], plot_types)]
plot_match = self.plots[np.isin(self.plots["plot_type"], plot_types)]
# Convert those potentially matching metricIds to metrics,
# using the subset info.
metrics = self.metric_ids_to_metrics(plot_match["metric_id"], metrics)
Expand Down Expand Up @@ -295,7 +295,7 @@ def metrics_with_summary_stat(self, summary_stat_name="Identity", metrics=None):
if metrics is None:
metrics = self.metrics
# Identify the potentially matching stats.
stats = self.stats[np.in1d(self.stats["summary_metric"], summary_stat_name)]
stats = self.stats[np.isin(self.stats["summary_metric"], summary_stat_name)]
# Identify the subset of relevant metrics.
metrics = self.metric_ids_to_metrics(stats["metric_id"], metrics)
# Re-sort metrics because at this point, probably want displayOrder
Expand All @@ -320,7 +320,7 @@ def metrics_with_stats(self, metrics=None):
if metrics is None:
metrics = self.metrics
# Identify metricIds which are also in stats.
metrics = metrics[np.in1d(metrics["metric_id"], self.stats["metric_id"])]
metrics = metrics[np.isin(metrics["metric_id"], self.stats["metric_id"])]
metrics = self.sort_metrics(
metrics,
order=[
Expand Down Expand Up @@ -548,7 +548,7 @@ def order_plots(self, sky_plots):
ordered_sky_plots.append(self.plot_dict(np.array([sky_plot])))

elif too_many_plots:
metrics = self.metrics[np.in1d(self.metrics["metric_id"], sky_plots["metric_id"])]
metrics = self.metrics[np.isin(self.metrics["metric_id"], sky_plots["metric_id"])]
metrics = self.sort_metrics(metrics, order=["display_order"])
ordered_sky_plots = []
for m in metrics:
Expand All @@ -569,9 +569,9 @@ def get_sky_maps(self, metrics=None, plot_type="SkyMap"):
if metrics is None:
metrics = self.metrics
# Match the plots to the metrics required.
plot_metric_match = self.plots[np.in1d(self.plots["metric_id"], metrics["metric_id"])]
plot_metric_match = self.plots[np.isin(self.plots["metric_id"], metrics["metric_id"])]
# Match the plot type (which could be a list)
plot_match = plot_metric_match[np.in1d(plot_metric_match["plot_type"], plot_type)]
plot_match = plot_metric_match[np.isin(plot_metric_match["plot_type"], plot_type)]
return plot_match

# Set of methods to deal with summary stats.
Expand Down Expand Up @@ -631,7 +631,7 @@ def all_stat_names(self, metrics):
unique 'summary_metric' names in a default ordering.
"""
names = np.unique(
self.stats["summary_metric"][np.in1d(self.stats["metric_id"], metrics["metric_id"])]
self.stats["summary_metric"][np.isin(self.stats["metric_id"], metrics["metric_id"])]
)
names = list(names)
# Add some default sorting.
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/moving_objects/cheby_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def get_ephemerides(self, times, obj_ids=None, extrapolate=False):
else:
if isinstance(obj_ids, str) or isinstance(obj_ids, int):
obj_ids = np.array([obj_ids])
obj_match = np.in1d(self.coeffs["obj_id"], obj_ids)
obj_match = np.isin(self.coeffs["obj_id"], obj_ids)
ephemerides["obj_id"] = obj_ids
# Now find ephemeris values.
ephemerides["time"] = np.zeros((len(ephemerides["obj_id"]), ntimes), float) + times
Expand Down
7 changes: 6 additions & 1 deletion rubin_sim/phot_utils/bandpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
import warnings

import numpy as np

try:
from numpy import trapezoid as trapezoid
except ImportError:
from numpy import trapz as trapezoid
import scipy.interpolate as interpolate

from rubin_sim.data import get_data_dir
Expand Down Expand Up @@ -322,7 +327,7 @@ def sb_tophi(self):
# The definition of phi = (Sb/wavelength)/\int(Sb/wavelength)dlambda.
self.phi = self.sb / self.wavelen
# Normalize phi so that the integral of phi is 1.
norm = np.trapz(self.phi, x=self.wavelen)
norm = trapezoid(self.phi, x=self.wavelen)
self.phi = self.phi / norm
return

Expand Down
7 changes: 6 additions & 1 deletion rubin_sim/phot_utils/sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
import warnings

import numpy

try:
from numpy import trapezoid as trapezoid
except ImportError:
from numpy import trapz as trapezoid
from rubin_scheduler.data import get_data_dir

from .physical_parameters import PhysicalParameters
Expand Down Expand Up @@ -1318,7 +1323,7 @@ def calc_flux(self, bandpass, wavelen=None, fnu=None, fill=numpy.nan):
if bandpass.phi is None:
bandpass.sb_tophi()
# Calculate flux in bandpass and return this value.
flux = numpy.trapz(fnu * bandpass.phi, x=wavelen)
flux = trapezoid(fnu * bandpass.phi, x=wavelen)
return flux

def calc_mag(self, bandpass, wavelen=None, fnu=None, fill=numpy.nan):
Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/skybrightness/interp_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def _weighting(self, interp_points, values):
self.nside, np.pi / 2.0 - interp_points["alt"], interp_points["azRelMoon"]
)

badhp = np.in1d(hpids.ravel(), self.dim_dict["hpid"], invert=True).reshape(hpids.shape)
badhp = np.isin(hpids.ravel(), self.dim_dict["hpid"], invert=True).reshape(hpids.shape)
hweights[badhp] = 0.0

norm = np.sum(hweights, axis=0)
Expand Down Expand Up @@ -777,7 +777,7 @@ def _weighting(self, interp_points, values):
use_points["azEclipRelSun"],
)

badhp = np.in1d(hpids.ravel(), self.dim_dict["hpid"], invert=True).reshape(hpids.shape)
badhp = np.isin(hpids.ravel(), self.dim_dict["hpid"], invert=True).reshape(hpids.shape)
hweights[badhp] = 0.0

norm = np.sum(hweights, axis=0)
Expand Down
5 changes: 3 additions & 2 deletions tests/maf/test_cadencemetrics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import unittest

import numpy as np
Expand Down Expand Up @@ -136,7 +137,7 @@ def test_t_gap_metric(self):
metric = metrics.TgapsMetric(all_gaps=True, bins=np.arange(1, 100, 10))
result3 = metric.run(data)
self.assertEqual(result3[1], 2)
ngaps = np.math.factorial(data.size - 1)
ngaps = math.factorial(data.size - 1)
self.assertEqual(np.sum(result3), ngaps)

def test_t_gaps_percent_metric(self):
Expand Down Expand Up @@ -187,7 +188,7 @@ def test_night_gap_metric(self):
metric = metrics.NightgapsMetric(all_gaps=True, bins=np.arange(1, 100, 10))
result3 = metric.run(data)
self.assertEqual(result3[1], 2)
ngaps = np.math.factorial(data.size - 1)
ngaps = math.factorial(data.size - 1)
self.assertEqual(np.sum(result3), ngaps)

data = np.zeros(6, dtype=list(zip(names, types)))
Expand Down
1 change: 1 addition & 0 deletions tests/moving_objects/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from rubin_sim.moving_objects import BaseObs


@unittest.skip("Temporary skip until ephemerides replaced")
class TestCamera(unittest.TestCase):
def setUp(self):
obj_ra = np.array([10.0, 12.1], float)
Expand Down
2 changes: 2 additions & 0 deletions tests/moving_objects/test_chebyfits.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ROOT = os.path.abspath(os.path.dirname(__file__))


@unittest.skip("Temporary skip until ephemerides replaced")
class TestChebyFits(unittest.TestCase):
def setUp(self):
self.testdir = os.path.join(get_data_dir(), "tests", "orbits_testdata")
Expand Down Expand Up @@ -135,6 +136,7 @@ def test_write(self):
self.assertTrue(os.path.isfile(resid_name))


@unittest.skip("Temporary skip until ephemerides replaced")
class TestRun(unittest.TestCase):
def setUp(self):
self.testdir = os.path.join(get_data_dir(), "tests", "orbits_testdata")
Expand Down
2 changes: 2 additions & 0 deletions tests/moving_objects/test_chebyvalues.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ROOT = os.path.abspath(os.path.dirname(__file__))


@unittest.skip("Temporary skip until ephemerides replaced")
class TestChebyValues(unittest.TestCase):
def setUp(self):
self.testdatadir = os.path.join(get_data_dir(), "tests", "orbits_testdata")
Expand Down Expand Up @@ -149,6 +150,7 @@ def test_get_ephemerides(self):
)


@unittest.skip("Temporary skip until ephemerides replaced")
class TestJPLValues(unittest.TestCase):
# Test the interpolation-generated RA/Dec values against JPL
# generated RA/Dec values.
Expand Down
2 changes: 2 additions & 0 deletions tests/moving_objects/test_ephemerides.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rubin_sim.moving_objects import Orbits, PyOrbEphemerides


@unittest.skip("Temporary skip until ephemerides replaced")
class TestPyOrbEphemerides(unittest.TestCase):
def setUp(self):
self.testdir = os.path.join(get_data_dir(), "tests", "orbits_testdata")
Expand Down Expand Up @@ -153,6 +154,7 @@ def test_ephemeris(self):
np.testing.assert_allclose(ephs_all_kep[column], ephs_all[column], rtol=1e-5, atol=1e-4)


@unittest.skip("Temporary skip until ephemerides replaced")
class TestJPLValues(unittest.TestCase):
"""Test the oorb generated RA/Dec values against
JPL generated RA/Dec values."""
Expand Down
Loading

0 comments on commit ab59ca0

Please sign in to comment.