def init_frame(self, n): """ NOTE: this is called from the IIS_RequestHandler """ self.logger.debug("initializing frame %d" % (n)) # create the frame, if needed try: fb = self.get_frame(n) except KeyError: fb = iis.framebuffer() self.fb[n] = fb fb.width = None fb.height = None fb.wcs = '' fb.image = None fb.bitmap = None fb.zoom = 1.0 fb.buffer = array.array('B') fb.ct = iis.coord_tran() #fb.chname = None return fb
def init_frame(self, n): """ NOTE: this is called from the IIS_RequestHandler """ self.logger.debug("initializing frame %d" % (n)) # create the frame, if needed try: fb = self.get_frame(n) except KeyError: fb = iis.framebuffer() self.fb[n] = fb fb.width = None fb.height = None fb.wcs = '' fb.image = None fb.bitmap = None fb.zoom = 1.0 fb.buffer = array.array('B') fb.ct = iis.coord_tran() #fb.chname = None return fb
def new_image_cb(self, fitsimage, image, chinfo): # check if this is an image we received from IRAF or # one that was loaded locally. ct = image.get('ct', None) if ct != None: # This image was sent by IRAF--we don't need to # construct extra fb information for it return n = self.channel_to_frame(chinfo.name) if n == None: return self.logger.debug("new image, frame is %d" % (n)) fb = self.get_frame(n) #image = fitsimage.get_image() newpath = image.get('path', 'NO_PATH') host = socket.getfqdn() newhost = image.get('host', host) # protocol has a bizarre 16-char limit on hostname newhost = newhost[:16] # this is just a placeholder so that IIS_RequestHandler will # report something in this buffer fb.buffer = array.array('B', ' ') # Update IRAF "wcs" info so that IRAF can load this image #print "filling wcs info" fb.ct = iis.coord_tran() image.set(ct=ct) # iis version 1 data fb.ct.valid = 1 fb.ct.a = 1 fb.ct.b = 0 fb.ct.c = 0 fb.ct.d = 1 fb.ct.tx = 0 fb.ct.ty = 0 fb.ct.z1 = 0 fb.ct.z2 = 1 fb.ct.zt = iis.W_UNITARY fb.ct.format = '' fb.ct.imtitle = '' # iis version 1+ data fb.ct.region = 'image' #x1, y1, x2, y2 = fitsimage.get_datarect() #wd, ht = x2-x1, y2-y1 #x1, y1, x2, y2 = x1+1, y1+1, x2+1, y2+1 #fb.ct.sx, fb.ct.sy = float(x1), float(y1) wd, ht = image.get_size() fb.ct.sx, fb.ct.sy = float(1), float(1) fb.ct.snx, fb.ct.sny = wd, ht fb.ct.dx, fb.ct.dy = 1, 1 fb.ct.dnx, fb.ct.dny = wd, ht # ref newref = "!".join([newhost, newpath]) fb.ct.ref = newref # TODO: we shouldn't have to know about this here... if (fb and fb.ct.a != None): wcs = "%s\n%f %f %f %f %f %f %f %f %d\n" % ( fb.ct.imtitle, fb.ct.a, fb.ct.b, fb.ct.c, fb.ct.d, fb.ct.tx, fb.ct.ty, fb.ct.z1, fb.ct.z2, fb.ct.zt) else: wcs = "[NOSUCHWCS]\n" if (fb and fb.ct.sx != None): mapping = "%s %f %f %d %d %d %d %d %d\n%s\n" % ( fb.ct.region, fb.ct.sx, fb.ct.sy, fb.ct.snx, fb.ct.sny, fb.ct.dx, fb.ct.dy, fb.ct.dnx, fb.ct.dny, fb.ct.ref) else: mapping = "" fb.wcs = wcs + mapping
def new_image_cb(self, fitsimage, image, chinfo): if not self.gui_up: return # check if this is an image we received from IRAF or # one that was loaded locally. ct = image.get('ct', None) if ct != None: # This image was sent by IRAF--we don't need to # construct extra fb information for it return n = self.channel_to_frame(chinfo.name) if n == None: return self.logger.debug("new image, frame is %d" % (n)) fb = self.get_frame(n) #image = fitsimage.get_image() newpath = image.get('path', 'NO_PATH') host = socket.getfqdn() newhost = image.get('host', host) # protocol has a bizarre 16-char limit on hostname newhost = newhost[:16] # this is just a placeholder so that IIS_RequestHandler will # report something in this buffer fb.buffer = array.array('B', ' ') # Update IRAF "wcs" info so that IRAF can load this image #print "filling wcs info" fb.ct = iis.coord_tran() image.set(ct=ct) # iis version 1 data fb.ct.valid = 1 fb.ct.a = 1 fb.ct.b = 0 fb.ct.c = 0 fb.ct.d = 1 fb.ct.tx = 0 fb.ct.ty = 0 fb.ct.z1 = 0 fb.ct.z2 = 1 fb.ct.zt = iis.W_UNITARY fb.ct.format = '' fb.ct.imtitle = '' # iis version 1+ data fb.ct.region = 'image' #x1, y1, x2, y2 = fitsimage.get_datarect() #wd, ht = x2-x1, y2-y1 #x1, y1, x2, y2 = x1+1, y1+1, x2+1, y2+1 #fb.ct.sx, fb.ct.sy = float(x1), float(y1) wd, ht = image.get_size() fb.ct.sx, fb.ct.sy = float(1), float(1) fb.ct.snx, fb.ct.sny = wd, ht fb.ct.dx, fb.ct.dy = 1, 1 fb.ct.dnx, fb.ct.dny = wd, ht # ref newref = "!".join([newhost, newpath]) fb.ct.ref = newref # TODO: we shouldn't have to know about this here... if (fb and fb.ct.a != None): wcs = "%s\n%f %f %f %f %f %f %f %f %d\n" % ( fb.ct.imtitle, fb.ct.a, fb.ct.b, fb.ct.c, fb.ct.d, fb.ct.tx, fb.ct.ty, fb.ct.z1, fb.ct.z2, fb.ct.zt) else: wcs = "[NOSUCHWCS]\n" if (fb and fb.ct.sx != None): mapping = "%s %f %f %d %d %d %d %d %d\n%s\n" % ( fb.ct.region, fb.ct.sx, fb.ct.sy, fb.ct.snx, fb.ct.sny, fb.ct.dx, fb.ct.dy, fb.ct.dnx, fb.ct.dny, fb.ct.ref) else: mapping = "" fb.wcs = wcs + mapping