LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions
lsst.display.firefly.footprints Namespace Reference

Functions

 recordSelector (record, selection)
 
 createFootprintsTable (catalog, xy0=None, insertColumn=4)
 

Function Documentation

◆ createFootprintsTable()

lsst.display.firefly.footprints.createFootprintsTable ( catalog,
xy0 = None,
insertColumn = 4 )
make a VOTable of SourceData table and footprints

Parameters:
-----------
catalog : `lsst.afw.table.SourceCatalog`
        Source catalog from which to display footprints.
xy0 : tuple or list or None
    Pixel origin to subtract off from the footprint coordinates.
    If None, the value used is (0,0)
insertColumn : `int`
    Column at which to insert the "family_id" and "category" columns

Returns:
--------
`astropy.io.votable.voTableFile`
    VOTable object to upload to Firefly

Definition at line 63 of file footprints.py.

63def createFootprintsTable(catalog, xy0=None, insertColumn=4):
64 """make a VOTable of SourceData table and footprints
65
66 Parameters:
67 -----------
68 catalog : `lsst.afw.table.SourceCatalog`
69 Source catalog from which to display footprints.
70 xy0 : tuple or list or None
71 Pixel origin to subtract off from the footprint coordinates.
72 If None, the value used is (0,0)
73 insertColumn : `int`
74 Column at which to insert the "family_id" and "category" columns
75
76 Returns:
77 --------
78 `astropy.io.votable.voTableFile`
79 VOTable object to upload to Firefly
80 """
81 if xy0 is None:
82 xy0 = geom.Point2I(0, 0)
83
84 _catalog = afwTable.SourceCatalog(catalog.table.clone())
85 _catalog.extend(catalog, deep=True)
86 sourceTable = _catalog.asAstropy()
87
88 # Change int64 dtypes so they convert to VOTable
89 for colName in sourceTable.colnames:
90 if sourceTable[colName].dtype.num == 9:
91 sourceTable[colName].dtype = np.dtype('long')
92
93 inputColumnNames = sourceTable.colnames
94
95 x0, y0 = xy0
96 spanList = []
97 peakList = []
98 familyList = []
99 categoryList = []
100 fpxll = []
101 fpyll = []
102 fpxur = []
103 fpyur = []
104 for record in catalog:
105 footprint = record.getFootprint()
106 recordId = record.getId()
107 spans = footprint.getSpans()
108 scoords = [(s.getY()-y0, s.getX0()-x0, s.getX1()-x0) for s in spans]
109 scoords = np.array(scoords).flatten()
110 scoords = np.ma.MaskedArray(scoords, mask=np.zeros(len(scoords),
111 dtype=np.bool))
112 fpbbox = footprint.getBBox()
113 corners = [(c.getX()-x0, c.getY()-y0) for c in fpbbox.getCorners()]
114 fpxll.append(corners[0][0])
115 fpyll.append(corners[0][1])
116 fpxur.append(corners[2][0])
117 fpyur.append(corners[2][1])
118 peaks = footprint.getPeaks()
119 pcoords = [(p.getFx()-x0, p.getFy()-y0) for p in peaks]
120 pcoords = np.array(pcoords).flatten()
121 pcoords = np.ma.MaskedArray(pcoords, mask=np.zeros(len(pcoords),
122 dtype=np.bool))
123 fpbbox = footprint.getBBox()
124 parentId = record.getParent()
125 nChild = record.get('deblend_nChild')
126 if parentId == 0:
127 familyList.append(recordId)
128 if nChild > 0:
129 # blended parent
130 categoryList.append('blended parent')
131 else:
132 # isolated
133 categoryList.append('isolated')
134 else:
135 # deblended child
136 familyList.append(parentId)
137 categoryList.append('deblended child')
138 spanList.append(scoords)
139 peakList.append(pcoords)
140
141 sourceTable.add_column(Column(np.array(familyList)),
142 name='family_id',
143 index=insertColumn)
144 sourceTable.add_column(Column(np.array(categoryList)),
145 name='category',
146 index=insertColumn+1)
147 sourceTable.add_column(Column(np.array(spanList)), name='spans')
148 sourceTable.add_column(Column(np.array(peakList)), name='peaks')
149 sourceTable.add_column(Column(np.array(fpxll)), name='footprint_corner1_x')
150 sourceTable.add_column(Column(np.array(fpyll)), name='footprint_corner1_y')
151 sourceTable.add_column(Column(np.array(fpxur)), name='footprint_corner2_x')
152 sourceTable.add_column(Column(np.array(fpyur)), name='footprint_corner2_y')
153
154 outputVO = from_table(sourceTable)
155 outTable = outputVO.get_first_table()
156
157 outTable.infos.append(Info(name='contains_lsst_footprints', value='true'))
158 outTable.infos.append(Info(name='contains_lsst_measurements', value='true'))
159 outTable.infos.append(Info(name='FootPrintColumnNames',
160 value='id;footprint_corner1_x;footprint_corner1_y;' +
161 'footprint_corner2_x;footprint_corner2_y;spans;peaks'))
162 outTable.infos.append(Info(name='pixelsys', value='zero-based'))
163 # Check whether the coordinates are included and are valid
164 if (('slot_Centroid_x' in inputColumnNames) and
165 ('slot_Centroid_y' in inputColumnNames) and
166 np.isfinite(outTable.array['slot_Centroid_x']).any() and
167 np.isfinite(outTable.array['slot_Centroid_y']).any()):
168 coord_column_string = 'slot_Centroid_x;slot_Centroid_y;ZERO_BASED'
169 elif (('coord_ra' in inputColumnNames) and
170 ('coord_dec' in inputColumnNames) and
171 np.isfinite(outTable.array['coord_ra']).any() and
172 np.isfinite(outTable.array['coord_dec']).any()):
173 coord_column_string = 'coord_ra;coord_dec;EQ_J2000'
174 elif (('base_SdssCentroid_x' in inputColumnNames) and
175 ('base_SdssCentroid_y' in inputColumnNames) and
176 np.isfinite(outTable.array['base_SdssCentroid_x']).any() and
177 np.isfinite(outTable.array['base_SdssCentroid_y']).any()):
178 coord_column_string = 'base_SdssCentroid_x;base_SdssCentroid_y;ZERO_BASED'
179 else:
180 raise RuntimeError('No valid coordinate columns in catalog')
181 outTable.infos.append(Info(name='CatalogCoordColumns',
182 value=coord_column_string))
183
184 for f in outTable.fields:
185 if f.datatype == 'bit':
186 f.datatype = 'boolean'
187
188 outTable._config['version_1_3_or_later'] = True
189 outputVO.set_all_tables_format('binary2')
190
191 return outputVO

◆ recordSelector()

lsst.display.firefly.footprints.recordSelector ( record,
selection )
Select records from source catalog

Parameters:
-----------
record : `lsst.afw.detect.SourceRecord`
    record to select
selection : `str`
    'all' to select all records. 'blended parents' to select records with
    more than zero children. 'deblended children' to select records with
    non-zero parents. 'isolated' to select records that are not blended,
    meaning zero parents and zero children.
    Values to check for sel

Definition at line 32 of file footprints.py.

32def recordSelector(record, selection):
33 """Select records from source catalog
34
35 Parameters:
36 -----------
37 record : `lsst.afw.detect.SourceRecord`
38 record to select
39 selection : `str`
40 'all' to select all records. 'blended parents' to select records with
41 more than zero children. 'deblended children' to select records with
42 non-zero parents. 'isolated' to select records that are not blended,
43 meaning zero parents and zero children.
44 Values to check for sel
45 """
46 nChildren = record.get('deblend_nChild')
47 parentId = record.getParent()
48 if selection == 'all':
49 return True
50 elif selection == 'blended parents':
51 return (nChildren > 0)
52 elif selection == 'deblended children':
53 return (parentId > 0)
54 elif selection == 'isolated':
55 return ((parentId == 0) and (nChildren == 0))
56 else:
57 raise RuntimeError(
58 f'invalid selection: {selection}\n'
59 'Must be one of "all", "blended parents", "deblended children", "isolated"'
60 )
61
62