Skip to content
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
2 changes: 1 addition & 1 deletion agasc/scripts/mag_estimate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def main():
stars = np.unique(obs_stats[ok]["agasc_id"])
sections = [{"id": "stars", "title": "Stars", "stars": stars}]

agasc_stats = agasc_stats[np.in1d(agasc_stats["agasc_id"], stars)]
agasc_stats = agasc_stats[np.isin(agasc_stats["agasc_id"], stars)]

if args.weekly_report:
t = CxoTime(args.stop)
Expand Down
2 changes: 1 addition & 1 deletion agasc/supplement/magnitudes/mag_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def get_telemetry(obs):
telem = {"times": times}
telem.update({k: slot_data[k] for k in slot_data_cols[2:]})
telem.update(
{name: msids[name].vals[np.in1d(msids[name].times, times)] for name in names}
{name: msids[name].vals[np.isin(msids[name].times, times)] for name in names}
)

# get the normal sun and safe sun mode intervals, which will be removed
Expand Down
10 changes: 5 additions & 5 deletions agasc/supplement/magnitudes/mag_estimate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def multi_star_html(
"id": "other_stars",
"title": "Other Stars",
"stars": self.agasc_stats["agasc_id"][
~np.in1d(self.agasc_stats["agasc_id"], agasc_ids)
~np.isin(self.agasc_stats["agasc_id"], agasc_ids)
],
}
)
Expand Down Expand Up @@ -290,15 +290,15 @@ def multi_star_html(
agasc_stats["t_mean_dr3"] - agasc_stats["mag_aca"]
) / agasc_stats["mag_aca_err"]
agasc_stats["new"] = True
agasc_stats["new"][np.in1d(agasc_stats["agasc_id"], updated_star_ids)] = (
agasc_stats["new"][np.isin(agasc_stats["agasc_id"], updated_star_ids)] = (
False
)
agasc_stats["update_mag_aca"] = np.nan
agasc_stats["update_mag_aca_err"] = np.nan
agasc_stats["last_obs"] = CxoTime(agasc_stats["last_obs_time"]).date

if len(updated_stars) > 0:
in_agasc_stats = np.in1d(updated_stars["agasc_id"], agasc_stats["agasc_id"])
in_agasc_stats = np.isin(updated_stars["agasc_id"], agasc_stats["agasc_id"])
if np.any(~in_agasc_stats):
# This should never happen in weekly processing, because updated_stars is created
# in update_mag_supplement.update_supplement. If there is an error, it will mean
Expand Down Expand Up @@ -349,7 +349,7 @@ def multi_star_html(
sections = [section for section in sections if len(section["stars"])]
for section in sections:
section["stars"] = agasc_stats[
np.in1d(agasc_stats["agasc_id"], section["stars"])
np.isin(agasc_stats["agasc_id"], section["stars"])
].as_array()

# this is a hack
Expand Down Expand Up @@ -538,7 +538,7 @@ def plot_agasc_id_single(
# set flags for different categories of markers
highlighted = np.zeros(len(timeline["times"]), dtype=bool)
if highlight_obsid:
highlighted = highlighted | np.in1d(timeline["obsid"], highlight_obsid)
highlighted = highlighted | np.isin(timeline["obsid"], highlight_obsid)
if highlight_outliers:
highlighted = highlighted | timeline["obs_outlier"]

Expand Down
2 changes: 1 addition & 1 deletion agasc/supplement/magnitudes/star_obs_catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_star_observations(start=None, stop=None, obsid=None):
catalogs = commands.get_starcats_as_table(
start=start, stop=stop, obsid=obsid, unique=True
)
catalogs = catalogs[np.in1d(catalogs["type"], ["BOT", "GUI"])]
catalogs = catalogs[np.isin(catalogs["type"], ["BOT", "GUI"])]
star_obs = join(observations, catalogs, keys=join_keys)
star_obs.rename_columns(["id", "starcat_date"], ["agasc_id", "mp_starcat_time"])
star_obs["row"], star_obs["col"] = yagzag_to_pixels(
Expand Down
12 changes: 6 additions & 6 deletions agasc/supplement/magnitudes/update_mag_supplement.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def update_supplement(agasc_stats, filename, include_all=True, d_mag_threshold=0
updated_stars["agasc_id"] = new["agasc_id"]

# find agasc_ids in new list but not in current list
new_stars = ~np.in1d(
new_stars = ~np.isin(
outliers_new["agasc_id"], outliers_current["agasc_id"]
)

Expand Down Expand Up @@ -547,7 +547,7 @@ def do(

agasc_ids = np.unique(agasc_ids)
stars_obs = star_obs_catalogs.STARS_OBS[
np.in1d(star_obs_catalogs.STARS_OBS["agasc_id"], agasc_ids)
np.isin(star_obs_catalogs.STARS_OBS["agasc_id"], agasc_ids)
]

# if supplement exists:
Expand All @@ -562,7 +562,7 @@ def do(
if not include_bad and "bad" in h5.root:
logger.info("Excluding bad stars")
stars_obs = stars_obs[
~np.in1d(stars_obs["agasc_id"], h5.root.bad[:]["agasc_id"])
~np.isin(stars_obs["agasc_id"], h5.root.bad[:]["agasc_id"])
]

if "obs" in h5.root:
Expand Down Expand Up @@ -611,7 +611,7 @@ def do(
)

stars_obs = stars_obs[
np.in1d(stars_obs["agasc_id"], times[update]["agasc_id"])
np.isin(stars_obs["agasc_id"], times[update]["agasc_id"])
]
agasc_ids = np.sort(np.unique(stars_obs["agasc_id"]))
if len(update) - np.sum(update):
Expand Down Expand Up @@ -757,8 +757,8 @@ def do(
"title": "Other (unexpectedly not updated)",
"stars": list(
agasc_stats["agasc_id"][
~np.in1d(agasc_stats["agasc_id"], new_stars)
& ~np.in1d(
~np.isin(agasc_stats["agasc_id"], new_stars)
& ~np.isin(
agasc_stats["agasc_id"], updated_stars["agasc_id"]
)
]
Expand Down
4 changes: 2 additions & 2 deletions agasc/supplement/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ def update_table(filename, table, path, dtype, keys, dry_run=False, create=False
i, j = np.argwhere(intersect).T

# entries not yet in supplement
append = ~np.in1d(table[keys[0]], suppl_table[keys[0]])
append = ~np.isin(table[keys[0]], suppl_table[keys[0]])
for key in keys[1:]:
append |= ~np.in1d(table[key], suppl_table[key])
append |= ~np.isin(table[key], suppl_table[key])
k = np.argwhere(append).T

if not len(i) and not len(k[0]):
Expand Down
4 changes: 2 additions & 2 deletions agasc/tests/test_agasc_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@


def get_ds_agasc_cone(ra, dec):
cmd = "mp_get_agasc -r {!r} -d {!r} -w {!r}".format(ra, dec, TEST_RADIUS)
cmd = "mp_get_agasc -r {} -d {} -w {}".format(ra, dec, TEST_RADIUS)
lines = Ska.Shell.tcsh(cmd, env=ascds_env)
dat = ascii.read(lines, format="no_header", names=AGASC_COLNAMES)

Expand Down Expand Up @@ -362,7 +362,7 @@ def test_add_pmcorr_is_consistent(agasc_id, date, ra_pmcorr, dec_pmcorr, label):


def mp_get_agascid(agasc_id):
cmd = "mp_get_agascid {!r}".format(agasc_id)
cmd = "mp_get_agascid {}".format(agasc_id)
lines = Ska.Shell.tcsh(cmd, env=ascds_env)
lines = [line for line in lines if re.match(r"^\s*\d", line)]
dat = ascii.read(lines, format="no_header", names=AGASC_COLNAMES)
Expand Down
12 changes: 6 additions & 6 deletions agasc/tests/test_obs_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,10 +1227,10 @@ def test_override(monkeypatch):
agasc_stats["n_obsids_suspect"] == 2
) # two suspect count as "fail" in this context
assert not np.isclose(
np.mean(telem[np.in1d(telem["obsid"], [12800])]["mags"]), agasc_stats["mag_obs"]
np.mean(telem[np.isin(telem["obsid"], [12800])]["mags"]), agasc_stats["mag_obs"]
)
assert np.isclose(
np.mean(telem[np.in1d(telem["obsid"], [12800, 23682, 23683])]["mags"]),
np.mean(telem[np.isin(telem["obsid"], [12800, 23682, 23683])]["mags"]),
agasc_stats["mag_obs"],
)

Expand All @@ -1253,10 +1253,10 @@ def test_override(monkeypatch):
agasc_stats["n_obsids_suspect"] == 0
) # no fails because all status==1 skipped
assert np.isclose(
np.mean(telem[np.in1d(telem["obsid"], [12800])]["mags"]), agasc_stats["mag_obs"]
np.mean(telem[np.isin(telem["obsid"], [12800])]["mags"]), agasc_stats["mag_obs"]
)
assert not np.isclose(
np.mean(telem[np.in1d(telem["obsid"], [12800, 23682, 23683])]["mags"]),
np.mean(telem[np.isin(telem["obsid"], [12800, 23682, 23683])]["mags"]),
agasc_stats["mag_obs"],
)

Expand All @@ -1276,7 +1276,7 @@ def test_override(monkeypatch):
assert agasc_stats["n_obsids_ok"] == 3
assert agasc_stats["n_obsids_suspect"] == 1 # one failed
assert np.isclose(
np.mean(telem[np.in1d(telem["obsid"], [12800, 23681, 23683])]["mags"]),
np.mean(telem[np.isin(telem["obsid"], [12800, 23681, 23683])]["mags"]),
agasc_stats["mag_obs"],
)

Expand Down Expand Up @@ -1346,7 +1346,7 @@ def recreate_mag_stats_test_data(filename=TEST_DATA_DIR / "mag-stats.h5"):
"2018:296:15:53:14.596",
]
STARS_OBS = star_obs_catalogs.STARS_OBS[
np.in1d(star_obs_catalogs.STARS_OBS["mp_starcat_time"], mp_starcat_time)
np.isin(star_obs_catalogs.STARS_OBS["mp_starcat_time"], mp_starcat_time)
]
STARS_OBS = STARS_OBS.group_by("agasc_id")
STARS_OBS.add_index("agasc_id")
Expand Down