LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
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

def add_measurement (job, name, value)
 
def lookupStaticCalibrations (datasetType, registry, quantumDataId, collections)
 
def lookupVisitRefCats (datasetType, registry, quantumDataId, collections)
 
def writeModel (model, filename, log)
 
def make_schema_table ()
 
def get_sourceTable_visit_columns (inColumns, config, sourceSelector)
 
def 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()

def 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()

def 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 1611 of file jointcal.py.

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

◆ get_sourceTable_visit_columns()

def 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 1565 of file jointcal.py.

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

◆ lookupStaticCalibrations()

def 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()

def 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()

def 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 1540 of file jointcal.py.

1540def make_schema_table():
1541 """Return an afw SourceTable to use as a base for creating the
1542 SourceCatalog to insert values from the dataFrame into.
1543
1544 Returns
1545 -------
1547 Table with schema and slots to use to make SourceCatalogs.
1548 """
1550 schema.addField("centroid_x", "D")
1551 schema.addField("centroid_y", "D")
1552 schema.addField("centroid_xErr", "F")
1553 schema.addField("centroid_yErr", "F")
1554 schema.addField("shape_xx", "D")
1555 schema.addField("shape_yy", "D")
1556 schema.addField("shape_xy", "D")
1557 schema.addField("flux_instFlux", "D")
1558 schema.addField("flux_instFluxErr", "D")
1559 table = lsst.afw.table.SourceTable.make(schema)
1560 table.defineCentroid("centroid")
1561 table.defineShape("shape")
1562 return table
1563
1564
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()

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

Definition at line 546 of file jointcal.py.

546def writeModel(model, filename, log):
547 """Write model to outfile."""
548 with open(filename, "w") as file:
549 file.write(repr(model))
550 log.info("Wrote %s to file: %s", model, filename)
551
552
553@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.