-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-11957: Cannot round-trip >7th degree Chebyshev photometry models #277
Changes from 2 commits
8de7d66
c20f022
abc3b23
3d2d45a
43af436
adf97df
6ecb45e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,11 +103,13 @@ PyBaseRecord declareBaseRecord(py::module &mod) { | |
declareBaseRecordOverloads<double>(cls, "D"); | ||
declareBaseRecordOverloads<float>(cls, "F"); | ||
declareBaseRecordOverloads<lsst::afw::table::Flag>(cls, "Flag"); | ||
declareBaseRecordOverloads<std::uint8_t>(cls, "B"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really think we should add some kind of type trait at some point to standardize the suffixes. Such that we can say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree this code would benefit from a cleanup pass. But I'm not comfortable enough with type traits to have an opinion on this exact issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is another issue that is worth doing as a separate ticket. |
||
declareBaseRecordOverloads<std::uint16_t>(cls, "U"); | ||
declareBaseRecordOverloads<std::int32_t>(cls, "I"); | ||
declareBaseRecordOverloads<std::int64_t>(cls, "L"); | ||
declareBaseRecordOverloads<std::string>(cls, "String"); | ||
declareBaseRecordOverloads<lsst::afw::geom::Angle>(cls, "Angle"); | ||
declareBaseRecordArrayOverloads<std::uint8_t>(cls, "ArrayB"); | ||
declareBaseRecordArrayOverloads<std::uint16_t>(cls, "ArrayU"); | ||
declareBaseRecordArrayOverloads<int>(cls, "ArrayI"); | ||
declareBaseRecordArrayOverloads<float>(cls, "ArrayF"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,10 @@ struct FitsType<char> { | |
static int const CONSTANT = TSTRING; | ||
}; | ||
template <> | ||
struct FitsType<signed char> { | ||
static int const CONSTANT = TSBYTE; | ||
}; | ||
template <> | ||
struct FitsType<unsigned char> { | ||
static int const CONSTANT = TBYTE; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason we don't specifically also specialize for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure. I am copying existing code which may be based on this entry in the CFITSIO documentation: https://heasarc.gsfc.nasa.gov/docs/software/fitsio/quick/node9.html. It is true that the entry refers to images (it was the only description of 'TSBYTE' I found). (begin quote) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, as @r-owen said, this is limited by what cfitsio supports. |
||
|
@@ -690,6 +694,15 @@ void writeKeyFromProperty(Fits &fits, daf::base::PropertySet const &metadata, st | |
} else { | ||
writeKeyImpl(fits, key.c_str(), metadata.get<bool>(key), comment); | ||
} | ||
} else if (valueType == typeid(std::uint8_t)) { | ||
if (metadata.isArray(key)) { | ||
std::vector<std::uint8_t> tmp = metadata.getArray<std::uint8_t>(key); | ||
for (std::size_t i = 0; i != tmp.size(); ++i) { | ||
writeKeyImpl(fits, key.c_str(), tmp[i], comment); | ||
} | ||
} else { | ||
writeKeyImpl(fits, key.c_str(), metadata.get<std::uint8_t>(key), comment); | ||
} | ||
} else if (valueType == typeid(int)) { | ||
if (metadata.isArray(key)) { | ||
std::vector<int> tmp = metadata.getArray<int>(key); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ namespace { | |
template <typename T> | ||
struct TypeTraits; | ||
|
||
template <> | ||
struct TypeTraits<std::uint8_t> { | ||
static char const *getName() { return "B"; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so we have one. Then why don't we use it everywhere? Preferably pulling it up to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These characters are FITS table characters. I'm not sure I'd want to use it anywhere else. I don't understand your suggested modification but respectfully suggest that any significant refactoring should go into a new ticket. |
||
}; | ||
template <> | ||
struct TypeTraits<std::uint16_t> { | ||
static char const *getName() { return "U"; } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, but is there any reason why we use
Array<int>
while the scalar is specifically qualified asstd::int32_t
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea. @TallJimbo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::int32_t
would be better, but changing it would require concerted changes across a lot of the codebase. Should probably be spun off into another ticket.