LSST Applications g00274db5b6+edbf708997,g00d0e8bbd7+edbf708997,g199a45376c+5137f08352,g1fd858c14a+1d4b6db739,g262e1987ae+f4d9505c4f,g29ae962dfc+7156fb1a53,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3e17d7035e+5b3adc59f5,g3fd5ace14f+852fa6fbcb,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+9f17e571f4,g67b6fd64d1+6dc8069a4c,g74acd417e5+ae494d68d9,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+536efcc10a,g7cc15d900a+d121454f8d,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d7436a09f+28c28d8d6d,g8ea07a8fe4+db21c37724,g92c671f44c+9f17e571f4,g98df359435+b2e6376b13,g99af87f6a8+b0f4ad7b8d,gac66b60396+966efe6077,gb88ae4c679+7dec8f19df,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gc24b5d6ed1+9f17e571f4,gca7fc764a6+6dc8069a4c,gcc769fe2a4+97d0256649,gd7ef33dd92+6dc8069a4c,gdab6d2f7ff+ae494d68d9,gdbb4c4dda9+9f17e571f4,ge410e46f29+6dc8069a4c,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.pipe.tasks.functors.ConvertPixelToArcseconds Class Reference
Inheritance diagram for lsst.pipe.tasks.functors.ConvertPixelToArcseconds:
lsst.pipe.tasks.functors.ComputePixelScale lsst.pipe.tasks.functors.LocalWcs lsst.pipe.tasks.functors.Functor

Public Member Functions

 __init__ (self, col, colCD_1_1, colCD_1_2, colCD_2_1, colCD_2_2, **kwargs)
 
 name (self)
 
 columns (self)
 
 pixelScaleArcseconds (self, cd11, cd12, cd21, cd22)
 
 computeDeltaRaDec (self, x, y, cd11, cd12, cd21, cd22)
 
 computeSkySeparation (self, ra1, dec1, ra2, dec2)
 
 getSkySeparationFromPixel (self, x1, y1, x2, y2, cd11, cd12, cd21, cd22)
 
 computePositionAngle (self, ra1, dec1, ra2, dec2)
 
 getPositionAngleFromDetectorAngle (self, theta, cd11, cd12, cd21, cd22)
 
 noDup (self)
 
 multilevelColumns (self, data, columnIndex=None, returnTuple=False)
 
 __call__ (self, data, dropna=False)
 
 difference (self, data1, data2, **kwargs)
 
 fail (self, df)
 
 shortname (self)
 

Public Attributes

 col = col
 
 colCD_1_1 = colCD_1_1
 
 colCD_1_2 = colCD_1_2
 
 colCD_2_1 = colCD_2_1
 
 colCD_2_2 = colCD_2_2
 
 filt = filt
 
str dataset = dataset if dataset is not None else self._defaultDataset
 
 log = logging.getLogger(type(self).__name__)
 

Protected Member Functions

 _func (self, df)
 
 _get_data_columnLevels (self, data, columnIndex=None)
 
 _get_data_columnLevelNames (self, data, columnIndex=None)
 
 _colsFromDict (self, colDict, columnIndex=None)
 
 _get_columnIndex (self, data)
 
 _get_data (self, data)
 
 _setLevels (self, df)
 
 _dropna (self, vals)
 

Protected Attributes

 _noDup = noDup
 

Static Protected Attributes

str _defaultDataset = 'ref'
 
tuple _dfLevels = ('column',)
 
bool _defaultNoDup = False
 

Detailed Description

Convert a value in units of pixels to units of arcseconds.

Definition at line 1435 of file functors.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pipe.tasks.functors.ConvertPixelToArcseconds.__init__ ( self,
col,
colCD_1_1,
colCD_1_2,
colCD_2_1,
colCD_2_2,
** kwargs )

Definition at line 1438 of file functors.py.

1444 **kwargs):
1445 self.col = col
1446 super().__init__(colCD_1_1,
1447 colCD_1_2,
1448 colCD_2_1,
1449 colCD_2_2,
1450 **kwargs)
1451

Member Function Documentation

◆ __call__()

lsst.pipe.tasks.functors.Functor.__call__ ( self,
data,
dropna = False )
inherited

Definition at line 348 of file functors.py.

348 def __call__(self, data, dropna=False):
349 df = self._get_data(data)
350 try:
351 vals = self._func(df)
352 except Exception as e:
353 self.log.error("Exception in %s call: %s: %s", self.name, type(e).__name__, e)
354 vals = self.fail(df)
355 if dropna:
356 vals = self._dropna(vals)
357
358 return vals
359

◆ _colsFromDict()

lsst.pipe.tasks.functors.Functor._colsFromDict ( self,
colDict,
columnIndex = None )
protectedinherited
Converts dictionary column specficiation to a list of columns.

Definition at line 218 of file functors.py.

218 def _colsFromDict(self, colDict, columnIndex=None):
219 """Converts dictionary column specficiation to a list of columns."""
220 new_colDict = {}
221 columnLevels = self._get_data_columnLevels(None, columnIndex=columnIndex)
222
223 for i, lev in enumerate(columnLevels):
224 if lev in colDict:
225 if isinstance(colDict[lev], str):
226 new_colDict[lev] = [colDict[lev]]
227 else:
228 new_colDict[lev] = colDict[lev]
229 else:
230 new_colDict[lev] = columnIndex.levels[i]
231
232 levelCols = [new_colDict[lev] for lev in columnLevels]
233 cols = list(product(*levelCols))
234 colsAvailable = [col for col in cols if col in columnIndex]
235 return colsAvailable
236

◆ _dropna()

lsst.pipe.tasks.functors.Functor._dropna ( self,
vals )
protectedinherited

Definition at line 345 of file functors.py.

345 def _dropna(self, vals):
346 return vals.dropna()
347

◆ _func()

lsst.pipe.tasks.functors.ConvertPixelToArcseconds._func ( self,
df )
protected

Reimplemented from lsst.pipe.tasks.functors.ComputePixelScale.

Definition at line 1464 of file functors.py.

1464 def _func(self, df):
1465 return df[self.col] * self.pixelScaleArcseconds(df[self.colCD_1_1],
1466 df[self.colCD_1_2],
1467 df[self.colCD_2_1],
1468 df[self.colCD_2_2])
1469
1470

◆ _get_columnIndex()

lsst.pipe.tasks.functors.Functor._get_columnIndex ( self,
data )
protectedinherited
Return columnIndex.

Definition at line 294 of file functors.py.

294 def _get_columnIndex(self, data):
295 """Return columnIndex."""
296
297 if isinstance(data, (DeferredDatasetHandle, InMemoryDatasetHandle)):
298 return data.get(component="columns")
299 else:
300 return None
301

◆ _get_data()

lsst.pipe.tasks.functors.Functor._get_data ( self,
data )
protectedinherited
Retrieve DataFrame necessary for calculation.

The data argument can be a `~pandas.DataFrame`, a
`~lsst.daf.butler.DeferredDatasetHandle`, or
an `~lsst.pipe.base.InMemoryDatasetHandle`.

Returns a DataFrame upon which `self._func` can act.

Definition at line 302 of file functors.py.

302 def _get_data(self, data):
303 """Retrieve DataFrame necessary for calculation.
304
305 The data argument can be a `~pandas.DataFrame`, a
306 `~lsst.daf.butler.DeferredDatasetHandle`, or
307 an `~lsst.pipe.base.InMemoryDatasetHandle`.
308
309 Returns a DataFrame upon which `self._func` can act.
310 """
311 # We wrap a DataFrame in a handle here to take advantage of the
312 # DataFrame delegate DataFrame column wrangling abilities.
313 if isinstance(data, pd.DataFrame):
314 _data = InMemoryDatasetHandle(data, storageClass="DataFrame")
315 elif isinstance(data, (DeferredDatasetHandle, InMemoryDatasetHandle)):
316 _data = data
317 else:
318 raise RuntimeError(f"Unexpected type provided for data. Got {get_full_type_name(data)}.")
319
320 # First thing to do: check to see if the data source has a multilevel
321 # column index or not.
322 columnIndex = self._get_columnIndex(_data)
323 is_multiLevel = isinstance(columnIndex, pd.MultiIndex)
324
325 # Get proper columns specification for this functor.
326 if is_multiLevel:
327 columns = self.multilevelColumns(_data, columnIndex=columnIndex)
328 else:
329 columns = self.columns
330
331 # Load in-memory DataFrame with appropriate columns the gen3 way.
332 df = _data.get(parameters={"columns": columns})
333
334 # Drop unnecessary column levels.
335 if is_multiLevel:
336 df = self._setLevels(df)
337
338 return df
339

◆ _get_data_columnLevelNames()

lsst.pipe.tasks.functors.Functor._get_data_columnLevelNames ( self,
data,
columnIndex = None )
protectedinherited
Gets the content of each of the column levels for a multilevel
table.

Definition at line 204 of file functors.py.

204 def _get_data_columnLevelNames(self, data, columnIndex=None):
205 """Gets the content of each of the column levels for a multilevel
206 table.
207 """
208 if columnIndex is None:
209 columnIndex = data.get(component="columns")
210
211 columnLevels = columnIndex.names
212 columnLevelNames = {
213 level: list(np.unique(np.array([c for c in columnIndex])[:, i]))
214 for i, level in enumerate(columnLevels)
215 }
216 return columnLevelNames
217

◆ _get_data_columnLevels()

lsst.pipe.tasks.functors.Functor._get_data_columnLevels ( self,
data,
columnIndex = None )
protectedinherited
Gets the names of the column index levels.

This should only be called in the context of a multilevel table.

Parameters
----------
data : various
    The data to be read, can be a
    `~lsst.daf.butler.DeferredDatasetHandle` or
    `~lsst.pipe.base.InMemoryDatasetHandle`.
columnIndex (optional): pandas `~pandas.Index` object
    If not passed, then it is read from the
    `~lsst.daf.butler.DeferredDatasetHandle`
    for `~lsst.pipe.base.InMemoryDatasetHandle`.

Definition at line 184 of file functors.py.

184 def _get_data_columnLevels(self, data, columnIndex=None):
185 """Gets the names of the column index levels.
186
187 This should only be called in the context of a multilevel table.
188
189 Parameters
190 ----------
191 data : various
192 The data to be read, can be a
193 `~lsst.daf.butler.DeferredDatasetHandle` or
194 `~lsst.pipe.base.InMemoryDatasetHandle`.
195 columnIndex (optional): pandas `~pandas.Index` object
196 If not passed, then it is read from the
197 `~lsst.daf.butler.DeferredDatasetHandle`
198 for `~lsst.pipe.base.InMemoryDatasetHandle`.
199 """
200 if columnIndex is None:
201 columnIndex = data.get(component="columns")
202 return columnIndex.names
203

◆ _setLevels()

lsst.pipe.tasks.functors.Functor._setLevels ( self,
df )
protectedinherited

Definition at line 340 of file functors.py.

340 def _setLevels(self, df):
341 levelsToDrop = [n for n in df.columns.names if n not in self._dfLevels]
342 df.columns = df.columns.droplevel(levelsToDrop)
343 return df
344

◆ columns()

lsst.pipe.tasks.functors.ConvertPixelToArcseconds.columns ( self)
Columns required to perform calculation.

Reimplemented from lsst.pipe.tasks.functors.ComputePixelScale.

Definition at line 1457 of file functors.py.

1457 def columns(self):
1458 return [self.col,
1459 self.colCD_1_1,
1460 self.colCD_1_2,
1461 self.colCD_2_1,
1462 self.colCD_2_2]
1463

◆ computeDeltaRaDec()

lsst.pipe.tasks.functors.LocalWcs.computeDeltaRaDec ( self,
x,
y,
cd11,
cd12,
cd21,
cd22 )
inherited
Compute the dRA, dDec from dx, dy.

Parameters
----------
x : `~pandas.Series`
    X pixel coordinate.
y : `~pandas.Series`
    Y pixel coordinate.
cd11 : `~pandas.Series`
    [1, 1] element of the local Wcs affine transform.
cd12 : `~pandas.Series`
    [1, 2] element of the local Wcs affine transform.
cd21 : `~pandas.Series`
    [2, 1] element of the local Wcs affine transform.
cd22 : `~pandas.Series`
    [2, 2] element of the local Wcs affine transform.

Returns
-------
raDecTuple : tuple
    RA and Dec conversion of x and y given the local Wcs.
    Returned units are in radians.

Notes
-----
If x and y are with respect to the CRVAL1, CRVAL2
then this will return the RA, Dec for that WCS.

Definition at line 1233 of file functors.py.

1233 def computeDeltaRaDec(self, x, y, cd11, cd12, cd21, cd22):
1234 """Compute the dRA, dDec from dx, dy.
1235
1236 Parameters
1237 ----------
1238 x : `~pandas.Series`
1239 X pixel coordinate.
1240 y : `~pandas.Series`
1241 Y pixel coordinate.
1242 cd11 : `~pandas.Series`
1243 [1, 1] element of the local Wcs affine transform.
1244 cd12 : `~pandas.Series`
1245 [1, 2] element of the local Wcs affine transform.
1246 cd21 : `~pandas.Series`
1247 [2, 1] element of the local Wcs affine transform.
1248 cd22 : `~pandas.Series`
1249 [2, 2] element of the local Wcs affine transform.
1250
1251 Returns
1252 -------
1253 raDecTuple : tuple
1254 RA and Dec conversion of x and y given the local Wcs.
1255 Returned units are in radians.
1256
1257 Notes
1258 -----
1259 If x and y are with respect to the CRVAL1, CRVAL2
1260 then this will return the RA, Dec for that WCS.
1261 """
1262 return (x * cd11 + y * cd12, x * cd21 + y * cd22)
1263

◆ computePositionAngle()

lsst.pipe.tasks.functors.LocalWcs.computePositionAngle ( self,
ra1,
dec1,
ra2,
dec2 )
inherited
Compute position angle (E of N) from (ra1, dec1) to (ra2, dec2).

Parameters
----------
ra1 : iterable [`float`]
    RA of the first coordinate [radian].
dec1 : iterable [`float`]
    Dec of the first coordinate [radian].
ra2 : iterable [`float`]
    RA of the second coordinate [radian].
dec2 : iterable [`float`]
    Dec of the second coordinate [radian].

Returns
-------
Position Angle: `~pandas.Series`
    radians E of N

Notes
-----
(ra1, dec1) -> (ra2, dec2) is interpreted as the shorter way around the sphere

For a separation of 0.0001 rad, the position angle is good to 0.0009 rad
all over the sphere.

Definition at line 1322 of file functors.py.

1322 def computePositionAngle(self, ra1, dec1, ra2, dec2):
1323 """Compute position angle (E of N) from (ra1, dec1) to (ra2, dec2).
1324
1325 Parameters
1326 ----------
1327 ra1 : iterable [`float`]
1328 RA of the first coordinate [radian].
1329 dec1 : iterable [`float`]
1330 Dec of the first coordinate [radian].
1331 ra2 : iterable [`float`]
1332 RA of the second coordinate [radian].
1333 dec2 : iterable [`float`]
1334 Dec of the second coordinate [radian].
1335
1336 Returns
1337 -------
1338 Position Angle: `~pandas.Series`
1339 radians E of N
1340
1341 Notes
1342 -----
1343 (ra1, dec1) -> (ra2, dec2) is interpreted as the shorter way around the sphere
1344
1345 For a separation of 0.0001 rad, the position angle is good to 0.0009 rad
1346 all over the sphere.
1347 """
1348 # lsst.geom.SpherePoint has "bearingTo", which returns angle N of E
1349 # We instead want the astronomy convention of "Position Angle", which is angle E of N
1350 position_angle = np.zeros(len(ra1))
1351 for i, (r1, d1, r2, d2) in enumerate(zip(ra1, dec1, ra2, dec2)):
1352 point1 = geom.SpherePoint(r1, d1, geom.radians)
1353 point2 = geom.SpherePoint(r2, d2, geom.radians)
1354 bearing = point1.bearingTo(point2)
1355 pa_ref_angle = geom.Angle(np.pi/2, geom.radians) # in bearing system
1356 pa = pa_ref_angle - bearing
1357 # Wrap around to get Delta_RA from -pi to +pi
1358 pa = pa.wrapCtr()
1359 position_angle[i] = pa.asRadians()
1360
1361 return pd.Series(position_angle)
1362
A class representing an angle.
Definition Angle.h:128
Point in an unspecified spherical coordinate system.
Definition SpherePoint.h:57

◆ computeSkySeparation()

lsst.pipe.tasks.functors.LocalWcs.computeSkySeparation ( self,
ra1,
dec1,
ra2,
dec2 )
inherited
Compute the local pixel scale conversion.

Parameters
----------
ra1 : `~pandas.Series`
    Ra of the first coordinate in radians.
dec1 : `~pandas.Series`
    Dec of the first coordinate in radians.
ra2 : `~pandas.Series`
    Ra of the second coordinate in radians.
dec2 : `~pandas.Series`
    Dec of the second coordinate in radians.

Returns
-------
dist : `~pandas.Series`
    Distance on the sphere in radians.

Definition at line 1264 of file functors.py.

1264 def computeSkySeparation(self, ra1, dec1, ra2, dec2):
1265 """Compute the local pixel scale conversion.
1266
1267 Parameters
1268 ----------
1269 ra1 : `~pandas.Series`
1270 Ra of the first coordinate in radians.
1271 dec1 : `~pandas.Series`
1272 Dec of the first coordinate in radians.
1273 ra2 : `~pandas.Series`
1274 Ra of the second coordinate in radians.
1275 dec2 : `~pandas.Series`
1276 Dec of the second coordinate in radians.
1277
1278 Returns
1279 -------
1280 dist : `~pandas.Series`
1281 Distance on the sphere in radians.
1282 """
1283 deltaDec = dec2 - dec1
1284 deltaRa = ra2 - ra1
1285 return 2 * np.arcsin(
1286 np.sqrt(
1287 np.sin(deltaDec / 2) ** 2
1288 + np.cos(dec2) * np.cos(dec1) * np.sin(deltaRa / 2) ** 2))
1289

◆ difference()

lsst.pipe.tasks.functors.Functor.difference ( self,
data1,
data2,
** kwargs )
inherited
Computes difference between functor called on two different
DataFrame/Handle objects.

Definition at line 360 of file functors.py.

360 def difference(self, data1, data2, **kwargs):
361 """Computes difference between functor called on two different
362 DataFrame/Handle objects.
363 """
364 return self(data1, **kwargs) - self(data2, **kwargs)
365

◆ fail()

lsst.pipe.tasks.functors.Functor.fail ( self,
df )
inherited

Definition at line 366 of file functors.py.

366 def fail(self, df):
367 return pd.Series(np.full(len(df), np.nan), index=df.index)
368

◆ getPositionAngleFromDetectorAngle()

lsst.pipe.tasks.functors.LocalWcs.getPositionAngleFromDetectorAngle ( self,
theta,
cd11,
cd12,
cd21,
cd22 )
inherited
Compute position angle (E of N) from detector angle (+y of +x).

Parameters
----------
theta : `float`
    detector angle [radian]
cd11 : `float`
    [1, 1] element of the local Wcs affine transform.
cd12 : `float`
    [1, 2] element of the local Wcs affine transform.
cd21 : `float`
    [2, 1] element of the local Wcs affine transform.
cd22 : `float`
    [2, 2] element of the local Wcs affine transform.

Returns
-------
Position Angle: `~pandas.Series`
    Degrees E of N.

Definition at line 1363 of file functors.py.

1363 def getPositionAngleFromDetectorAngle(self, theta, cd11, cd12, cd21, cd22):
1364 """Compute position angle (E of N) from detector angle (+y of +x).
1365
1366 Parameters
1367 ----------
1368 theta : `float`
1369 detector angle [radian]
1370 cd11 : `float`
1371 [1, 1] element of the local Wcs affine transform.
1372 cd12 : `float`
1373 [1, 2] element of the local Wcs affine transform.
1374 cd21 : `float`
1375 [2, 1] element of the local Wcs affine transform.
1376 cd22 : `float`
1377 [2, 2] element of the local Wcs affine transform.
1378
1379 Returns
1380 -------
1381 Position Angle: `~pandas.Series`
1382 Degrees E of N.
1383 """
1384 # Create a unit vector in (x, y) along da
1385 dx = np.cos(theta)
1386 dy = np.sin(theta)
1387 ra1, dec1 = self.computeDeltaRaDec(0, 0, cd11, cd12, cd21, cd22)
1388 ra2, dec2 = self.computeDeltaRaDec(dx, dy, cd11, cd12, cd21, cd22)
1389 # Position angle of vector from (RA1, Dec1) to (RA2, Dec2)
1390 return np.rad2deg(self.computePositionAngle(ra1, dec1, ra2, dec2))
1391
1392

◆ getSkySeparationFromPixel()

lsst.pipe.tasks.functors.LocalWcs.getSkySeparationFromPixel ( self,
x1,
y1,
x2,
y2,
cd11,
cd12,
cd21,
cd22 )
inherited
Compute the distance on the sphere from x2, y1 to x1, y1.

Parameters
----------
x1 : `~pandas.Series`
    X pixel coordinate.
y1 : `~pandas.Series`
    Y pixel coordinate.
x2 : `~pandas.Series`
    X pixel coordinate.
y2 : `~pandas.Series`
    Y pixel coordinate.
cd11 : `~pandas.Series`
    [1, 1] element of the local Wcs affine transform.
cd12 : `~pandas.Series`
    [1, 2] element of the local Wcs affine transform.
cd21 : `~pandas.Series`
    [2, 1] element of the local Wcs affine transform.
cd22 : `~pandas.Series`
    [2, 2] element of the local Wcs affine transform.

Returns
-------
Distance : `~pandas.Series`
    Arcseconds per pixel at the location of the local WC.

Definition at line 1290 of file functors.py.

1290 def getSkySeparationFromPixel(self, x1, y1, x2, y2, cd11, cd12, cd21, cd22):
1291 """Compute the distance on the sphere from x2, y1 to x1, y1.
1292
1293 Parameters
1294 ----------
1295 x1 : `~pandas.Series`
1296 X pixel coordinate.
1297 y1 : `~pandas.Series`
1298 Y pixel coordinate.
1299 x2 : `~pandas.Series`
1300 X pixel coordinate.
1301 y2 : `~pandas.Series`
1302 Y pixel coordinate.
1303 cd11 : `~pandas.Series`
1304 [1, 1] element of the local Wcs affine transform.
1305 cd12 : `~pandas.Series`
1306 [1, 2] element of the local Wcs affine transform.
1307 cd21 : `~pandas.Series`
1308 [2, 1] element of the local Wcs affine transform.
1309 cd22 : `~pandas.Series`
1310 [2, 2] element of the local Wcs affine transform.
1311
1312 Returns
1313 -------
1314 Distance : `~pandas.Series`
1315 Arcseconds per pixel at the location of the local WC.
1316 """
1317 ra1, dec1 = self.computeDeltaRaDec(x1, y1, cd11, cd12, cd21, cd22)
1318 ra2, dec2 = self.computeDeltaRaDec(x2, y2, cd11, cd12, cd21, cd22)
1319 # Great circle distance for small separations.
1320 return self.computeSkySeparation(ra1, dec1, ra2, dec2)
1321

◆ multilevelColumns()

lsst.pipe.tasks.functors.Functor.multilevelColumns ( self,
data,
columnIndex = None,
returnTuple = False )
inherited
Returns columns needed by functor from multilevel dataset.

To access tables with multilevel column structure, the
`~lsst.daf.butler.DeferredDatasetHandle` or
`~lsst.pipe.base.InMemoryDatasetHandle` needs to be passed
either a list of tuples or a dictionary.

Parameters
----------
data : various
    The data as either `~lsst.daf.butler.DeferredDatasetHandle`, or
    `~lsst.pipe.base.InMemoryDatasetHandle`.
columnIndex (optional): pandas `~pandas.Index` object
    Either passed or read in from
    `~lsst.daf.butler.DeferredDatasetHandle`.
`returnTuple` : `bool`
    If true, then return a list of tuples rather than the column
    dictionary specification.
    This is set to `True` by `CompositeFunctor` in order to be able to
    combine columns from the various component functors.

Reimplemented in lsst.pipe.tasks.functors.Color, and lsst.pipe.tasks.functors.CompositeFunctor.

Definition at line 237 of file functors.py.

237 def multilevelColumns(self, data, columnIndex=None, returnTuple=False):
238 """Returns columns needed by functor from multilevel dataset.
239
240 To access tables with multilevel column structure, the
241 `~lsst.daf.butler.DeferredDatasetHandle` or
242 `~lsst.pipe.base.InMemoryDatasetHandle` needs to be passed
243 either a list of tuples or a dictionary.
244
245 Parameters
246 ----------
247 data : various
248 The data as either `~lsst.daf.butler.DeferredDatasetHandle`, or
249 `~lsst.pipe.base.InMemoryDatasetHandle`.
250 columnIndex (optional): pandas `~pandas.Index` object
251 Either passed or read in from
252 `~lsst.daf.butler.DeferredDatasetHandle`.
253 `returnTuple` : `bool`
254 If true, then return a list of tuples rather than the column
255 dictionary specification.
256 This is set to `True` by `CompositeFunctor` in order to be able to
257 combine columns from the various component functors.
258
259 """
260 if not isinstance(data, (DeferredDatasetHandle, InMemoryDatasetHandle)):
261 raise RuntimeError(f"Unexpected data type. Got {get_full_type_name(data)}.")
262
263 if columnIndex is None:
264 columnIndex = data.get(component="columns")
265
266 # Confirm that the dataset has the column levels the functor is
267 # expecting it to have.
268 columnLevels = self._get_data_columnLevels(data, columnIndex)
269
270 columnDict = {'column': self.columns,
271 'dataset': self.dataset}
272 if self.filt is None:
273 columnLevelNames = self._get_data_columnLevelNames(data, columnIndex)
274 if "band" in columnLevels:
275 if self.dataset == "ref":
276 columnDict["band"] = columnLevelNames["band"][0]
277 else:
278 raise ValueError(f"'filt' not set for functor {self.name}"
279 f"(dataset {self.dataset}) "
280 "and DataFrame "
281 "contains multiple filters in column index. "
282 "Set 'filt' or set 'dataset' to 'ref'.")
283 else:
284 columnDict['band'] = self.filt
285
286 if returnTuple:
287 return self._colsFromDict(columnDict, columnIndex=columnIndex)
288 else:
289 return columnDict
290

◆ name()

lsst.pipe.tasks.functors.ConvertPixelToArcseconds.name ( self)

Reimplemented from lsst.pipe.tasks.functors.ComputePixelScale.

Definition at line 1453 of file functors.py.

1453 def name(self):
1454 return f"{self.col}_asArcseconds"
1455

◆ noDup()

lsst.pipe.tasks.functors.Functor.noDup ( self)
inherited
Do not explode by band if used on object table.

Definition at line 170 of file functors.py.

170 def noDup(self):
171 """Do not explode by band if used on object table."""
172 if self._noDup is not None:
173 return self._noDup
174 else:
175 return self._defaultNoDup
176

◆ pixelScaleArcseconds()

lsst.pipe.tasks.functors.ComputePixelScale.pixelScaleArcseconds ( self,
cd11,
cd12,
cd21,
cd22 )
inherited
Compute the local pixel to scale conversion in arcseconds.

Parameters
----------
cd11 : `~pandas.Series`
    [1, 1] element of the local Wcs affine transform in radians.
cd11 : `~pandas.Series`
    [1, 1] element of the local Wcs affine transform in radians.
cd12 : `~pandas.Series`
    [1, 2] element of the local Wcs affine transform in radians.
cd21 : `~pandas.Series`
    [2, 1] element of the local Wcs affine transform in radians.
cd22 : `~pandas.Series`
    [2, 2] element of the local Wcs affine transform in radians.

Returns
-------
pixScale : `~pandas.Series`
    Arcseconds per pixel at the location of the local WC.

Definition at line 1405 of file functors.py.

1405 def pixelScaleArcseconds(self, cd11, cd12, cd21, cd22):
1406 """Compute the local pixel to scale conversion in arcseconds.
1407
1408 Parameters
1409 ----------
1410 cd11 : `~pandas.Series`
1411 [1, 1] element of the local Wcs affine transform in radians.
1412 cd11 : `~pandas.Series`
1413 [1, 1] element of the local Wcs affine transform in radians.
1414 cd12 : `~pandas.Series`
1415 [1, 2] element of the local Wcs affine transform in radians.
1416 cd21 : `~pandas.Series`
1417 [2, 1] element of the local Wcs affine transform in radians.
1418 cd22 : `~pandas.Series`
1419 [2, 2] element of the local Wcs affine transform in radians.
1420
1421 Returns
1422 -------
1423 pixScale : `~pandas.Series`
1424 Arcseconds per pixel at the location of the local WC.
1425 """
1426 return 3600 * np.degrees(np.sqrt(np.fabs(cd11 * cd22 - cd12 * cd21)))
1427

◆ shortname()

lsst.pipe.tasks.functors.Functor.shortname ( self)
inherited
Short name of functor (suitable for column name/dict key).

Reimplemented in lsst.pipe.tasks.functors.Color, and lsst.pipe.tasks.functors.MagDiff.

Definition at line 375 of file functors.py.

375 def shortname(self):
376 """Short name of functor (suitable for column name/dict key)."""
377 return self.name
378
379

Member Data Documentation

◆ _defaultDataset

str lsst.pipe.tasks.functors.Functor._defaultDataset = 'ref'
staticprotectedinherited

Definition at line 159 of file functors.py.

◆ _defaultNoDup

bool lsst.pipe.tasks.functors.Functor._defaultNoDup = False
staticprotectedinherited

Definition at line 161 of file functors.py.

◆ _dfLevels

tuple lsst.pipe.tasks.functors.Functor._dfLevels = ('column',)
staticprotectedinherited

Definition at line 160 of file functors.py.

◆ _noDup

lsst.pipe.tasks.functors.Functor._noDup = noDup
protectedinherited

Definition at line 166 of file functors.py.

◆ col

lsst.pipe.tasks.functors.ConvertPixelToArcseconds.col = col

Definition at line 1445 of file functors.py.

◆ colCD_1_1

lsst.pipe.tasks.functors.LocalWcs.colCD_1_1 = colCD_1_1
inherited

Definition at line 1227 of file functors.py.

◆ colCD_1_2

lsst.pipe.tasks.functors.LocalWcs.colCD_1_2 = colCD_1_2
inherited

Definition at line 1228 of file functors.py.

◆ colCD_2_1

lsst.pipe.tasks.functors.LocalWcs.colCD_2_1 = colCD_2_1
inherited

Definition at line 1229 of file functors.py.

◆ colCD_2_2

lsst.pipe.tasks.functors.LocalWcs.colCD_2_2 = colCD_2_2
inherited

Definition at line 1230 of file functors.py.

◆ dataset

str lsst.pipe.tasks.functors.Functor.dataset = dataset if dataset is not None else self._defaultDataset
inherited

Definition at line 165 of file functors.py.

◆ filt

lsst.pipe.tasks.functors.Functor.filt = filt
inherited

◆ log

lsst.pipe.tasks.functors.Functor.log = logging.getLogger(type(self).__name__)
inherited

Definition at line 167 of file functors.py.


The documentation for this class was generated from the following file: