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
Classes | Functions | Variables
lsst.jointcal.jointcal Namespace Reference

Classes

class  JointcalConfig
 
class  JointcalInputData
 
class  JointcalTask
 
class  JointcalTaskConnections
 

Functions

 add_measurement (job, name, value)
 
 writeModel (model, filename, log)
 
 make_schema_table ()
 
 get_sourceTable_visit_columns (inColumns, config, sourceSelector)
 
 extract_detector_catalog_from_visit_catalog (table, visitCatalog, detectorId, ixxColumns, sourceFluxType, log)
 

Variables

 Photometry = collections.namedtuple('Photometry', ('fit', 'model'))
 
 Astrometry = collections.namedtuple('Astrometry', ('fit', 'model', 'sky_to_tan_projection'))
 

Function Documentation

◆ add_measurement()

lsst.jointcal.jointcal.add_measurement ( job,
name,
value )

Definition at line 55 of file jointcal.py.

55def add_measurement(job, name, value):
56 meas = Measurement(job.metrics[name], value)
57 job.measurements.insert(meas)
58
59

◆ extract_detector_catalog_from_visit_catalog()

lsst.jointcal.jointcal.extract_detector_catalog_from_visit_catalog ( table,
visitCatalog,
detectorId,
ixxColumns,
sourceFluxType,
log )
Return an afw SourceCatalog extracted from a visit-level dataframe,
limited to just one detector.

Parameters
----------
table : `lsst.afw.table.SourceTable`
    Table factory to use to make the SourceCatalog that will be
    populated with data from ``visitCatalog``.
visitCatalog : `pandas.DataFrame`
    DataFrame to extract a detector catalog from.
detectorId : `int`
    Numeric id of the detector to extract from ``visitCatalog``.
ixxColumns : `list` [`str`]
    Names of the ixx/iyy/ixy columns in the catalog.
sourceFluxType : `str`
    Name of the catalog field to load instFluxes from.
log : `logging.Logger`
    Logging instance to log to.

Returns
-------
catalog : `lsst.afw.table.SourceCatalog`, or `None`
    Detector-level catalog extracted from ``visitCatalog``, or `None`
    if there was no data to load.

Definition at line 1534 of file jointcal.py.

1535 ixxColumns, sourceFluxType, log):
1536 """Return an afw SourceCatalog extracted from a visit-level dataframe,
1537 limited to just one detector.
1538
1539 Parameters
1540 ----------
1541 table : `lsst.afw.table.SourceTable`
1542 Table factory to use to make the SourceCatalog that will be
1543 populated with data from ``visitCatalog``.
1544 visitCatalog : `pandas.DataFrame`
1545 DataFrame to extract a detector catalog from.
1546 detectorId : `int`
1547 Numeric id of the detector to extract from ``visitCatalog``.
1548 ixxColumns : `list` [`str`]
1549 Names of the ixx/iyy/ixy columns in the catalog.
1550 sourceFluxType : `str`
1551 Name of the catalog field to load instFluxes from.
1552 log : `logging.Logger`
1553 Logging instance to log to.
1554
1555 Returns
1556 -------
1557 catalog : `lsst.afw.table.SourceCatalog`, or `None`
1558 Detector-level catalog extracted from ``visitCatalog``, or `None`
1559 if there was no data to load.
1560 """
1561 # map from dataFrame column to afw table column
1562 mapping = {'x': 'centroid_x',
1563 'y': 'centroid_y',
1564 'xErr': 'centroid_xErr',
1565 'yErr': 'centroid_yErr',
1566 ixxColumns[0]: 'shape_xx',
1567 ixxColumns[1]: 'shape_yy',
1568 ixxColumns[2]: 'shape_xy',
1569 f'{sourceFluxType}_instFlux': 'flux_instFlux',
1570 f'{sourceFluxType}_instFluxErr': 'flux_instFluxErr',
1571 }
1572
1573 catalog = lsst.afw.table.SourceCatalog(table)
1574 matched = visitCatalog['detector'] == detectorId
1575 n = sum(matched)
1576 if n == 0:
1577 return None
1578 catalog.resize(sum(matched))
1579 view = visitCatalog.loc[matched]
1580 catalog['id'] = view.index
1581 for dfCol, afwCol in mapping.items():
1582 catalog[afwCol] = view[dfCol]
1583
1584 log.debug("%d sources selected in visit %d detector %d",
1585 len(catalog),
1586 view['visit'].iloc[0], # all visits in this catalog are the same, so take the first
1587 detectorId)
1588 return catalog

◆ get_sourceTable_visit_columns()

lsst.jointcal.jointcal.get_sourceTable_visit_columns ( inColumns,
config,
sourceSelector )
Get the sourceTable_visit columns to load from the catalogs.

Parameters
----------
inColumns : `list`
    List of columns known to be available in the sourceTable_visit.
config : `JointcalConfig`
    A filled-in config to to help define column names.
sourceSelector : `lsst.meas.algorithms.BaseSourceSelectorTask`
    A configured source selector to define column names to load.

Returns
-------
columns : `list`
    List of columns to read from sourceTable_visit.
ixxColumns : `list`
    Name of the ixx/iyy/ixy columns.

Definition at line 1486 of file jointcal.py.

1486def get_sourceTable_visit_columns(inColumns, config, sourceSelector):
1487 """
1488 Get the sourceTable_visit columns to load from the catalogs.
1489
1490 Parameters
1491 ----------
1492 inColumns : `list`
1493 List of columns known to be available in the sourceTable_visit.
1494 config : `JointcalConfig`
1495 A filled-in config to to help define column names.
1496 sourceSelector : `lsst.meas.algorithms.BaseSourceSelectorTask`
1497 A configured source selector to define column names to load.
1498
1499 Returns
1500 -------
1501 columns : `list`
1502 List of columns to read from sourceTable_visit.
1503 ixxColumns : `list`
1504 Name of the ixx/iyy/ixy columns.
1505 """
1506 columns = ['visit', 'detector',
1507 'sourceId', 'x', 'xErr', 'y', 'yErr',
1508 config.sourceFluxType + '_instFlux', config.sourceFluxType + '_instFluxErr']
1509
1510 if 'ixx' in inColumns:
1511 # New columns post-DM-31825
1512 ixxColumns = ['ixx', 'iyy', 'ixy']
1513 else:
1514 # Old columns pre-DM-31825
1515 ixxColumns = ['Ixx', 'Iyy', 'Ixy']
1516 columns.extend(ixxColumns)
1517
1518 if sourceSelector.config.doFlags:
1519 columns.extend(sourceSelector.config.flags.bad)
1520 if sourceSelector.config.doUnresolved:
1521 columns.append(sourceSelector.config.unresolved.name)
1522 if sourceSelector.config.doIsolated:
1523 columns.append(sourceSelector.config.isolated.parentName)
1524 columns.append(sourceSelector.config.isolated.nChildName)
1525 if sourceSelector.config.doRequireFiniteRaDec:
1526 columns.append(sourceSelector.config.requireFiniteRaDec.raColName)
1527 columns.append(sourceSelector.config.requireFiniteRaDec.decColName)
1528 if sourceSelector.config.doRequirePrimary:
1529 columns.append(sourceSelector.config.requirePrimary.primaryColName)
1530
1531 return columns, ixxColumns
1532
1533

◆ make_schema_table()

lsst.jointcal.jointcal.make_schema_table ( )
Return an afw SourceTable to use as a base for creating the
SourceCatalog to insert values from the dataFrame into.

Returns
-------
table : `lsst.afw.table.SourceTable`
    Table with schema and slots to use to make SourceCatalogs.

Definition at line 1461 of file jointcal.py.

1461def make_schema_table():
1462 """Return an afw SourceTable to use as a base for creating the
1463 SourceCatalog to insert values from the dataFrame into.
1464
1465 Returns
1466 -------
1467 table : `lsst.afw.table.SourceTable`
1468 Table with schema and slots to use to make SourceCatalogs.
1469 """
1471 schema.addField("centroid_x", "D")
1472 schema.addField("centroid_y", "D")
1473 schema.addField("centroid_xErr", "F")
1474 schema.addField("centroid_yErr", "F")
1475 schema.addField("shape_xx", "D")
1476 schema.addField("shape_yy", "D")
1477 schema.addField("shape_xy", "D")
1478 schema.addField("flux_instFlux", "D")
1479 schema.addField("flux_instFluxErr", "D")
1480 table = lsst.afw.table.SourceTable.make(schema)
1481 table.defineCentroid("centroid")
1482 table.defineShape("shape")
1483 return table
1484
1485
static std::shared_ptr< SourceTable > make(Schema const &schema, std::shared_ptr< IdFactory > const &idFactory)
Construct a new table.
Definition Source.cc:400
static Schema makeMinimalSchema()
Return a minimal schema for Source tables and records.
Definition Source.h:258

◆ writeModel()

lsst.jointcal.jointcal.writeModel ( model,
filename,
log )
Write model to outfile.

Definition at line 467 of file jointcal.py.

467def writeModel(model, filename, log):
468 """Write model to outfile."""
469 with open(filename, "w") as file:
470 file.write(repr(model))
471 log.info("Wrote %s to file: %s", model, filename)
472
473
474@dataclasses.dataclass

Variable Documentation

◆ Astrometry

lsst.jointcal.jointcal.Astrometry = collections.namedtuple('Astrometry', ('fit', 'model', 'sky_to_tan_projection'))

Definition at line 51 of file jointcal.py.

◆ Photometry

lsst.jointcal.jointcal.Photometry = collections.namedtuple('Photometry', ('fit', 'model'))

Definition at line 50 of file jointcal.py.