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

Plotting candidates in skymap, plot t_min in lightcurves #177

Merged
merged 3 commits into from
Nov 11, 2022
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
6 changes: 5 additions & 1 deletion nuztf/base_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,12 @@ def create_candidate_summary(self, outfile=None):
for (name, alert) in tqdm(sorted(self.cache.items())):

fig, _ = lightcurve_from_alert(
[alert], include_cutouts=True, logger=self.logger
[alert],
include_cutouts=True,
logger=self.logger,
t_0_mjd=self.t_min.mjd,
)

pdf.savefig()
plt.close()

Expand Down
39 changes: 26 additions & 13 deletions nuztf/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def alert_to_pandas(alert):
df_ulims_list.append(_df)

df_detections = pd.concat(df_detections_list)
df_ulims = pd.concat(df_ulims_list)
if len(df_ulims_list) > 0:
df_ulims = pd.concat(df_ulims_list)
else:
df_ulims = None

return df_detections, df_ulims

Expand All @@ -59,6 +62,7 @@ def lightcurve_from_alert(
z: float = None,
legend: bool = False,
grid_interval: int = None,
t_0_mjd: float = None,
logger=None,
):
"""plot AMPEL alerts as lightcurve"""
Expand Down Expand Up @@ -190,16 +194,17 @@ def absmag_to_mag(absmag):
)

# Plot upper limits
if include_ulims:
df_temp2 = df_ulims.query("fid == @fid")
lc_ax1.scatter(
df_temp2["mjd"],
df_temp2["diffmaglim"],
c=BAND_COLORS[fid],
marker="v",
s=1.3,
alpha=0.5,
)
if df_ulims is not None:
if include_ulims:
df_temp2 = df_ulims.query("fid == @fid")
lc_ax1.scatter(
df_temp2["mjd"],
df_temp2["diffmaglim"],
c=BAND_COLORS[fid],
marker="v",
s=1.3,
alpha=0.5,
)

# Plot datapoint from alert
df_temp = df.iloc[0]
Expand Down Expand Up @@ -257,9 +262,17 @@ def absmag_to_mag(absmag):
alpha=0.5,
)

if t_0_mjd is not None:
lc_ax1.axvline(t_0_mjd, linestyle=":")
else:
t_0_mjd = np.mean(df.mjd.values)

# Ugly hack because secondary_axis does not work with astropy.time.Time datetime conversion
mjd_min = np.min(df.mjd.values)
mjd_max = np.max(df.mjd.values)
mjd_min = min(np.min(df.mjd.values), t_0_mjd)

print(mjd_min, t_0_mjd)

mjd_max = max(np.max(df.mjd.values), t_0_mjd)
length = mjd_max - mjd_min

lc_ax1.set_xlim([mjd_min - (length / 20), mjd_max + (length / 20)])
Expand Down
15 changes: 14 additions & 1 deletion nuztf/skymap_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,24 @@ def plot_skymap(self):

return fig

def plot_coverage(self):
def plot_coverage(self, plot_candidates: bool = True):
"""Plot ZTF coverage of skymap region"""
fig, message = self.plot_overlap_with_observations(
first_det_window_days=self.n_days
)

if plot_candidates:
for candidate, res in self.cache.items():

ra = np.deg2rad(
self.wrap_around_180(np.array([res["candidate"]["ra"]]))
)
dec = np.deg2rad(res["candidate"]["dec"])

plt.scatter(
ra, dec, color="white", marker="*", s=50.0, edgecolor="black"
)

plt.tight_layout()

outpath = os.path.join(
Expand Down