LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Namespaces | Classes | Functions
lsst::ap::match Namespace Reference

Namespaces

 config
 
 detail
 

Classes

class  BBox
 
struct  CatalogControl
 
class  ExposureInfo
 
class  ExposureInfoMap
 
class  ReferencePosition
 

Functions

void readExposureInfos (std::vector< ExposureInfo::Ptr > &exposures, std::string const &csvFile, CsvControl const &control, std::string const &idColumn)
 
void referenceMatch (std::string const &refFile, CatalogControl const &refControl, CsvControl const &refDialect, std::string const &posFile, CatalogControl const &posControl, CsvControl const &posDialect, std::string const &outFile, CsvControl const &outDialect, lsst::afw::geom::Angle const radius, lsst::afw::geom::Angle const parallaxThresh, bool outputRefExtras, bool truncateOutFile)
 
void referenceFilter (std::vector< ExposureInfo::Ptr > &exposures, std::string const &refFile, CatalogControl const &refControl, CsvControl const &refDialect, std::string const &outFile, CsvControl const &outDialect, lsst::afw::geom::Angle const parallaxThresh, bool truncateOutFile)
 

Function Documentation

void lsst::ap::match::readExposureInfos ( std::vector< ExposureInfo::Ptr > &  exposures,
std::string const &  csvFile,
lsst::ap::utils::CsvControl const &  control,
std::string const &  idColumn 
)

Reads an exposure metadata key-value CSV file (where metadata keys must have been grouped by exposure id). An ExposureInfo object is created for each input exposure and appended to exposures.

Parameters
[in,out]exposuresExposureInfo objects are appended to this vector.
[in]csvFileMetadata table path.
[in]controlMetadata table CSV format.
[in]idColumnName of ID column, e.g. "scienceCcdExposureId".

Definition at line 307 of file ExposureInfo.cc.

312  {
313  typedef std::tr1::unordered_map<std::string, int> FkMap;
314  typedef FkMap::const_iterator FkIter;
315 
316  static boost::regex const sipRegex("^[AB]P?_[0-9]+_[0-9]+$");
317 
318  Log log(Log::getDefaultLog(), "lsst.ap.match");
319  log.log(Log::INFO, "Reading exposure metadata from " + csvFile);
320 
321  FkMap const & fkMap = fitsKeyMap();
322  // open CSV file and get column indexes
323  CsvReader reader(csvFile, control, true);
324  int const idCol = reader.getIndexOf(idColumn);
325  int const keyCol = reader.getIndexOf("metadataKey");
326  int const intCol = reader.getIndexOf("intValue");
327  int const doubleCol = reader.getIndexOf("doubleValue");
328  int const stringCol = reader.getIndexOf("stringValue");
329  if (idCol == -1) {
330  throw LSST_EXCEPT(RuntimeError, "Exposure metadata table "
331  "has no column named " + idColumn);
332  }
333  if (keyCol == -1) {
334  throw LSST_EXCEPT(RuntimeError, "Exposure metadata table "
335  "has no column named metadataKey");
336  }
337  if (intCol == -1) {
338  throw LSST_EXCEPT(RuntimeError, "Exposure metadata table "
339  "has no column named intValue");
340  }
341  if (doubleCol == -1) {
342  throw LSST_EXCEPT(RuntimeError, "Exposure metadata table "
343  "has no column named doubleValue");
344  }
345  if (stringCol == -1) {
346  throw LSST_EXCEPT(RuntimeError, "Exposure metadata table "
347  "has no column named stringValue");
348  }
349  PropertySet::Ptr ps;
350  int64_t lastId = reader.get<int64_t>(idCol) - 1;
351  for (; !reader.isDone(); reader.nextRecord()) {
352  int64_t id = reader.get<int64_t>(idCol);
353  if (id != lastId) {
354  if (ps) {
355  exposures.push_back(ExposureInfo::Ptr(
356  new ExposureInfo(ps, lastId)));
357  }
358  ps.reset(new PropertySet());
359  lastId = id;
360  }
361  std::string const key = reader.get(keyCol);
362  FkIter k = fkMap.find(key);
363  if (k != fkMap.end()) {
364  if (k->second == INT_T) { // integer-valued key
365  ps->set(key, reader.get<int>(intCol));
366  } else if (k->second == DOUBLE_T) { // double-valued key
367  ps->set(key, reader.get<double>(doubleCol));
368  } else { // string-valued key
369  ps->set(key, reader.get(stringCol));
370  }
371  } else if (boost::regex_search(key.begin(), key.end(), sipRegex)) {
372  // key is a SIP coefficient
373  ps->set(key, reader.get<double>(doubleCol));
374  }
375  }
376  if (ps) {
377  exposures.push_back(ExposureInfo::Ptr(
378  new ExposureInfo(ps, lastId)));
379  }
380 }
a place to record messages and descriptions of the state of processing.
Definition: Log.h:154
lsst::daf::base::PropertySet PropertySet
Definition: Wcs.cc:57
def log
Definition: log.py:85
int INFO
Definition: log.py:37
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int id
Definition: CR.cc:151
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
void lsst::ap::match::referenceFilter ( std::vector< ExposureInfo::Ptr > &  exposures,
std::string const &  refFile,
CatalogControl const &  refControl,
lsst::ap::utils::CsvControl const &  refDialect,
std::string const &  outFile,
lsst::ap::utils::CsvControl const &  outDialect,
lsst::afw::geom::Angle const  parallaxThresh = 0.01 *lsst::afw::geom::arcseconds,
bool  truncateOutFile = false 
)

Computes the number of times a reference catalog should have been observed in each filter with an ideal observatory, given a set of exposures. The per-filter observation counts are appended as columns "<filter>Cov", in order of filter ID. Note that filter IDs are required to be contiguous integers 0, 1, .... N - 1.

Reference catalog entries not falling on any of the given exposures are dropped from the output.

Note that a reduction for parallax from barycentric to geocentric place is applied to reference catalog entries with parallax above parallaxThresh. To disable this reduction, use a large threshold (e.g. +Inf).

Parameters
[in]exposuresExposures to filter against - reordered by the call.
[in]refFileDeclination sorted reference catalog CSV file name.
[in]refControlCSV dialect of reference catalog CSV file.
[in]refDialectCSV dialect of reference catalog CSV file.
[in]outFileOutput file name.
[in]outDialectOutput file CSV dialect.
[in]parallaxThreshParallax threshold
[in]truncateOutFileTruncate outFile before appending to it?

Definition at line 1671 of file ReferenceMatch.cc.

1680  {
1681  typedef std::vector<ExposureInfo::Ptr>::const_iterator Iter;
1682  if (exposures.empty()) {
1683  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
1684  "no input exposure information");
1685  }
1686  checkFilters();
1687 
1688  Log log(Log::getDefaultLog(), "lsst.ap.match");
1689  log.log(Log::INFO, "Filtering out reference catalog entries not "
1690  "observable in any exposure...");
1691 
1692  // determine min/max epoch of exposures
1693  Iter i = exposures.begin();
1694  double minEpoch = (*i)->getEpoch();
1695  double maxEpoch = minEpoch;
1696  ++i;
1697  for (Iter e = exposures.end(); i != e; ++i) {
1698  double epoch = (*i)->getEpoch();
1699  if (epoch < minEpoch) {
1700  minEpoch = epoch;
1701  } else if (epoch > maxEpoch) {
1702  maxEpoch = epoch;
1703  }
1704  }
1705  log.format(Log::INFO, "Time range of exposures is [%.3f, %.3f] MJD",
1706  minEpoch, maxEpoch);
1707 
1708  // Create reader, writer and matcher
1709  RefReader<RefWithCov> refReader(
1710  refFile, refControl, refDialect, outDialect,
1711  minEpoch, maxEpoch, parallaxThresh);
1712  CsvWriter writer(outFile, outDialect, truncateOutFile);
1713  RefExpMatcher matcher;
1714 
1715  log.log(Log::INFO, "Starting reference catalog to exposure match");
1716  matcher.match(writer, refReader, exposures);
1717  log.format(Log::INFO, "Wrote %llu records to output match table %s",
1718  static_cast<unsigned long long>(writer.getNumRecords()),
1719  outFile.c_str());
1720 }
a place to record messages and descriptions of the state of processing.
Definition: Log.h:154
def log
Definition: log.py:85
int INFO
Definition: log.py:37
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void lsst::ap::match::referenceMatch ( std::string const &  refFile,
CatalogControl const &  refControl,
lsst::ap::utils::CsvControl const &  refDialect,
std::string const &  posFile,
CatalogControl const &  posControl,
lsst::ap::utils::CsvControl const &  posDialect,
std::string const &  outFile,
lsst::ap::utils::CsvControl const &  outDialect,
lsst::afw::geom::Angle const  radius = 2.0 *lsst::afw::geom::arcseconds,
lsst::afw::geom::Angle const  parallaxThresh = 0.01 *lsst::afw::geom::arcseconds,
bool  outputRefExtras = true,
bool  truncateOutFile = false 
)

Matches a declination sorted reference catalog (stored as a CSV file) to a table of positions.

Note that a reduction for parallax from barycentric to geocentric place is applied to reference catalog entries with parallax above parallaxThresh. To disable this reduction, use a large threshold (e.g. +Inf).

Parameters
[in]refFileDeclination sorted reference catalog CSV file name.
[in]refControlReference catalog CSV file properties.
[in]refDialectCSV dialect of reference catalog CSV file.
[in]posFileDeclination sorted position CSV file name.
[in]posControlPosition CSV file properties.
[in]posDialectCSV dialect of position CSV file.
[in]outFileOutput file name.
[in]outDialectOutput file CSV dialect.
[in]radiusMatch radius.
[in]parallaxThreshParallax threshold.
[in]outputRefExtrasOutput proper-motion/parallax corrected reference object position and associated flags in match records?
[in]truncateOutFileTruncate outFile before appending to it?

Definition at line 1637 of file ReferenceMatch.cc.

1650  {
1651  Log log(Log::getDefaultLog(), "lsst.ap.match");
1652  log.log(Log::INFO, "Matching reference catalog to position table...");
1653 
1654  // Create readers, writer and matcher
1655  MatchablePosReader posReader(
1656  posFile, posControl, posDialect, outDialect, radius);
1657  RefReader<MatchableRef> refReader(
1658  refFile, refControl, refDialect, outDialect,
1659  posReader.getMinEpoch(), posReader.getMaxEpoch(), parallaxThresh);
1660  CsvWriter writer(outFile, outDialect, truncateOutFile);
1661  RefPosMatcher matcher(outputRefExtras);
1662 
1663  log.log(Log::INFO, "Starting reference catalog to position table match");
1664  matcher.match(writer, refReader, posReader);
1665  log.format(Log::INFO, "Wrote %llu records to output match table %s",
1666  static_cast<unsigned long long>(writer.getNumRecords()),
1667  outFile.c_str());
1668 }
a place to record messages and descriptions of the state of processing.
Definition: Log.h:154
def log
Definition: log.py:85
int INFO
Definition: log.py:37