SourceXtractorPlusPlus 0.18
SourceXtractor++, the next generation SExtractor
FitsImageSource.h
Go to the documentation of this file.
1
17/*
18 * FitsImageSource.h
19 *
20 * Created on: Feb 21, 2018
21 * Author: mschefer
22 */
23
24#ifndef _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_
25#define _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_
26
27#include <memory>
28#include <vector>
29#include <map>
30
31#include <boost/lexical_cast.hpp>
32
37#include "SEUtils/VariantCast.h"
38
39
40namespace SourceXtractor {
41
44
45class FitsImageSource : public ImageSource, public std::enable_shared_from_this<ImageSource> {
46public:
47
48
57 explicit FitsImageSource(const std::string& filename, int hdu_number = 0,
60
61 FitsImageSource(const std::string& filename, int width, int height,
62 ImageTile::ImageType image_type,
63 const std::shared_ptr<CoordinateSystem> coord_system = nullptr,
64 bool append = false,
65 bool empty_primary = false,
67
68 virtual ~FitsImageSource() = default;
69
70 std::string getRepr() const override {
71 return m_filename;
72 }
73
75 int getWidth() const override {
76 return m_width;
77 }
78
80 int getHeight() const override {
81 return m_height;
82 }
83
84 std::shared_ptr<ImageTile> getImageTile(int x, int y, int width, int height) const override;
85
86 void saveTile(ImageTile& tile) override;
87
88 template<typename TT>
89 bool readFitsKeyword(const std::string& header_keyword, TT& out_value) const {
90 auto& headers = getMetadata();
91 auto i = headers.find(header_keyword);
92 if (i != headers.end()) {
93 out_value = VariantCast<TT>(i->second.m_value);
94 return true;
95 }
96 return false;
97 }
98
99 int getHDU() const {
100 return m_hdu_number;
101 }
102
103 ImageTile::ImageType getType() const override {
104 return m_image_type;
105 }
106
107 std::unique_ptr<std::vector<char>> getFitsHeaders(int& number_of_records) const;
108
110
111 void setMetadata(std::string key, MetadataEntry value) override;
112
113private:
114 void switchHdu(fitsfile *fptr, int hdu_number) const;
115
116 int getDataType() const;
117
118 int getImageType() const;
119
122
124
128};
129
130}
131
132
133#endif /* _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_ */
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
static std::shared_ptr< FileManager > getDefault()
const std::map< std::string, MetadataEntry > getMetadata() const override
ImageTile::ImageType getType() const override
std::string getRepr() const override
Human readable representation of this source.
int getWidth() const override
Returns the width of the image in pixels.
bool readFitsKeyword(const std::string &header_keyword, TT &out_value) const
std::shared_ptr< ImageTile > getImageTile(int x, int y, int width, int height) const override
ImageTile::ImageType m_image_type
virtual ~FitsImageSource()=default
void saveTile(ImageTile &tile) override
FitsImageSource(const std::string &filename, int hdu_number=0, ImageTile::ImageType image_type=ImageTile::AutoType, std::shared_ptr< FileManager > manager=FileManager::getDefault())
std::unique_ptr< std::vector< char > > getFitsHeaders(int &number_of_records) const
int getHeight() const override
Returns the height of the image in pixels.
void setMetadata(std::string key, MetadataEntry value) override
std::shared_ptr< FileHandler > m_handler
void switchHdu(fitsfile *fptr, int hdu_number) const
string filename
Definition: conf.py:65