SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
FitsImageSource.h
Go to the documentation of this file.
1
18/*
19 * FitsImageSource.h
20 *
21 * Created on: Feb 21, 2018
22 * Author: mschefer
23 */
24
25#ifndef _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_
26#define _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_
27
28#include <memory>
29#include <vector>
30#include <map>
31
32#include <boost/lexical_cast.hpp>
33
34#include "FilePool/FileManager.h"
38#include "SEUtils/VariantCast.h"
39
40
41namespace SourceXtractor {
42
45
46class FitsImageSource : public ImageSource, public std::enable_shared_from_this<ImageSource> {
47public:
48
49
58 explicit FitsImageSource(const std::string& filename, int hdu_number = 0,
61
62 FitsImageSource(const std::string& filename, int width, int height,
65 bool append = false,
66 bool empty_primary = false,
68
69 virtual ~FitsImageSource() = default;
70
71 std::string getRepr() const override {
72 return m_filename;
73 }
74
76 int getWidth() const override {
77 return m_width;
78 }
79
81 int getHeight() const override {
82 return m_height;
83 }
84
86 int getDepth() const {
87 return m_depth;
88 }
89
90 void setLayer(int layer);
91
92 std::shared_ptr<ImageTile> getImageTile(int x, int y, int width, int height) const override;
93
94 void saveTile(ImageTile& tile) override;
95
96 template<typename TT>
98 auto& headers = getMetadata();
99 auto i = headers.find(header_keyword);
100 if (i != headers.end()) {
101 out_value = VariantCast<TT>(i->second.m_value);
102 return true;
103 }
104 return false;
105 }
106
107 int getHDU() const {
108 return m_hdu_number;
109 }
110
111 ImageTile::ImageType getType() const override {
112 return m_image_type;
113 }
114
116
118
119 void setMetadata(const std::string& key, const MetadataEntry& value) override;
120
121private:
122 void switchHdu(fitsfile *fptr, int hdu_number) const;
123
124 int getDataType() const;
125
126 int getImageType() const;
127
131
133
138
140};
141
142}
143
144
145#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()
std::shared_ptr< FileManager > m_file_manager
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.
const std::map< std::string, MetadataEntry > & getMetadata() const override
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
int getDepth() const
Returns the depth of the image in pixels.
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(const std::string &key, const MetadataEntry &value) override
std::shared_ptr< FileHandler > m_handler
void switchHdu(fitsfile *fptr, int hdu_number) const