def show(self, length, label=None, corner='bottom right', frame=False, borderpad=0.4, pad=0.5, **kwargs): ''' Overlay a scale bar on the image. Required Arguments: *length*:[ float ] The length of the scalebar, in degrees Optional Keyword Arguments: *label*: [ string ] Label to place below the scalebar *corner*: [ integer ] Where to place the scalebar. Acceptable values are:, 'left', 'right', 'top', 'bottom', 'top left', 'top right', 'bottom left' (default), 'bottom right' *frame*: [ True | False ] Whether to display a frame behind the scalebar (default is False) Advanced: Additional arguments are passed to the matplotlib Rectangle and Text classes. See the matplotlib documentation for more details. In cases where the same argument exists for the two objects, the argument is passed to both the Text and Rectangle instance. ''' self._length = length self._base_settings['corner'] = corner self._base_settings['frame'] = frame self._base_settings['borderpad'] = borderpad self._base_settings['pad'] = pad degperpix = wcs_util.degperpix(self._wcs) length = length / degperpix try: self._scalebar.remove() except: pass if type(corner) == str: corner = corners[corner] self._scalebar = AnchoredSizeBar(self._ax.transData, length, label, corner, \ pad=pad, borderpad=borderpad, sep=5, frameon=frame) self._ax.add_artist(self._scalebar) self.set(**kwargs)
def update_compass(self, *args, **kwargs): if not self._compass_show: return rx, ry = self._compass_position length = self._compass_length color = self._compass_color xmin, xmax = self._ax1.get_xlim() ymin, ymax = self._ax1.get_ylim() x0 = rx * (xmax - xmin) + xmin y0 = ry * (ymax - ymin) + ymin xw, yw = self.pixel2world(x0, y0) len_pix = length * (ymax - ymin) degperpix = wcs_util.degperpix(self._wcs) len_deg = len_pix * degperpix # Should really only do tiny displacement then magnify the vectors - important if there is curvature x1, y1 = self.world2pixel(xw + len_deg / np.cos(np.radians(yw)), yw) x2, y2 = self.world2pixel(xw, yw + len_deg) if self._compass: self._compass[0].remove() self._compass[1].remove() arrow1 = FancyArrowPatch(posA=(x0, y0), posB=(x1, y1), arrowstyle='-|>', mutation_scale=20., fc=color, ec=color, shrinkA=0., shrinkB=0.) arrow2 = FancyArrowPatch(posA=(x0, y0), posB=(x2, y2), arrowstyle='-|>', mutation_scale=20., fc=color, ec=color, shrinkA=0., shrinkB=0.) self._compass = (arrow1, arrow2) self._ax1.add_patch(arrow1) self._ax1.add_patch(arrow2)
def show(self, major='BMAJ', minor='BMIN', \ angle='BPA', corner='bottom left', frame=False, borderpad=0.4, pad=0.5, **kwargs): ''' Display the beam shape and size for the primary image By default, this method will search for the BMAJ, BMIN, and BPA keywords in the FITS header to set the major and minor axes and the position angle on the sky. Optional Keyword Arguments: *major*: [ float ] Major axis of the beam in degrees (overrides BMAJ if present) *minor*: [ float ] Minor axis of the beam in degrees (overrides BMIN if present) *angle*: [ float ] Position angle of the beam on the sky in degrees (overrides BPA if present) in the anticlockwise direction. *corner*: [ integer ] The beam location. Acceptable values are 'left','right', 'top', 'bottom', 'top left', 'top right', 'bottom left' (default), and 'bottom right'. *frame*: [ True | False ] Whether to display a frame behind the beam (default is False) Advanced: Additional arguments are passed to the matplotlib Ellipse classe. See the matplotlib documentation for more details. ''' if type(major) == str: major = self._hdu.header[major] if type(minor) == str: minor = self._hdu.header[minor] if type(angle) == str: angle = self._hdu.header[angle] degperpix = wcs_util.degperpix(self._wcs) self._base_settings['minor'] = minor self._base_settings['major'] = major self._base_settings['angle'] = angle self._base_settings['corner'] = corner self._base_settings['frame'] = frame self._base_settings['borderpad'] = borderpad self._base_settings['pad'] = pad minor /= degperpix major /= degperpix try: self._beam.remove() except: pass if type(corner) == str: corner = corners[corner] self._beam = AnchoredEllipse(self._ax.transData, \ width=minor, height=major, angle=angle, \ loc=corner, pad=pad, borderpad=borderpad, frameon=frame) self._ax.add_artist(self._beam) self.set(**kwargs)