Skip to content

Commit

Permalink
Implement SourceTable version 3
Browse files Browse the repository at this point in the history
Increment schema version and add v1 and v2 compatibliity.

Add a v2 test .fits file, to test v2 compatibility, and use it in a test.
  • Loading branch information
parejkoj committed Sep 18, 2018
1 parent e0e7ddc commit 3b79e2f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/lsst/afw/table/detail/SchemaImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SchemaImpl : public daf::base::Citizen {
};

public:
static int const VERSION = 2;
static int const VERSION = 3;

/// An MPL sequence of all the allowed SchemaItem templates.
typedef boost::mpl::transform<FieldTypes, MakeItem>::type ItemTypes;
Expand Down
34 changes: 29 additions & 5 deletions src/table/io/FitsSchemaInputMapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,11 @@ Schema FitsSchemaInputMapper::finalize() {
// the same prefix, but AliasMap know hows to handle that no-op set.
aliases.set(prefix + "flags", prefix + "flag");
} else if (iter->ttype.find("flux") != std::string::npos) {
// Create aliases that resolve "(.*)_flux" to "$1"
// and "(.*)_fluxErr" to "$1_err" if $1 contains the string "flux".
// Create an alias that resolves "X_instFlux" to "X" or "X_instFluxErr" to "X_err".
if (endswith(iter->ttype, "_err")) {
aliases.set(replaceSuffix(iter->ttype, 4, "_fluxErr"), iter->ttype);
aliases.set(replaceSuffix(iter->ttype, 4, "_instFluxErr"), iter->ttype);
} else {
aliases.set(iter->ttype + "_flux", iter->ttype);
aliases.set(iter->ttype + "_instFlux", iter->ttype);
}
} else if (endswith(iter->ttype, "_err")) {
// Create aliases that resolve "(.*)_(.*)Err" and "(.*)_(.*)_(.*)_Cov" to
Expand Down Expand Up @@ -770,11 +769,36 @@ Schema FitsSchemaInputMapper::finalize() {
// that should have been named Sigma. So provide aliases xErr -> xSigma
AliasMap &aliases = *_impl->schema.getAliasMap();
for (auto iter = _impl->asList().begin(); iter != _impl->asList().end(); ++iter) {
if (endswith(iter->ttype, "Sigma")) {
if (iter->ttype.find("flux") != std::string::npos) {
// Create an alias that resolves "X_instFlux" to "X_flux" or "X_instFluxErr" to "X_fluxSigma".
if (endswith(iter->ttype, "fluxSigma")) {
// replace "fluxSigma"->"instFluxErr"
aliases.set(replaceSuffix(iter->ttype, 9, "instFluxErr"), iter->ttype);
} else {
// replace "flux"->"instFlux"
aliases.set(replaceSuffix(iter->ttype, 4, "instFlux"), iter->ttype);
}
} else if (endswith(iter->ttype, "Sigma")) {
aliases.set(replaceSuffix(iter->ttype, 5, "Err"), iter->ttype);
}
}
}
if (_impl->version == 2) {
// Version 2 tables used _flux when we should use _instFlux (see RFC-322).
AliasMap &aliases = *_impl->schema.getAliasMap();
for (auto iter = _impl->asList().begin(); iter != _impl->asList().end(); ++iter) {
if (iter->ttype.find("flux") != std::string::npos) {
// Create an alias that resolves "X_instFlux" to "X_flux" or "X_instFluxErr" to "X_fluxErr".
if (endswith(iter->ttype, "fluxErr")) {
// replace "fluxErr"->"instFluxErr"
aliases.set(replaceSuffix(iter->ttype, 9, "instFluxErr"), iter->ttype);
} else {
// replace "flux"->"instFlux"
aliases.set(replaceSuffix(iter->ttype, 4, "instFlux"), iter->ttype);
}
}
}
}
for (auto iter = _impl->asList().begin(); iter != _impl->asList().end(); ++iter) {
if (iter->bit < 0) { // not a Flag column
std::unique_ptr<FitsColumnReader> reader = makeColumnReader(_impl->schema, *iter);
Expand Down

0 comments on commit 3b79e2f

Please sign in to comment.