LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
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.