LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
Classes | Functions
lsst::afw::formatters Namespace Reference

Classes

class  DecoratedImageFormatterTraits
 
class  ImageFormatterTraits
 
class  MaskedImageFormatterTraits
 
class  MaskFormatterTraits
 
class  DecoratedImageFormatter
 Class implementing persistence and retrieval for DecoratedImages. More...
 
class  ExposureFormatter
 Class implementing persistence and retrieval for Exposures. More...
 
class  ImageFormatter
 Class implementing persistence and retrieval for Images. More...
 
class  KernelFormatter
 
class  MaskedImageFormatter
 Class implementing persistence and retrieval for MaskedImages. More...
 
class  MaskFormatter
 Class implementing persistence and retrieval for Masks. More...
 
class  TanWcsFormatter
 Class implementing persistence and retrieval for TanWcs objects. More...
 
class  WcsFormatter
 Class implementing persistence and retrieval for Wcs objects. More...
 

Functions

int extractSliceId (boost::shared_ptr< PropertySet const > const &properties)
 
int extractVisitId (boost::shared_ptr< PropertySet const > const &properties)
 
int64_t extractFpaExposureId (boost::shared_ptr< PropertySet const > const &properties)
 
int extractCcdId (boost::shared_ptr< PropertySet const > const &properties)
 
int extractAmpId (boost::shared_ptr< PropertySet const > const &properties)
 
int64_t extractCcdExposureId (boost::shared_ptr< PropertySet const > const &properties)
 
int64_t extractAmpExposureId (boost::shared_ptr< PropertySet const > const &properties)
 
std::string const getItemName (boost::shared_ptr< PropertySet const > const &properties)
 Extracts and returns the string-valued "itemName" property from the given data property object. More...
 
bool extractOptionalFlag (boost::shared_ptr< PropertySet const > const &properties, std::string const &name)
 Returns true if and only if properties is non-null and contains a unique property with the given name that has type bool and a value of true. More...
 
std::string const getTableName (boost::shared_ptr< Policy const > const &policy, boost::shared_ptr< PropertySet const > const &properties)
 Returns the name of the table that a single slice of a pipeline involved in the processing of a single visit should use for persistence of a particular output. More...
 
std::vector< std::string > getAllSliceTableNames (boost::shared_ptr< Policy const > const &policy, boost::shared_ptr< PropertySet const > const &properties)
 Stores the name of the table that each slice of a pipeline involved in processing a visit used for persistence of its outputs. More...
 
void createTable (lsst::daf::persistence::LogicalLocation const &location, boost::shared_ptr< lsst::pex::policy::Policy const > const &policy, boost::shared_ptr< PropertySet const > const &properties)
 Creates the table identified by calling getTableName() with the given policy and properties. More...
 
void dropAllSliceTables (lsst::daf::persistence::LogicalLocation const &location, boost::shared_ptr< lsst::pex::policy::Policy const > const &policy, boost::shared_ptr< PropertySet const > const &properties)
 Drops the database table(s) identified by getAllSliceTables(). More...
 
std::string formatFitsProperties (boost::shared_ptr< lsst::daf::base::PropertySet const > const &prop)
 
int countFitsHeaderCards (boost::shared_ptr< lsst::daf::base::PropertySet const > const &prop)
 
bool extractOptionalFlag (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties, std::string const &name)
 
std::string const getItemName (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
std::string const getTableName (boost::shared_ptr< lsst::pex::policy::Policy const > const &policy, boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
std::vector< std::string > getAllSliceTableNames (boost::shared_ptr< lsst::pex::policy::Policy const > const &policy, boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
void createTable (lsst::daf::persistence::LogicalLocation const &location, boost::shared_ptr< lsst::pex::policy::Policy const > const &policy, boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
void dropAllSliceTables (lsst::daf::persistence::LogicalLocation const &location, boost::shared_ptr< lsst::pex::policy::Policy const > const &policy, boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
int extractSliceId (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
int64_t extractFpaExposureId (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
int64_t extractCcdExposureId (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
int64_t extractAmpExposureId (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
int extractVisitId (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
int extractCcdId (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
int extractAmpId (boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
 
std::string formatFitsProperties (boost::shared_ptr< lsst::daf::base::PropertySet const > const &prop)
 
int countFitsHeaderCards (boost::shared_ptr< lsst::daf::base::PropertySet const > const &prop)
 

Function Documentation

int lsst::afw::formatters::countFitsHeaderCards ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  prop)
int lsst::afw::formatters::countFitsHeaderCards ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  prop)

Definition at line 329 of file Utils.cc.

329  {
330  return prop->paramNames(false).size();
331 }
void lsst::afw::formatters::createTable ( lsst::daf::persistence::LogicalLocation const &  location,
boost::shared_ptr< lsst::pex::policy::Policy const > const &  policy,
boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties 
)
void lsst::afw::formatters::createTable ( lsst::daf::persistence::LogicalLocation const &  location,
boost::shared_ptr< lsst::pex::policy::Policy const > const &  policy,
boost::shared_ptr< PropertySet const > const &  properties 
)

Creates the table identified by calling getTableName() with the given policy and properties.

A key named "${itemName}.templateTableName" (where ${itemName} refers to the value of a property named "itemName" extracted from properties) must be available and set to the name of the template table to use for creation.

Note that the template table must exist in the database identified by location, and that if the desired table already exists, an exception is thrown.

Definition at line 258 of file Utils.cc.

262  {
263  std::string itemName(getItemName(properties));
264  std::string name(getTableName(policy, properties));
265  std::string model(policy->getString(itemName + ".templateTableName"));
266 
268  db.setPersistLocation(location);
269  db.createTableFromTemplate(name, model);
270 }
std::string const getTableName(boost::shared_ptr< Policy const > const &policy, boost::shared_ptr< PropertySet const > const &properties)
Returns the name of the table that a single slice of a pipeline involved in the processing of a singl...
Definition: Utils.cc:193
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void setPersistLocation(LogicalLocation const &location)
Set the database location to persist to.
Definition: DbTsvStorage.cc:91
std::string const getItemName(boost::shared_ptr< PropertySet const > const &properties)
Extracts and returns the string-valued &quot;itemName&quot; property from the given data property object...
Definition: Utils.cc:152
Class for database storage with data loading from TSV files.
Definition: DbTsvStorage.h:66
void lsst::afw::formatters::dropAllSliceTables ( lsst::daf::persistence::LogicalLocation const &  location,
boost::shared_ptr< lsst::pex::policy::Policy const > const &  policy,
boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties 
)
void lsst::afw::formatters::dropAllSliceTables ( lsst::daf::persistence::LogicalLocation const &  location,
boost::shared_ptr< lsst::pex::policy::Policy const > const &  policy,
boost::shared_ptr< PropertySet const > const &  properties 
)

Drops the database table(s) identified by getAllSliceTables().

Definition at line 274 of file Utils.cc.

278  {
279  std::vector<std::string> names = getAllSliceTableNames(policy, properties);
280 
282  db.setPersistLocation(location);
283  for (std::vector<std::string>::const_iterator i(names.begin()), end(names.end()); i != end; ++i) {
284  db.dropTable(*i);
285  }
286 }
virtual void setPersistLocation(LogicalLocation const &location)
Set the database location to persist to.
Definition: DbTsvStorage.cc:91
std::vector< std::string > getAllSliceTableNames(boost::shared_ptr< Policy const > const &policy, boost::shared_ptr< PropertySet const > const &properties)
Stores the name of the table that each slice of a pipeline involved in processing a visit used for pe...
Definition: Utils.cc:224
virtual void dropTable(std::string const &tableName)
Drop a table.
Class for database storage with data loading from TSV files.
Definition: DbTsvStorage.h:66
int64_t lsst::afw::formatters::extractAmpExposureId ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties)
int64_t lsst::afw::formatters::extractAmpExposureId ( boost::shared_ptr< PropertySet const > const &  properties)

Definition at line 134 of file Utils.cc.

134  {
135  if (properties->isArray("ampExposureId")) {
136  throw LSST_EXCEPT(ex::RuntimeError, "\"ampExposureId\" property has multiple values");
137  }
138  int64_t ampExposureId = properties->getAsInt64("ampExposureId");
139  if (ampExposureId < 0) {
140  throw LSST_EXCEPT(ex::RangeError, "negative \"ampExposureId\"");
141  }
142  return ampExposureId;
143 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int lsst::afw::formatters::extractAmpId ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties)
int lsst::afw::formatters::extractAmpId ( boost::shared_ptr< PropertySet const > const &  properties)

Definition at line 109 of file Utils.cc.

109  {
110  if (properties->isArray("ampId")) {
111  throw LSST_EXCEPT(ex::RuntimeError, "\"ampId\" property has multiple values");
112  }
113  int ampId = properties->getAsInt("ampId");
114  if (ampId < 0) {
115  throw LSST_EXCEPT(ex::RangeError, "negative \"ampId\"");
116  }
117  if (ampId > 63) {
118  throw LSST_EXCEPT(ex::RangeError, "\"ampId\" is too large");
119  }
120  return (extractCcdId(properties) << 6) + ampId;
121 }
int extractCcdId(boost::shared_ptr< PropertySet const > const &properties)
Definition: Utils.cc:95
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int64_t lsst::afw::formatters::extractCcdExposureId ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties)
int64_t lsst::afw::formatters::extractCcdExposureId ( boost::shared_ptr< PropertySet const > const &  properties)

Definition at line 123 of file Utils.cc.

123  {
124  if (properties->isArray("ccdExposureId")) {
125  throw LSST_EXCEPT(ex::RuntimeError, "\"ccdExposureId\" property has multiple values");
126  }
127  int64_t ccdExposureId = properties->getAsInt64("ccdExposureId");
128  if (ccdExposureId < 0) {
129  throw LSST_EXCEPT(ex::RangeError, "negative \"ccdExposureId\"");
130  }
131  return ccdExposureId;
132 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int lsst::afw::formatters::extractCcdId ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties)
int lsst::afw::formatters::extractCcdId ( boost::shared_ptr< PropertySet const > const &  properties)

Definition at line 95 of file Utils.cc.

95  {
96  if (properties->isArray("ccdId")) {
97  throw LSST_EXCEPT(ex::RuntimeError, "\"ccdId\" property has multiple values");
98  }
99  int ccdId = properties->getAsInt("ccdId");
100  if (ccdId < 0) {
101  throw LSST_EXCEPT(ex::RangeError, "negative \"ccdId\"");
102  }
103  if (ccdId > 255) {
104  throw LSST_EXCEPT(ex::RangeError, "\"ccdId\" is too large");
105  }
106  return static_cast<int>(ccdId);
107 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int64_t lsst::afw::formatters::extractFpaExposureId ( boost::shared_ptr< PropertySet const > const &  properties)

Definition at line 81 of file Utils.cc.

81  {
82  if (properties->isArray("fpaExposureId")) {
83  throw LSST_EXCEPT(ex::RuntimeError, "\"fpaExposureId\" property has multiple values");
84  }
85  int64_t fpaExposureId = properties->getAsInt64("fpaExposureId");
86  if (fpaExposureId < 0) {
87  throw LSST_EXCEPT(ex::RangeError, "negative \"fpaExposureId\"");
88  }
89  if ((fpaExposureId & 0xfffffffe00000000LL) != 0LL) {
90  throw LSST_EXCEPT(ex::RangeError, "\"fpaExposureId\" is too large");
91  }
92  return fpaExposureId;
93 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int64_t lsst::afw::formatters::extractFpaExposureId ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties)
bool lsst::afw::formatters::extractOptionalFlag ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties,
std::string const &  name 
)
bool lsst::afw::formatters::extractOptionalFlag ( boost::shared_ptr< PropertySet const > const &  properties,
std::string const &  name 
)

Returns true if and only if properties is non-null and contains a unique property with the given name that has type bool and a value of true.

Definition at line 167 of file Utils.cc.

170  {
171  if (properties && properties->exists(name)) {
172  return properties->getAsBool(name);
173  }
174  return false;
175 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
int lsst::afw::formatters::extractSliceId ( boost::shared_ptr< PropertySet const > const &  properties)

Definition at line 53 of file Utils.cc.

53  {
54  if (properties->isArray("sliceId")) {
55  throw LSST_EXCEPT(ex::RuntimeError, "\"sliceId\" property has multiple values");
56  }
57  int sliceId = properties->getAsInt("sliceId");
58  if (sliceId < 0) {
59  throw LSST_EXCEPT(ex::RangeError, "negative \"sliceId\"");
60  }
61  if (properties->exists("universeSize") && !properties->isArray("universeSize")) {
62  int universeSize = properties->getAsInt("universeSize");
63  if (sliceId >= universeSize) {
64  throw LSST_EXCEPT(ex::RangeError, "\"sliceId\" must be less than \"universeSize \"");
65  }
66  }
67  return sliceId;
68 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int lsst::afw::formatters::extractSliceId ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties)
int lsst::afw::formatters::extractVisitId ( boost::shared_ptr< PropertySet const > const &  properties)

Definition at line 70 of file Utils.cc.

70  {
71  if (properties->isArray("visitId")) {
72  throw LSST_EXCEPT(ex::RuntimeError, "\"visitId\" property has multiple values");
73  }
74  int visitId = properties->getAsInt("visitId");
75  if (visitId < 0) {
76  throw LSST_EXCEPT(ex::RangeError, "negative \"visitId\"");
77  }
78  return visitId;
79 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int lsst::afw::formatters::extractVisitId ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties)
std::string lsst::afw::formatters::formatFitsProperties ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  prop)
std::string lsst::afw::formatters::formatFitsProperties ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  prop)

Definition at line 289 of file Utils.cc.

289  {
290  typedef std::vector<std::string> NameList;
291  std::string sout;
292 
293  NameList paramNames = prop->paramNames(false);
294 
295  for (NameList::const_iterator i = paramNames.begin(), end = paramNames.end(); i != end; ++i) {
296  std::size_t lastPeriod = i->rfind(char('.'));
297  std::string name = (lastPeriod == std::string::npos) ? *i : i->substr(lastPeriod + 1);
298  std::type_info const & type = prop->typeOf(*i);
299 
300  std::string out = "";
301  if (name.size() > 8) { // Oh dear; too long for a FITS keyword
302  out += "HIERARCH = " + name;
303  } else {
304  out = (boost::format("%-8s= ") % name).str();
305  }
306 
307  if (type == typeid(int)) {
308  out += (boost::format("%20d") % prop->get<int>(*i)).str();
309  } else if (type == typeid(double)) {
310  out += (boost::format("%20.15g") % prop->get<double>(*i)).str();
311  } else if (type == typeid(std::string)) {
312  out += (boost::format("'%-67s' ") % prop->get<std::string>(*i)).str();
313  }
314 
315  int const len = out.size();
316  if (len < 80) {
317  out += std::string(80 - len, ' ');
318  } else {
319  out = out.substr(0, 80);
320  }
321 
322  sout += out;
323  }
324 
325  return sout.c_str();
326 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::vector<std::string> lsst::afw::formatters::getAllSliceTableNames ( boost::shared_ptr< lsst::pex::policy::Policy const > const &  policy,
boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties 
)
std::vector<std::string> lsst::afw::formatters::getAllSliceTableNames ( boost::shared_ptr< Policy const > const &  policy,
boost::shared_ptr< PropertySet const > const &  properties 
)

Stores the name of the table that each slice of a pipeline involved in processing a visit used for persistence of its outputs.

If slices were configured to all use the same (per-visit) table name, a single name is stored.

Parameters
[in]policyThe Policy containing the table name pattern ("${itemName}.tableNamePattern", where ${itemName} is looked up in properties using the "itemName" key) from which the the actual table name is derived. This pattern may contain a set of parameters in %(key) format - these are interpolated by looking up "key" in the properties PropertySet.
[in]propertiesThe runtime specific properties necessary to construct the table names.

string. The "visitId" property must also be present, and shall be a non-negative integer of type int64_t uniquely identifying the current LSST visit. If the "${itemName}.isPerSliceTable" property is present, is of type bool and is set to true, then it is assumed that "${itemName}.numSlices" (a positive integer of type int) output tables exist and are to be read in.

Returns
a list of table names
See Also
getTableName()

Definition at line 224 of file Utils.cc.

227  {
228  std::string itemName(getItemName(properties));
229  std::string pattern(policy->getString(itemName + ".tableNamePattern"));
230  int numSlices = 1;
231  if (properties->exists(itemName + ".numSlices")) {
232  numSlices = properties->getAsInt(itemName + ".numSlices");
233  }
234  if (numSlices <= 0) {
235  throw LSST_EXCEPT(ex::RuntimeError,
236  itemName + " \".numSlices\" property value must be positive");
237  }
238  std::vector<std::string> names;
239  names.reserve(numSlices);
240  PTR(PropertySet) props = properties->deepCopy();
241  for (int i = 0; i < numSlices; ++i) {
242  props->set("sliceId", i);
243  names.push_back(LogicalLocation(pattern, props).locString());
244  }
245  return names;
246 }
for(FootprintList::const_iterator ptr=feet->begin(), end=feet->end();ptr!=end;++ptr)
Definition: saturated.cc:82
Class for logical location of a persisted Persistable instance.
std::string const getItemName(boost::shared_ptr< PropertySet const > const &properties)
Extracts and returns the string-valued &quot;itemName&quot; property from the given data property object...
Definition: Utils.cc:152
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
#define PTR(...)
Definition: base.h:41
Class for storing generic metadata.
Definition: PropertySet.h:82
std::string const lsst::afw::formatters::getItemName ( boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties)
std::string const lsst::afw::formatters::getItemName ( boost::shared_ptr< PropertySet const > const &  properties)

Extracts and returns the string-valued "itemName" property from the given data property object.

Exceptions
lsst::pex::exceptions::InvalidParameterErrorIf the given pointer is null, or the PropertySet pointed to does not contain a unique property named "itemName".

Definition at line 152 of file Utils.cc.

152  {
153  if (!properties) {
154  throw LSST_EXCEPT(ex::InvalidParameterError, "Null PropertySet::Ptr");
155  }
156  if (properties->isArray("itemName")) {
157  throw LSST_EXCEPT(ex::InvalidParameterError, "\"itemName\" property has multiple values");
158  }
159  return properties->getAsString("itemName");
160 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
std::string const lsst::afw::formatters::getTableName ( boost::shared_ptr< lsst::pex::policy::Policy const > const &  policy,
boost::shared_ptr< lsst::daf::base::PropertySet const > const &  properties 
)
std::string const lsst::afw::formatters::getTableName ( boost::shared_ptr< Policy const > const &  policy,
boost::shared_ptr< PropertySet const > const &  properties 
)

Returns the name of the table that a single slice of a pipeline involved in the processing of a single visit should use for persistence of a particular output.

All slices can be configured to use the same (per-visit) table name using policy parameters.

Parameters
[in]policyThe Policy containing the table name pattern ("${itemName}.tableNamePattern", where ${itemName} is looked up in properties using the "itemName" key) from which the the actual table name is derived. This pattern may contain a set of parameters in %(key) format - these are interpolated by looking up "key" in the properties PropertySet.
[in]propertiesProvides runtime specific properties necessary to construct the output table name.
Returns
table name

Definition at line 193 of file Utils.cc.

196  {
197  std::string itemName(getItemName(properties));
198  return LogicalLocation(policy->getString(itemName + ".tableNamePattern"), properties).locString();
199 }
Class for logical location of a persisted Persistable instance.
std::string const getItemName(boost::shared_ptr< PropertySet const > const &properties)
Extracts and returns the string-valued &quot;itemName&quot; property from the given data property object...
Definition: Utils.cc:152