lsst.afw
20.0.0-4-gde602ef96+5
|
Go to the documentation of this file.
32 #include "boost/format.hpp"
33 #include "boost/algorithm/string/trim.hpp"
50 FilterProperty::PropertyMap* FilterProperty::_propertyMap = NULL;
53 : _name(
name), _lambdaEff(NAN), _lambdaMin(NAN), _lambdaMax(NAN) {
54 if (prop.
exists(
"lambdaEff")) {
57 if (prop.
exists(
"lambdaMin")) {
60 if (prop.
exists(
"lambdaMax")) {
66 void FilterProperty::_insert(
bool force) {
71 PropertyMap::iterator keyVal = _propertyMap->
find(
getName());
73 if (keyVal != _propertyMap->
end()) {
74 if (keyVal->second == *
this) {
81 _propertyMap->
erase(keyVal);
88 return (_lambdaEff == rhs._lambdaEff);
93 void FilterProperty::_initRegistry() {
98 _propertyMap =
new PropertyMap;
106 PropertyMap::iterator keyVal = _propertyMap->
find(
name);
108 if (keyVal == _propertyMap->
end()) {
112 return keyVal->second;
126 _id = _lookup(filterName, force);
150 for (AliasMap::iterator ptr = _aliasMap->
begin(),
end = _aliasMap->
end(); ptr !=
end; ++ptr) {
151 if (ptr->second == canonicalName) {
166 for (NameMap::const_iterator ptr = _nameMap->
begin(),
end = _nameMap->
end(); ptr !=
end; ++ptr) {
167 if (ptr->first != unknownFilter) {
177 return std::make_unique<Filter>(*
this);
181 return singleClassEquals(*
this,
other);
186 struct PersistenceHelper {
190 static PersistenceHelper
const& get() {
191 static PersistenceHelper
const instance;
196 PersistenceHelper() :
schema(),
name(
schema.addField<
std::string>(
"name",
"name of the filter")) {}
199 class FilterFactory :
public table::io::PersistableFactory {
202 CatalogVector
const& catalogs)
const override {
203 PersistenceHelper
const&
keys = PersistenceHelper::get();
206 return std::make_shared<Filter>(catalogs.front().begin()->get(
keys.name),
true);
212 std::string _getPersistenceName() {
return "Filter"; }
214 FilterFactory registration(_getPersistenceName());
225 PersistenceHelper
const&
keys = PersistenceHelper::get();
236 void Filter::_initRegistry() {
242 _aliasMap =
new AliasMap;
243 _nameMap =
new NameMap;
252 Filter::AliasMap* Filter::_aliasMap = NULL;
253 Filter::NameMap* Filter::_nameMap = NULL;
254 Filter::IdMap* Filter::_idMap = NULL;
262 NameMap::iterator keyVal = _nameMap->
find(
name);
264 if (keyVal != _nameMap->
end()) {
265 int oid = keyVal->second;
267 if (
id == oid ||
id ==
AUTO) {
274 _nameMap->
erase(keyVal);
295 NameMap::iterator keyVal = _nameMap->
find(oldName);
296 if (keyVal == _nameMap->
end()) {
299 int const id = keyVal->second;
302 AliasMap::iterator aliasKeyVal = _aliasMap->
find(newName);
303 if (aliasKeyVal != _aliasMap->
end()) {
304 if (aliasKeyVal->second == oldName) {
311 _aliasMap->
erase(aliasKeyVal);
324 NameMap::iterator keyVal = _nameMap->
find(
name);
326 if (keyVal == _nameMap->
end()) {
327 AliasMap::iterator aliasKeyVal = _aliasMap->
find(
name);
328 if (aliasKeyVal != _aliasMap->
end()) {
329 return _lookup(aliasKeyVal->second);
339 return keyVal->second;
347 IdMap::iterator keyVal = _idMap->
find(
id);
349 if (keyVal == _idMap->
end()) {
353 return keyVal->second;
359 int const id = _lookup(_name,
true);
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Filter(std::string const &name, bool const force=false)
Creates a Filter with the given name.
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
static int define(FilterProperty const &filterProperty, int id=AUTO, bool force=false)
Define a filter name to have the specified id.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
An object passed to Persistable::write to allow it to persist itself.
Holds an integer identifier for an LSST filter.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
Describe the properties of a Filter (e.g.
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
@ UNKNOWN
Rotation angle is unknown.
bool exists(std::string const &name) const
Interface supporting iteration over heterogenous containers.
FilterProperty(std::string const &name, double lambdaEff, double lambdaMin=NAN, double lambdaMax=NAN, bool force=false)
static int defineAlias(std::string const &oldName, std::string const &newName, bool force=false)
Define an alias for a filter.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
std::size_t hash_value() const noexcept
Return a hash of this object.
bool operator==(Filter const &rhs) const noexcept
Are two filters identical?
std::string getAsString(std::string const &name) const
ItemVariant const * other
static std::vector< std::string > getNames()
Return a list of known filters.
FilterProperty const & getFilterProperty() const
Return a Filter's FilterProperty.
std::size_t hash_value() const noexcept override
Return a hash of this object.
std::string const & getName() const noexcept
Return a filter's name.
A base class for image defects.
virtual void remove(std::string const &name)
#define LSST_EXCEPT(type,...)
double getAsDouble(std::string const &name) const
bool equals(typehandling::Storable const &other) const noexcept override
Compare this object to another Storable.
table::Key< std::string > name
std::string const & getCanonicalName() const
Return a filter's canonical name.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
std::string const & getName() const noexcept
Return a Filter's name.
std::vector< std::string > getAliases() const
Return all aliases by which this filter is known.
static FilterProperty const & lookup(std::string const &name)
Lookup the properties of a filter "name".
std::shared_ptr< typehandling::Storable > cloneStorable() const override
Create a new Filter that is a copy of this one.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
bool operator==(FilterProperty const &rhs) const noexcept
Return true iff two FilterProperties are identical.