Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-10257: Fix compiler warnings in afw #250

Merged
merged 8 commits into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/wcsTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ int main(int argc, char **argv) {
}
std::cout << "Opening exposure " << inImagePath << std::endl;

auto miMetadata(new PropertySet);
afwImage::Exposure<Pixel> exposure(inImagePath);
if (!exposure.hasWcs()) {
std::cerr << "Exposure does not have a WCS." << std::endl;
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/afw/display/scaling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ static void getSample(image::Image<T> const& image, std::size_t const nSamples,
for (int stride = initialStride; stride >= 1; --stride) {
vSample.clear();

for (std::size_t y = 0; y < height; y += stride) {
for (std::size_t x = 0; x < width; x += stride) {
for (int y = 0; y < height; y += stride) {
for (int x = 0; x < width; x += stride) {
T const elem = image(x, y);
if (std::isfinite(elem)) {
vSample.push_back(elem);
Expand Down Expand Up @@ -85,8 +85,8 @@ static std::pair<double, double> fitLine(
// Mask that is used in k-sigma clipping
std::vector<int> vBadPix(vSample.size(), 0);

std::size_t nGoodPix = vSample.size();
std::size_t nGoodPixOld = nGoodPix + 1;
int nGoodPix = vSample.size();
int nGoodPixOld = nGoodPix + 1;

// values to be obtained
double intercept = 0;
Expand Down
21 changes: 0 additions & 21 deletions src/coord/Coord.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,28 +188,7 @@ geom::Angle meanSiderealTimeGreenwich(double const jd ///< Julian Day
geom::degrees;
}

/*
* A pair of utility functions to go from cartesian to spherical
*/
double const atPoleEpsilon = 0.0; // std::numeric_limits<double>::epsilon();
geom::Angle pointToLongitude(geom::Point3D const &p3d, double const defaultLongitude = 0.0) {
geom::Angle lon;
if (fabs(p3d.getX()) <= atPoleEpsilon && fabs(p3d.getY()) <= atPoleEpsilon) {
lon = geom::Angle(0.0);
} else {
lon = (std::atan2(p3d.getY(), p3d.getX()) * geom::radians).wrap();
}
return lon;
}
geom::Angle pointToLatitude(geom::Point3D const &p3d) {
geom::Angle lat;
if (fabs(p3d.getX()) <= atPoleEpsilon && fabs(p3d.getY()) <= atPoleEpsilon) {
lat = (p3d.getZ() >= 0) ? geom::Angle(geom::HALFPI) : geom::Angle(-geom::HALFPI);
} else {
lat = std::asin(p3d.getZ()) * geom::radians;
}
return lat;
}
std::pair<geom::Angle, geom::Angle> pointToLonLat(geom::Point3D const &p3d,
double const defaultLongitude = 0.0,
bool normalize = true) {
Expand Down
21 changes: 13 additions & 8 deletions src/detection/PsfFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ void PsfFormatter::write(dafBase::Persistable const* persistable,
if (ps == 0) {
throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Persisting non-Psf");
}
if (typeid(*storage) == typeid(dafPersist::BoostStorage)) {
// TODO: Replace this with something better in DM-10776
auto boost = std::dynamic_pointer_cast<dafPersist::BoostStorage>(storage);
if (boost) {
LOGL_DEBUG(_log, "PsfFormatter write BoostStorage");
dafPersist::BoostStorage* boost = dynamic_cast<dafPersist::BoostStorage*>(storage.get());
boost->getOArchive() & ps;
LOGL_DEBUG(_log, "PsfFormatter write end");
return;
} else if (typeid(*storage) == typeid(dafPersist::XmlStorage)) {
}
auto xml = std::dynamic_pointer_cast<dafPersist::XmlStorage>(storage);
if (xml) {
LOGL_DEBUG(_log, "PsfFormatter write XmlStorage");
dafPersist::XmlStorage* xml = dynamic_cast<dafPersist::XmlStorage*>(storage.get());
xml->getOArchive() & make_nvp("psf", ps);
LOGL_DEBUG(_log, "PsfFormatter write end");
return;
Expand All @@ -69,15 +71,18 @@ dafBase::Persistable* PsfFormatter::read(std::shared_ptr<dafPersist::FormatterSt
std::shared_ptr<dafBase::PropertySet>) {
LOGL_DEBUG(_log, "PsfFormatter read start");
Psf* ps;
if (typeid(*storage) == typeid(dafPersist::BoostStorage)) {

// TODO: Replace this with something better in DM-10776
auto boost = std::dynamic_pointer_cast<dafPersist::BoostStorage>(storage);
if (boost) {
LOGL_DEBUG(_log, "PsfFormatter read BoostStorage");
dafPersist::BoostStorage* boost = dynamic_cast<dafPersist::BoostStorage*>(storage.get());
boost->getIArchive() & ps;
LOGL_DEBUG(_log, "PsfFormatter read end");
return ps;
} else if (typeid(*storage) == typeid(dafPersist::XmlStorage)) {
}
auto xml = std::dynamic_pointer_cast<dafPersist::XmlStorage>(storage);
if (xml) {
LOGL_DEBUG(_log, "PsfFormatter read XmlStorage");
dafPersist::XmlStorage* xml = dynamic_cast<dafPersist::XmlStorage*>(storage.get());
xml->getIArchive() & make_nvp("psf", ps);
LOGL_DEBUG(_log, "PsfFormatter read end");
return ps;
Expand Down
46 changes: 27 additions & 19 deletions src/formatters/DecoratedImageFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,25 @@ void DecoratedImageFormatter<ImagePixelT>::write(Persistable const* persistable,
if (ip == 0) {
throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Persisting non-DecoratedImage");
}
if (typeid(*storage) == typeid(BoostStorage)) {

// TODO: Replace this with something better in DM-10776
auto boost = std::dynamic_pointer_cast<BoostStorage>(storage);
if (boost) {
LOGL_DEBUG(_log, "DecoratedImageFormatter write BoostStorage");
BoostStorage* boost = dynamic_cast<BoostStorage*>(storage.get());
boost->getOArchive() & *ip;
LOGL_DEBUG(_log, "DecoratedImageFormatter write end");
return;
} else if (typeid(*storage) == typeid(XmlStorage)) {
}
auto xml = std::dynamic_pointer_cast<XmlStorage>(storage);
if (xml) {
LOGL_DEBUG(_log, "DecoratedImageFormatter write XmlStorage");
XmlStorage* boost = dynamic_cast<XmlStorage*>(storage.get());
boost->getOArchive() & make_nvp("img", *ip);
xml->getOArchive() & make_nvp("img", *ip);
LOGL_DEBUG(_log, "DecoratedImageFormatter write end");
return;
} else if (typeid(*storage) == typeid(FitsStorage)) {
}
auto fits = std::dynamic_pointer_cast<FitsStorage>(storage);
if (fits) {
LOGL_DEBUG(_log, "DecoratedImageFormatter write FitsStorage");
FitsStorage* fits = dynamic_cast<FitsStorage*>(storage.get());
typedef DecoratedImage<ImagePixelT> DecoratedImage;

ip->writeFits(fits->getPath());
// @todo Do something with these fields?
Expand All @@ -139,30 +142,34 @@ void DecoratedImageFormatter<ImagePixelT>::write(Persistable const* persistable,
LOGL_DEBUG(_log, "DecoratedImageFormatter write end");
return;
}
throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Unrecognized FormatterStorage for DecoratedImage");
throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized FormatterStorage for DecoratedImage");
}

template <typename ImagePixelT>
Persistable* DecoratedImageFormatter<ImagePixelT>::read(std::shared_ptr<FormatterStorage> storage,
std::shared_ptr<lsst::daf::base::PropertySet>) {
LOGL_DEBUG(_log, "DecoratedImageFormatter read start");
if (typeid(*storage) == typeid(BoostStorage)) {
// TODO: Replace this with something better in DM-10776
auto boost = std::dynamic_pointer_cast<BoostStorage>(storage);
if (boost) {
LOGL_DEBUG(_log, "DecoratedImageFormatter read BoostStorage");
BoostStorage* boost = dynamic_cast<BoostStorage*>(storage.get());
DecoratedImage<ImagePixelT>* ip = new DecoratedImage<ImagePixelT>;
boost->getIArchive() & *ip;
LOGL_DEBUG(_log, "DecoratedImageFormatter read end");
return ip;
} else if (typeid(*storage) == typeid(XmlStorage)) {
}
auto xml = std::dynamic_pointer_cast<XmlStorage>(storage);
if (xml) {
LOGL_DEBUG(_log, "DecoratedImageFormatter read XmlStorage");
XmlStorage* boost = dynamic_cast<XmlStorage*>(storage.get());
DecoratedImage<ImagePixelT>* ip = new DecoratedImage<ImagePixelT>;
boost->getIArchive() & make_nvp("img", *ip);
LOGL_DEBUG(_log, "DecoratedImageFormatter read end");
return ip;
} else if (typeid(*storage) == typeid(FitsStorage)) {
}
auto fits = std::dynamic_pointer_cast<FitsStorage>(storage);
if (fits) {
LOGL_DEBUG(_log, "DecoratedImageFormatter read FitsStorage");
FitsStorage* fits = dynamic_cast<FitsStorage*>(storage.get());

DecoratedImage<ImagePixelT>* ip = new DecoratedImage<ImagePixelT>(fits->getPath(), fits->getHdu());
// @todo Do something with these fields?
Expand All @@ -171,7 +178,8 @@ Persistable* DecoratedImageFormatter<ImagePixelT>::read(std::shared_ptr<Formatte
LOGL_DEBUG(_log, "DecoratedImageFormatter read end");
return ip;
}
throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Unrecognized FormatterStorage for DecoratedImage");
throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized FormatterStorage for DecoratedImage");
}

template <typename ImagePixelT>
Expand Down Expand Up @@ -218,6 +226,6 @@ InstantiateFormatter(double);
InstantiateFormatter(std::uint64_t);

#undef InstantiateFormatter
}
}
} // namespace lsst::afw::formatters
} // namespace formatters
} // namespace afw
} // namespace lsst
30 changes: 18 additions & 12 deletions src/formatters/ExposureFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,25 @@ void ExposureFormatter<ImagePixelT, MaskPixelT, VariancePixelT>::write(
if (ip == 0) {
throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Persisting non-Exposure");
}
if (typeid(*storage) == typeid(dafPersist::BoostStorage)) {
// TODO: Replace this with something better in DM-10776
auto boost = std::dynamic_pointer_cast<dafPersist::BoostStorage>(storage);
if (boost) {
LOGL_DEBUG(_log, "ExposureFormatter write BoostStorage");
dafPersist::BoostStorage* boost = dynamic_cast<dafPersist::BoostStorage*>(storage.get());
boost->getOArchive() & *ip;
LOGL_DEBUG(_log, "ExposureFormatter write end");
return;
} else if (typeid(*storage) == typeid(dafPersist::FitsStorage)) {
}
auto fits = std::dynamic_pointer_cast<dafPersist::FitsStorage>(storage);
if (fits) {
LOGL_DEBUG(_log, "ExposureFormatter write FitsStorage");
dafPersist::FitsStorage* fits = dynamic_cast<dafPersist::FitsStorage*>(storage.get());

ip->writeFits(fits->getPath());
LOGL_DEBUG(_log, "ExposureFormatter write end");
return;
} else if (typeid(*storage) == typeid(dafPersist::DbStorage)) {
}
auto db = dynamic_cast<dafPersist::DbStorage*>(storage.get());
if (db) {
LOGL_DEBUG(_log, "ExposureFormatter write DbStorage");
dafPersist::DbStorage* db = dynamic_cast<dafPersist::DbStorage*>(storage.get());

// Get the Wcs headers.
std::shared_ptr<daf::base::PropertySet> wcsProps = ip->getWcs()->getFitsMetadata();
Expand Down Expand Up @@ -291,17 +294,19 @@ dafBase::Persistable* ExposureFormatter<ImagePixelT, MaskPixelT, VariancePixelT>
std::shared_ptr<dafPersist::FormatterStorage> storage,
std::shared_ptr<daf::base::PropertySet> additionalData) {
LOGL_DEBUG(_log, "ExposureFormatter read start");
if (typeid(*storage) == typeid(dafPersist::BoostStorage)) {
// TODO: Replace this with something better in DM-10776
auto boost = std::dynamic_pointer_cast<dafPersist::BoostStorage>(storage);
if (boost) {
LOGL_DEBUG(_log, "ExposureFormatter read BoostStorage");
dafPersist::BoostStorage* boost = dynamic_cast<dafPersist::BoostStorage*>(storage.get());
image::Exposure<ImagePixelT, MaskPixelT, VariancePixelT>* ip =
new image::Exposure<ImagePixelT, MaskPixelT, VariancePixelT>;
boost->getIArchive() & *ip;
LOGL_DEBUG(_log, "ExposureFormatter read end");
return ip;
} else if (typeid(*storage) == typeid(dafPersist::FitsStorage)) {
}
auto fits = std::dynamic_pointer_cast<dafPersist::FitsStorage>(storage);
if (fits) {
LOGL_DEBUG(_log, "ExposureFormatter read FitsStorage");
dafPersist::FitsStorage* fits = dynamic_cast<dafPersist::FitsStorage*>(storage.get());
geom::Box2I box;
if (additionalData->exists("llcX")) {
int llcX = additionalData->get<int>("llcX");
Expand Down Expand Up @@ -330,9 +335,10 @@ dafBase::Persistable* ExposureFormatter<ImagePixelT, MaskPixelT, VariancePixelT>
new image::Exposure<ImagePixelT, MaskPixelT, VariancePixelT>(fits->getPath(), box, origin);
LOGL_DEBUG(_log, "ExposureFormatter read end");
return ip;
} else if (typeid(*storage) == typeid(dafPersist::DbStorage)) {
}
auto db = dynamic_cast<dafPersist::DbStorage*>(storage.get());
if (db) {
LOGL_DEBUG(_log, "ExposureFormatter read DbStorage");
dafPersist::DbStorage* db = dynamic_cast<dafPersist::DbStorage*>(storage.get());

// Select a table to retrieve from based on the itemName.
std::string itemName = additionalData->get<std::string>("itemName");
Expand Down
51 changes: 28 additions & 23 deletions src/formatters/ImageFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,35 @@ ImageFormatter<ImagePixelT>::~ImageFormatter(void) {}
namespace {
namespace dafBase = lsst::daf::base;
namespace afwImage = lsst::afw::image;
}
} // namespace

template <typename ImagePixelT>
void ImageFormatter<ImagePixelT>::write(Persistable const* persistable, std::shared_ptr<FormatterStorage> storage,
void ImageFormatter<ImagePixelT>::write(Persistable const* persistable,
std::shared_ptr<FormatterStorage> storage,
std::shared_ptr<lsst::daf::base::PropertySet>) {
LOGL_DEBUG(_log, "ImageFormatter write start");
Image<ImagePixelT> const* ip = dynamic_cast<Image<ImagePixelT> const*>(persistable);
if (ip == 0) {
throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Persisting non-Image");
}
if (typeid(*storage) == typeid(BoostStorage)) {
// TODO: Replace this with something better in DM-10776
auto boost = std::dynamic_pointer_cast<BoostStorage>(storage);
if (boost) {
LOGL_DEBUG(_log, "ImageFormatter write BoostStorage");
BoostStorage* boost = dynamic_cast<BoostStorage*>(storage.get());
boost->getOArchive() & *ip;
LOGL_DEBUG(_log, "ImageFormatter write end");
return;
} else if (typeid(*storage) == typeid(XmlStorage)) {
}
auto xml = std::dynamic_pointer_cast<XmlStorage>(storage);
if (xml) {
LOGL_DEBUG(_log, "ImageFormatter write XmlStorage");
XmlStorage* boost = dynamic_cast<XmlStorage*>(storage.get());
boost->getOArchive() & make_nvp("img", *ip);
xml->getOArchive() & make_nvp("img", *ip);
LOGL_DEBUG(_log, "ImageFormatter write end");
return;
} else if (typeid(*storage) == typeid(FitsStorage)) {
}
auto fits = std::dynamic_pointer_cast<FitsStorage>(storage);
if (fits) {
LOGL_DEBUG(_log, "ImageFormatter write FitsStorage");
FitsStorage* fits = dynamic_cast<FitsStorage*>(storage.get());
typedef Image<ImagePixelT> Image;

ip->writeFits(fits->getPath());
// @todo Do something with these fields?
Expand All @@ -155,23 +158,26 @@ template <typename ImagePixelT>
Persistable* ImageFormatter<ImagePixelT>::read(std::shared_ptr<FormatterStorage> storage,
std::shared_ptr<lsst::daf::base::PropertySet> additionalData) {
LOGL_DEBUG(_log, "ImageFormatter read start");
if (typeid(*storage) == typeid(BoostStorage)) {
// TODO: Replace this with something better in DM-10776
auto boost = std::dynamic_pointer_cast<BoostStorage>(storage);
if (boost) {
LOGL_DEBUG(_log, "ImageFormatter read BoostStorage");
BoostStorage* boost = dynamic_cast<BoostStorage*>(storage.get());
Image<ImagePixelT>* ip = new Image<ImagePixelT>;
boost->getIArchive() & *ip;
LOGL_DEBUG(_log, "ImageFormatter read end");
return ip;
} else if (typeid(*storage) == typeid(XmlStorage)) {
}
auto xml = std::dynamic_pointer_cast<XmlStorage>(storage);
if (xml) {
LOGL_DEBUG(_log, "ImageFormatter read XmlStorage");
XmlStorage* boost = dynamic_cast<XmlStorage*>(storage.get());
Image<ImagePixelT>* ip = new Image<ImagePixelT>;
boost->getIArchive() & make_nvp("img", *ip);
xml->getIArchive() & make_nvp("img", *ip);
LOGL_DEBUG(_log, "ImageFormatter read end");
return ip;
} else if (typeid(*storage) == typeid(FitsStorage)) {
}
auto fits = std::dynamic_pointer_cast<FitsStorage>(storage);
if (fits) {
LOGL_DEBUG(_log, "ImageFormatter read FitsStorage");
FitsStorage* fits = dynamic_cast<FitsStorage*>(storage.get());
geom::Box2I box;
if (additionalData->exists("llcX")) {
int llcX = additionalData->get<int>("llcX");
Expand All @@ -191,9 +197,8 @@ Persistable* ImageFormatter<ImagePixelT>::read(std::shared_ptr<FormatterStorage>
throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
(boost::format("Unknown ImageOrigin type %s specified in additional"
"data for retrieving Image from fits") %
originStr

).str());
originStr)
.str());
}
}
std::shared_ptr<lsst::daf::base::PropertySet> metadata;
Expand Down Expand Up @@ -271,6 +276,6 @@ InstantiateFormatter(double);
InstantiateFormatter(std::uint64_t);

#undef InstantiateSerializer
}
}
} // namespace lsst::afw::formatters
} // namespace formatters
} // namespace afw
} // namespace lsst