Coverage for python/lsst/ap/association/afwUtils.py : 3%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of ap_association.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22"""Defines afw schemas and conversions for use in ap_association tasks.
24Until a more finalized interface between the alert production database (APDB) can
25be established, we put many utility functions for converting `lsst.afw.table` and
26`lsst.afw.image` objects to a PPD. This includes both mapping schemas between
27different catalogs and the DB.
28"""
30__all__ = ["make_dia_object_schema",
31 "make_dia_source_schema",
32 "make_dia_forced_source_schema",
33 "getCcdVisitSchemaSql"]
35from collections import OrderedDict as oDict
37import lsst.afw.table as afwTable
40def make_dia_object_schema(filter_names=None):
41 """Define and create the minimal schema required for a DIAObject.
43 Parameters
44 ----------
45 filter_names : `list` of `str`
46 Names of the filters expect and compute means for.
48 Returns
49 -------
50 schema : `lsst.afw.table.Schema`
51 Minimal schema for DIAObjects.
52 """
53 schema = afwTable.SourceTable.makeMinimalSchema()
54 # For the MVP/S we currently only care about the position though
55 # in the future we will add summary computations for fluxes etc.
56 # as well as their errors.
58 # TODO: In the future we would like to store a covariance of the coordinate.
59 # This functionality is not defined currently in the stack, so we will hold
60 # off until it is implemented. This is to be addressed in DM-7101.
62 # Generated automatically from apdb-schema.yaml in dax_apdb/data.
63 schema.addField('validityStart', type='L',
64 doc='Time when validity of this diaObject starts.')
65 schema.addField('validityEnd', type='L',
66 doc='Time when validity of this diaObject ends.')
67 schema.addField('raErr', type='Angle',
68 doc='Uncertainty of ra.')
69 schema.addField('declErr', type='Angle',
70 doc='Uncertainty of decl.')
71 schema.addField('ra_decl_Cov', type='F',
72 doc='Covariance between ra and decl.')
73 schema.addField('radecTai', type='D',
74 doc='Time at which the object was at a position ra/decl.')
75 schema.addField('pmRa', type='F',
76 doc='Proper motion (ra).')
77 schema.addField('pmRaErr', type='F',
78 doc='Uncertainty of pmRa.')
79 schema.addField('pmDecl', type='F',
80 doc='Proper motion (decl).')
81 schema.addField('pmDeclErr', type='F',
82 doc='Uncertainty of pmDecl.')
83 schema.addField('parallax', type='F',
84 doc='Parallax.')
85 schema.addField('parallaxErr', type='F',
86 doc='Uncertainty of parallax.')
87 schema.addField('pmRa_pmDecl_Cov', type='F',
88 doc='Covariance of pmRa and pmDecl.')
89 schema.addField('pmRa_parallax_Cov', type='F',
90 doc='Covariance of pmRa and parallax.')
91 schema.addField('pmDecl_parallax_Cov', type='F',
92 doc='Covariance of pmDecl and parallax.')
93 schema.addField('pmParallaxLnL', type='F',
94 doc='Natural log of the likelihood of the linear proper motion parallax fit.')
95 schema.addField('pmParallaxChi2', type='F',
96 doc='Chi^2 static of the model fit.')
97 schema.addField('pmParallaxNdata', type='I',
98 doc='The number of data points used to fit the model.')
99 schema.addField('uPSFluxMean', type='F',
100 doc='Weighted mean point-source model magnitude for u filter.')
101 schema.addField('uPSFluxMeanErr', type='F',
102 doc='Standard error of uPSFluxMean.')
103 schema.addField('uPSFluxSigma', type='F',
104 doc='Standard deviation of the distribution of uPSFlux.')
105 schema.addField('uPSFluxChi2', type='F',
106 doc='Chi^2 statistic for the scatter of uPSFlux around uPSFluxMean.')
107 schema.addField('uPSFluxNdata', type='I',
108 doc='The number of data points used to compute uPSFluxChi2.')
109 schema.addField('uFPFluxMean', type='F',
110 doc='Weighted mean forced photometry flux for u filter.')
111 schema.addField('uFPFluxMeanErr', type='F',
112 doc='Standard error of uFPFluxMean.')
113 schema.addField('uFPFluxSigma', type='F',
114 doc='Standard deviation of the distribution of uFPFlux.')
115 schema.addField('gPSFluxMean', type='F',
116 doc='Weighted mean point-source model magnitude for g filter.')
117 schema.addField('gPSFluxMeanErr', type='F',
118 doc='Standard error of gPSFluxMean.')
119 schema.addField('gPSFluxSigma', type='F',
120 doc='Standard deviation of the distribution of gPSFlux.')
121 schema.addField('gPSFluxChi2', type='F',
122 doc='Chi^2 statistic for the scatter of gPSFlux around gPSFluxMean.')
123 schema.addField('gPSFluxNdata', type='I',
124 doc='The number of data points used to compute gPSFluxChi2.')
125 schema.addField('gFPFluxMean', type='F',
126 doc='Weighted mean forced photometry flux for g filter.')
127 schema.addField('gFPFluxMeanErr', type='F',
128 doc='Standard error of gFPFluxMean.')
129 schema.addField('gFPFluxSigma', type='F',
130 doc='Standard deviation of the distribution of gFPFlux.')
131 schema.addField('rPSFluxMean', type='F',
132 doc='Weighted mean point-source model magnitude for r filter.')
133 schema.addField('rPSFluxMeanErr', type='F',
134 doc='Standard error of rPSFluxMean.')
135 schema.addField('rPSFluxSigma', type='F',
136 doc='Standard deviation of the distribution of rPSFlux.')
137 schema.addField('rPSFluxChi2', type='F',
138 doc='Chi^2 statistic for the scatter of rPSFlux around rPSFluxMean.')
139 schema.addField('rPSFluxNdata', type='I',
140 doc='The number of data points used to compute rPSFluxChi2.')
141 schema.addField('rFPFluxMean', type='F',
142 doc='Weighted mean forced photometry flux for r filter.')
143 schema.addField('rFPFluxMeanErr', type='F',
144 doc='Standard error of rFPFluxMean.')
145 schema.addField('rFPFluxSigma', type='F',
146 doc='Standard deviation of the distribution of rFPFlux.')
147 schema.addField('iPSFluxMean', type='F',
148 doc='Weighted mean point-source model magnitude for i filter.')
149 schema.addField('iPSFluxMeanErr', type='F',
150 doc='Standard error of iPSFluxMean.')
151 schema.addField('iPSFluxSigma', type='F',
152 doc='Standard deviation of the distribution of iPSFlux.')
153 schema.addField('iPSFluxChi2', type='F',
154 doc='Chi^2 statistic for the scatter of iPSFlux around iPSFluxMean.')
155 schema.addField('iPSFluxNdata', type='I',
156 doc='The number of data points used to compute iPSFluxChi2.')
157 schema.addField('iFPFluxMean', type='F',
158 doc='Weighted mean forced photometry flux for i filter.')
159 schema.addField('iFPFluxMeanErr', type='F',
160 doc='Standard error of iFPFluxMean.')
161 schema.addField('iFPFluxSigma', type='F',
162 doc='Standard deviation of the distribution of iFPFlux.')
163 schema.addField('zPSFluxMean', type='F',
164 doc='Weighted mean point-source model magnitude for z filter.')
165 schema.addField('zPSFluxMeanErr', type='F',
166 doc='Standard error of zPSFluxMean.')
167 schema.addField('zPSFluxSigma', type='F',
168 doc='Standard deviation of the distribution of zPSFlux.')
169 schema.addField('zPSFluxChi2', type='F',
170 doc='Chi^2 statistic for the scatter of zPSFlux around zPSFluxMean.')
171 schema.addField('zPSFluxNdata', type='I',
172 doc='The number of data points used to compute zPSFluxChi2.')
173 schema.addField('zFPFluxMean', type='F',
174 doc='Weighted mean forced photometry flux for z filter.')
175 schema.addField('zFPFluxMeanErr', type='F',
176 doc='Standard error of zFPFluxMean.')
177 schema.addField('zFPFluxSigma', type='F',
178 doc='Standard deviation of the distribution of zFPFlux.')
179 schema.addField('yPSFluxMean', type='F',
180 doc='Weighted mean point-source model magnitude for y filter.')
181 schema.addField('yPSFluxMeanErr', type='F',
182 doc='Standard error of yPSFluxMean.')
183 schema.addField('yPSFluxSigma', type='F',
184 doc='Standard deviation of the distribution of yPSFlux.')
185 schema.addField('yPSFluxChi2', type='F',
186 doc='Chi^2 statistic for the scatter of yPSFlux around yPSFluxMean.')
187 schema.addField('yPSFluxNdata', type='I',
188 doc='The number of data points used to compute yPSFluxChi2.')
189 schema.addField('yFPFluxMean', type='F',
190 doc='Weighted mean forced photometry flux for y filter.')
191 schema.addField('yFPFluxMeanErr', type='F',
192 doc='Standard error of yFPFluxMean.')
193 schema.addField('yFPFluxSigma', type='F',
194 doc='Standard deviation of the distribution of yFPFlux.')
195 # Mapping of arrays and BLOBs is not currently supported by the APDB so we
196 # these columns out.
197 # schema.addField('uLcPeriodic', type='ArrayF',
198 # doc='Periodic features extracted from light-curves using generalized Lomb-Scargle '
199 # 'periodogram for u filter. [32 FLOAT].')
200 # schema.addField('gLcPeriodic', type='ArrayF',
201 # doc='Periodic features extracted from light-curves using generalized Lomb-Scargle '
202 # 'periodogram for g filter. [32 FLOAT].')
203 # schema.addField('rLcPeriodic', type='ArrayF',
204 # doc='Periodic features extracted from light-curves using generalized Lomb-Scargle '
205 # 'periodogram for r filter. [32 FLOAT].')
206 # schema.addField('iLcPeriodic', type='ArrayF',
207 # doc='Periodic features extracted from light-curves using generalized Lomb-Scargle '
208 # 'periodogram for i filter. [32 FLOAT].')
209 # schema.addField('zLcPeriodic', type='ArrayF',
210 # doc='Periodic features extracted from light-curves using generalized Lomb-Scargle '
211 # 'periodogram for z filter. [32 FLOAT].')
212 # schema.addField('yLcPeriodic', type='ArrayF',
213 # doc='Periodic features extracted from light-curves using generalized Lomb-Scargle '
214 # 'periodogram for y filter. [32 FLOAT].')
215 # schema.addField('uLcNonPeriodic', type='ArrayF',
216 # doc='Non-periodic features extracted from light-curves using generalized Lomb-Scargle '
217 # 'periodogram for u filter. [20 FLOAT].')
218 # schema.addField('gLcNonPeriodic', type='ArrayF',
219 # doc='Non-periodic features extracted from light-curves using generalized Lomb-Scargle '
220 # 'periodogram for g filter. [20 FLOAT].')
221 # schema.addField('rLcNonPeriodic', type='ArrayF',
222 # doc='Non-periodic features extracted from light-curves using generalized Lomb-Scargle '
223 # 'periodogram for r filter. [20 FLOAT].')
224 # schema.addField('iLcNonPeriodic', type='ArrayF',
225 # doc='Non-periodic features extracted from light-curves using generalized Lomb-Scargle '
226 # 'periodogram for i filter. [20 FLOAT].')
227 # schema.addField('zLcNonPeriodic', type='ArrayF',
228 # doc='Non-periodic features extracted from light-curves using generalized Lomb-Scargle '
229 # 'periodogram for z filter. [20 FLOAT].')
230 # schema.addField('yLcNonPeriodic', type='ArrayF',
231 # doc='Non-periodic features extracted from light-curves using generalized Lomb-Scargle '
232 # 'periodogram for y filter. [20 FLOAT].')
233 schema.addField('nearbyObj1', type='L',
234 doc='Id of the closest nearby object.')
235 schema.addField('nearbyObj1Dist', type='F',
236 doc='Distance to nearbyObj1.')
237 schema.addField('nearbyObj1LnP', type='F',
238 doc='Natural log of the probability that the observed diaObject is the same as the '
239 'nearbyObj1.')
240 schema.addField('nearbyObj2', type='L',
241 doc='Id of the second-closest nearby object.')
242 schema.addField('nearbyObj2Dist', type='F',
243 doc='Distance to nearbyObj2.')
244 schema.addField('nearbyObj2LnP', type='F',
245 doc='Natural log of the probability that the observed diaObject is the same as the '
246 'nearbyObj2.')
247 schema.addField('nearbyObj3', type='L',
248 doc='Id of the third-closest nearby object.')
249 schema.addField('nearbyObj3Dist', type='F',
250 doc='Distance to nearbyObj3.')
251 schema.addField('nearbyObj3LnP', type='F',
252 doc='Natural log of the probability that the observed diaObject is the same as the '
253 'nearbyObj3.')
254 schema.addField('flags', type='L',
255 doc='Flags, bitwise OR tbd.')
256 schema.addField('pixelId', type='L',
257 doc='HTM index.')
258 schema.addField('lastNonForcedSource', type='L',
259 doc='Last time when non-forced DIASource was seen for this object')
260 schema.addField('nDiaSources', type='I',
261 doc='Total number of DiaSources associated with this DiaObject.')
262 schema.addField('uTOTFluxMean', type='F',
263 doc='Weighted mean forced photometry flux for u filter.')
264 schema.addField('uTOTFluxMeanErr', type='F',
265 doc='Standard error of uTOTFluxMean.')
266 schema.addField('uTOTFluxSigma', type='F',
267 doc='Standard deviation of the distribution of uTOTFlux.')
268 schema.addField('gTOTFluxMean', type='F',
269 doc='Weighted mean forced photometry flux for g filter.')
270 schema.addField('gTOTFluxMeanErr', type='F',
271 doc='Standard error of uTOTFluxMean.')
272 schema.addField('gTOTFluxSigma', type='F',
273 doc='Standard deviation of the distribution of gTOTFlux.')
274 schema.addField('rTOTFluxMean', type='F',
275 doc='Weighted mean forced photometry flux for r filter.')
276 schema.addField('rTOTFluxMeanErr', type='F',
277 doc='Standard error of uTOTFluxMean.')
278 schema.addField('rTOTFluxSigma', type='F',
279 doc='Standard deviation of the distribution of rTOTFlux.')
280 schema.addField('iTOTFluxMean', type='F',
281 doc='Weighted mean forced photometry flux for i filter.')
282 schema.addField('iTOTFluxMeanErr', type='F',
283 doc='Standard error of uTOTFluxMean.')
284 schema.addField('iTOTFluxSigma', type='F',
285 doc='Standard deviation of the distribution of iTOTFlux.')
286 schema.addField('zTOTFluxMean', type='F',
287 doc='Weighted mean forced photometry flux for z filter.')
288 schema.addField('zTOTFluxMeanErr', type='F',
289 doc='Standard error of uTOTFluxMean.')
290 schema.addField('zTOTFluxSigma', type='F',
291 doc='Standard deviation of the distribution of zTOTFlux.')
292 schema.addField('yTOTFluxMean', type='F',
293 doc='Weighted mean forced photometry flux for y filter.')
294 schema.addField('yTOTFluxMeanErr', type='F',
295 doc='Standard error of uTOTFluxMean.')
296 schema.addField('yTOTFluxSigma', type='F',
297 doc='Standard deviation of the distribution of yTOTFlux.')
298 schema.addField('uPSFluxMAD', type='F',
299 doc='Median absolute deviation u band fluxes.')
300 schema.addField('uPSFluxSkew', type='F',
301 doc='Skewness of the u band fluxes.')
302 schema.addField('uPSFluxPercentile05', type='F',
303 doc='Value at the 5% percentile of the u band fluxes.')
304 schema.addField('uPSFluxPercentile25', type='F',
305 doc='Value at the 25% percentile of the u band fluxes.')
306 schema.addField('uPSFluxPercentile50', type='F',
307 doc='Value at the 50% percentile of the u band fluxes.')
308 schema.addField('uPSFluxPercentile75', type='F',
309 doc='Value at the 75% percentile of the u band fluxes.')
310 schema.addField('uPSFluxPercentile95', type='F',
311 doc='Value at the 95% percentile of the u band fluxes.')
312 schema.addField('uPSFluxMin', type='F',
313 doc='Minimum observed u band fluxes.')
314 schema.addField('uPSFluxMax', type='F',
315 doc='Maximum observed u band fluxes.')
316 schema.addField('uPSFluxStetsonJ', type='F',
317 doc='StetsonJ statistic for the u band fluxes.')
318 schema.addField('uPSFluxLinearSlope', type='F',
319 doc='Linear best fit slope of the u band fluxes.')
320 schema.addField('uPSFluxLinearIntercept', type='F',
321 doc='Linear best fit Intercept of the u band fluxes.')
322 schema.addField('uPSFluxMaxSlope', type='F',
323 doc='Maximum slope between u band flux observations max(delta_flux/delta_time)')
324 schema.addField('uPSFluxErrMean', type='F',
325 doc='Mean of the u band flux errors.')
326 schema.addField('gPSFluxMAD', type='F',
327 doc='Median absolute deviation g band fluxes.')
328 schema.addField('gPSFluxSkew', type='F',
329 doc='Skewness of the g band fluxes.')
330 schema.addField('gPSFluxPercentile05', type='F',
331 doc='Value at the 5% percentile of the g band fluxes.')
332 schema.addField('gPSFluxPercentile25', type='F',
333 doc='Value at the 25% percentile of the g band fluxes.')
334 schema.addField('gPSFluxPercentile50', type='F',
335 doc='Value at the 50% percentile of the g band fluxes.')
336 schema.addField('gPSFluxPercentile75', type='F',
337 doc='Value at the 75% percentile of the g band fluxes.')
338 schema.addField('gPSFluxPercentile95', type='F',
339 doc='Value at the 95% percentile of the g band fluxes.')
340 schema.addField('gPSFluxMin', type='F',
341 doc='Minimum observed g band fluxes.')
342 schema.addField('gPSFluxMax', type='F',
343 doc='Maximum observed g band fluxes.')
344 schema.addField('gPSFluxStetsonJ', type='F',
345 doc='StetsonJ statistic for the g band fluxes.')
346 schema.addField('gPSFluxLinearSlope', type='F',
347 doc='Linear best fit slope of the g band fluxes.')
348 schema.addField('gPSFluxLinearIntercept', type='F',
349 doc='Linear best fit Intercept of the g band fluxes.')
350 schema.addField('gPSFluxMaxSlope', type='F',
351 doc='Maximum slope between g band flux observations max(delta_flux/delta_time)')
352 schema.addField('gPSFluxErrMean', type='F',
353 doc='Mean of the g band flux errors.')
354 schema.addField('rPSFluxMAD', type='F',
355 doc='Median absolute deviation r band fluxes.')
356 schema.addField('rPSFluxSkew', type='F',
357 doc='Skewness of the r band fluxes.')
358 schema.addField('rPSFluxPercentile05', type='F',
359 doc='Value at the 5% percentile of the r band fluxes.')
360 schema.addField('rPSFluxPercentile25', type='F',
361 doc='Value at the 25% percentile of the r band fluxes.')
362 schema.addField('rPSFluxPercentile50', type='F',
363 doc='Value at the 50% percentile of the r band fluxes.')
364 schema.addField('rPSFluxPercentile75', type='F',
365 doc='Value at the 75% percentile of the r band fluxes.')
366 schema.addField('rPSFluxPercentile95', type='F',
367 doc='Value at the 95% percentile of the r band fluxes.')
368 schema.addField('rPSFluxMin', type='F',
369 doc='Minimum observed r band fluxes.')
370 schema.addField('rPSFluxMax', type='F',
371 doc='Maximum observed r band fluxes.')
372 schema.addField('rPSFluxStetsonJ', type='F',
373 doc='StetsonJ statistic for the r band fluxes.')
374 schema.addField('rPSFluxLinearSlope', type='F',
375 doc='Linear best fit slope of the r band fluxes.')
376 schema.addField('rPSFluxLinearIntercept', type='F',
377 doc='Linear best fit Intercept of the r band fluxes.')
378 schema.addField('rPSFluxMaxSlope', type='F',
379 doc='Maximum slope between r band flux observations max(delta_flux/delta_time)')
380 schema.addField('rPSFluxErrMean', type='F',
381 doc='Mean of the r band flux errors.')
382 schema.addField('iPSFluxMAD', type='F',
383 doc='Median absolute deviation i band fluxes.')
384 schema.addField('iPSFluxSkew', type='F',
385 doc='Skewness of the i band fluxes.')
386 schema.addField('iPSFluxPercentile05', type='F',
387 doc='Value at the 5% percentile of the i band fluxes.')
388 schema.addField('iPSFluxPercentile25', type='F',
389 doc='Value at the 25% percentile of the i band fluxes.')
390 schema.addField('iPSFluxPercentile50', type='F',
391 doc='Value at the 50% percentile of the i band fluxes.')
392 schema.addField('iPSFluxPercentile75', type='F',
393 doc='Value at the 75% percentile of the i band fluxes.')
394 schema.addField('iPSFluxPercentile95', type='F',
395 doc='Value at the 95% percentile of the i band fluxes.')
396 schema.addField('iPSFluxMin', type='F',
397 doc='Minimum observed i band fluxes.')
398 schema.addField('iPSFluxMax', type='F',
399 doc='Maximum observed i band fluxes.')
400 schema.addField('iPSFluxStetsonJ', type='F',
401 doc='StetsonJ statistic for the i band fluxes.')
402 schema.addField('iPSFluxLinearSlope', type='F',
403 doc='Linear best fit slope of the i band fluxes.')
404 schema.addField('iPSFluxLinearIntercept', type='F',
405 doc='Linear best fit Intercept of the i band fluxes.')
406 schema.addField('iPSFluxMaxSlope', type='F',
407 doc='Maximum slope between i band flux observations max(delta_flux/delta_time)')
408 schema.addField('iPSFluxErrMean', type='F',
409 doc='Mean of the i band flux errors.')
410 schema.addField('zPSFluxMAD', type='F',
411 doc='Median absolute deviation z band fluxes.')
412 schema.addField('zPSFluxSkew', type='F',
413 doc='Skewness of the z band fluxes.')
414 schema.addField('zPSFluxPercentile05', type='F',
415 doc='Value at the 5% percentile of the z band fluxes.')
416 schema.addField('zPSFluxPercentile25', type='F',
417 doc='Value at the 25% percentile of the z band fluxes.')
418 schema.addField('zPSFluxPercentile50', type='F',
419 doc='Value at the 50% percentile of the z band fluxes.')
420 schema.addField('zPSFluxPercentile75', type='F',
421 doc='Value at the 75% percentile of the z band fluxes.')
422 schema.addField('zPSFluxPercentile95', type='F',
423 doc='Value at the 95% percentile of the z band fluxes.')
424 schema.addField('zPSFluxMin', type='F',
425 doc='Minimum observed z band fluxes.')
426 schema.addField('zPSFluxMax', type='F',
427 doc='Maximum observed z band fluxes.')
428 schema.addField('zPSFluxStetsonJ', type='F',
429 doc='StetsonJ statistic for the z band fluxes.')
430 schema.addField('zPSFluxLinearSlope', type='F',
431 doc='Linear best fit slope of the z band fluxes.')
432 schema.addField('zPSFluxLinearIntercept', type='F',
433 doc='Linear best fit Intercept of the z band fluxes.')
434 schema.addField('zPSFluxMaxSlope', type='F',
435 doc='Maximum slope between z band flux observations max(delta_flux/delta_time)')
436 schema.addField('zPSFluxErrMean', type='F',
437 doc='Mean of the z band flux errors.')
438 schema.addField('yPSFluxMAD', type='F',
439 doc='Median absolute deviation y band fluxes.')
440 schema.addField('yPSFluxSkew', type='F',
441 doc='Skewness of the y band fluxes.')
442 schema.addField('yPSFluxPercentile05', type='F',
443 doc='Value at the 5% percentile of the y band fluxes.')
444 schema.addField('yPSFluxPercentile25', type='F',
445 doc='Value at the 25% percentile of the y band fluxes.')
446 schema.addField('yPSFluxPercentile50', type='F',
447 doc='Value at the 50% percentile of the y band fluxes.')
448 schema.addField('yPSFluxPercentile75', type='F',
449 doc='Value at the 75% percentile of the y band fluxes.')
450 schema.addField('yPSFluxPercentile95', type='F',
451 doc='Value at the 95% percentile of the y band fluxes.')
452 schema.addField('yPSFluxMin', type='F',
453 doc='Minimum observed y band fluxes.')
454 schema.addField('yPSFluxMax', type='F',
455 doc='Maximum observed y band fluxes.')
456 schema.addField('yPSFluxStetsonJ', type='F',
457 doc='StetsonJ statistic for the y band fluxes.')
458 schema.addField('yPSFluxLinearSlope', type='F',
459 doc='Linear best fit slope of the y band fluxes.')
460 schema.addField('yPSFluxLinearIntercept', type='F',
461 doc='Linear best fit Intercept of the y band fluxes.')
462 schema.addField('yPSFluxMaxSlope', type='F',
463 doc='Maximum slope between y band flux observations max(delta_flux/delta_time)')
464 schema.addField('yPSFluxErrMean', type='F',
465 doc='Mean of the y band flux errors.')
467 return schema
470def make_dia_source_schema():
471 """ Define and create the schema required for a DIASource with additional
472 needed columns for later calculation in `DiaPipeTask`.
474 Returns
475 -------
476 schema : `lsst.afw.table.Schema`
477 Minimal schema for DiaSources.
478 """
480 # Generated automatically from apdb-schema.yaml in dax_apdb/data.
481 schema = afwTable.SourceTable.makeMinimalSchema()
482 schema.addField('ccdVisitId', type='L',
483 doc='Id of the ccdVisit where this diaSource was measured. Note that we are allowing a '
484 'diaSource to belong to multiple amplifiers, but it may not span multiple ccds.')
485 schema.addField('diaObjectId', type='L',
486 doc='Id of the diaObject this source was associated with, if any. If not, it is set to '
487 'NULL (each diaSource will be associated with either a diaObject or ssObject).')
488 schema.addField('ssObjectId', type='L',
489 doc='Id of the ssObject this source was associated with, if any. If not, it is set to '
490 'NULL (each diaSource will be associated with either a diaObject or ssObject).')
491 schema.addField('prv_procOrder', type='I',
492 doc='Position of this diaSource in the processing order relative to other diaSources '
493 'within a given diaObjectId or ssObjectId.')
494 schema.addField('ssObjectReassocTime', type='D',
495 doc='Time when this diaSource was reassociated from diaObject to ssObject (if such '
496 'reassociation happens, otherwise NULL).')
497 schema.addField('midPointTai', type='D',
498 doc='Effective mid-exposure time for this diaSource.')
499 schema.addField('raErr', type='D',
500 doc='Uncertainty of ra.')
501 schema.addField('declErr', type='D',
502 doc='Uncertainty of decl.')
503 schema.addField('ra_decl_Cov', type='D',
504 doc='Covariance between ra and decl.')
505 schema.addField('x', type='D',
506 doc='x position computed by a centroiding algorithm.')
507 schema.addField('xErr', type='F',
508 doc='Uncertainty of x.')
509 schema.addField('y', type='D',
510 doc='y position computed by a centroiding algorithm.')
511 schema.addField('yErr', type='F',
512 doc='Uncertainty of y.')
513 schema.addField('x_y_Cov', type='D',
514 doc='Covariance between x and y.')
515 schema.addField('apFlux', type='D',
516 doc='Calibrated aperture flux. Note that this actually measures the difference between '
517 'the template and the visit image.')
518 schema.addField('apFluxErr', type='D',
519 doc='Estimated uncertainty of apFlux.')
520 schema.addField('snr', type='D',
521 doc='The signal-to-noise ratio at which this source was detected in the difference '
522 'image.')
523 schema.addField('psFlux', type='D',
524 doc='Calibrated flux for Point Source model. Note this actually measures the flux '
525 'difference between the template and the visit image.')
526 schema.addField('psFluxErr', type='D',
527 doc='Uncertainty of psFlux.')
528 schema.addField('psRa', type='D',
529 doc=' RA-coordinate of centroid for point source model.')
530 schema.addField('psRaErr', type='D',
531 doc='Uncertainty of psRa.')
532 schema.addField('psDecl', type='D',
533 doc=' Decl-coordinate of centroid for point source model.')
534 schema.addField('psDeclErr', type='D',
535 doc='Uncertainty of psDecl.')
536 schema.addField('psFlux_psRa_Cov', type='D',
537 doc='Covariance between psFlux and psRa.')
538 schema.addField('psFlux_psDecl_Cov', type='D',
539 doc='Covariance between psFlux and psDecl.')
540 schema.addField('psRa_psDecl_Cov', type='D',
541 doc='Covariance between psRa and psDecl.')
542 schema.addField('psLnL', type='D',
543 doc='Natural log likelihood of the observed data given the Point Source model.')
544 schema.addField('psChi2', type='D',
545 doc='Chi^2 statistic of the model fit.')
546 schema.addField('psNdata', type='I',
547 doc='The number of data points (pixels) used to fit the model.')
548 schema.addField('trailFlux', type='D',
549 doc='Calibrated flux for a trailed source model. Note this actually measures the flux '
550 'difference between the template and the visit image.')
551 schema.addField('trailFluxErr', type='D',
552 doc='Uncertainty of trailFlux.')
553 schema.addField('trailRa', type='D',
554 doc=' RA-coordinate of centroid for trailed source model.')
555 schema.addField('trailRaErr', type='D',
556 doc='Uncertainty of trailRa.')
557 schema.addField('trailDecl', type='D',
558 doc=' Decl-coordinate of centroid for trailed source model.')
559 schema.addField('trailDeclErr', type='D',
560 doc='Uncertainty of trailDecl.')
561 schema.addField('trailLength', type='D',
562 doc='Maximum likelihood fit of trail length.')
563 schema.addField('trailLengthErr', type='D',
564 doc='Uncertainty of trailLength.')
565 schema.addField('trailAngle', type='D',
566 doc='Maximum likelihood fit of the angle between the meridian through the centroid and '
567 'the trail direction (bearing).')
568 schema.addField('trailAngleErr', type='D',
569 doc='Uncertainty of trailAngle.')
570 schema.addField('trailFlux_trailRa_Cov', type='D',
571 doc='Covariance of trailFlux and trailRa.')
572 schema.addField('trailFlux_trailDecl_Cov', type='D',
573 doc='Covariance of trailFlux and trailDecl.')
574 schema.addField('trailFlux_trailLength_Cov', type='D',
575 doc='Covariance of trailFlux and trailLength')
576 schema.addField('trailFlux_trailAngle_Cov', type='D',
577 doc='Covariance of trailFlux and trailAngle')
578 schema.addField('trailRa_trailDecl_Cov', type='D',
579 doc='Covariance of trailRa and trailDecl.')
580 schema.addField('trailRa_trailLength_Cov', type='D',
581 doc='Covariance of trailRa and trailLength.')
582 schema.addField('trailRa_trailAngle_Cov', type='D',
583 doc='Covariance of trailRa and trailAngle.')
584 schema.addField('trailDecl_trailLength_Cov', type='D',
585 doc='Covariance of trailDecl and trailLength.')
586 schema.addField('trailDecl_trailAngle_Cov', type='D',
587 doc='Covariance of trailDecl and trailAngle.')
588 schema.addField('trailLength_trailAngle_Cov', type='D',
589 doc='Covariance of trailLength and trailAngle')
590 schema.addField('trailLnL', type='D',
591 doc='Natural log likelihood of the observed data given the trailed source model.')
592 schema.addField('trailChi2', type='D',
593 doc='Chi^2 statistic of the model fit.')
594 schema.addField('trailNdata', type='I',
595 doc='The number of data points (pixels) used to fit the model.')
596 schema.addField('dipMeanFlux', type='D',
597 doc='Maximum likelihood value for the mean absolute flux of the two lobes for a dipole '
598 'model.')
599 schema.addField('dipMeanFluxErr', type='D',
600 doc='Uncertainty of dipMeanFlux.')
601 schema.addField('dipFluxDiff', type='D',
602 doc='Maximum likelihood value for the difference of absolute fluxes of the two lobes for '
603 'a dipole model.')
604 schema.addField('dipFluxDiffErr', type='D',
605 doc='Uncertainty of dipFluxDiff.')
606 schema.addField('dipRa', type='D',
607 doc=' RA-coordinate of centroid for dipole model.')
608 schema.addField('dipRaErr', type='D',
609 doc='Uncertainty of trailRa.')
610 schema.addField('dipDecl', type='D',
611 doc=' Decl-coordinate of centroid for dipole model.')
612 schema.addField('dipDeclErr', type='D',
613 doc='Uncertainty of dipDecl.')
614 schema.addField('dipLength', type='D',
615 doc='Maximum likelihood value for the lobe separation in dipole model.')
616 schema.addField('dipLengthErr', type='D',
617 doc='Uncertainty of dipLength.')
618 schema.addField('dipAngle', type='D',
619 doc='Maximum likelihood fit of the angle between the meridian through the centroid and '
620 'the dipole direction (bearing, from negative to positive lobe).')
621 schema.addField('dipAngleErr', type='D',
622 doc='Uncertainty of dipAngle.')
623 schema.addField('dipMeanFlux_dipFluxDiff_Cov', type='D',
624 doc='Covariance of dipMeanFlux and dipFluxDiff.')
625 schema.addField('dipMeanFlux_dipRa_Cov', type='D',
626 doc='Covariance of dipMeanFlux and dipRa.')
627 schema.addField('dipMeanFlux_dipDecl_Cov', type='D',
628 doc='Covariance of dipMeanFlux and dipDecl.')
629 schema.addField('dipMeanFlux_dipLength_Cov', type='D',
630 doc='Covariance of dipMeanFlux and dipLength.')
631 schema.addField('dipMeanFlux_dipAngle_Cov', type='D',
632 doc='Covariance of dipMeanFlux and dipAngle.')
633 schema.addField('dipFluxDiff_dipRa_Cov', type='D',
634 doc='Covariance of dipFluxDiff and dipRa.')
635 schema.addField('dipFluxDiff_dipDecl_Cov', type='D',
636 doc='Covariance of dipFluxDiff and dipDecl.')
637 schema.addField('dipFluxDiff_dipLength_Cov', type='D',
638 doc='Covariance of dipFluxDiff and dipLength.')
639 schema.addField('dipFluxDiff_dipAngle_Cov', type='D',
640 doc='Covariance of dipFluxDiff and dipAngle.')
641 schema.addField('dipRa_dipDecl_Cov', type='D',
642 doc='Covariance of dipRa and dipDecl.')
643 schema.addField('dipRa_dipLength_Cov', type='D',
644 doc='Covariance of dipRa and dipLength.')
645 schema.addField('dipRa_dipAngle_Cov', type='D',
646 doc='Covariance of dipRa and dipAngle.')
647 schema.addField('dipDecl_dipLength_Cov', type='D',
648 doc='Covariance of dipDecl and dipLength.')
649 schema.addField('dipDecl_dipAngle_Cov', type='D',
650 doc='Covariance of dipDecl and dipAngle.')
651 schema.addField('dipLength_dipAngle_Cov', type='D',
652 doc='Covariance of dipLength and dipAngle.')
653 schema.addField('dipLnL', type='D',
654 doc='Natural log likelihood of the observed data given the dipole source model.')
655 schema.addField('dipChi2', type='D',
656 doc='Chi^2 statistic of the model fit.')
657 schema.addField('dipNdata', type='I',
658 doc='The number of data points (pixels) used to fit the model.')
659 schema.addField('totFlux', type='D',
660 doc='Calibrated flux for Point Source model measured on the visit image centered at the '
661 'centroid measured on the difference image (forced photometry flux).')
662 schema.addField('totFluxErr', type='D',
663 doc='Estimated uncertainty of totFlux.')
664 schema.addField('diffFlux', type='D',
665 doc='Calibrated flux for Point Source model centered on radec but measured on the '
666 'difference of snaps comprising this visit.')
667 schema.addField('diffFluxErr', type='D',
668 doc='Estimated uncertainty of diffFlux.')
669 schema.addField('fpBkgd', type='D',
670 doc='Estimated sky background at the position (centroid) of the object.')
671 schema.addField('fpBkgdErr', type='D',
672 doc='Estimated uncertainty of fpBkgd.')
673 schema.addField('ixx', type='D',
674 doc='Adaptive second moment of the source intensity.')
675 schema.addField('ixxErr', type='F',
676 doc='Uncertainty of ixx.')
677 schema.addField('iyy', type='D',
678 doc='Adaptive second moment of the source intensity.')
679 schema.addField('iyyErr', type='F',
680 doc='Uncertainty of iyy.')
681 schema.addField('ixy', type='D',
682 doc='Adaptive second moment of the source intensity.')
683 schema.addField('ixyErr', type='F',
684 doc='Uncertainty of ixy.')
685 schema.addField('ixx_iyy_Cov', type='D',
686 doc='Covariance of ixx and iyy.')
687 schema.addField('ixx_ixy_Cov', type='D',
688 doc='Covariance of ixx and ixy.')
689 schema.addField('iyy_ixy_Cov', type='D',
690 doc='Covariance of iyy and ixy.')
691 schema.addField('ixxPSF', type='D',
692 doc='Adaptive second moment for the PSF.')
693 schema.addField('iyyPSF', type='D',
694 doc='Adaptive second moment for the PSF.')
695 schema.addField('ixyPSF', type='D',
696 doc='Adaptive second moment for the PSF.')
697 schema.addField('extendedness', type='D',
698 doc='A measure of extendedness, Computed using a combination of available moments and '
699 'model fluxes or from a likelihood ratio of point/trailed source models (exact '
700 'algorithm TBD). extendedness = 1 implies a high degree of confidence that the '
701 'source is extended. extendedness = 0 implies a high degree of confidence that the '
702 'source is point-like.')
703 schema.addField('spuriousness', type='D',
704 doc='A measure of spuriousness, computed using information from the source and image '
705 'characterization, as well as the information on the Telescope and Camera system '
706 '(e.g., ghost maps, defect maps, etc.).')
707 schema.addField('flags', type='L',
708 doc='Flags, bitwise OR tbd.')
709 schema.addField('pixelId', type='L',
710 doc='HTM index.')
711 schema.addField("filterName", type='String', size=10,
712 doc='String name of the filter this source was observed '
713 'in.')
714 schema.addField("filterId", type='L',
715 doc='Obs package id of the filter this source was '
716 'observed in.')
717 schema.addField("isDipole", type='Flag',
718 doc='Object determined to be a dipole.')
719 schema.addField("bboxSize", type='L',
720 doc='Length of the square bounding box for cutouts in the '
721 'alerts.')
722 return schema
725def make_dia_forced_source_schema():
726 """ Define and create the minimal schema required for a DiaForcedSource.
728 Returns
729 -------
730 schema : `lsst.afw.table.Schema`
731 Minimal schema for DiaForcedSources.
732 """
734 # Generated automatically from apdb-schema.yaml in dax_apdb/data.
735 schema = afwTable.SourceTable.makeMinimalSchema()
736 schema.addField('ccdVisitId', type='L',
737 doc='Id of the ccdVisit where this diaSource was measured. Note that we are allowing a '
738 'diaSource to belong to multiple amplifiers, but it may not span multiple ccds.')
739 schema.addField('psFlux', type='D',
740 doc='Calibrated flux for Point Source model. Note this actually measures the flux '
741 'difference between the template and the visit image.')
742 schema.addField('psFluxErr', type='D',
743 doc='Uncertainty of psFlux.')
744 schema.addField('totFlux', type='D',
745 doc='Calibrated flux measured in direct image.')
746 schema.addField('totFluxErr', type='D',
747 doc='Uncertainty of totFlux.')
748 schema.addField('x', type='D',
749 doc='x position at which psFlux has been measured.')
750 schema.addField('y', type='D',
751 doc='y position at which psFlux has been measured.')
752 schema.addField('flags', type='L',
753 doc='Flags from measurement on the difference image, '
754 'bitwise OR tbd')
755 schema.addField('flagsDirectIm', type='L',
756 doc='Flags from measurement on the direct image, bitwise '
757 'OR tbd')
758 return schema
761def getCcdVisitSchemaSql():
762 """Define the schema for the CcdVisit table.
764 Returns
765 -------
766 ccdVisitNames : `collections.OrderedDict`
767 Names of columns in the ccdVisit table.
768 """
769 return oDict([("ccdVisitId", "INTEGER PRIMARY KEY"),
770 ("ccdNum", "INTEGER"),
771 ("filterName", "TEXT"),
772 ("filterId", "INTEGER"),
773 ("ra", "REAL"),
774 ("decl", "REAL"),
775 ("expTime", "REAL"),
776 ("expMidptMJD", "REAL"),
777 ("calibrationMean", "REAL"),
778 ("calibrationErr", "REAL")])