def gki_text(self, arg): self.wcs.commit() x = gki.ndc(arg[0]) y = gki.ndc(arg[1]) text = ndarr2str(arg[3:].astype(numpy.int8)) self._tkplotAppend(self.tkplot_text, x, y, text)
def gki_text(self, arg): """ Instructed to draw some GKI text """ # record this operation as a tuple in the draw buffer self._plotAppend(self.gki_text, arg) # commit pending WCS changes self.wcs.commit() # add the text x = gki.ndc(arg[0]) y = gki.ndc(arg[1]) text = ndarr2str(arg[3:].astype(numpy.int8)) ta = self.textAttributes # For now, force this to be non-bold for decent looking plots. It # seems (oddly) that IRAF/GKI tends to overuse boldness in graphics. # A fix to mpl (near 0.91.2) makes bold text show as reeeeally bold. # However, assume the user knows what they are doing with their # settings if they have set a non-standard (1.0) charSize. weight = 'normal' if (MPL_MAJ_MIN < 0.91) or (abs(ta.charSize - 1.0) > .0001): # only on these cases do we pay attention to 'bold' in textFont if ta.textFont.find('bold') >= 0: weight = 'bold' style = 'italic' if ta.textFont.find('italic') < 0: style = 'normal' # Calculate initial fontsize fsz = self.getTextPointSize(ta.charSize, self.__xsz, self.__ysz) # figure rotation angle rot = self.calculateMplTextAngle(ta.charUp, ta.textPath) # Kludge alert - only use the GKI_TEXT_Y_OFFSET in cases where # we know the text is a simple level label (not in a contour, etc) yOffset = 0.0 if abs(rot) < .0001 and ta.textHorizontalJust=='center': yOffset = GKI_TEXT_Y_OFFSET # Note that we add the text here in NDC (0.0-1.0) x,y and that # the fig takes care of resizing for us. t = self.__fig.text(x, y-yOffset, text, \ color=ta.textColor, rotation=rot, horizontalalignment=ta.textHorizontalJust, verticalalignment=ta.textVerticalJust, fontweight=weight, # [ 'normal' | 'bold' | ... ] fontstyle=style, # [ 'normal' | 'italic' | 'oblique'] fontsize=fsz) # To this Text object just created, we need to attach the GKI charSize # scale factor, since we will need it later during a resize. Mpl # knows nothing about this, but we support it for GKI. t.gkiTextSzFactor = ta.charSize # add attribute
def gki_text(self, arg): """ Instructed to draw some GKI text """ # record this operation as a tuple in the draw buffer self._plotAppend(self.gki_text, arg) # commit pending WCS changes self.wcs.commit() # add the text x = gki.ndc(arg[0]) y = gki.ndc(arg[1]) text = ndarr2str(arg[3:].astype(numpy.int8)) ta = self.textAttributes # For now, force this to be non-bold for decent looking plots. It # seems (oddly) that IRAF/GKI tends to overuse boldness in graphics. # A fix to mpl (near 0.91.2) makes bold text show as reeeeally bold. # However, assume the user knows what they are doing with their # settings if they have set a non-standard (1.0) charSize. weight = 'normal' if (MPL_MAJ_MIN < 0.91) or (abs(ta.charSize - 1.0) > .0001): # only on these cases do we pay attention to 'bold' in textFont if ta.textFont.find('bold') >= 0: weight = 'bold' style = 'italic' if ta.textFont.find('italic') < 0: style = 'normal' # Calculate initial fontsize fsz = self.getTextPointSize(ta.charSize, self.__xsz, self.__ysz) # figure rotation angle rot = self.calculateMplTextAngle(ta.charUp, ta.textPath) # Kludge alert - only use the GKI_TEXT_Y_OFFSET in cases where # we know the text is a simple level label (not in a contour, etc) yOffset = 0.0 if abs(rot) < .0001 and ta.textHorizontalJust == 'center': yOffset = GKI_TEXT_Y_OFFSET # Note that we add the text here in NDC (0.0-1.0) x,y and that # the fig takes care of resizing for us. t = self.__fig.text(x, y-yOffset, text, \ color=ta.textColor, rotation=rot, horizontalalignment=ta.textHorizontalJust, verticalalignment=ta.textVerticalJust, fontweight=weight, # [ 'normal' | 'bold' | ... ] fontstyle=style, # [ 'normal' | 'italic' | 'oblique'] fontsize=fsz) # To this Text object just created, we need to attach the GKI charSize # scale factor, since we will need it later during a resize. Mpl # knows nothing about this, but we support it for GKI. t.gkiTextSzFactor = ta.charSize # add attribute
def Iraf2AscString(iraf_string): """translate 16-bit IRAF characters to ascii""" inarr = numpy.fromstring(iraf_string, numpy.int16) # OK if str or uni retval = ndarr2str(inarr.astype(numpy.int8)) # log_task_comm('Iraf2AscString', retval, True) return retval
def control_openws(self, arg): mode = arg[0] device = ndarr2str(arg[2:].astype(numpy.int8)).strip() self.openKernel(device)