if label: f.write('FONT hershey%d\n' % (style.label_size * 2)) f.write('COLOR %s\n' % style.label_color) f.write('TEXT %.12f %.12f %s\n' % (ra, dec, label)) f.close() except IOError as err: busy = None self.qerrmsg.showMessage( "Error writing Karma annotations file %s: %s" % (filename, str(err))) return busy = None self.parent().showMessage( "Wrote Karma annotations for %d sources to file %s" % (len(sources), filename)) return QDialog.accept(self) def export_karma_annotations(mainwin, model): dialog = getattr(mainwin, '_export_karma_dialog', None) if not dialog: dialog = mainwin._export_karma_dialog = ExportKarmaDialog(mainwin) dialog.setModel(model) # show dialog return dialog.exec_() from TigGUI.Tools import registerTool registerTool("Export Karma annotations...", export_karma_annotations)
shape=shape) sources.append(img_src) changed = True if changed: self.model.setSources(sources) self.model.emitUpdate(SkyModel.SkyModel.UpdateAll, origin=self) self.parent().showMessage("Wrote %d sources to FITS file %s" % (len(sources), filename)) busy = None return QDialog.accept(self) def make_brick(mainwin, model): # check that something is selected if not [src for src in model.sources if src.selected]: mainwin.showErrorMessage( "Cannot make FITS brick without a source selection. Please select some sources first." ) return dialog = getattr(mainwin, '_make_brick_dialog', None) if not dialog: dialog = mainwin._make_brick_dialog = MakeBrickDialog(mainwin) dialog.setModel(model) # show dialog return dialog.exec_() from TigGUI.Tools import registerTool registerTool("Make FITS brick from selected sources...", make_brick)
bmin = bmin/(Imaging.FWHM*3600)*DEG; pa = pa*DEG; # restore try: Imaging.restoreSources(input_hdu,sources,bmaj,bmin,pa); except Exception,err: busy = None; self.qerrmsg.showMessage("Error restoring model into image: %s"%str(err)); return; # save fits file try: input_hdu.writeto(outfile,clobber=True); except Exception,err: busy = None; self.qerrmsg.showMessage("Error writing FITS file %s: %s"%(outfile,str(err))); return; self.parent().loadImage(outfile); busy = None; return QDialog.accept(self); def restore_into_image (mainwin,model): dialog = getattr(mainwin,'_restore_into_image_dialog',None); if not dialog: dialog = mainwin._restore_into_image_dialog = RestoreImageDialog(mainwin); dialog.setModel(model); # show dialog return dialog.exec_(); from TigGUI.Tools import registerTool registerTool("Restore model into image...",restore_into_image);
try: Imaging.restoreSources(input_hdu, sources, bmaj, bmin, pa) except Exception as err: busy = None self.qerrmsg.showMessage("Error restoring model into image: %s" % str(err)) return # save fits file try: input_hdu.writeto(outfile, clobber=True) except Exception as err: busy = None self.qerrmsg.showMessage("Error writing FITS file %s: %s" % (outfile, str(err))) return self.parent().loadImage(outfile) busy = None return QDialog.accept(self) def restore_into_image(mainwin, model): dialog = getattr(mainwin, '_restore_into_image_dialog', None) if not dialog: dialog = mainwin._restore_into_image_dialog = RestoreImageDialog(mainwin) dialog.setModel(model) # show dialog return dialog.exec_() from TigGUI.Tools import registerTool registerTool("Restore model into image...", restore_into_image)
flux = ModelClasses.Flux(max_flux) shape = ModelClasses.FITSImage(sx, sy, 0, os.path.basename(filename), nx, ny, pad=pad) img_src = SkyModel.Source(os.path.splitext(os.path.basename(filename))[0], pos, flux, shape=shape) sources.append(img_src) changed = True if changed: self.model.setSources(sources) self.model.emitUpdate(SkyModel.SkyModel.UpdateAll, origin=self) self.parent().showMessage("Wrote %d sources to FITS file %s" % (len(sources), filename)) busy = None return QDialog.accept(self) def make_brick(mainwin, model): # check that something is selected if not [src for src in model.sources if src.selected]: mainwin.showErrorMessage( "Cannot make FITS brick without a source selection. Please select some sources first.") return dialog = getattr(mainwin, '_make_brick_dialog', None) if not dialog: dialog = mainwin._make_brick_dialog = MakeBrickDialog(mainwin) dialog.setModel(model) # show dialog return dialog.exec_() from TigGUI.Tools import registerTool registerTool("Make FITS brick from selected sources...", make_brick)
sy *= DEG nx, ny = input_hdu.data.shape[-1:-3:-1] pos = ModelClasses.Position(ra0, dec0) flux = ModelClasses.Flux(max_flux) shape = ModelClasses.FITSImage(sx, sy, 0, os.path.basename(filename), nx, ny, pad=float(str(self.wpad.text()) or "1")) img_src = SkyModel.Source(srcname, pos, flux, shape=shape) self.model.setSources(self.model.sources + [img_src]) self.model.emitUpdate(SkyModel.SkyModel.UpdateAll, origin=self) busy.reset_cursor() return QDialog.accept(self) def add_brick(mainwin, model): dialog = getattr(mainwin, '_add_brick_dialog', None) if not dialog: dialog = mainwin._add_brick_dialog = AddBrickDialog(mainwin) dialog.setModel(model) # show dialog return dialog.exec_() from TigGUI.Tools import registerTool registerTool("Add FITS brick to model...", add_brick)
elif style.symbol == "dot": f.write('DOT %.12f %.12f\n'%(ra,dec)); elif style.symbol == "square": f.write('CBOX %.12f %.12f %f %f\n'%(ra,dec,xsize,ysize)); elif style.symbol == "diamond": f.write('CBOX %.12f %.12f %f %f 45\n'%(ra,dec,xsize,ysize)); # write label if label: f.write('FONT hershey%d\n'%(style.label_size*2)); f.write('COLOR %s\n'%style.label_color); f.write('TEXT %.12f %.12f %s\n'%(ra,dec,label)); f.close(); except IOError,err: busy = None; self.qerrmsg.showMessage("Error writing Karma annotations file %s: %s"%(filename,str(err))); return; busy = None; self.parent().showMessage("Wrote Karma annotations for %d sources to file %s"%(len(sources),filename)); return QDialog.accept(self); def export_karma_annotations (mainwin,model): dialog = getattr(mainwin,'_export_karma_dialog',None); if not dialog: dialog = mainwin._export_karma_dialog = ExportKarmaDialog(mainwin); dialog.setModel(model); # show dialog return dialog.exec_(); from TigGUI.Tools import registerTool registerTool("Export Karma annotations...",export_karma_annotations);