LSST Applications 26.0.0,g0265f82a02+6660c170cc,g07994bdeae+30b05a742e,g0a0026dc87+17526d298f,g0a60f58ba1+17526d298f,g0e4bf8285c+96dd2c2ea9,g0ecae5effc+c266a536c8,g1e7d6db67d+6f7cb1f4bb,g26482f50c6+6346c0633c,g2bbee38e9b+6660c170cc,g2cc88a2952+0a4e78cd49,g3273194fdb+f6908454ef,g337abbeb29+6660c170cc,g337c41fc51+9a8f8f0815,g37c6e7c3d5+7bbafe9d37,g44018dc512+6660c170cc,g4a941329ef+4f7594a38e,g4c90b7bd52+5145c320d2,g58be5f913a+bea990ba40,g635b316a6c+8d6b3a3e56,g67924a670a+bfead8c487,g6ae5381d9b+81bc2a20b4,g93c4d6e787+26b17396bd,g98cecbdb62+ed2cb6d659,g98ffbb4407+81bc2a20b4,g9ddcbc5298+7f7571301f,ga1e77700b3+99e9273977,gae46bcf261+6660c170cc,gb2715bf1a1+17526d298f,gc86a011abf+17526d298f,gcf0d15dbbd+96dd2c2ea9,gdaeeff99f8+0d8dbea60f,gdb4ec4c597+6660c170cc,ge23793e450+96dd2c2ea9,gf041782ebf+171108ac67
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)
 
 lookupStaticCalibrations (datasetType, registry, quantumDataId, collections)
 
 lookupVisitRefCats (datasetType, registry, quantumDataId, collections)
 
 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 56 of file jointcal.py.

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

◆ 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 1618 of file jointcal.py.

1619 ixxColumns, sourceFluxType, log):
1620 """Return an afw SourceCatalog extracted from a visit-level dataframe,
1621 limited to just one detector.
1622
1623 Parameters
1624 ----------
1626 Table factory to use to make the SourceCatalog that will be
1627 populated with data from ``visitCatalog``.
1628 visitCatalog : `pandas.DataFrame`
1629 DataFrame to extract a detector catalog from.
1630 detectorId : `int`
1631 Numeric id of the detector to extract from ``visitCatalog``.
1632 ixxColumns : `list` [`str`]
1633 Names of the ixx/iyy/ixy columns in the catalog.
1634 sourceFluxType : `str`
1635 Name of the catalog field to load instFluxes from.
1636 log : `logging.Logger`
1637 Logging instance to log to.
1638
1639 Returns
1640 -------
1641 catalog : `lsst.afw.table.SourceCatalog`, or `None`
1642 Detector-level catalog extracted from ``visitCatalog``, or `None`
1643 if there was no data to load.
1644 """
1645 # map from dataFrame column to afw table column
1646 mapping = {'x': 'centroid_x',
1647 'y': 'centroid_y',
1648 'xErr': 'centroid_xErr',
1649 'yErr': 'centroid_yErr',
1650 ixxColumns[0]: 'shape_xx',
1651 ixxColumns[1]: 'shape_yy',
1652 ixxColumns[2]: 'shape_xy',
1653 f'{sourceFluxType}_instFlux': 'flux_instFlux',
1654 f'{sourceFluxType}_instFluxErr': 'flux_instFluxErr',
1655 }
1656
1657 catalog = lsst.afw.table.SourceCatalog(table)
1658 matched = visitCatalog['detector'] == detectorId
1659 n = sum(matched)
1660 if n == 0:
1661 return None
1662 catalog.resize(sum(matched))
1663 view = visitCatalog.loc[matched]
1664 catalog['id'] = view.index
1665 for dfCol, afwCol in mapping.items():
1666 catalog[afwCol] = view[dfCol]
1667
1668 log.debug("%d sources selected in visit %d detector %d",
1669 len(catalog),
1670 view['visit'].iloc[0], # all visits in this catalog are the same, so take the first
1671 detectorId)
1672 return catalog
Table class that contains measurements made on a single exposure.
Definition Source.h:217

◆ 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 1570 of file jointcal.py.

1570def get_sourceTable_visit_columns(inColumns, config, sourceSelector):
1571 """
1572 Get the sourceTable_visit columns to load from the catalogs.
1573
1574 Parameters
1575 ----------
1576 inColumns : `list`
1577 List of columns known to be available in the sourceTable_visit.
1578 config : `JointcalConfig`
1579 A filled-in config to to help define column names.
1581 A configured source selector to define column names to load.
1582
1583 Returns
1584 -------
1585 columns : `list`
1586 List of columns to read from sourceTable_visit.
1587 ixxColumns : `list`
1588 Name of the ixx/iyy/ixy columns.
1589 """
1590 columns = ['visit', 'detector',
1591 'sourceId', 'x', 'xErr', 'y', 'yErr',
1592 config.sourceFluxType + '_instFlux', config.sourceFluxType + '_instFluxErr']
1593
1594 if 'ixx' in inColumns:
1595 # New columns post-DM-31825
1596 ixxColumns = ['ixx', 'iyy', 'ixy']
1597 else:
1598 # Old columns pre-DM-31825
1599 ixxColumns = ['Ixx', 'Iyy', 'Ixy']
1600 columns.extend(ixxColumns)
1601
1602 if sourceSelector.config.doFlags:
1603 columns.extend(sourceSelector.config.flags.bad)
1604 if sourceSelector.config.doUnresolved:
1605 columns.append(sourceSelector.config.unresolved.name)
1606 if sourceSelector.config.doIsolated:
1607 columns.append(sourceSelector.config.isolated.parentName)
1608 columns.append(sourceSelector.config.isolated.nChildName)
1609 if sourceSelector.config.doRequireFiniteRaDec:
1610 columns.append(sourceSelector.config.requireFiniteRaDec.raColName)
1611 columns.append(sourceSelector.config.requireFiniteRaDec.decColName)
1612 if sourceSelector.config.doRequirePrimary:
1613 columns.append(sourceSelector.config.requirePrimary.primaryColName)
1614
1615 return columns, ixxColumns
1616
1617

◆ lookupStaticCalibrations()

lsst.jointcal.jointcal.lookupStaticCalibrations (   datasetType,
  registry,
  quantumDataId,
  collections 
)
Lookup function that asserts/hopes that a static calibration dataset
exists in a particular collection, since this task can't provide a single
date/time to use to search for one properly.

This is mostly useful for the ``camera`` dataset, in cases where the task's
quantum dimensions do *not* include something temporal, like ``exposure``
or ``visit``.

Parameters
----------
datasetType : `lsst.daf.butler.DatasetType`
    Type of dataset being searched for.
registry : `lsst.daf.butler.Registry`
    Data repository registry to search.
quantumDataId : `lsst.daf.butler.DataCoordinate`
    Data ID of the quantum this camera should match.
collections : `Iterable` [ `str` ]
    Collections that should be searched - but this lookup function works
    by ignoring this in favor of a more-or-less hard-coded value.

Returns
-------
refs : `Iterator` [ `lsst.daf.butler.DatasetRef` ]
    Iterator over dataset references; should have only one element.

Notes
-----
This implementation duplicates one in fgcmcal, and is at least quite
similar to another in cp_pipe.  This duplicate has the most documentation.
Fixing this is DM-29661.

Definition at line 61 of file jointcal.py.

61def lookupStaticCalibrations(datasetType, registry, quantumDataId, collections):
62 """Lookup function that asserts/hopes that a static calibration dataset
63 exists in a particular collection, since this task can't provide a single
64 date/time to use to search for one properly.
65
66 This is mostly useful for the ``camera`` dataset, in cases where the task's
67 quantum dimensions do *not* include something temporal, like ``exposure``
68 or ``visit``.
69
70 Parameters
71 ----------
72 datasetType : `lsst.daf.butler.DatasetType`
73 Type of dataset being searched for.
74 registry : `lsst.daf.butler.Registry`
75 Data repository registry to search.
76 quantumDataId : `lsst.daf.butler.DataCoordinate`
77 Data ID of the quantum this camera should match.
78 collections : `Iterable` [ `str` ]
79 Collections that should be searched - but this lookup function works
80 by ignoring this in favor of a more-or-less hard-coded value.
81
82 Returns
83 -------
84 refs : `Iterator` [ `lsst.daf.butler.DatasetRef` ]
85 Iterator over dataset references; should have only one element.
86
87 Notes
88 -----
89 This implementation duplicates one in fgcmcal, and is at least quite
90 similar to another in cp_pipe. This duplicate has the most documentation.
91 Fixing this is DM-29661.
92 """
93 instrument = Instrument.fromName(quantumDataId["instrument"], registry)
94 unboundedCollection = instrument.makeUnboundedCalibrationRunName()
95 return registry.queryDatasets(datasetType,
96 dataId=quantumDataId,
97 collections=[unboundedCollection],
98 findFirst=True)
99
100

◆ lookupVisitRefCats()

lsst.jointcal.jointcal.lookupVisitRefCats (   datasetType,
  registry,
  quantumDataId,
  collections 
)
Lookup function that finds all refcats for all visits that overlap a
tract, rather than just the refcats that directly overlap the tract.

Parameters
----------
datasetType : `lsst.daf.butler.DatasetType`
    Type of dataset being searched for.
registry : `lsst.daf.butler.Registry`
    Data repository registry to search.
quantumDataId : `lsst.daf.butler.DataCoordinate`
    Data ID of the quantum; expected to be something we can use as a
    constraint to query for overlapping visits.
collections : `Iterable` [ `str` ]
    Collections to search.

Returns
-------
refs : `Iterator` [ `lsst.daf.butler.DatasetRef` ]
    Iterator over refcat references.

Definition at line 101 of file jointcal.py.

101def lookupVisitRefCats(datasetType, registry, quantumDataId, collections):
102 """Lookup function that finds all refcats for all visits that overlap a
103 tract, rather than just the refcats that directly overlap the tract.
104
105 Parameters
106 ----------
107 datasetType : `lsst.daf.butler.DatasetType`
108 Type of dataset being searched for.
109 registry : `lsst.daf.butler.Registry`
110 Data repository registry to search.
111 quantumDataId : `lsst.daf.butler.DataCoordinate`
112 Data ID of the quantum; expected to be something we can use as a
113 constraint to query for overlapping visits.
114 collections : `Iterable` [ `str` ]
115 Collections to search.
116
117 Returns
118 -------
119 refs : `Iterator` [ `lsst.daf.butler.DatasetRef` ]
120 Iterator over refcat references.
121 """
122 refs = set()
123 # Use .expanded() on the query methods below because we need data IDs with
124 # regions, both in the outer loop over visits (queryDatasets will expand
125 # any data ID we give it, but doing it up-front in bulk is much more
126 # efficient) and in the data IDs of the DatasetRefs this function yields
127 # (because the RefCatLoader relies on them to do some of its own
128 # filtering).
129 for visit_data_id in set(registry.queryDataIds("visit", dataId=quantumDataId).expanded()):
130 refs.update(
131 registry.queryDatasets(
132 datasetType,
133 collections=collections,
134 dataId=visit_data_id,
135 findFirst=True,
136 ).expanded()
137 )
138 yield from refs
139
140
daf::base::PropertySet * set
Definition fits.cc:927

◆ 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 1545 of file jointcal.py.

1545def make_schema_table():
1546 """Return an afw SourceTable to use as a base for creating the
1547 SourceCatalog to insert values from the dataFrame into.
1548
1549 Returns
1550 -------
1552 Table with schema and slots to use to make SourceCatalogs.
1553 """
1555 schema.addField("centroid_x", "D")
1556 schema.addField("centroid_y", "D")
1557 schema.addField("centroid_xErr", "F")
1558 schema.addField("centroid_yErr", "F")
1559 schema.addField("shape_xx", "D")
1560 schema.addField("shape_yy", "D")
1561 schema.addField("shape_xy", "D")
1562 schema.addField("flux_instFlux", "D")
1563 schema.addField("flux_instFluxErr", "D")
1564 table = lsst.afw.table.SourceTable.make(schema)
1565 table.defineCentroid("centroid")
1566 table.defineShape("shape")
1567 return table
1568
1569
static std::shared_ptr< SourceTable > make(Schema const &schema, std::shared_ptr< IdFactory > const &idFactory)
Construct a new table.
Definition Source.cc:382
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 551 of file jointcal.py.

551def writeModel(model, filename, log):
552 """Write model to outfile."""
553 with open(filename, "w") as file:
554 file.write(repr(model))
555 log.info("Wrote %s to file: %s", model, filename)
556
557
558@dataclasses.dataclass

Variable Documentation

◆ Astrometry

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

Definition at line 52 of file jointcal.py.

◆ Photometry

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

Definition at line 51 of file jointcal.py.