LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Classes | Functions
lsst::afw::formatters Namespace Reference

Classes

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...
 
class  DecoratedImageFormatterTraits
 
class  ImageFormatterTraits
 
class  MaskedImageFormatterTraits
 
class  MaskFormatterTraits
 

Functions

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)
 
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)
 
bool extractOptionalFlag (boost::shared_ptr< PropertySet const > const &properties, std::string const &name)
 
std::string const getTableName (boost::shared_ptr< Policy const > const &policy, boost::shared_ptr< PropertySet const > const &properties)
 
std::vector< std::string > getAllSliceTableNames (boost::shared_ptr< Policy const > const &policy, boost::shared_ptr< 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< 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< 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 328 of file Utils.cc.

328  {
329  return prop->paramNames(false).size();
330 }
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 257 of file Utils.cc.

261  {
262  std::string itemName(getItemName(properties));
263  std::string name(getTableName(policy, properties));
264  std::string model(policy->getString(itemName + ".templateTableName"));
265 
267  db.setPersistLocation(location);
268  db.createTableFromTemplate(name, model);
269 }
std::string const getItemName(boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void setPersistLocation(LogicalLocation const &location)
Definition: DbTsvStorage.cc:91
Class for database storage with data loading from TSV files.
Definition: DbTsvStorage.h:66
std::string const getTableName(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< 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 273 of file Utils.cc.

277  {
278  std::vector<std::string> names = getAllSliceTableNames(policy, properties);
279 
281  db.setPersistLocation(location);
282  for (std::vector<std::string>::const_iterator i(names.begin()), end(names.end()); i != end; ++i) {
283  db.dropTable(*i);
284  }
285 }
virtual void setPersistLocation(LogicalLocation const &location)
Definition: DbTsvStorage.cc:91
Class for database storage with data loading from TSV files.
Definition: DbTsvStorage.h:66
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)
virtual void dropTable(std::string const &tableName)
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 133 of file Utils.cc.

133  {
134  if (properties->isArray("ampExposureId")) {
135  throw LSST_EXCEPT(ex::RuntimeError, "\"ampExposureId\" property has multiple values");
136  }
137  int64_t ampExposureId = properties->getAsInt64("ampExposureId");
138  if (ampExposureId < 0) {
139  throw LSST_EXCEPT(ex::RangeError, "negative \"ampExposureId\"");
140  }
141  return ampExposureId;
142 }
#define LSST_EXCEPT(type,...)
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 108 of file Utils.cc.

108  {
109  if (properties->isArray("ampId")) {
110  throw LSST_EXCEPT(ex::RuntimeError, "\"ampId\" property has multiple values");
111  }
112  int ampId = properties->getAsInt("ampId");
113  if (ampId < 0) {
114  throw LSST_EXCEPT(ex::RangeError, "negative \"ampId\"");
115  }
116  if (ampId > 63) {
117  throw LSST_EXCEPT(ex::RangeError, "\"ampId\" is too large");
118  }
119  return (extractCcdId(properties) << 6) + ampId;
120 }
int extractCcdId(boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
#define LSST_EXCEPT(type,...)
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 122 of file Utils.cc.

122  {
123  if (properties->isArray("ccdExposureId")) {
124  throw LSST_EXCEPT(ex::RuntimeError, "\"ccdExposureId\" property has multiple values");
125  }
126  int64_t ccdExposureId = properties->getAsInt64("ccdExposureId");
127  if (ccdExposureId < 0) {
128  throw LSST_EXCEPT(ex::RangeError, "negative \"ccdExposureId\"");
129  }
130  return ccdExposureId;
131 }
#define LSST_EXCEPT(type,...)
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 94 of file Utils.cc.

94  {
95  if (properties->isArray("ccdId")) {
96  throw LSST_EXCEPT(ex::RuntimeError, "\"ccdId\" property has multiple values");
97  }
98  int ccdId = properties->getAsInt("ccdId");
99  if (ccdId < 0) {
100  throw LSST_EXCEPT(ex::RangeError, "negative \"ccdId\"");
101  }
102  if (ccdId > 255) {
103  throw LSST_EXCEPT(ex::RangeError, "\"ccdId\" is too large");
104  }
105  return static_cast<int>(ccdId);
106 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int64_t lsst::afw::formatters::extractFpaExposureId ( boost::shared_ptr< PropertySet const > const &  properties)

Definition at line 80 of file Utils.cc.

80  {
81  if (properties->isArray("fpaExposureId")) {
82  throw LSST_EXCEPT(ex::RuntimeError, "\"fpaExposureId\" property has multiple values");
83  }
84  int64_t fpaExposureId = properties->getAsInt64("fpaExposureId");
85  if (fpaExposureId < 0) {
86  throw LSST_EXCEPT(ex::RangeError, "negative \"fpaExposureId\"");
87  }
88  if ((fpaExposureId & 0xfffffffe00000000LL) != 0LL) {
89  throw LSST_EXCEPT(ex::RangeError, "\"fpaExposureId\" is too large");
90  }
91  return fpaExposureId;
92 }
#define LSST_EXCEPT(type,...)
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 166 of file Utils.cc.

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

Definition at line 52 of file Utils.cc.

52  {
53  if (properties->isArray("sliceId")) {
54  throw LSST_EXCEPT(ex::RuntimeError, "\"sliceId\" property has multiple values");
55  }
56  int sliceId = properties->getAsInt("sliceId");
57  if (sliceId < 0) {
58  throw LSST_EXCEPT(ex::RangeError, "negative \"sliceId\"");
59  }
60  if (properties->exists("universeSize") && !properties->isArray("universeSize")) {
61  int universeSize = properties->getAsInt("universeSize");
62  if (sliceId >= universeSize) {
63  throw LSST_EXCEPT(ex::RangeError, "\"sliceId\" must be less than \"universeSize \"");
64  }
65  }
66  return sliceId;
67 }
#define LSST_EXCEPT(type,...)
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 69 of file Utils.cc.

69  {
70  if (properties->isArray("visitId")) {
71  throw LSST_EXCEPT(ex::RuntimeError, "\"visitId\" property has multiple values");
72  }
73  int visitId = properties->getAsInt("visitId");
74  if (visitId < 0) {
75  throw LSST_EXCEPT(ex::RangeError, "negative \"visitId\"");
76  }
77  return visitId;
78 }
#define LSST_EXCEPT(type,...)
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 288 of file Utils.cc.

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

226  {
227  std::string itemName(getItemName(properties));
228  std::string pattern(policy->getString(itemName + ".tableNamePattern"));
229  int numSlices = 1;
230  if (properties->exists(itemName + ".numSlices")) {
231  numSlices = properties->getAsInt(itemName + ".numSlices");
232  }
233  if (numSlices <= 0) {
234  throw LSST_EXCEPT(ex::RuntimeError,
235  itemName + " \".numSlices\" property value must be positive");
236  }
237  std::vector<std::string> names;
238  names.reserve(numSlices);
239  PTR(PropertySet) props = properties->deepCopy();
240  for (int i = 0; i < numSlices; ++i) {
241  props->set("sliceId", i);
242  names.push_back(LogicalLocation(pattern, props).locString());
243  }
244  return names;
245 }
std::string const getItemName(boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
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.
#define PTR(...)
Definition: base.h:41
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
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 151 of file Utils.cc.

151  {
152  if (!properties) {
153  throw LSST_EXCEPT(ex::InvalidParameterError, "Null PropertySet::Ptr");
154  }
155  if (properties->isArray("itemName")) {
156  throw LSST_EXCEPT(ex::InvalidParameterError, "\"itemName\" property has multiple values");
157  }
158  return properties->getAsString("itemName");
159 }
#define LSST_EXCEPT(type,...)
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 192 of file Utils.cc.

195  {
196  std::string itemName(getItemName(properties));
197  return LogicalLocation(policy->getString(itemName + ".tableNamePattern"), properties).locString();
198 }
std::string const getItemName(boost::shared_ptr< lsst::daf::base::PropertySet const > const &properties)
Class for logical location of a persisted Persistable instance.