LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
lsst::afw::table::Schema Class Referencefinal

Defines the fields and offsets for a table. More...

#include <Schema.h>

Public Types

enum  ComparisonFlags {
  EQUAL_KEYS = 0x01 , EQUAL_NAMES = 0x02 , EQUAL_DOCS = 0x04 , EQUAL_UNITS = 0x08 ,
  EQUAL_FIELDS = 0x0F , EQUAL_ALIASES = 0x10 , IDENTICAL = 0x1F
}
 Bit flags used when comparing schemas. More...
 

Public Member Functions

std::string join (std::string const &a, std::string const &b) const
 Join strings using the field delimiter appropriate for this Schema. More...
 
std::string join (std::string const &a, std::string const &b, std::string const &c) const
 
std::string join (std::string const &a, std::string const &b, std::string const &c, std::string const &d) const
 
template<typename T >
SchemaItem< T > find (std::string const &name) const
 Find a SchemaItem in the Schema by name. More...
 
template<typename T >
SchemaItem< T > find (Key< T > const &key) const
 Find a SchemaItem in the Schema by key. More...
 
template<typename F >
void findAndApply (std::string const &name, F &&func) const
 Find a SchemaItem by name and run a functor on it. More...
 
SubSchema operator[] (std::string const &name) const
 Look up a (possibly incomplete) name in the Schema. More...
 
std::set< std::stringgetNames (bool topOnly=false) const
 Return a set of field names in the schema. More...
 
std::size_t getRecordSize () const
 Return the raw size of a record in bytes. More...
 
std::size_t getFieldCount () const
 The total number of fields. More...
 
std::size_t getFlagFieldCount () const
 The number of Flag fields. More...
 
std::size_t getNonFlagFieldCount () const
 The number of non-Flag fields. More...
 
template<typename T >
Key< T > addField (Field< T > const &field, bool doReplace=false)
 Add a new field to the Schema, and return the associated Key. More...
 
template<typename T >
Key< T > addField (std::string const &name, std::string const &doc, std::string const &units="", FieldBase< T > const &base=FieldBase< T >(), bool doReplace=false)
 Add a new field to the Schema, and return the associated Key. More...
 
template<typename T >
Key< T > addField (std::string const &name, std::string const &doc, FieldBase< T > const &base, bool doReplace=false)
 Add a new field to the Schema, and return the associated Key. More...
 
template<typename T >
void replaceField (Key< T > const &key, Field< T > const &field)
 Replace the Field (name/description) for an existing Key. More...
 
template<typename F >
void forEach (F &func) const
 Apply a functor to each SchemaItem in the Schema. More...
 
template<typename F >
void forEach (F const &func) const
 
bool operator== (Schema const &other) const
 Equality comparison. More...
 
bool operator!= (Schema const &other) const
 
std::size_t hash_value () const noexcept
 Return a hash of this object. More...
 
int compare (Schema const &other, int flags=EQUAL_KEYS) const
 Do a detailed equality comparison of two schemas. More...
 
int contains (Schema const &other, int flags=EQUAL_KEYS) const
 Test whether the given schema is a subset of this. More...
 
template<typename T >
int contains (SchemaItem< T > const &item, int flags=EQUAL_KEYS) const
 Return true if the given item is in this schema. More...
 
std::shared_ptr< AliasMapgetAliasMap () const
 Return the map of aliases. More...
 
void setAliasMap (std::shared_ptr< AliasMap > aliases)
 Set the alias map. More...
 
void disconnectAliases ()
 Sever the connection between this schema and any others with which it shares aliases. More...
 
 Schema ()
 Construct an empty Schema. More...
 
 Schema (Schema const &other)
 Copy constructor. More...
 
 Schema (Schema &&other)
 
Schemaoperator= (Schema const &other)
 
Schemaoperator= (Schema &&other)
 
 ~Schema ()
 

Static Public Member Functions

static Schema readFits (std::string const &filename, int hdu=fits::DEFAULT_HDU)
 Construct from reading a FITS file. More...
 
static Schema readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 
static Schema readFits (fits::Fits &fitsfile)
 
static Schema fromFitsMetadata (daf::base::PropertyList &header, bool stripMetadata=true)
 Construct from reading a FITS header. More...
 

Static Public Attributes

static int const VERSION = detail::SchemaImpl::VERSION
 

Friends

class detail::Access
 
class SubSchema
 
std::ostreamoperator<< (std::ostream &os, Schema const &schema)
 Stringification. More...
 

Detailed Description

Defines the fields and offsets for a table.

Schema behaves like a container of SchemaItem objects, mapping a descriptive Field object with the Key object used to access record and ColumnView values. A Schema is the most important ingredient in creating a table.

Because offsets for fields are assigned when the field is added to the Schema, Schemas do not support removing fields, though they do allow renaming.

Field names in Schemas are expected to be underscore-separated names (e.g. 'a_b_c', but see Field Names for the full conventions, including when to use underscores vs. CamelCase). The SubSchema class and Schema::operator[] provide a heirarchical interface to these names, but are implemented entirely as string splitting/joining operations that ultimately forward to member functions that operate on the fully-qualified field name, so there is no requirement that names be separated by underscores, and no performance advantage to using a SubSchema.

A SchemaMapper object can be used to define a relationship between two Schemas to be used when copying values from one table to another or loading/saving selected fields to disk.

Schema uses copy-on-write, and hence should always be held by value rather than smart pointer. When creating a Python interface, functions that return Schema by const reference should be converted to return by value (returnCopy) to ensure proper memory management and encapsulation.

Definition at line 51 of file Schema.h.

Member Enumeration Documentation

◆ ComparisonFlags

Bit flags used when comparing schemas.

All quantities are compared in insertion order, so if two schemas have the same fields added in opposite order, they will not be considered equal.

Enumerator
EQUAL_KEYS 

Keys have the same types offsets, and sizes.

EQUAL_NAMES 

Fields have the same names (ordered).

EQUAL_DOCS 

Fields have the same documentation (ordered).

EQUAL_UNITS 

Fields have the same units (ordered).

EQUAL_FIELDS 

Fields are identical (but aliases may not be).

EQUAL_ALIASES 

Schemas have identical AliasMaps.

IDENTICAL 

Everything is the same.

Definition at line 65 of file Schema.h.

65  {
66  EQUAL_KEYS = 0x01,
67  EQUAL_NAMES = 0x02,
68  EQUAL_DOCS = 0x04,
69  EQUAL_UNITS = 0x08,
70  EQUAL_FIELDS = 0x0F,
71  EQUAL_ALIASES = 0x10,
72  IDENTICAL = 0x1F
73  };
@ EQUAL_DOCS
Fields have the same documentation (ordered).
Definition: Schema.h:68
@ IDENTICAL
Everything is the same.
Definition: Schema.h:72
@ EQUAL_NAMES
Fields have the same names (ordered).
Definition: Schema.h:67
@ EQUAL_UNITS
Fields have the same units (ordered).
Definition: Schema.h:69
@ EQUAL_KEYS
Keys have the same types offsets, and sizes.
Definition: Schema.h:66
@ EQUAL_FIELDS
Fields are identical (but aliases may not be).
Definition: Schema.h:70
@ EQUAL_ALIASES
Schemas have identical AliasMaps.
Definition: Schema.h:71

Constructor & Destructor Documentation

◆ Schema() [1/3]

lsst::afw::table::Schema::Schema ( )

Construct an empty Schema.

Definition at line 420 of file Schema.cc.

420 : _impl(std::make_shared<Impl>()), _aliases(std::make_shared<AliasMap>()) {}

◆ Schema() [2/3]

lsst::afw::table::Schema::Schema ( Schema const &  other)
default

Copy constructor.

◆ Schema() [3/3]

lsst::afw::table::Schema::Schema ( Schema &&  other)

Definition at line 424 of file Schema.cc.

424 : Schema(other) {}
Schema()
Construct an empty Schema.
Definition: Schema.cc:420

◆ ~Schema()

lsst::afw::table::Schema::~Schema ( )
default

Member Function Documentation

◆ addField() [1/3]

template<typename T >
Key< T > lsst::afw::table::Schema::addField ( Field< T > const &  field,
bool  doReplace = false 
)

Add a new field to the Schema, and return the associated Key.

The offsets of fields are determined by the order they are added, but may be not contiguous (the Schema may add padding to align fields, and how much padding is considered an implementation detail).

If doReplace is true and the field exists, it will be replaced instead of throwing an exception.

Definition at line 479 of file Schema.cc.

479  {
480  _edit();
481  return _impl->addField(field, doReplace);
482 }
table::Key< int > field
Definition: ApCorrMap.cc:77
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a field to the schema (used to implement Schema::addField).
Definition: Schema.cc:314

◆ addField() [2/3]

template<typename T >
Key<T> lsst::afw::table::Schema::addField ( std::string const &  name,
std::string const &  doc,
FieldBase< T > const &  base,
bool  doReplace = false 
)
inline

Add a new field to the Schema, and return the associated Key.

This is simply a convenience wrapper, equivalent to:

addField(Field<T>(name, doc, base), doReplace)

Definition at line 194 of file Schema.h.

195  {
196  return addField(Field<T>(name, doc, base), doReplace);
197  }
table::Key< std::string > name
Definition: Amplifier.cc:116
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
Definition: Schema.cc:479

◆ addField() [3/3]

template<typename T >
Key<T> lsst::afw::table::Schema::addField ( std::string const &  name,
std::string const &  doc,
std::string const &  units = "",
FieldBase< T > const &  base = FieldBase<T>(),
bool  doReplace = false 
)
inline

Add a new field to the Schema, and return the associated Key.

This is simply a convenience wrapper, equivalent to:

addField(Field<T>(name, doc, units, base), doReplace)

Definition at line 181 of file Schema.h.

182  {
183  return addField(Field<T>(name, doc, units, base), doReplace);
184  }

◆ compare()

int lsst::afw::table::Schema::compare ( Schema const &  other,
int  flags = EQUAL_KEYS 
) const

Do a detailed equality comparison of two schemas.

See ComparisonFlags for a description of the possible return values

Parameters
[in]otherThe other schema to compare to.
[in]flagsWhich types of comparisions to perform. Flag bits not present here will never be returned.

Definition at line 509 of file Schema.cc.

509  {
510  int result = contains(other, flags);
511  if (_impl->getItems().size() != other._impl->getItems().size()) {
512  result &= ~EQUAL_FIELDS;
513  }
514  if (getAliasMap()->size() != other.getAliasMap()->size()) {
515  result &= ~EQUAL_ALIASES;
516  }
517  return result;
518 }
py::object result
Definition: _schema.cc:429
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
Definition: Schema.cc:490
std::shared_ptr< AliasMap > getAliasMap() const
Return the map of aliases.
Definition: Schema.h:279
ItemContainer const & getItems() const
Return the vector of SchemaItem variants.
Definition: SchemaImpl.h:133
T size(T... args)

◆ contains() [1/2]

int lsst::afw::table::Schema::contains ( Schema const &  other,
int  flags = EQUAL_KEYS 
) const

Test whether the given schema is a subset of this.

This function behaves very similarly to compare(), but ignores fields that are present in this but absent in other.

Definition at line 490 of file Schema.cc.

490  {
491  if (_impl == other._impl) return flags;
492  if (_impl->getItems().size() < other._impl->getItems().size()) return 0;
493  int result = flags;
494  if (result & EQUAL_FIELDS) {
495  for (Impl::ItemContainer::const_iterator i1 = _impl->getItems().begin(),
496  i2 = other._impl->getItems().begin();
497  i2 != other._impl->getItems().end(); ++i1, ++i2) {
498  if ((result & EQUAL_KEYS) && !ItemFunctors::compareKeys(*i1, *i2)) result &= ~EQUAL_KEYS;
499  if ((result & EQUAL_NAMES) && !ItemFunctors::compareNames(*i1, *i2)) result &= ~EQUAL_NAMES;
500  if ((result & EQUAL_DOCS) && !ItemFunctors::compareDocs(*i1, *i2)) result &= ~EQUAL_DOCS;
501  if ((result & EQUAL_UNITS) && !ItemFunctors::compareUnits(*i1, *i2)) result &= ~EQUAL_UNITS;
502  if (!result) break;
503  }
504  }
505  if ((result & EQUAL_ALIASES) && !getAliasMap()->contains(*other.getAliasMap())) result &= ~EQUAL_ALIASES;
506  return result;
507 }
T begin(T... args)

◆ contains() [2/2]

template<typename T >
int lsst::afw::table::Schema::contains ( SchemaItem< T > const &  item,
int  flags = EQUAL_KEYS 
) const

Return true if the given item is in this schema.

The flags must include the EQUAL_KEYS bit, and if the item cannot be found by key no bits will be set on return.

Definition at line 529 of file Schema.cc.

529  {
530  return _impl->contains(item, flags);
531 }
int contains(SchemaItem< T > const &item, int flags) const
Definition: Schema.cc:225

◆ disconnectAliases()

void lsst::afw::table::Schema::disconnectAliases ( )

Sever the connection between this schema and any others with which it shares aliases.

Definition at line 540 of file Schema.cc.

540 { _aliases = std::make_shared<AliasMap>(*_aliases); }

◆ find() [1/2]

template<typename T >
SchemaItem< T > lsst::afw::table::Schema::find ( Key< T > const &  key) const

Find a SchemaItem in the Schema by key.

Keys corresponding to named subfields are accepted, and will return a SchemaItem whose field is copied from the parent field with only the name changed. Keys corresponding to unnamed subfields (such as array elements) are not accepted.

Definition at line 474 of file Schema.cc.

474  {
475  return _impl->find(key);
476 }
SchemaItem< T > find(std::string const &name) const
Find an item by name (used to implement Schema::find).
Definition: Schema.cc:92

◆ find() [2/2]

template<typename T >
SchemaItem< T > lsst::afw::table::Schema::find ( std::string const &  name) const

Find a SchemaItem in the Schema by name.

Names corresponding to named subfields are accepted, and will return a SchemaItem whose field is copied from the parent field with only the name changed.

Definition at line 467 of file Schema.cc.

467  {
468  std::string tmp(name);
469  _aliases->_apply(tmp);
470  return _impl->find<T>(tmp);
471 }

◆ findAndApply()

template<typename F >
void lsst::afw::table::Schema::findAndApply ( std::string const &  name,
F &&  func 
) const
inline

Find a SchemaItem by name and run a functor on it.

Names corresponding to named subfields are not accepted. The given functor must have an overloaded function call operator that accepts any SchemaItem type (the same as a functor provided to forEach).

Definition at line 117 of file Schema.h.

117  {
118  _impl->findAndApply(_aliases->apply(name), std::forward<F>(func));
119  }
decltype(auto) findAndApply(std::string const &name, F &&func) const
Find an item by name and run the given functor on it.
Definition: SchemaImpl.h:90

◆ forEach() [1/2]

template<typename F >
void lsst::afw::table::Schema::forEach ( F &  func) const
inline

Apply a functor to each SchemaItem in the Schema.

The functor must have a templated or sufficiently overloaded operator() that supports SchemaItems of all supported field types - even those that are not present in this particular Schema.

Fields will be processed in the order they were added to the schema.

Definition at line 214 of file Schema.h.

214  {
215  for (auto const & item : _impl->getItems()) {
216  std::visit(func, item);
217  }
218  }

◆ forEach() [2/2]

template<typename F >
void lsst::afw::table::Schema::forEach ( F const &  func) const
inline

Definition at line 220 of file Schema.h.

220  {
221  for (auto const & item : _impl->getItems()) {
222  std::visit(func, item);
223  }
224  }

◆ fromFitsMetadata()

Schema lsst::afw::table::Schema::fromFitsMetadata ( daf::base::PropertyList header,
bool  stripMetadata = true 
)
static

Construct from reading a FITS header.

If 'stripMetadata', then the header will be modified, removing the relevant keywords.

Definition at line 448 of file Schema.cc.

448  {
449  return io::FitsSchemaInputMapper(header, stripMetadata).finalize();
450 }

◆ getAliasMap()

std::shared_ptr<AliasMap> lsst::afw::table::Schema::getAliasMap ( ) const
inline

Return the map of aliases.

Note that while this is a const method, it does allow the Schema's aliases to be edited - this allows the aliases to be modified even after a Table has been constructed from the Schema.

See AliasMap for more information on schema aliases.

Definition at line 279 of file Schema.h.

279 { return _aliases; }

◆ getFieldCount()

std::size_t lsst::afw::table::Schema::getFieldCount ( ) const
inline

The total number of fields.

Definition at line 152 of file Schema.h.

152 { return _impl->getFieldCount(); }
std::size_t getFieldCount() const
The total number of fields.
Definition: SchemaImpl.h:69

◆ getFlagFieldCount()

std::size_t lsst::afw::table::Schema::getFlagFieldCount ( ) const
inline

The number of Flag fields.

Definition at line 155 of file Schema.h.

155 { return _impl->getFlagFieldCount(); }
std::size_t getFlagFieldCount() const
The number of Flag fields.
Definition: SchemaImpl.h:72

◆ getNames()

std::set< std::string > lsst::afw::table::Schema::getNames ( bool  topOnly = false) const

Return a set of field names in the schema.

If topOnly==true, return a unique list of only the part of the names before the first underscore. For example, if the full list of field names is ['a_b_c', 'a_d', 'e_f'], topOnly==true will return ['a', 'e'].

Returns an instance of Python's builtin set in Python.

Aliases are not returned.

Definition at line 464 of file Schema.cc.

464 { return _impl->getNames(topOnly); }
std::set< std::string > getNames(bool topOnly) const
Return a set of field names (used to implement Schema::getNames).
Definition: Schema.cc:251

◆ getNonFlagFieldCount()

std::size_t lsst::afw::table::Schema::getNonFlagFieldCount ( ) const
inline

The number of non-Flag fields.

Definition at line 158 of file Schema.h.

158 { return _impl->getNonFlagFieldCount(); }
std::size_t getNonFlagFieldCount() const
The number of non-Flag fields.
Definition: SchemaImpl.h:75

◆ getRecordSize()

std::size_t lsst::afw::table::Schema::getRecordSize ( ) const
inline

Return the raw size of a record in bytes.

Definition at line 149 of file Schema.h.

149 { return _impl->getRecordSize(); }
std::size_t getRecordSize() const
The size of a record in bytes.
Definition: SchemaImpl.h:66

◆ hash_value()

std::size_t lsst::afw::table::Schema::hash_value ( ) const
noexcept

Return a hash of this object.

Definition at line 520 of file Schema.cc.

520  {
521  // Completely arbitrary seed
522  std::size_t result = 17;
523  auto hasher = [&result](auto const &item) { result = utils::hashCombine(result, item.key); };
524  forEach(hasher);
525  return result;
526 }
void forEach(F &func) const
Apply a functor to each SchemaItem in the Schema.
Definition: Schema.h:214
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35

◆ join() [1/3]

std::string lsst::afw::table::Schema::join ( std::string const &  a,
std::string const &  b 
) const

Join strings using the field delimiter appropriate for this Schema.

Definition at line 452 of file Schema.cc.

452  {
453  // delegate to utility funcs at top of this file
454  return afw::table::join(a, b, getDelimiter());
455 }
table::Key< int > b
table::Key< int > a

◆ join() [2/3]

std::string lsst::afw::table::Schema::join ( std::string const &  a,
std::string const &  b,
std::string const &  c 
) const
inline

Definition at line 78 of file Schema.h.

78  {
79  return join(join(a, b), c);
80  }
std::string join(std::string const &a, std::string const &b) const
Join strings using the field delimiter appropriate for this Schema.
Definition: Schema.cc:452

◆ join() [3/3]

std::string lsst::afw::table::Schema::join ( std::string const &  a,
std::string const &  b,
std::string const &  c,
std::string const &  d 
) const
inline

Definition at line 81 of file Schema.h.

82  {
83  return join(join(a, b), join(c, d));
84  }

◆ operator!=()

bool lsst::afw::table::Schema::operator!= ( Schema const &  other) const
inline

Definition at line 236 of file Schema.h.

236 { return !this->operator==(other); }
bool operator==(Schema const &other) const
Equality comparison.
Definition: Schema.h:235

◆ operator=() [1/2]

Schema & lsst::afw::table::Schema::operator= ( Schema &&  other)
default

◆ operator=() [2/2]

Schema & lsst::afw::table::Schema::operator= ( Schema const &  other)
default

◆ operator==()

bool lsst::afw::table::Schema::operator== ( Schema const &  other) const
inline

Equality comparison.

Schemas are considered equal according the standard equality operator if their sequence of keys are identical (same types with the same offsets); names and descriptions of fields are not considered. For a more precise comparison, use compare() or contains().

Definition at line 235 of file Schema.h.

235 { return compare(other, EQUAL_KEYS); }
int compare(Schema const &other, int flags=EQUAL_KEYS) const
Do a detailed equality comparison of two schemas.
Definition: Schema.cc:509

◆ operator[]()

SubSchema lsst::afw::table::Schema::operator[] ( std::string const &  name) const
inline

Look up a (possibly incomplete) name in the Schema.

See SubSchema for more information.

This member function should generally only be used on "finished" Schemas; modifying a Schema after a SubSchema to it has been constructed will not allow the proxy to track the additions, and will invoke the copy-on-write mechanism of the Schema itself.

Definition at line 464 of file Schema.h.

464  {
465  return SubSchema(_impl, _aliases, name);
466 }
friend class SubSchema
Definition: Schema.h:326

◆ readFits() [1/3]

Schema lsst::afw::table::Schema::readFits ( fits::Fits fitsfile)
static

Definition at line 442 of file Schema.cc.

442  {
443  daf::base::PropertyList header;
444  fitsfile.readMetadata(header, false);
445  return fromFitsMetadata(header);
446 }
static Schema fromFitsMetadata(daf::base::PropertyList &header, bool stripMetadata=true)
Construct from reading a FITS header.
Definition: Schema.cc:448

◆ readFits() [2/3]

Schema lsst::afw::table::Schema::readFits ( fits::MemFileManager manager,
int  hdu = fits::DEFAULT_HDU 
)
static

Definition at line 436 of file Schema.cc.

436  {
437  fits::Fits fp{manager, "r", fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK};
438  fp.setHdu(hdu);
439  return readFits(fp);
440 }
static Schema readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU)
Construct from reading a FITS file.
Definition: Schema.cc:430

◆ readFits() [3/3]

Schema lsst::afw::table::Schema::readFits ( std::string const &  filename,
int  hdu = fits::DEFAULT_HDU 
)
static

Construct from reading a FITS file.

Reads from the nominated 'hdu' (0=PHU which cannot be a catalog, afw::fits::DEFAULT_HDU is a special value meaning read from the first HDU with NAXIS != 0).

Definition at line 430 of file Schema.cc.

430  {
431  fits::Fits fp{filename, "r", fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK};
432  fp.setHdu(hdu);
433  return readFits(fp);
434 }

◆ replaceField()

template<typename T >
void lsst::afw::table::Schema::replaceField ( Key< T > const &  key,
Field< T > const &  field 
)

Replace the Field (name/description) for an existing Key.

Definition at line 485 of file Schema.cc.

485  {
486  _edit();
487  _impl->replaceField(key, field);
488 }
void replaceField(Key< T > const &key, Field< T > const &field)
Replace the Field in an existing SchemaItem without changing the Key.
Definition: Schema.cc:193

◆ setAliasMap()

void lsst::afw::table::Schema::setAliasMap ( std::shared_ptr< AliasMap aliases)

Set the alias map.

This resets the internal pointer to the alias map, disconnecting this schema from any others it shares aliases with.

Passing a null pointer is equivalent to passing an empty map.

Definition at line 533 of file Schema.cc.

533  {
534  if (!aliases) {
535  aliases = std::make_shared<AliasMap>();
536  }
537  _aliases = aliases;
538 }

Friends And Related Function Documentation

◆ detail::Access

friend class detail::Access
friend

Definition at line 325 of file Schema.h.

◆ operator<<

std::ostream& operator<< ( std::ostream os,
Schema const &  schema 
)
friend

Stringification.

Definition at line 562 of file Schema.cc.

562  {
563  os << "Schema(\n";
564  schema.forEach(Stream(&os));
565  for (auto const &iter : *schema.getAliasMap()) {
566  os << " '" << iter.first << "'->'" << iter.second << "'\n";
567  }
568  return os << ")\n";
569 }
std::ostream * os
Definition: Schema.cc:557
table::Schema schema
Definition: python.h:134

◆ SubSchema

friend class SubSchema
friend

Definition at line 326 of file Schema.h.

Member Data Documentation

◆ VERSION

int const lsst::afw::table::Schema::VERSION = detail::SchemaImpl::VERSION
static

Definition at line 57 of file Schema.h.


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