30 #define __attribute__(x) 38 #include "boost/serialization/shared_ptr.hpp" 39 #include <boost/archive/binary_iarchive.hpp> 40 #include <boost/archive/binary_oarchive.hpp> 41 #include <boost/archive/text_iarchive.hpp> 42 #include <boost/archive/text_oarchive.hpp> 56 LOG_LOGGER _log =
LOG_GET(
"afw.ExposureFormatter");
61 namespace formatters {
66 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
98 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
104 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
109 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
126 (boost::format(
"Unable to get name for filter id: %d") % filterId).str());
131 (boost::format(
"Multiple names for filter id: %d") % filterId).str());
146 template <
typename T>
149 if (!source->exists(propName)) {
160 template <
typename T1,
typename T2>
166 if (!source->exists(propName)) {
169 db->
setColumn<T1>(colName,
static_cast<T1
>(source->
get<T2>(propName)));
173 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
177 LOGL_DEBUG(_log,
"ExposureFormatter write start");
186 LOGL_DEBUG(_log,
"ExposureFormatter write BoostStorage");
187 boost->getOArchive() & *ip;
188 LOGL_DEBUG(_log,
"ExposureFormatter write end");
193 LOGL_DEBUG(_log,
"ExposureFormatter write FitsStorage");
196 if (additionalData) {
202 LOGLS_WARN(_log,
"Unable to construct Exposure write options (" << exc.
what() <<
203 "); writing with default options");
207 ip->
writeFits(fits->getPath(), imageOptions, maskOptions, varianceOptions);
208 LOGL_DEBUG(_log,
"ExposureFormatter write end");
213 LOGL_DEBUG(_log,
"ExposureFormatter write DbStorage");
222 "Unable to retrieve metadata from MaskedImage's Image");
228 if (_policy->exists(itemName)) {
230 if (itemPolicy->exists(
"TableName")) {
231 tableName = itemPolicy->getString(
"TableName");
234 if (tableName !=
"Raw_Amp_Exposure" && tableName !=
"Science_Amp_Exposure") {
236 "Unknown table name for persisting Exposure to DbStorage: " + tableName +
237 "for item " + itemName);
249 if (tableName ==
"Raw_Amp_Exposure") {
250 db->
setColumn<
long long>(
"rawAmpExposureId", ampExposureId);
251 db->
setColumn<
long long>(
"rawCCDExposureId", ccdExposureId);
252 db->
setColumn<
long long>(
"rawFPAExposureId", fpaExposureId);
254 db->
setColumn<
long long>(
"scienceAmpExposureId", ampExposureId);
255 db->
setColumn<
long long>(
"scienceCCDExposureId", ccdExposureId);
256 db->
setColumn<
long long>(
"scienceFPAExposureId", fpaExposureId);
257 db->
setColumn<
long long>(
"rawAmpExposureId", ampExposureId);
265 setColumn<std::string>(db,
"url", additionalData,
"StorageLocation.FitsStorage");
268 setColumn<std::string>(db,
"ctype1", wcsProps,
"CTYPE1");
269 setColumn<std::string>(db,
"ctype2", wcsProps,
"CTYPE2");
270 setColumn<float, double>(db,
"crpix1", wcsProps,
"CRPIX1");
271 setColumn<float, double>(db,
"crpix2", wcsProps,
"CRPIX2");
272 setColumn<double>(db,
"crval1", wcsProps,
"CRVAL1");
273 setColumn<double>(db,
"crval2", wcsProps,
"CRVAL2");
274 if (tableName ==
"Raw_Amp_Exposure") {
275 setColumn<double>(db,
"cd11", wcsProps,
"CD1_1");
276 setColumn<double>(db,
"cd21", wcsProps,
"CD2_1");
277 setColumn<double>(db,
"cd12", wcsProps,
"CD1_2");
278 setColumn<double>(db,
"cd22", wcsProps,
"CD2_2");
280 setColumn<double>(db,
"cd1_1", wcsProps,
"CD1_1");
281 setColumn<double>(db,
"cd2_1", wcsProps,
"CD2_1");
282 setColumn<double>(db,
"cd1_2", wcsProps,
"CD1_2");
283 setColumn<double>(db,
"cd2_2", wcsProps,
"CD2_2");
286 if (tableName ==
"Science_Amp_Exposure") {
288 setColumn<float, double>(db,
"photoFlam", dp,
"PHOTFLAM");
289 setColumn<float, double>(db,
"photoZP", dp,
"PHOTZP");
295 LOGL_DEBUG(_log,
"ExposureFormatter write end");
301 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
305 LOGL_DEBUG(_log,
"ExposureFormatter read start");
309 LOGL_DEBUG(_log,
"ExposureFormatter read BoostStorage");
312 boost->getIArchive() & *ip;
313 LOGL_DEBUG(_log,
"ExposureFormatter read end");
318 LOGL_DEBUG(_log,
"ExposureFormatter read FitsStorage");
320 if (additionalData->exists(
"llcX")) {
321 int llcX = additionalData->
get<
int>(
"llcX");
322 int llcY = additionalData->
get<
int>(
"llcY");
323 int width = additionalData->
get<
int>(
"width");
324 int height = additionalData->
get<
int>(
"height");
328 if (additionalData->exists(
"imageOrigin")) {
330 if (originStr ==
"LOCAL") {
332 }
else if (originStr ==
"PARENT") {
336 (boost::format(
"Unknown ImageOrigin type %s specified in additional" 337 "data for retrieving Exposure from fits") %
345 LOGL_DEBUG(_log,
"ExposureFormatter read end");
350 LOGL_DEBUG(_log,
"ExposureFormatter read DbStorage");
355 if (_policy->exists(itemName)) {
357 if (itemPolicy->exists(
"TableName")) {
358 tableName = itemPolicy->getString(
"TableName");
361 if (tableName !=
"Raw_Amp_Exposure" && tableName !=
"Science_Amp_Exposure") {
363 "Unknown table name for retrieving Exposure from DbStorage: " + tableName +
364 " for item " + itemName);
369 db->
condParam<int64_t>(
"id", additionalData->getAsInt64(
"ampExposureId"));
370 if (tableName ==
"Raw_Amp_Exposure") {
378 if (tableName ==
"Science_Amp_Exposure") {
418 std::string filterName = lookupFilterName(db, filterId);
419 dp->set(
"FILTER", filterName);
427 LOGL_DEBUG(_log,
"ExposureFormatter read end");
433 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
442 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
443 template <
class Archive>
446 LOGL_DEBUG(_log,
"ExposureFormatter delegateSerialize start");
454 LOGL_DEBUG(_log,
"ExposureFormatter delegateSerialize end");
457 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
466 #define INSTANTIATE(I, M, V) \ 467 template class ExposureFormatter<I, M, V>; \ 468 template void ExposureFormatter<I, M, V>::delegateSerialize<boost::archive::text_oarchive>( \ 469 boost::archive::text_oarchive&, unsigned int const, dafBase::Persistable*); \ 470 template void ExposureFormatter<I, M, V>::delegateSerialize<boost::archive::text_iarchive>( \ 471 boost::archive::text_iarchive&, unsigned int const, dafBase::Persistable*); \ 472 template void ExposureFormatter<I, M, V>::delegateSerialize<boost::archive::binary_oarchive>( \ 473 boost::archive::binary_oarchive&, unsigned int const, dafBase::Persistable*); \ 474 template void ExposureFormatter<I, M, V>::delegateSerialize<boost::archive::binary_iarchive>( \ 475 boost::archive::binary_iarchive&, unsigned int const, dafBase::Persistable*); #define LOGLS_WARN(logger, message)
virtual void outColumn(std::string const &columnName, bool isExpr=false)
void setColumn(std::string const &columnName, T const &value)
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Options for writing an image to FITS.
virtual void setQueryWhere(std::string const &whereClause)
#define LOGL_DEBUG(logger, message...)
bool columnIsNull(int pos)
void condParam(std::string const ¶mName, T const &value)
An integer coordinate rectangle.
A base class for image defects.
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Return flexible metadata.
#define INSTANTIATE(FROMSYS, TOSYS)
T dynamic_pointer_cast(T... args)
virtual void setTableForQuery(std::string const &tableName, bool isExpr=false)
#define LSST_EXCEPT(type,...)
T const & getColumnByPos(int pos)
std::shared_ptr< geom::SkyWcs const > getWcs() const
virtual void finishQuery(void)
void writeFits(std::string const &fileName) const
Write an Exposure to a regular multi-extension FITS file.
virtual void setTableForInsert(std::string const &tableName)
float VariancePixel
default type for MaskedImage variance images
virtual void setColumnToNull(std::string const &columnName)