LSST Applications g180d380827+0f66a164bb,g2079a07aa2+86d27d4dc4,g2305ad1205+7d304bc7a0,g29320951ab+500695df56,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+e42ea45bea,g48712c4677+36a86eeaa5,g487adcacf7+2dd8f347ac,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+c70619cc9d,g5a732f18d5+53520f316c,g5ea96fc03c+341ea1ce94,g64a986408d+f7cd9c7162,g858d7b2824+f7cd9c7162,g8a8a8dda67+585e252eca,g99cad8db69+469ab8c039,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+c92fc63c7e,gbd866b1f37+f7cd9c7162,gc120e1dc64+02c66aa596,gc28159a63d+0e5473021a,gc3e9b769f7+b0068a2d9f,gcf0d15dbbd+e42ea45bea,gdaeeff99f8+f9a426f77a,ge6526c86ff+84383d05b3,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+f7cd9c7162,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
slots.cc
Go to the documentation of this file.
3
4namespace lsst {
5namespace afw {
6namespace table {
7
8namespace {
9
10// Return true if 'a' starts with 'b'
11bool startsWith(std::string const &a, std::string const b) { return a.compare(0, b.size(), b) == 0; }
12
13// helper class that resolves aliases for a slot's main measurement field, while
14// distiguishing between two cases where the field can't be found:
15// - if the alias points to an invalid field, we should throw an exception (which is actually
16// done by the calling setKeys() method, by allowing a lower-level exception to propagate up).
17// - if the alias simply isn't defined, we should just reset the slot with invalid keys
18class MeasFieldNameGetter {
19public:
20 MeasFieldNameGetter(SubSchema const &s, Schema const &schema)
21 : replaced(schema[schema.getAliasMap()->apply(s.getPrefix())]),
22 defined(replaced.getPrefix() !=
23 s.getPrefix()) // slot is defined if applying alias wasn't a no-op
24 {}
25
26 SubSchema replaced; // a SubSchema that includes alias replacement
27 bool defined; // whether the slot is defined at all
28};
29
30} // namespace
31
33 SubSchema s = schema["slot"][_name];
34 if (!alias.empty() && !startsWith(alias, s.getPrefix())) return;
35 _measKey = MeasKey();
36 _errKey = ErrKey();
37 _flagKey = Key<Flag>();
38 MeasFieldNameGetter helper(s["instFlux"], schema);
39 if (!helper.defined) {
40 return;
41 }
42 _measKey = helper.replaced;
43 try {
44 _errKey = s["instFluxErr"];
46 }
47 try {
48 _flagKey = s["flag"];
50 }
51}
52
53namespace {
54
57 v.push_back("x");
58 v.push_back("y");
59 return v;
60}
61
62} // namespace
63
65 SubSchema s = schema["slot"][_name];
66 if (!alias.empty() && !startsWith(alias, s.getPrefix())) return;
68 _measKey = MeasKey();
69 _errKey = ErrKey();
70 _flagKey = Key<Flag>();
71 MeasFieldNameGetter helper(s, schema);
72 if (!helper.defined) return;
73 _measKey = helper.replaced;
74 try {
75 _errKey = ErrKey(s, names);
77 }
78 try {
79 _flagKey = s["flag"];
81 }
82}
83
84namespace {
85
88 v.push_back("xx");
89 v.push_back("yy");
90 v.push_back("xy");
91 return v;
92}
93
94} // namespace
95
97 SubSchema s = schema["slot"][_name];
98 if (!alias.empty() && !startsWith(alias, s.getPrefix())) return;
100 _measKey = MeasKey();
101 _errKey = ErrKey();
102 _flagKey = Key<Flag>();
103 MeasFieldNameGetter helper(s, schema);
104 if (!helper.defined) return;
105 _measKey = helper.replaced;
106 try {
107 _errKey = ErrKey(s, names);
109 }
110 try {
111 _flagKey = s["flag"];
113 }
114}
115
117 defPsfFlux.setKeys(alias, schema);
118 defApFlux.setKeys(alias, schema);
120 defModelFlux.setKeys(alias, schema);
121 defCalibFlux.setKeys(alias, schema);
122 defCentroid.setKeys(alias, schema);
123 defShape.setKeys(alias, schema);
124}
125
127 : defPsfFlux("PsfFlux"),
128 defApFlux("ApFlux"),
129 defGaussianFlux("GaussianFlux"),
130 defModelFlux("ModelFlux"),
131 defCalibFlux("CalibFlux"),
132 defCentroid("Centroid"),
133 defShape("Shape") {
134 defPsfFlux.setKeys("", schema);
135 defApFlux.setKeys("", schema);
136 defGaussianFlux.setKeys("", schema);
137 defModelFlux.setKeys("", schema);
138 defCalibFlux.setKeys("", schema);
139 defCentroid.setKeys("", schema);
140 defShape.setKeys("", schema);
141}
142} // namespace table
143} // namespace afw
144} // namespace lsst
table::Key< int > b
Tag types used to declare specialized field types.
Definition misc.h:31
CovarianceMatrixKey< float, 2 > ErrKey
Key type used to access the slot uncertainty.
Definition slots.h:125
Point2DKey MeasKey
Key type used to access the slot measurement.
Definition slots.h:124
void setKeys(std::string const &alias, Schema const &schema)
Update the cached Keys following an change of aliases in the given Schema.
Definition slots.cc:64
Key< double > MeasKey
Key type used to access the slot measurement.
Definition slots.h:77
Key< double > ErrKey
Key type used to access the slot uncertainty.
Definition slots.h:78
void setKeys(std::string const &alias, Schema const &schema)
Update the cached Keys following an change of aliases in the given Schema.
Definition slots.cc:32
Defines the fields and offsets for a table.
Definition Schema.h:51
CovarianceMatrixKey< float, 3 > ErrKey
Key type used to access the slot uncertainty.
Definition slots.h:172
void setKeys(std::string const &alias, Schema const &schema)
Update the cached Keys following an change of aliases in the given Schema.
Definition slots.cc:96
QuadrupoleKey MeasKey
Key type used to access the slot measurement.
Definition slots.h:171
A proxy type for name lookups in a Schema.
Definition Schema.h:367
Reports attempts to access elements using an invalid key.
Definition Runtime.h:151
T push_back(T... args)
bool defined
Definition slots.cc:27
SubSchema replaced
Definition slots.cc:26
CentroidSlotDefinition defCentroid
Definition slots.h:225
FluxSlotDefinition defModelFlux
Definition slots.h:223
SlotSuite(Schema const &schema)
Initialize the slots.
Definition slots.cc:126
FluxSlotDefinition defCalibFlux
Definition slots.h:224
FluxSlotDefinition defApFlux
Definition slots.h:221
FluxSlotDefinition defPsfFlux
Definition slots.h:220
ShapeSlotDefinition defShape
Definition slots.h:226
FluxSlotDefinition defGaussianFlux
Definition slots.h:222
void handleAliasChange(std::string const &alias, Schema const &schema)
Handle a callback from an AliasMap informing the table that an alias has changed.
Definition slots.cc:116