LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Classes | Functions | Variables
lsst.jointcal.jointcal Namespace Reference

Classes

class  JointcalConfig
 
class  JointcalInputData
 
class  JointcalRunner
 
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, detectorColumn, 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 60 of file jointcal.py.

60def add_measurement(job, name, value):
61 meas = Measurement(job.metrics[name], value)
62 job.measurements.insert(meas)
63
64
def add_measurement(job, name, value)
Definition: jointcal.py:60

◆ extract_detector_catalog_from_visit_catalog()

def lsst.jointcal.jointcal.extract_detector_catalog_from_visit_catalog (   table,
  visitCatalog,
  detectorId,
  detectorColumn,
  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``.
detectorColumn : `str`
    Name of the detector column in the catalog.
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 : `lsst.log.Log`
    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 1904 of file jointcal.py.

1905 detectorColumn, ixxColumns, sourceFluxType, log):
1906 """Return an afw SourceCatalog extracted from a visit-level dataframe,
1907 limited to just one detector.
1908
1909 Parameters
1910 ----------
1912 Table factory to use to make the SourceCatalog that will be
1913 populated with data from ``visitCatalog``.
1914 visitCatalog : `pandas.DataFrame`
1915 DataFrame to extract a detector catalog from.
1916 detectorId : `int`
1917 Numeric id of the detector to extract from ``visitCatalog``.
1918 detectorColumn : `str`
1919 Name of the detector column in the catalog.
1920 ixxColumns : `list` [`str`]
1921 Names of the ixx/iyy/ixy columns in the catalog.
1922 sourceFluxType : `str`
1923 Name of the catalog field to load instFluxes from.
1924 log : `lsst.log.Log`
1925 Logging instance to log to.
1926
1927 Returns
1928 -------
1929 catalog : `lsst.afw.table.SourceCatalog`, or `None`
1930 Detector-level catalog extracted from ``visitCatalog``, or `None`
1931 if there was no data to load.
1932 """
1933 # map from dataFrame column to afw table column
1934 mapping = {'x': 'centroid_x',
1935 'y': 'centroid_y',
1936 'xErr': 'centroid_xErr',
1937 'yErr': 'centroid_yErr',
1938 ixxColumns[0]: 'shape_xx',
1939 ixxColumns[1]: 'shape_yy',
1940 ixxColumns[2]: 'shape_xy',
1941 f'{sourceFluxType}_instFlux': 'flux_instFlux',
1942 f'{sourceFluxType}_instFluxErr': 'flux_instFluxErr',
1943 }
1944
1945 catalog = lsst.afw.table.SourceCatalog(table)
1946 matched = visitCatalog[detectorColumn] == detectorId
1947 n = sum(matched)
1948 if n == 0:
1949 return None
1950 catalog.resize(sum(matched))
1951 view = visitCatalog.loc[matched]
1952 catalog['id'] = view.index
1953 for dfCol, afwCol in mapping.items():
1954 catalog[afwCol] = view[dfCol]
1955
1956 log.debug("%d sources selected in visit %d detector %d",
1957 len(catalog),
1958 view['visit'].iloc[0], # all visits in this catalog are the same, so take the first
1959 detectorId)
1960 return catalog
Table class that contains measurements made on a single exposure.
Definition: Source.h:217
This static class includes a variety of methods for interacting with the the logging module.
Definition: Log.h:724

◆ 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.
detectorColumn : `str`
    Name of the detector column.
ixxColumns : `list`
    Name of the ixx/iyy/ixy columns.

Definition at line 1852 of file jointcal.py.

1852def get_sourceTable_visit_columns(inColumns, config, sourceSelector):
1853 """
1854 Get the sourceTable_visit columns to load from the catalogs.
1855
1856 Parameters
1857 ----------
1858 inColumns : `list`
1859 List of columns known to be available in the sourceTable_visit.
1860 config : `JointcalConfig`
1861 A filled-in config to to help define column names.
1863 A configured source selector to define column names to load.
1864
1865 Returns
1866 -------
1867 columns : `list`
1868 List of columns to read from sourceTable_visit.
1869 detectorColumn : `str`
1870 Name of the detector column.
1871 ixxColumns : `list`
1872 Name of the ixx/iyy/ixy columns.
1873 """
1874 if 'detector' in inColumns:
1875 # Default name for Gen3.
1876 detectorColumn = 'detector'
1877 else:
1878 # Default name for Gen2 and Gen2 conversions.
1879 detectorColumn = 'ccd'
1880
1881 columns = ['visit', detectorColumn,
1882 'sourceId', 'x', 'xErr', 'y', 'yErr',
1883 config.sourceFluxType + '_instFlux', config.sourceFluxType + '_instFluxErr']
1884
1885 if 'ixx' in inColumns:
1886 # New columns post-DM-31825
1887 ixxColumns = ['ixx', 'iyy', 'ixy']
1888 else:
1889 # Old columns pre-DM-31825
1890 ixxColumns = ['Ixx', 'Iyy', 'Ixy']
1891 columns.extend(ixxColumns)
1892
1893 if sourceSelector.config.doFlags:
1894 columns.extend(sourceSelector.config.flags.bad)
1895 if sourceSelector.config.doUnresolved:
1896 columns.append(sourceSelector.config.unresolved.name)
1897 if sourceSelector.config.doIsolated:
1898 columns.append(sourceSelector.config.isolated.parentName)
1899 columns.append(sourceSelector.config.isolated.nChildName)
1900
1901 return columns, detectorColumn, ixxColumns
1902
1903
def get_sourceTable_visit_columns(inColumns, config, sourceSelector)
Definition: jointcal.py:1852

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

142def lookupStaticCalibrations(datasetType, registry, quantumDataId, collections):
143 """Lookup function that asserts/hopes that a static calibration dataset
144 exists in a particular collection, since this task can't provide a single
145 date/time to use to search for one properly.
146
147 This is mostly useful for the ``camera`` dataset, in cases where the task's
148 quantum dimensions do *not* include something temporal, like ``exposure``
149 or ``visit``.
150
151 Parameters
152 ----------
153 datasetType : `lsst.daf.butler.DatasetType`
154 Type of dataset being searched for.
155 registry : `lsst.daf.butler.Registry`
156 Data repository registry to search.
157 quantumDataId : `lsst.daf.butler.DataCoordinate`
158 Data ID of the quantum this camera should match.
159 collections : `Iterable` [ `str` ]
160 Collections that should be searched - but this lookup function works
161 by ignoring this in favor of a more-or-less hard-coded value.
162
163 Returns
164 -------
165 refs : `Iterator` [ `lsst.daf.butler.DatasetRef` ]
166 Iterator over dataset references; should have only one element.
167
168 Notes
169 -----
170 This implementation duplicates one in fgcmcal, and is at least quite
171 similar to another in cp_pipe. This duplicate has the most documentation.
172 Fixing this is DM-29661.
173 """
174 instrument = Instrument.fromName(quantumDataId["instrument"], registry)
175 unboundedCollection = instrument.makeUnboundedCalibrationRunName()
176 return registry.queryDatasets(datasetType,
177 dataId=quantumDataId,
178 collections=[unboundedCollection],
179 findFirst=True)
180
181
def lookupStaticCalibrations(datasetType, registry, quantumDataId, collections)
Definition: jointcal.py:142

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

182def lookupVisitRefCats(datasetType, registry, quantumDataId, collections):
183 """Lookup function that finds all refcats for all visits that overlap a
184 tract, rather than just the refcats that directly overlap the tract.
185
186 Parameters
187 ----------
188 datasetType : `lsst.daf.butler.DatasetType`
189 Type of dataset being searched for.
190 registry : `lsst.daf.butler.Registry`
191 Data repository registry to search.
192 quantumDataId : `lsst.daf.butler.DataCoordinate`
193 Data ID of the quantum; expected to be something we can use as a
194 constraint to query for overlapping visits.
195 collections : `Iterable` [ `str` ]
196 Collections to search.
197
198 Returns
199 -------
200 refs : `Iterator` [ `lsst.daf.butler.DatasetRef` ]
201 Iterator over refcat references.
202 """
203 refs = set()
204 # Use .expanded() on the query methods below because we need data IDs with
205 # regions, both in the outer loop over visits (queryDatasets will expand
206 # any data ID we give it, but doing it up-front in bulk is much more
207 # efficient) and in the data IDs of the DatasetRefs this function yields
208 # (because the RefCatLoader relies on them to do some of its own
209 # filtering).
210 for visit_data_id in set(registry.queryDataIds("visit", dataId=quantumDataId).expanded()):
211 refs.update(
212 registry.queryDatasets(
213 datasetType,
214 collections=collections,
215 dataId=visit_data_id,
216 findFirst=True,
217 ).expanded()
218 )
219 yield from refs
220
221
daf::base::PropertySet * set
Definition: fits.cc:912
def lookupVisitRefCats(datasetType, registry, quantumDataId, collections)
Definition: jointcal.py:182

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

1827def make_schema_table():
1828 """Return an afw SourceTable to use as a base for creating the
1829 SourceCatalog to insert values from the dataFrame into.
1830
1831 Returns
1832 -------
1834 Table with schema and slots to use to make SourceCatalogs.
1835 """
1837 schema.addField("centroid_x", "D")
1838 schema.addField("centroid_y", "D")
1839 schema.addField("centroid_xErr", "F")
1840 schema.addField("centroid_yErr", "F")
1841 schema.addField("shape_xx", "D")
1842 schema.addField("shape_yy", "D")
1843 schema.addField("shape_xy", "D")
1844 schema.addField("flux_instFlux", "D")
1845 schema.addField("flux_instFluxErr", "D")
1846 table = lsst.afw.table.SourceTable.make(schema)
1847 table.defineCentroid("centroid")
1848 table.defineShape("shape")
1849 return table
1850
1851
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 632 of file jointcal.py.

632def writeModel(model, filename, log):
633 """Write model to outfile."""
634 with open(filename, "w") as file:
635 file.write(repr(model))
636 log.info("Wrote %s to file: %s", model, filename)
637
638
639@dataclasses.dataclass
def writeModel(model, filename, log)
Definition: jointcal.py:632

Variable Documentation

◆ Astrometry

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

Definition at line 56 of file jointcal.py.

◆ Photometry

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

Definition at line 55 of file jointcal.py.