LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | List of all members
lsst.gdb.afw.printers_oldgdb.PrintImageCommand Class Reference
Inheritance diagram for lsst.gdb.afw.printers_oldgdb.PrintImageCommand:

Public Member Functions

def __init__
 
def get
 
def invoke
 

Detailed Description

Print an Image
Usage: image x0 y0 [nx [ny] [centerPatch] [obeyXY0]]

Definition at line 114 of file printers_oldgdb.py.

Constructor & Destructor Documentation

def lsst.gdb.afw.printers_oldgdb.PrintImageCommand.__init__ (   self)

Definition at line 119 of file printers_oldgdb.py.

120  def __init__ (self):
121  super (PrintImageCommand, self).__init__ ("show image",
122  gdb.COMMAND_DATA,
123  gdb.COMPLETE_SYMBOL)

Member Function Documentation

def lsst.gdb.afw.printers_oldgdb.PrintImageCommand.get (   self,
  var,
  x,
  y 
)

Definition at line 124 of file printers_oldgdb.py.

125  def get(self, var, x, y):
126  if False:
127  return var["operator()(int, int, bool)"](x, y, True)
128  else:
129  dimensions = var["_gilView"]["_dimensions"]
130  if x < 0 or x >= dimensions["x"] or y < 0 or y >= dimensions["y"]:
131  raise gdb.GdbError("Pixel (%d, %d) is out of range 0:%d, 0:%d" %
132  (x, y, dimensions["x"] - 1, dimensions["y"] - 1))
133 
134  pixels = var["_gilView"]["_pixels"]["_p"]
135  step = pixels["_step_fn"]["_step"]/var.type.template_argument(0).sizeof
136 
137  return pixels["m_iterator"][x + y*step]["_v0"]
def lsst.gdb.afw.printers_oldgdb.PrintImageCommand.invoke (   self,
  args,
  fromTty 
)

Definition at line 138 of file printers_oldgdb.py.

139  def invoke (self, args, fromTty):
140  self.dont_repeat()
141 
142  args = gdb.string_to_argv(args)
143  if len(args) < 1:
144  raise gdb.GdbError("Please specify an image")
145  imgName = args.pop(0)
146  var = gdb.parse_and_eval(imgName)
147 
148  if re.search(r"MaskedImage", str(var.type)):
149  print "N.b. %s is a MaskedImage; showing image" % (imgName)
150  var = var["_image"]
151 
152  if re.search(r"shared_ptr<", str(var.type)):
153  var = var["px"].dereference()
154 
155  if var.type.code == gdb.TYPE_CODE_PTR:
156  var = var.dereference() # be nice
157 
158  pixelTypeName = str(var.type.template_argument(0))
159 
160  if len(args) < 2:
161  raise gdb.GdbError("Please specify a pixel's x and y indexes")
162 
163  x0 = gdb.parse_and_eval(args.pop(0))
164  y0 = gdb.parse_and_eval(args.pop(0))
165 
166  if len(args) == 0:
167  print "%g" % self.get(var, x0, y0)
168  return
169 
170  nx = int(args.pop(0))
171  if args:
172  ny = int(args.pop(0))
173  else:
174  ny = 1
175 
176  if args:
177  centerPatch = gdb.parse_and_eval(args.pop(0))
178  if centerPatch:
179  x0 -= nx//2
180  y0 -= ny//2
181 
182  if args:
183  obeyXY0 = gdb.parse_and_eval(args.pop(0))
184 
185  if obeyXY0:
186  arr = var["_origin"]["_vector"]["m_storage"]["m_data"]["array"]
187 
188  x0 -= arr[0]
189  y0 -= arr[1]
190 
191  if args:
192  raise gdb.GdbError('Unexpected trailing arguments: "%s"' % '", "'.join(args))
193  #
194  # OK, finally time to print
195  #
196  if pixelTypeName in ["short", "unsigned short"]:
197  dataFmt = "0x%x"
198  elif pixelTypeName in ["int", "unsigned int"]:
199  dataFmt = "%d"
200  else:
201  dataFmt = "%.2f"
202 
203  print "%-4s" % "",
204  for x in range(x0, x0 + nx):
205  print "%8d" % x,
206  print ""
207 
208  for y in reversed(range(y0, y0 + ny)):
209  print "%-4d" % y,
210  for x in range(x0, x0 + nx):
211  print "%8s" % (dataFmt % self.get(var, x, y)),
212  print ""
213 
214 
216 
217 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
218 #
219 # These two classes (RxPrinter and Printer) come directly from
220 # python/libstdcxx/v6/printers.py and the GPL license therein applies
221 #
222 # A "regular expression" printer which conforms to the
# "SubPrettyPrinter" protocol from gdb.printing.

The documentation for this class was generated from the following file: