LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Public Member Functions | List of all members
lsst.afw.table.base.baseContinued.BaseRecord Class Reference

Public Member Functions

def extract (self, patterns, kwds)
 
def __repr__ (self)
 

Detailed Description

Definition at line 33 of file baseContinued.py.

Member Function Documentation

◆ __repr__()

def lsst.afw.table.base.baseContinued.BaseRecord.__repr__ (   self)

Definition at line 90 of file baseContinued.py.

90  def __repr__(self):
91  return "%s\n%s" % (type(self), str(self))
92 
93 
table::Key< int > type
Definition: Detector.cc:167

◆ extract()

def lsst.afw.table.base.baseContinued.BaseRecord.extract (   self,
  patterns,
  kwds 
)
Extract a dictionary of {<name>: <field-value>} in which the field names
match the given shell-style glob pattern(s).

Any number of glob patterns may be passed; the result will be the union of all
the result of each glob considered separately.

Parameters
----------

items : `dict`
    The result of a call to self.schema.extract(); this will be used
    instead of doing any new matching, and allows the pattern matching
    to be reused to extract values from multiple records.  This
    keyword is incompatible with any position arguments and the regex,
    sub, and ordered keyword arguments.

split : `bool`
    If True, fields with named subfields (e.g. points) will be split
    into separate items in the dict; instead of {"point":
    lsst.geom.Point2I(2,3)}, for instance, you'd get {"point.x":
    2, "point.y": 3}. Default is False.

regex : `str` or `re` pattern object
    A regular expression to be used in addition to any glob patterns
    passed as positional arguments.  Note that this will be compared
    with re.match, not re.search.

sub : `str`
    A replacement string (see `re.MatchObject.expand`) used to set the
    dictionary keys of any fields matched by regex.

ordered : `bool`
    If `True`, a `collections.OrderedDict` will be returned instead of
    a standard dict, with the order corresponding to the definition
    order of the `Schema`. `Default is False`.

Definition at line 35 of file baseContinued.py.

35  def extract(self, *patterns, **kwds):
36  """Extract a dictionary of {<name>: <field-value>} in which the field names
37  match the given shell-style glob pattern(s).
38 
39  Any number of glob patterns may be passed; the result will be the union of all
40  the result of each glob considered separately.
41 
42  Parameters
43  ----------
44 
45  items : `dict`
46  The result of a call to self.schema.extract(); this will be used
47  instead of doing any new matching, and allows the pattern matching
48  to be reused to extract values from multiple records. This
49  keyword is incompatible with any position arguments and the regex,
50  sub, and ordered keyword arguments.
51 
52  split : `bool`
53  If True, fields with named subfields (e.g. points) will be split
54  into separate items in the dict; instead of {"point":
55  lsst.geom.Point2I(2,3)}, for instance, you'd get {"point.x":
56  2, "point.y": 3}. Default is False.
57 
58  regex : `str` or `re` pattern object
59  A regular expression to be used in addition to any glob patterns
60  passed as positional arguments. Note that this will be compared
61  with re.match, not re.search.
62 
63  sub : `str`
64  A replacement string (see `re.MatchObject.expand`) used to set the
65  dictionary keys of any fields matched by regex.
66 
67  ordered : `bool`
68  If `True`, a `collections.OrderedDict` will be returned instead of
69  a standard dict, with the order corresponding to the definition
70  order of the `Schema`. `Default is False`.
71  """
72  d = kwds.pop("items", None)
73  split = kwds.pop("split", False)
74  if d is None:
75  d = self.schema.extract(*patterns, **kwds).copy()
76  elif kwds:
77  raise ValueError(
78  "Unrecognized keyword arguments for extract: %s" % ", ".join(kwds.keys()))
79  # must use list because we might be adding/deleting elements
80  for name, schemaItem in list(d.items()):
81  key = schemaItem.key
82  if split and key.HAS_NAMED_SUBFIELDS:
83  for subname, subkey in zip(key.subfields, key.subkeys):
84  d["%s.%s" % (name, subname)] = self.get(subkey)
85  del d[name]
86  else:
87  d[name] = self.get(schemaItem.key)
88  return d
89 
daf::base::PropertyList * list
Definition: fits.cc:885

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