26 void operator()(SchemaItem<T>
const& item)
const {
30 if (!item.field.getDoc().empty()) {
34 fits->writeColumnKey(
"TDOC", n, item.field.getDoc());
39 void operator()(SchemaItem<std::string>
const& item)
const {
42 if (!item.field.getDoc().empty()) {
43 fits->writeColumnKey(
"TDOC", n, item.field.getDoc());
48 void operator()(SchemaItem<Flag>
const& item)
const {
50 fits->writeColumnKey(
"TFLAG", nFlags,
name);
51 if (!item.field.getDoc().empty()) {
55 fits->writeColumnKey(
"TFDOC", nFlags, item.field.getDoc());
61 static void apply(Fits& fits, Schema
const&
schema) {
62 ProcessSchema f = {&fits, 0};
67 void specialize(SchemaItem<T>
const& item,
int n)
const {
68 if (!item.field.getUnits().empty()) fits->writeColumnKey(
"TUNIT", n, item.field.getUnits());
69 fits->writeColumnKey(
"TCCLS", n,
"Scalar",
"Field template used by lsst.afw.table");
72 void specialize(SchemaItem<lsst::geom::Angle>
const& item,
int n)
const {
75 fits->writeColumnKey(
"TUNIT", n,
"rad");
76 fits->writeColumnKey(
"TCCLS", n,
"Angle",
"Field template used by lsst.afw.table");
80 void specialize(SchemaItem<Array<T> >
const& item,
int n)
const {
81 if (!item.field.getUnits().empty()) fits->writeColumnKey(
"TUNIT", n, item.field.getUnits());
82 fits->writeColumnKey(
"TCCLS", n,
"Array",
"Field template used by lsst.afw.table");
85 void specialize(SchemaItem<std::string>
const& item,
std::size_t n)
const {
86 if (!item.field.getUnits().empty()) fits->writeColumnKey(
"TUNIT", n, item.field.getUnits());
87 fits->writeColumnKey(
"TCCLS", n,
"String",
"Field template used by lsst.afw.table");
94void writeAliasMap(Fits& fits, AliasMap
const& aliases) {
95 for (
auto const &aliase : aliases) {
96 fits.writeKey(
"ALIAS", aliase.first +
":" + aliase.second);
110 _fits->
writeKey(
"FLAGCOL", n + 1,
"Column number for the bitflags.");
117 metadata = std::make_shared<daf::base::PropertyList>();
122 metadata->remove(
"AFW_TABLE_VERSION");
137 template <
typename T>
143 template <
typename T>
145 if (item.key.isVariableLength()) {
146 ndarray::Array<T const, 1, 1> array =
record->
get(item.key);
191 _processor->apply(&record);
table::Key< std::string > name
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
void writeKey(std::string const &key, T const &value, std::string const &comment)
Add a FITS header key to the bottom of the header.
void createTable()
Create a new binary table extension.
void writeTableScalar(std::size_t row, int col, T value)
Write a scalar value to a binary table.
int addColumn(std::string const &ttype, int size, std::string const &comment)
Add a column to a table.
void writeTableArray(std::size_t row, int col, int nElements, T const *value)
Write an array value to a binary table.
void writeMetadata(daf::base::PropertySet const &metadata)
Read a FITS header into a PropertySet or PropertyList.
std::size_t addRows(std::size_t nRows)
Append rows to a table, and return the index of the first new row.
Tag types used to declare specialized field types.
Base class for all records.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Defines the fields and offsets for a table.
void forEach(F &func) const
Apply a functor to each SchemaItem in the Schema.
virtual void _writeRecord(BaseRecord const &source)
Write an individual record.
virtual void _writeTable(std::shared_ptr< BaseTable const > const &table, std::size_t nRows)
Write a table and its schema.
#define LSST_FITS_CHECK_STATUS(fitsObj,...)
Throw a FitsError exception if the status of the given Fits object is nonzero.
typename FieldBase< T >::Element Element
Type used to store field data in the table (a field may have multiple elements).
A simple pair-like struct for mapping a Field (name and description) with a Key (used for actual data...
void apply(BaseRecord const *r)
BaseRecord const * record
void operator()(SchemaItem< Flag > const &item) const
ProcessRecords(Fits *fits_, Schema const &schema_, int nFlags_, std::size_t const &row_)
void operator()(SchemaItem< std::string > const &item) const
void operator()(SchemaItem< T > const &item) const
void operator()(SchemaItem< Array< T > > const &item) const
std::unique_ptr< bool[]> flags