Details
-
Type:
Bug
-
Status: To Do
-
Resolution: Unresolved
-
Fix Version/s: None
-
Component/s: afw
-
Labels:None
-
Team:Data Release Production
Description
Given a schema which contains field names with underscores in them, it's useful to be able to strip off a prefix by making a subschema. For example:
In [1]: import lsst.afw.table as afwTable
|
In [2]: import lsst.meas.base as measBase
|
In [3]: c = measBase.NaiveCentroidControl()
|
In [4]: s = afwTable.SourceTable.makeMinimalSchema()
|
In [5]: measBase.NaiveCentroidAlgorithm(c, "test", s)
|
Out[5]: <lsst.meas.base.baseLib.NaiveCentroidAlgorithm; proxy of <Swig Object of type 'lsst::meas::base::NaiveCentroidAlgorithm *' at 0x113448210> >
|
|
In [6]: s
|
Out[6]:
|
Schema(
|
(Field['L'](name="id", doc="unique ID"), Key<L>(offset=0, nElements=1)),
|
(Field['Angle'](name="coord_ra", doc="position in ra/dec"), Key<Angle>(offset=8, nElements=1)),
|
(Field['Angle'](name="coord_dec", doc="position in ra/dec"), Key<Angle>(offset=16, nElements=1)),
|
(Field['L'](name="parent", doc="unique ID of parent source"), Key<L>(offset=24, nElements=1)),
|
(Field['D'](name="test_x", doc="centroid from Naive Centroid algorithm", units="pixel"), Key<D>(offset=32, nElements=1)),
|
(Field['D'](name="test_y", doc="centroid from Naive Centroid algorithm", units="pixel"), Key<D>(offset=40, nElements=1)),
|
(Field['Flag'](name="test_flag", doc="general failure flag, set if anything went wrong"), Key['Flag'](offset=48, bit=0)),
|
(Field['Flag'](name="test_flag_noCounts", doc="Object to be centroided has no counts"), Key['Flag'](offset=48, bit=1)),
|
(Field['Flag'](name="test_flag_edge", doc="Object too close to edge"), Key['Flag'](offset=48, bit=2)),
|
'test_flag_badInitialCentroid'->'slot_Centroid_flag'
|
)
|
|
In [7]: s['test'].getNames()
|
Out[7]: ('flag', 'flag_edge', 'flag_noCounts', 'x', 'y')
|
However, if we attempt to strip off a longer prefix including the underscore, we throw an unhelpful exception:
In [8]: s['test_flag'].getNames()
|
---------------------------------------------------------------------------
|
Exception Traceback (most recent call last)
|
<ipython-input-8-a15d95e770e9> in <module>()
|
----> 1 s['test_flag'].getNames()
|
|
/Users/jds/Projects/Astronomy/LSST/stack/DarwinX86/afw/2.2016.10-23-g120d329/python/lsst/afw/table/tableLib.pyc in getNames(self, topOnly)
|
1401 getNames(SubSchema self) -> std::set< std::string,std::less< std::string >,std::allocator< std::string > >
|
1402 """
|
-> 1403 return _tableLib.SubSchema_getNames(self, topOnly)
|
1404
|
1405 def find(self, k):
|
|
Exception: basic_string
|
Please fix it.
Attachments
Issue Links
- mentioned in
-
Page Loading...
As of this now throws an IndexError:
[ins] In [7]: s['test_flag'].getNames()
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-7-ab1855bab59d> in <module>
----> 1 s['test_flag'].getNames()
IndexError: basic_string::substr: __pos (which is 10) > this->size() (which is 9)