LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
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.