Skip to content

Commit ab59ca0

Browse files
Merge pull request #438 from lsst/tickets/SP-1035
SP-1305: Remove openorb dependency
2 parents 238cf10 + bc4b218 commit ab59ca0

23 files changed

+55
-37
lines changed

.github/workflows/test_and_build.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
os: ["ubuntu-latest", "macos-latest"]
24-
python-version: ["3.11"]
24+
python-version: ["3.11", "3.12"]
2525
steps:
2626
- uses: actions/checkout@v4
2727
- uses: conda-incubator/setup-miniconda@v3
2828
with:
2929
auto-update-conda: true
3030
python-version: ${{ matrix.python-version }}
3131
miniforge-variant: Miniforge3
32-
channels: conda-forge,defaults
32+
channels: conda-forge
3333
use-mamba: true
3434
channel-priority: strict
3535
show-channel-urls: true

optional-requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
openorb
2+
openorb-data-de405

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ classifiers = [
1515
"Programming Language :: Python :: 3",
1616
"Programming Language :: Python :: 3.10",
1717
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
1819
"Topic :: Scientific/Engineering :: Astronomy",
1920
]
2021
urls = {documentation = "https://rubin-sim.lsst.io", repository = "https://github.com/lsst/rubin_sim" }
@@ -38,7 +39,6 @@ dependencies = [
3839
"shapely",
3940
"skyfield",
4041
"skyproj",
41-
"pyoorb",
4242
"tqdm",
4343
"rubin-scheduler",
4444
"pyarrow",

requirements.txt

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ sqlalchemy
1111
astropy
1212
pytables
1313
h5py
14-
openorb
15-
openorb-data-de405
1614
astroplan
1715
colorcet
1816
cycler

rubin_sim/maf/maf_contrib/periodic_star_modulation_metric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def __init__(
116116
self.amplitude = amplitude
117117
self.time_interval = time_interval
118118
if random_phase:
119-
self.phase = np.NaN
119+
self.phase = np.nan
120120
else:
121121
self.phase = phase
122122
self.n_monte = n_monte

rubin_sim/maf/metrics/base_metric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(
140140
):
141141
# Turn cols into numpy array so we know
142142
# we can iterate over the columns.
143-
self.col_name_arr = np.array(col, copy=False, ndmin=1)
143+
self.col_name_arr = np.array(col, copy=None, ndmin=1)
144144
# To support simple metrics operating on a single column,
145145
# set self.colname
146146
if len(self.col_name_arr) == 1:

rubin_sim/maf/metrics/sn_cadence_metric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(
7373
def run(self, data_slice, slice_point=None):
7474
# Cut down to only include filters in correct wave range.
7575

76-
good_filters = np.in1d(data_slice["filter"], self.filter_names)
76+
good_filters = np.isin(data_slice["filter"], self.filter_names)
7777
data_slice = data_slice[good_filters]
7878
if data_slice.size == 0:
7979
return None

rubin_sim/maf/metrics/sn_n_sn_metric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def run(self, data_slice, slice_point):
254254
data_slice[self.m5_col] = new_m5
255255

256256
# select observations filter
257-
good_filters = np.in1d(data_slice[self.filter_col], list(self.bands))
257+
good_filters = np.isin(data_slice[self.filter_col], list(self.bands))
258258
data_slice = data_slice[good_filters]
259259

260260
# coaddition per night and per band (if requested by the user)

rubin_sim/maf/metrics/sn_snr_metric.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def run(self, data_slice, slice_point=None):
107107
-------
108108
detection rate : `float`
109109
"""
110-
good_filters = np.in1d(data_slice["filter"], self.filter_names)
110+
good_filters = np.isin(data_slice["filter"], self.filter_names)
111111
data_slice = data_slice[good_filters]
112112
if data_slice.size == 0:
113113
return None
@@ -134,7 +134,7 @@ def run(self, data_slice, slice_point=None):
134134
if self.info_season is None:
135135
return 0.0
136136

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

139139
detect_frac = None
140140
if len(sel) >= 5:

rubin_sim/maf/metrics/weak_lensing_systematics_metric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def run(self, data_slice, slice_point):
202202
# find all entries where exposure time is long enough and
203203
# in the detection bands
204204
exptime_msk = data_slice[self.exp_time_col] > self.min_exp_time
205-
filter_msk = np.in1d(data_slice[self.filter_col], self.det_bands)
205+
filter_msk = np.isin(data_slice[self.filter_col], self.det_bands)
206206
tot_msk = exptime_msk & filter_msk
207207

208208
res = np.sum(data_slice[self.exp_time_col][tot_msk])

rubin_sim/maf/slicers/healpix_subset_slicer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def make_wfd_subset_slicer(nside=64, use_cache=True, wfd_labels=None):
7474
if wfd_labels is None:
7575
wfd_labels = ["lowdust", "euclid_overlap", "virgo", "bulgy", "LMC_SMC"]
7676
footprints, labels = get_current_footprint(nside=nside)
77-
wfdpix = np.where(np.in1d(labels, wfd_labels))[0]
77+
wfdpix = np.where(np.isin(labels, wfd_labels))[0]
7878
slicer = HealpixSubsetSlicer(nside=nside, hpid=wfdpix, use_cache=use_cache)
7979
return slicer
8080

rubin_sim/maf/slicers/time_interval_slicers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(
5252
self,
5353
interval_seconds=90,
5454
mjd_column_name="observationStartMJD",
55-
badval=np.NaN,
55+
badval=np.nan,
5656
verbose=False,
5757
):
5858
super().__init__(verbose=verbose, badval=badval)
@@ -148,7 +148,7 @@ def __init__(
148148
mjd_column_name="observationStartMJD",
149149
duration_column_name="visitTime",
150150
note_column_name="scheduler_note",
151-
badval=np.NaN,
151+
badval=np.nan,
152152
verbose=False,
153153
):
154154
super().__init__(verbose=verbose, badval=badval)
@@ -242,7 +242,7 @@ def __init__(
242242
mjd_column_name="observationStartMJD",
243243
duration_column_name="visitTime",
244244
extra_column_names=tuple(),
245-
badval=np.NaN,
245+
badval=np.nan,
246246
verbose=False,
247247
):
248248
super().__init__(verbose=verbose, badval=badval)

rubin_sim/maf/web/maf_run_results.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def metric_ids_to_metrics(self, metric_ids, metrics=None):
177177
"""
178178
if metrics is None:
179179
metrics = self.metrics
180-
metrics = metrics[np.in1d(metrics["metric_id"], metric_ids)]
180+
metrics = metrics[np.isin(metrics["metric_id"], metric_ids)]
181181
return metrics
182182

183183
def metrics_to_metric_ids(self, metrics):
@@ -267,7 +267,7 @@ def metrics_with_plot_type(self, plot_type="SkyMap", metrics=None):
267267
if metrics is None:
268268
metrics = self.metrics
269269
# Identify the plots with the right plot_type, get their IDs.
270-
plot_match = self.plots[np.in1d(self.plots["plot_type"], plot_types)]
270+
plot_match = self.plots[np.isin(self.plots["plot_type"], plot_types)]
271271
# Convert those potentially matching metricIds to metrics,
272272
# using the subset info.
273273
metrics = self.metric_ids_to_metrics(plot_match["metric_id"], metrics)
@@ -295,7 +295,7 @@ def metrics_with_summary_stat(self, summary_stat_name="Identity", metrics=None):
295295
if metrics is None:
296296
metrics = self.metrics
297297
# Identify the potentially matching stats.
298-
stats = self.stats[np.in1d(self.stats["summary_metric"], summary_stat_name)]
298+
stats = self.stats[np.isin(self.stats["summary_metric"], summary_stat_name)]
299299
# Identify the subset of relevant metrics.
300300
metrics = self.metric_ids_to_metrics(stats["metric_id"], metrics)
301301
# Re-sort metrics because at this point, probably want displayOrder
@@ -320,7 +320,7 @@ def metrics_with_stats(self, metrics=None):
320320
if metrics is None:
321321
metrics = self.metrics
322322
# Identify metricIds which are also in stats.
323-
metrics = metrics[np.in1d(metrics["metric_id"], self.stats["metric_id"])]
323+
metrics = metrics[np.isin(metrics["metric_id"], self.stats["metric_id"])]
324324
metrics = self.sort_metrics(
325325
metrics,
326326
order=[
@@ -548,7 +548,7 @@ def order_plots(self, sky_plots):
548548
ordered_sky_plots.append(self.plot_dict(np.array([sky_plot])))
549549

550550
elif too_many_plots:
551-
metrics = self.metrics[np.in1d(self.metrics["metric_id"], sky_plots["metric_id"])]
551+
metrics = self.metrics[np.isin(self.metrics["metric_id"], sky_plots["metric_id"])]
552552
metrics = self.sort_metrics(metrics, order=["display_order"])
553553
ordered_sky_plots = []
554554
for m in metrics:
@@ -569,9 +569,9 @@ def get_sky_maps(self, metrics=None, plot_type="SkyMap"):
569569
if metrics is None:
570570
metrics = self.metrics
571571
# Match the plots to the metrics required.
572-
plot_metric_match = self.plots[np.in1d(self.plots["metric_id"], metrics["metric_id"])]
572+
plot_metric_match = self.plots[np.isin(self.plots["metric_id"], metrics["metric_id"])]
573573
# Match the plot type (which could be a list)
574-
plot_match = plot_metric_match[np.in1d(plot_metric_match["plot_type"], plot_type)]
574+
plot_match = plot_metric_match[np.isin(plot_metric_match["plot_type"], plot_type)]
575575
return plot_match
576576

577577
# Set of methods to deal with summary stats.
@@ -631,7 +631,7 @@ def all_stat_names(self, metrics):
631631
unique 'summary_metric' names in a default ordering.
632632
"""
633633
names = np.unique(
634-
self.stats["summary_metric"][np.in1d(self.stats["metric_id"], metrics["metric_id"])]
634+
self.stats["summary_metric"][np.isin(self.stats["metric_id"], metrics["metric_id"])]
635635
)
636636
names = list(names)
637637
# Add some default sorting.

rubin_sim/moving_objects/cheby_values.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def get_ephemerides(self, times, obj_ids=None, extrapolate=False):
189189
else:
190190
if isinstance(obj_ids, str) or isinstance(obj_ids, int):
191191
obj_ids = np.array([obj_ids])
192-
obj_match = np.in1d(self.coeffs["obj_id"], obj_ids)
192+
obj_match = np.isin(self.coeffs["obj_id"], obj_ids)
193193
ephemerides["obj_id"] = obj_ids
194194
# Now find ephemeris values.
195195
ephemerides["time"] = np.zeros((len(ephemerides["obj_id"]), ntimes), float) + times

rubin_sim/phot_utils/bandpass.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
import warnings
2828

2929
import numpy as np
30+
31+
try:
32+
from numpy import trapezoid as trapezoid
33+
except ImportError:
34+
from numpy import trapz as trapezoid
3035
import scipy.interpolate as interpolate
3136

3237
from rubin_sim.data import get_data_dir
@@ -322,7 +327,7 @@ def sb_tophi(self):
322327
# The definition of phi = (Sb/wavelength)/\int(Sb/wavelength)dlambda.
323328
self.phi = self.sb / self.wavelen
324329
# Normalize phi so that the integral of phi is 1.
325-
norm = np.trapz(self.phi, x=self.wavelen)
330+
norm = trapezoid(self.phi, x=self.wavelen)
326331
self.phi = self.phi / norm
327332
return
328333

rubin_sim/phot_utils/sed.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
import warnings
7979

8080
import numpy
81+
82+
try:
83+
from numpy import trapezoid as trapezoid
84+
except ImportError:
85+
from numpy import trapz as trapezoid
8186
from rubin_scheduler.data import get_data_dir
8287

8388
from .physical_parameters import PhysicalParameters
@@ -1318,7 +1323,7 @@ def calc_flux(self, bandpass, wavelen=None, fnu=None, fill=numpy.nan):
13181323
if bandpass.phi is None:
13191324
bandpass.sb_tophi()
13201325
# Calculate flux in bandpass and return this value.
1321-
flux = numpy.trapz(fnu * bandpass.phi, x=wavelen)
1326+
flux = trapezoid(fnu * bandpass.phi, x=wavelen)
13221327
return flux
13231328

13241329
def calc_mag(self, bandpass, wavelen=None, fnu=None, fill=numpy.nan):

rubin_sim/skybrightness/interp_components.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def _weighting(self, interp_points, values):
712712
self.nside, np.pi / 2.0 - interp_points["alt"], interp_points["azRelMoon"]
713713
)
714714

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

718718
norm = np.sum(hweights, axis=0)
@@ -777,7 +777,7 @@ def _weighting(self, interp_points, values):
777777
use_points["azEclipRelSun"],
778778
)
779779

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

783783
norm = np.sum(hweights, axis=0)

tests/maf/test_cadencemetrics.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import math
12
import unittest
23

34
import numpy as np
@@ -136,7 +137,7 @@ def test_t_gap_metric(self):
136137
metric = metrics.TgapsMetric(all_gaps=True, bins=np.arange(1, 100, 10))
137138
result3 = metric.run(data)
138139
self.assertEqual(result3[1], 2)
139-
ngaps = np.math.factorial(data.size - 1)
140+
ngaps = math.factorial(data.size - 1)
140141
self.assertEqual(np.sum(result3), ngaps)
141142

142143
def test_t_gaps_percent_metric(self):
@@ -187,7 +188,7 @@ def test_night_gap_metric(self):
187188
metric = metrics.NightgapsMetric(all_gaps=True, bins=np.arange(1, 100, 10))
188189
result3 = metric.run(data)
189190
self.assertEqual(result3[1], 2)
190-
ngaps = np.math.factorial(data.size - 1)
191+
ngaps = math.factorial(data.size - 1)
191192
self.assertEqual(np.sum(result3), ngaps)
192193

193194
data = np.zeros(6, dtype=list(zip(names, types)))

tests/moving_objects/test_camera.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from rubin_sim.moving_objects import BaseObs
66

77

8+
@unittest.skip("Temporary skip until ephemerides replaced")
89
class TestCamera(unittest.TestCase):
910
def setUp(self):
1011
obj_ra = np.array([10.0, 12.1], float)

tests/moving_objects/test_chebyfits.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ROOT = os.path.abspath(os.path.dirname(__file__))
1313

1414

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

137138

139+
@unittest.skip("Temporary skip until ephemerides replaced")
138140
class TestRun(unittest.TestCase):
139141
def setUp(self):
140142
self.testdir = os.path.join(get_data_dir(), "tests", "orbits_testdata")

tests/moving_objects/test_chebyvalues.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
ROOT = os.path.abspath(os.path.dirname(__file__))
1515

1616

17+
@unittest.skip("Temporary skip until ephemerides replaced")
1718
class TestChebyValues(unittest.TestCase):
1819
def setUp(self):
1920
self.testdatadir = os.path.join(get_data_dir(), "tests", "orbits_testdata")
@@ -149,6 +150,7 @@ def test_get_ephemerides(self):
149150
)
150151

151152

153+
@unittest.skip("Temporary skip until ephemerides replaced")
152154
class TestJPLValues(unittest.TestCase):
153155
# Test the interpolation-generated RA/Dec values against JPL
154156
# generated RA/Dec values.

tests/moving_objects/test_ephemerides.py

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from rubin_sim.moving_objects import Orbits, PyOrbEphemerides
1010

1111

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

155156

157+
@unittest.skip("Temporary skip until ephemerides replaced")
156158
class TestJPLValues(unittest.TestCase):
157159
"""Test the oorb generated RA/Dec values against
158160
JPL generated RA/Dec values."""

0 commit comments

Comments
 (0)