Exemplo n.º 1
0
    def plot_reduced(self,
                     ax=None,
                     figsize=(6, 6),
                     plot_apertures=True,
                     minp=10,
                     maxp=100,
                     flt=lambda a: a,
                     transform=lambda im: (im.reduced, im._wcs),
                     **kwargs):

        if 'subfield_radius' in kwargs.keys() and kwargs['subfield_radius']:
            from astropy.nddata import Cutout2D
            sc = kwargs.get('target', self._target_center)
            assert isinstance(sc, SkyCoord)
            assert self._wcs is not None
            r = kwargs['subfield_radius'] * u.arcmin
            co = Cutout2D(self.reduced,
                          sc, (r, r),
                          mode='partial',
                          fill_value=median(self.reduced),
                          wcs=self._wcs)
            data, wcs = co.data, co.wcs
        else:
            data, wcs = transform(self)
        height, width = data.shape

        fig, ax = super().plot(flt(data),
                               ax=ax,
                               figsize=figsize,
                               title='Reduced image',
                               minp=minp,
                               maxp=maxp,
                               wcs=wcs)
        setp(ax, xlim=(0, width), ylim=(0, height))

        if plot_apertures:
            self.plot_apertures(ax, wcs=wcs)

        # Plot the circle of inclusion
        if self._separation_cut is not None:
            from photutils import SkyCircularAperture
            sa = SkyCircularAperture(self._target_center,
                                     self._separation_cut).to_pixel(wcs)
            ax.plot(*self._target_center.to_pixel(wcs),
                    marker='x',
                    c='k',
                    ms=15)
            sa.plot(ax=ax, color='0.4', ls=':', lw=2)
            if sa.positions[0][0] + sa.r - 20 < width:
                ax.text(sa.positions[0][0] + sa.r + 10,
                        sa.positions[0][1],
                        "r = {:3.1f}'".format(self._separation_cut.value),
                        size='larger')

        # Plot the margins
        if self._margins_cut:
            ax.axvline(self.margin, c='k', ls='--', alpha=0.5)
            ax.axvline(self.width - self.margin, c='k', ls='--', alpha=0.5)
            ax.axhline(self.margin, c='k', ls='--', alpha=0.5)
            ax.axhline(self.height - self.margin, c='k', ls='--', alpha=0.5)

        # Plot the image scale
        if self._wcs:
            xlims = ax.get_xlim()
            py = 0.96 * ax.get_ylim()[1]
            x0, x1 = 0.3 * xlims[1], 0.7 * xlims[1]
            scale = SkyCoord.from_pixel(x0, py, wcs).separation(
                SkyCoord.from_pixel(x1, py, wcs))
            ax.annotate('',
                        xy=(x0, py),
                        xytext=(x1, py),
                        arrowprops=dict(arrowstyle='|-|', lw=1.5, color='k'))
            ax.text(width / 2,
                    py - 7.5,
                    "{:3.1f}'".format(scale.arcmin),
                    va='top',
                    ha='center',
                    size='larger')

        return fig, ax
Exemplo n.º 2
0
## add the region file
from regions import read_ds9
file = regionDir + 'NGC5257_arm.reg'
arm_sky = read_ds9(file)[0]
armpix_spi = arm_sky.to_pixel(Spitzer_wcs_cut)
armpix_her = arm_sky.to_pixel(herschel_wcs_cut)

### plot the figure
from mpl_toolkits.axes_grid1 import make_axes_locatable

fig = plt.figure()
ax = plt.subplot('111', projection=Spitzer_wcs_cut)
ax.tick_params(direction='in')
ax.title.set_text('Spitzer 24um')
im = ax.imshow(Spitzer_cut, origin='lower', cmap='gist_ncar_r')
center_spi.plot(color='black')
south_spi.plot(color='black')
southarm.plot(color='black')
armpix_spi.plot(color='black')
plt.savefig(picDir + 'spitzer_24um.png', bbox_inches='tight', pad_inches=0.2)

fig = plt.figure()
ax1 = plt.subplot('111', projection=herschel_wcs_cut)
ax1.title.set_text('Herschel 70um')
ax1.tick_params(direction='in')
im = ax1.imshow(herschel_cut, origin='lower', cmap='gist_ncar_r')
center_her.plot(color='black')
south_her.plot(color='black')
southarm.plot(color='black')
armpix_her.plot(color='black')
plt.savefig(picDir + 'herschel_70um.png', bbox_inches='tight', pad_inches=0.2)