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
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
lsst::afw::formatters::TanWcsFormatter Class Reference

Class implementing persistence and retrieval for TanWcs objects. More...

#include <TanWcsFormatter.h>

Inheritance diagram for lsst::afw::formatters::TanWcsFormatter:
lsst::daf::persistence::Formatter lsst::daf::base::Citizen

Public Member Functions

virtual ~TanWcsFormatter (void)
 
virtual void write (lsst::daf::base::Persistable const *persistable, lsst::daf::persistence::Storage::Ptr storage, lsst::daf::base::PropertySet::Ptr additionalData)
 
virtual
lsst::daf::base::Persistable
read (lsst::daf::persistence::Storage::Ptr storage, lsst::daf::base::PropertySet::Ptr additionalData)
 
virtual void update (lsst::daf::base::Persistable *persistable, lsst::daf::persistence::Storage::Ptr storage, lsst::daf::base::PropertySet::Ptr additionalData)
 
- Public Member Functions inherited from lsst::daf::persistence::Formatter
virtual ~Formatter (void)
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 

Static Public Member Functions

static
lsst::daf::base::PropertyList::Ptr 
generatePropertySet (lsst::afw::image::TanWcs const &wcs)
 
static
lsst::daf::persistence::Formatter::Ptr 
createInstance (lsst::pex::policy::Policy::Ptr policy)
 
template<class Archive >
static void delegateSerialize (Archive &ar, int const version, lsst::daf::base::Persistable *persistable)
 
- Static Public Member Functions inherited from lsst::daf::persistence::Formatter
static Formatter::Ptr lookupFormatter (std::string const &persistableType, lsst::pex::policy::Policy::Ptr policy)
 
static Formatter::Ptr lookupFormatter (std::type_info const &persistableType, lsst::pex::policy::Policy::Ptr policy)
 
- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Private Member Functions

 TanWcsFormatter (lsst::pex::policy::Policy::Ptr policy)
 

Static Private Attributes

static
lsst::daf::persistence::FormatterRegistration 
registration
 

Additional Inherited Members

- Public Types inherited from lsst::daf::persistence::Formatter
typedef boost::shared_ptr
< Formatter
Ptr
 
typedef Ptr(* FactoryPtr )(lsst::pex::policy::Policy::Ptr)
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 
- Protected Member Functions inherited from lsst::daf::persistence::Formatter
 Formatter (std::type_info const &type)
 

Detailed Description

Class implementing persistence and retrieval for TanWcs objects.

Definition at line 57 of file TanWcsFormatter.h.

Constructor & Destructor Documentation

lsst::afw::formatters::TanWcsFormatter::~TanWcsFormatter ( void  )
virtual

Definition at line 83 of file TanWcsFormatter.cc.

83  {
84 }
lsst::afw::formatters::TanWcsFormatter::TanWcsFormatter ( lsst::pex::policy::Policy::Ptr  policy)
explicitprivate

Definition at line 78 of file TanWcsFormatter.cc.

79  :
80  dafPersist::Formatter(typeid(this)) {
81 }
Abstract base class for all formatters.
Definition: Formatter.h:79

Member Function Documentation

dafPersist::Formatter::Ptr lsst::afw::formatters::TanWcsFormatter::createInstance ( lsst::pex::policy::Policy::Ptr  policy)
static

Definition at line 300 of file TanWcsFormatter.cc.

301  {
303 }
boost::shared_ptr< Formatter > Ptr
Definition: Formatter.h:81
Class implementing persistence and retrieval for TanWcs objects.
template<class Archive >
template void lsst::afw::formatters::TanWcsFormatter::delegateSerialize ( Archive &  ar,
int const  version,
lsst::daf::base::Persistable persistable 
)
static

Definition at line 229 of file TanWcsFormatter.cc.

230  {
231  execTrace("TanWcsFormatter delegateSerialize start");
232  afwImg::TanWcs* ip = dynamic_cast<afwImg::TanWcs*>(persistable);
233  if (ip == 0) {
234  throw LSST_EXCEPT(pexExcept::RuntimeError, "Serializing non-TanWcs");
235  }
236 
237  // Serialize most fields normally
238  ar & ip->_nWcsInfo & ip->_relax;
239  ar & ip->_wcsfixCtrl & ip->_wcshdrCtrl & ip->_nReject;
240  ar & ip->_coordSystem;
241 
242  ar & ip->_hasDistortion;
243 
244  if(ip->_hasDistortion) {
245  serializeEigenArray(ar, ip->_sipA);
246  serializeEigenArray(ar, ip->_sipAp);
247  serializeEigenArray(ar, ip->_sipB);
248  serializeEigenArray(ar, ip->_sipBp);
249  }
250 
251  // If we are loading, create the array of Wcs parameter structs
252  if (Archive::is_loading::value) {
253  ip->_wcsInfo =
254  reinterpret_cast<wcsprm*>(malloc(ip->_nWcsInfo * sizeof(wcsprm)));
255  }
256 
257  for (int i = 0; i < ip->_nWcsInfo; ++i) {
258  // If we are loading, initialize the struct first
259  if (Archive::is_loading::value) {
260  ip->_wcsInfo[i].flag = -1;
261  wcsini(1, 2, &(ip->_wcsInfo[i]));
262  }
263 
264  // Serialize only critical Wcs parameters
265  ar & ip->_wcsInfo[i].naxis;
266  ar & ip->_wcsInfo[i].equinox;
267  ar & ip->_wcsInfo[i].radesys;
268  ar & ip->_wcsInfo[i].crpix[0];
269  ar & ip->_wcsInfo[i].crpix[1];
270  ar & ip->_wcsInfo[i].cd[0];
271  ar & ip->_wcsInfo[i].cd[1];
272  ar & ip->_wcsInfo[i].cd[2];
273  ar & ip->_wcsInfo[i].cd[3];
274  ar & ip->_wcsInfo[i].crval[0];
275  ar & ip->_wcsInfo[i].crval[1];
276  ar & ip->_wcsInfo[i].cunit[0];
277  ar & ip->_wcsInfo[i].cunit[1];
278  ar & ip->_wcsInfo[i].ctype[0];
279  ar & ip->_wcsInfo[i].ctype[1];
280  ar & ip->_wcsInfo[i].altlin;
281 
282  // If we are loading, compute intermediate values given those above
283  if (Archive::is_loading::value) {
284  ip->_wcsInfo[i].flag = 0;
285  wcsset(&(ip->_wcsInfo[i]));
286  }
287  }
288  execTrace("TanWcsFormatter delegateSerialize end");
289 }
Eigen::MatrixXd _sipAp
Definition: TanWcs.h:205
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
Eigen::MatrixXd _sipB
Definition: TanWcs.h:205
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int _wcshdrCtrl
Controls messages to stderr from wcshdr (0 for none); see wcshdr.h for details.
Definition: Wcs.h:395
int _relax
Degree of permissiveness for wcspih (0 for strict); see wcshdr.h for details.
Definition: Wcs.h:393
Eigen::MatrixXd _sipA
Definition: TanWcs.h:205
int _wcsfixCtrl
Do potentially unsafe translations of non-standard unit strings? 0/1 = no/yes.
Definition: Wcs.h:394
struct wcsprm * _wcsInfo
Definition: Wcs.h:391
coord::CoordSystem _coordSystem
Definition: Wcs.h:397
Eigen::MatrixXd _sipBp
Definition: TanWcs.h:205
void serializeEigenArray(Archive &ar, Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &m)
Provide a function to serialise an Eigen::Matrix so we can persist the SIP matrices.
dafBase::PropertyList::Ptr lsst::afw::formatters::TanWcsFormatter::generatePropertySet ( lsst::afw::image::TanWcs const &  wcs)
static

Definition at line 179 of file TanWcsFormatter.cc.

179  {
180  // Only generates properties for the first wcsInfo.
182 
183  if (wcs._wcsInfo == NULL) { // nothing to add
184  return wcsProps;
185  }
186 
187  wcsProps->add("NAXIS", wcs._wcsInfo[0].naxis, "number of data axes");
188  wcsProps->add("EQUINOX", wcs._wcsInfo[0].equinox, "Equinox of coordinates");
189  wcsProps->add("RADESYS", std::string(wcs._wcsInfo[0].radesys), "Coordinate system for equinox");
190  wcsProps->add("CRPIX1", wcs._wcsInfo[0].crpix[0], "WCS Coordinate reference pixel");
191  wcsProps->add("CRPIX2", wcs._wcsInfo[0].crpix[1], "WCS Coordinate reference pixel");
192  wcsProps->add("CD1_1", wcs._wcsInfo[0].cd[0], "WCS Coordinate scale matrix");
193  wcsProps->add("CD1_2", wcs._wcsInfo[0].cd[1], "WCS Coordinate scale matrix");
194  wcsProps->add("CD2_1", wcs._wcsInfo[0].cd[2], "WCS Coordinate scale matrix");
195  wcsProps->add("CD2_2", wcs._wcsInfo[0].cd[3], "WCS Coordinate scale matrix");
196  wcsProps->add("CRVAL1", wcs._wcsInfo[0].crval[0], "WCS Ref value (RA in decimal degrees)");
197  wcsProps->add("CRVAL2", wcs._wcsInfo[0].crval[1], "WCS Ref value (DEC in decimal degrees)");
198  wcsProps->add("CUNIT1", std::string(wcs._wcsInfo[0].cunit[0]));
199  wcsProps->add("CUNIT2", std::string(wcs._wcsInfo[0].cunit[1]));
200 
201  //Hack. Because wcslib4.3 gets confused when it's passed RA---TAN-SIP,
202  //we set the value of ctypes to just RA---TAN, regardless of whether
203  //the SIP types are present. But when we persist to a file, we need to
204  //check whether the SIP polynomials were actually there and correct
205  //ctypes if necessary. Bad things will happen if someone tries to
206  //use a system other than RA---TAN and DEC--TAN
207  std::string ctype1(wcs._wcsInfo[0].ctype[0]);
208  std::string ctype2(wcs._wcsInfo[0].ctype[1]);
209 
210  if (wcs._hasDistortion) {
211  if (ctype1.rfind("-SIP") == std::string::npos) {
212  ctype1 += "-SIP";
213  }
214  if (ctype2.rfind("-SIP") == std::string::npos) {
215  ctype2 += "-SIP";
216  }
217  encodeSipHeader(wcsProps, "A", wcs._sipA);
218  encodeSipHeader(wcsProps, "B", wcs._sipB);
219  encodeSipHeader(wcsProps, "AP", wcs._sipAp);
220  encodeSipHeader(wcsProps, "BP", wcs._sipBp);
221  }
222  wcsProps->add("CTYPE1", ctype1, "WCS Coordinate type");
223  wcsProps->add("CTYPE2", ctype2, "WCS Coordinate type");
224 
225  return wcsProps;
226 }
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
tbl::Key< int > wcs
table::Key< std::string > ctype2
Definition: Wcs.cc:1039
boost::shared_ptr< PropertyList > Ptr
Definition: PropertyList.h:84
table::Key< std::string > ctype1
Definition: Wcs.cc:1038
dafBase::Persistable * lsst::afw::formatters::TanWcsFormatter::read ( lsst::daf::persistence::Storage::Ptr  storage,
lsst::daf::base::PropertySet::Ptr  additionalData 
)
virtual

Read a Persistable instance from a Storage instance.

Parameters
[in]storagePointer to the Storage instance.
[in]additionalDataAdditional data used to find the proper instance within the Storage.
Returns
Shared pointer to the new Persistable instance.

Implements lsst::daf::persistence::Formatter.

Definition at line 105 of file TanWcsFormatter.cc.

107  {
108  execTrace("TanWcsFormatter read start");
109  if (typeid(*storage) == typeid(dafPersist::BoostStorage)) {
110  afwImg::TanWcs* ip = new afwImg::TanWcs;
111  execTrace("TanWcsFormatter read BoostStorage");
112  dafPersist::BoostStorage* boost = dynamic_cast<dafPersist::BoostStorage*>(storage.get());
113  boost->getIArchive() & *ip;
114  execTrace("TanWcsFormatter read end");
115  return ip;
116  }
117  else if (typeid(*storage) == typeid(dafPersist::FitsStorage)) {
118  execTrace("TanWcsFormatter read FitsStorage");
119  dafPersist::FitsStorage* fits = dynamic_cast<dafPersist::FitsStorage*>(storage.get());
120  int hdu = additionalData->get<int>("hdu", 0);
122  afwImg::readMetadata(fits->getPath(), hdu);
123  afwImg::TanWcs* ip = new afwImg::TanWcs(md);
124  execTrace("TanWcsFormatter read end");
125  return ip;
126  }
127  throw LSST_EXCEPT(pexExcept::RuntimeError, "Unrecognized Storage for TanWcs");
128 }
virtual boost::archive::text_iarchive & getIArchive(void)
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
virtual std::string const & getPath(void)
Definition: FitsStorage.cc:109
Class for FITS file storage.
Definition: FitsStorage.h:52
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< daf::base::PropertySet > readMetadata(std::string const &fileName, int hdu=0, bool strip=false)
Return the metadata (header entries) from a FITS file.
Class for boost::serialization storage.
Definition: BoostStorage.h:58
void lsst::afw::formatters::TanWcsFormatter::update ( lsst::daf::base::Persistable persistable,
lsst::daf::persistence::Storage::Ptr  storage,
lsst::daf::base::PropertySet::Ptr  additionalData 
)
virtual

Update an existing Persistable instance with information from an additional Storage instance.

Parameters
[in,out]persistablePointer to the Persistable instance.
[in]storageShared pointer to the additional Storage instance.
[in]additionalDataAdditional data used to find the proper instance within the Storage.

Implements lsst::daf::persistence::Formatter.

Definition at line 130 of file TanWcsFormatter.cc.

133  {
134  throw LSST_EXCEPT(pexExcept::RuntimeError, "Unexpected call to update for TanWcs");
135 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void lsst::afw::formatters::TanWcsFormatter::write ( lsst::daf::base::Persistable const *  persistable,
lsst::daf::persistence::Storage::Ptr  storage,
lsst::daf::base::PropertySet::Ptr  additionalData 
)
virtual

Write a Persistable instance to a Storage instance.

Parameters
[in]persistablePointer to the Persistable instance.
[in]storageShared pointer to the Storage instance.
[in]additionalDataAdditional data used to find the proper place to put the instance into the Storage.

Implements lsst::daf::persistence::Formatter.

Definition at line 86 of file TanWcsFormatter.cc.

89  {
90  execTrace("TamWcsFormatter write start");
91  afwImg::TanWcs const* ip = dynamic_cast<afwImg::TanWcs const*>(persistable);
92  if (ip == 0) {
93  throw LSST_EXCEPT(pexExcept::RuntimeError, "Persisting non-TanWcs");
94  }
95  if (typeid(*storage) == typeid(dafPersist::BoostStorage)) {
96  execTrace("TanWcsFormatter write BoostStorage");
97  dafPersist::BoostStorage* boost = dynamic_cast<dafPersist::BoostStorage*>(storage.get());
98  boost->getOArchive() & *ip;
99  execTrace("TanWcsFormatter write end");
100  return;
101  }
102  throw LSST_EXCEPT(pexExcept::RuntimeError, "Unrecognized Storage for TanWcs");
103 }
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
virtual boost::archive::text_oarchive & getOArchive(void)
Class for boost::serialization storage.
Definition: BoostStorage.h:58

Member Data Documentation

dafPersist::FormatterRegistration lsst::afw::formatters::TanWcsFormatter::registration
staticprivate

Definition at line 93 of file TanWcsFormatter.h.


The documentation for this class was generated from the following files: