Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def plot_diagnostics(self, data, figsize=(12, 4), *params, **kwargs):
"""Plots an image of the model for a given point in the parameter space."""
fig, ax = plt.subplots(nrows=1, ncols=3, figsize=figsize)
fit = self.fit(data)
extent = (self.prfmodel.column, self.prfmodel.column + self.prfmodel.shape[1],
self.prfmodel.row, self.prfmodel.row + self.prfmodel.shape[0])
plot_image(data, ax=ax[0],
title='Observed Data, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
plot_image(fit.predicted_image, ax=ax[1],
title='Predicted Image, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
plot_image(fit.residual_image, ax=ax[2],
title='Residual Image, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
return fit
def plot_diagnostics(self, data, figsize=(12, 4), *params, **kwargs):
"""Plots an image of the model for a given point in the parameter space."""
fig, ax = plt.subplots(nrows=1, ncols=3, figsize=figsize)
fit = self.fit(data)
extent = (self.prfmodel.column, self.prfmodel.column + self.prfmodel.shape[1],
self.prfmodel.row, self.prfmodel.row + self.prfmodel.shape[0])
plot_image(data, ax=ax[0],
title='Observed Data, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
plot_image(fit.predicted_image, ax=ax[1],
title='Predicted Image, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
plot_image(fit.residual_image, ax=ax[2],
title='Residual Image, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
return fit
def plot_diagnostics(self, data, figsize=(12, 4), *params, **kwargs):
"""Plots an image of the model for a given point in the parameter space."""
fig, ax = plt.subplots(nrows=1, ncols=3, figsize=figsize)
fit = self.fit(data)
extent = (self.prfmodel.column, self.prfmodel.column + self.prfmodel.shape[1],
self.prfmodel.row, self.prfmodel.row + self.prfmodel.shape[0])
plot_image(data, ax=ax[0],
title='Observed Data, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
plot_image(fit.predicted_image, ax=ax[1],
title='Predicted Image, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
plot_image(fit.residual_image, ax=ax[2],
title='Residual Image, Channel: {}'.format(self.prfmodel.channel),
extent=extent, **kwargs)
return fit
def plot(self, *params, **kwargs):
pflux = self.evaluate(*params)
plot_image(pflux, title='Kepler PRF Model, Channel: {}'.format(self.channel),
extent=(self.column, self.column + self.shape[1],
self.row, self.row + self.shape[0]), **kwargs)
Parameters
----------
ax : `~matplotlib.axes.Axes`
A matplotlib axes object to plot into. If no axes is provided,
a new one will be created.
**kwargs : dict
Extra parameters to be passed to `.plot_image`.
Returns
-------
`~matplotlib.axes.Axes`
The matplotlib axes object.
"""
with plt.style.context(MPLSTYLE):
ax = plot_image(self.values, ax=ax, xlabel='Component', ylabel='X',
clabel='Component Value', title=self.name, **kwargs)
ax.set_aspect(self.shape[1]/(1.6*self.shape[0]))
if self.shape[1] <= 40:
ax.set_xticks(np.arange(self.shape[1]))
ax.set_xticklabels([r'${}$'.format(i) for i in self.columns],
rotation=90, fontsize=8)
return ax
"must be in the range {}-{}.".format(
cadenceno, self.cadenceno[0], self.cadenceno[-1]))
try:
if bkg and np.any(np.isfinite(self.flux_bkg[frame])):
pflux = self.flux[frame] + self.flux_bkg[frame]
else:
pflux = self.flux[frame]
except IndexError:
raise ValueError("frame {} is out of bounds, must be in the range "
"0-{}.".format(frame, self.shape[0]))
with plt.style.context(style):
if title is None:
title = 'Target ID: {}, Cadence: {}'.format(self.targetid, self.cadenceno[frame])
img_extent = (self.column, self.column + self.shape[2],
self.row, self.row + self.shape[1])
ax = plot_image(pflux, ax=ax, title=title, extent=img_extent,
show_colorbar=show_colorbar, **kwargs)
ax.grid(False)
if aperture_mask is not None:
aperture_mask = self._parse_aperture_mask(aperture_mask)
for i in range(self.shape[1]):
for j in range(self.shape[2]):
if aperture_mask[i, j]:
ax.add_patch(patches.Rectangle((j+self.column, i+self.row),
1, 1, color=mask_color, fill=True,
alpha=.6))
return ax
def plot(self, *params, **kwargs):
"""Plots an image of the model for a given point in the parameter space."""
img = self.predict(*params)
plot_image(img,
title='TPF Model',
extent=(self.prfmodel.column, self.prfmodel.column + self.prfmodel.shape[1],
self.prfmodel.row, self.prfmodel.row + self.prfmodel.shape[0]),
**kwargs)