Skip to content

Commit

Permalink
Merge pull request #628 from lsst/tickets/DM-33470
Browse files Browse the repository at this point in the history
DM-33470: Remove unused daf_persistence dependency
  • Loading branch information
timj committed Feb 1, 2022
2 parents 596bf19 + ba43998 commit 4f4f280
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 158 deletions.
37 changes: 0 additions & 37 deletions include/lsst/afw/formatters/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,10 @@

#include "ndarray.h"

#include "lsst/base.h"
#include "lsst/daf/base.h"

namespace lsst {
namespace daf {
namespace base {
class PropertySet;
}
namespace persistence {
class LogicalLocation;
}
} // namespace daf
namespace afw {
namespace formatters {

/**
* 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`.
*/
bool extractOptionalFlag(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties,
std::string const& name);

/**
* Extracts and returns the string-valued `"itemName"` property from the given data property object.
*
* @throws lsst::pex::exceptions::InvalidParameterError
* If the given pointer is null, or the `PropertySet` pointed
* to does not contain a unique property named `"itemName"`.
*/
std::string const getItemName(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties);

int extractSliceId(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties);
int64_t extractFpaExposureId(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties);
int64_t extractCcdExposureId(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties);
int64_t extractAmpExposureId(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties);
int extractVisitId(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties);
int extractCcdId(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties);
int extractAmpId(std::shared_ptr<lsst::daf::base::PropertySet const> const& properties);

int countFitsHeaderCards(lsst::daf::base::PropertySet const& prop);

/**
* Encode a std::string as a vector of uint8
*/
Expand Down
118 changes: 0 additions & 118 deletions src/formatters/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,132 +32,14 @@
#include <cstdint>
#include <iostream>

#include "boost/format.hpp"
#include "lsst/pex/exceptions.h"
#include "lsst/daf/base/PropertySet.h"
#include "lsst/daf/persistence/LogicalLocation.h"
#include "lsst/afw/formatters/Utils.h"

using std::int64_t;
namespace ex = lsst::pex::exceptions;
using lsst::daf::base::PropertySet;
using lsst::daf::persistence::LogicalLocation;

namespace lsst {
namespace afw {
namespace formatters {

int extractSliceId(std::shared_ptr<PropertySet const> const& properties) {
if (properties->isArray("sliceId")) {
throw LSST_EXCEPT(ex::RuntimeError, "\"sliceId\" property has multiple values");
}
int sliceId = properties->getAsInt("sliceId");
if (sliceId < 0) {
throw LSST_EXCEPT(ex::RangeError, "negative \"sliceId\"");
}
if (properties->exists("universeSize") && !properties->isArray("universeSize")) {
int universeSize = properties->getAsInt("universeSize");
if (sliceId >= universeSize) {
throw LSST_EXCEPT(ex::RangeError, "\"sliceId\" must be less than \"universeSize \"");
}
}
return sliceId;
}

int extractVisitId(std::shared_ptr<PropertySet const> const& properties) {
if (properties->isArray("visitId")) {
throw LSST_EXCEPT(ex::RuntimeError, "\"visitId\" property has multiple values");
}
int visitId = properties->getAsInt("visitId");
if (visitId < 0) {
throw LSST_EXCEPT(ex::RangeError, "negative \"visitId\"");
}
return visitId;
}

int64_t extractFpaExposureId(std::shared_ptr<PropertySet const> const& properties) {
if (properties->isArray("fpaExposureId")) {
throw LSST_EXCEPT(ex::RuntimeError, "\"fpaExposureId\" property has multiple values");
}
int64_t fpaExposureId = properties->getAsInt64("fpaExposureId");
if (fpaExposureId < 0) {
throw LSST_EXCEPT(ex::RangeError, "negative \"fpaExposureId\"");
}
if ((fpaExposureId & 0xfffffffe00000000LL) != 0LL) {
throw LSST_EXCEPT(ex::RangeError, "\"fpaExposureId\" is too large");
}
return fpaExposureId;
}

int extractCcdId(std::shared_ptr<PropertySet const> const& properties) {
if (properties->isArray("ccdId")) {
throw LSST_EXCEPT(ex::RuntimeError, "\"ccdId\" property has multiple values");
}
int ccdId = properties->getAsInt("ccdId");
if (ccdId < 0) {
throw LSST_EXCEPT(ex::RangeError, "negative \"ccdId\"");
}
if (ccdId > 255) {
throw LSST_EXCEPT(ex::RangeError, "\"ccdId\" is too large");
}
return static_cast<int>(ccdId);
}

int extractAmpId(std::shared_ptr<PropertySet const> const& properties) {
if (properties->isArray("ampId")) {
throw LSST_EXCEPT(ex::RuntimeError, "\"ampId\" property has multiple values");
}
int ampId = properties->getAsInt("ampId");
if (ampId < 0) {
throw LSST_EXCEPT(ex::RangeError, "negative \"ampId\"");
}
if (ampId > 63) {
throw LSST_EXCEPT(ex::RangeError, "\"ampId\" is too large");
}
return (extractCcdId(properties) << 6) + ampId;
}

int64_t extractCcdExposureId(std::shared_ptr<PropertySet const> const& properties) {
if (properties->isArray("ccdExposureId")) {
throw LSST_EXCEPT(ex::RuntimeError, "\"ccdExposureId\" property has multiple values");
}
int64_t ccdExposureId = properties->getAsInt64("ccdExposureId");
if (ccdExposureId < 0) {
throw LSST_EXCEPT(ex::RangeError, "negative \"ccdExposureId\"");
}
return ccdExposureId;
}

int64_t extractAmpExposureId(std::shared_ptr<PropertySet const> const& properties) {
if (properties->isArray("ampExposureId")) {
throw LSST_EXCEPT(ex::RuntimeError, "\"ampExposureId\" property has multiple values");
}
int64_t ampExposureId = properties->getAsInt64("ampExposureId");
if (ampExposureId < 0) {
throw LSST_EXCEPT(ex::RangeError, "negative \"ampExposureId\"");
}
return ampExposureId;
}

std::string const getItemName(std::shared_ptr<PropertySet const> const& properties) {
if (!properties) {
throw LSST_EXCEPT(ex::InvalidParameterError, "Null std::shared_ptr<PropertySet>");
}
if (properties->isArray("itemName")) {
throw LSST_EXCEPT(ex::InvalidParameterError, "\"itemName\" property has multiple values");
}
return properties->getAsString("itemName");
}

bool extractOptionalFlag(std::shared_ptr<PropertySet const> const& properties, std::string const& name) {
if (properties && properties->exists(name)) {
return properties->getAsBool(name);
}
return false;
}

int countFitsHeaderCards(lsst::daf::base::PropertySet const& prop) { return prop.paramNames(false).size(); }

ndarray::Array<std::uint8_t, 1, 1> stringToBytes(std::string const& str) {
auto nbytes = str.size() * sizeof(char) / sizeof(std::uint8_t);
std::uint8_t const* byteCArr = reinterpret_cast<std::uint8_t const*>(str.data());
Expand Down
1 change: 0 additions & 1 deletion tests/test_fitsCompression.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import lsst.utils
import lsst.daf.base
import lsst.daf.persistence
import lsst.geom
import lsst.afw.geom
import lsst.afw.image
Expand Down
2 changes: 1 addition & 1 deletion ups/afw.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lsst.sconsUtils

dependencies = {
"required": ["cpputils", "daf_persistence", "daf_base", "pex_exceptions", "geom", "log", "pex_config",
"required": ["cpputils", "daf_base", "pex_exceptions", "geom", "log", "pex_config",
"eigen", "fftw", "ndarray", "numpy", "minuit2", "gsl", "cfitsio",
"astshim", "sphgeom"],
"buildRequired": ["boost_test", "boost_timer", "pybind11"],
Expand Down
1 change: 0 additions & 1 deletion ups/afw.table
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
setupRequired(daf_base)
setupRequired(daf_persistence)
setupRequired(pex_config)
setupRequired(geom)
setupRequired(log)
Expand Down

0 comments on commit 4f4f280

Please sign in to comment.