lsst.afw  14.0-52-g19103d347
schemaMapperContinued.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2017 LSST/AURA.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <http://www.lsstcorp.org/LegalNotices/>.
21 #
22 
23 from __future__ import absolute_import, division, print_function
24 
25 __all__ = [] # import only for the side effects
26 
27 from past.builtins import basestring
28 
29 from lsst.utils import continueClass
30 
31 from ..schema import Field
32 from .schemaMapper import SchemaMapper
33 
34 
35 @continueClass
37 
38  def addOutputField(self, field, type=None, doc=None, units="", size=None,
39  doReplace=False, parse_strict="raise"):
40  """Add an un-mapped field to the output Schema.
41 
42  Parameters
43  ----------
44  field : str,Field
45  The string name of the Field, or a fully-constructed Field object.
46  If the latter, all other arguments besides doReplace are ignored.
47  type\n : str,type
48  The type of field to create. Valid types are the keys of the
49  afw.table.Field dictionary.
50  doc : str
51  Documentation for the field.
52  unit : str
53  Units for the field, or an empty string if unitless.
54  size : int
55  Size of the field; valid for string and array fields only.
56  doReplace : bool
57  If a field with this name already exists, replace it instead of
58  raising pex.exceptions.InvalidParameterError.
59  parse_strict : str
60  One of 'raise' (default), 'warn', or 'strict', indicating how to
61  handle unrecognized unit strings. See also astropy.units.Unit.
62  """
63  if isinstance(field, basestring):
64  field = Field[type](field, doc=doc, units=units,
65  size=size, parse_strict=parse_strict)
66  return field._addTo(self.editOutputSchema(), doReplace)
67 
68  def addMapping(self, input, output=None, doReplace=True):
69  """Add a mapped field to the output schema.
70 
71  Parameters
72  ----------
73  input : Key
74  A Key from the input schema whose values will be mapped to the new
75  field.
76  output : str,Field
77  A Field object that describes the new field to be added to the
78  output schema, or the name of the field (with documentation and
79  units copied from the input schema). May be None to copy everything
80  from the input schema.
81  doReplace : bool
82  If a field with this name already exists in the output schema,
83  replace it instead of raising pex.exceptions.InvalidParameterError.
84  """
85  # Workaround for calling positional arguments; avoids an API change during pybind11 conversion,
86  # but we should just make that change and encourage using kwargs in the
87  # future.
88  if output is True or output is False:
89  doReplace = output
90  output = None
91  return input._addMappingTo(self, output, doReplace)
def addOutputField(self, field, type=None, doc=None, units="", size=None, doReplace=False, parse_strict="raise")
def addMapping(self, input, output=None, doReplace=True)