23 from __future__
import absolute_import, division, print_function
27 from past.builtins
import basestring
29 from lsst.utils
import continueClass
31 from ..schema
import Field
32 from .schemaMapper
import SchemaMapper
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.
45 The string name of the Field, or a fully-constructed Field object.
46 If the latter, all other arguments besides doReplace are ignored.
48 The type of field to create. Valid types are the keys of the
49 afw.table.Field dictionary.
51 Documentation for the field.
53 Units for the field, or an empty string if unitless.
55 Size of the field; valid for string and array fields only.
57 If a field with this name already exists, replace it instead of
58 raising pex.exceptions.InvalidParameterError.
60 One of 'raise' (default), 'warn', or 'strict', indicating how to
61 handle unrecognized unit strings. See also astropy.units.Unit.
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)
68 def addMapping(self, input, output=None, doReplace=True):
69 """Add a mapped field to the output schema.
74 A Key from the input schema whose values will be mapped to the new
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.
82 If a field with this name already exists in the output schema,
83 replace it instead of raising pex.exceptions.InvalidParameterError.
88 if output
is True or output
is False:
91 return input._addMappingTo(self, output, doReplace)