SourceXtractorPlusPlus
0.12
Please provide a description of the project.
SEFramework
SEFramework
FITS
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
33
#include "
SEFramework/CoordinateSystem/CoordinateSystem.h
"
34
#include "
SEFramework/Image/ImageSourceWithMetadata.h
"
35
#include "
SEFramework/FITS/FitsFileManager.h
"
36
#include "
SEFramework/FITS/FitsFile.h
"
37
#include "
SEUtils/VariantCast.h
"
38
39
40
namespace
SourceXtractor
{
41
42
template
<
typename
T>
43
class
FitsImageSource
:
public
ImageSourceWithMetadata
<T>,
public
std::enable_shared_from_this
<ImageSource<T>> {
44
public
:
45
54
FitsImageSource
(
const
std::string
&
filename
,
int
hdu_number = 0,
55
std::shared_ptr<FitsFileManager>
manager =
FitsFileManager::getInstance
());
56
57
FitsImageSource
(
const
std::string
&
filename
,
int
width,
int
height,
58
const
std::shared_ptr<CoordinateSystem>
coord_system =
nullptr
,
59
std::shared_ptr<FitsFileManager>
manager =
FitsFileManager::getInstance
());
60
61
virtual
~FitsImageSource
() =
default
;
62
63
std::string
getRepr
()
const override
{
64
return
m_filename
;
65
}
66
67
std::shared_ptr<ImageTile<T>
>
getImageTile
(
int
x
,
int
y
,
int
width,
int
height)
const override
;
68
70
int
getWidth
()
const override
{
71
return
m_width
;
72
}
73
75
int
getHeight
()
const override
{
76
return
m_height
;
77
}
78
79
void
saveTile
(
ImageTile<T>
& tile)
override
;
80
81
template
<
typename
TT>
82
bool
readFitsKeyword
(
const
std::string
& header_keyword, TT& out_value)
const
{
83
auto
& headers =
getMetadata
();
84
auto
i = headers.find(header_keyword);
85
if
(i != headers.end()) {
86
out_value = VariantCast<TT>(i->second.m_value);
87
return
true
;
88
}
89
return
false
;
90
}
91
92
int
getHDU
()
const
{
93
return
m_hdu_number
;
94
}
95
96
std::unique_ptr<std::vector<char>
>
getFitsHeaders
(
int
& number_of_records)
const
;
97
98
const
std::map<std::string, MetadataEntry>
&
getMetadata
()
const override
{
99
return
m_fits_file
->getHDUHeaders(
m_hdu_number
);
100
}
101
102
private
:
103
104
105
void
switchHdu
(fitsfile* fptr,
int
hdu_number)
const
;
106
107
int
getDataType
()
const
;
108
int
getImageType
()
const
;
109
110
std::string
m_filename
;
111
std::shared_ptr<FitsFile>
m_fits_file
;
112
std::shared_ptr<FitsFileManager>
m_manager
;
113
114
int
m_width
;
115
int
m_height
;
116
117
int
m_hdu_number
;
118
};
119
120
}
121
122
123
124
125
#endif
/* _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_ */
std::shared_ptr
SourceXtractor::FitsImageSource::m_height
int m_height
Definition:
FitsImageSource.h:115
SourceXtractor::FitsImageSource::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition:
FitsImageSource.h:75
SourceXtractor::FitsImageSource::~FitsImageSource
virtual ~FitsImageSource()=default
FitsFileManager.h
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition:
MoffatModelFittingTask.cpp:94
SourceXtractor::FitsImageSource::getDataType
int getDataType() const
SourceXtractor::FitsFileManager::getInstance
static std::shared_ptr< FitsFileManager > getInstance()
Definition:
FitsFileManager.h:47
SourceXtractor::FitsImageSource::getFitsHeaders
std::unique_ptr< std::vector< char > > getFitsHeaders(int &number_of_records) const
Definition:
FitsImageSource.cpp:197
SourceXtractor::FitsImageSource::m_fits_file
std::shared_ptr< FitsFile > m_fits_file
Definition:
FitsImageSource.h:111
SourceXtractor::FitsImageSource::getRepr
std::string getRepr() const override
Human readable representation of this source.
Definition:
FitsImageSource.h:63
SourceXtractor::FitsImageSource::readFitsKeyword
bool readFitsKeyword(const std::string &header_keyword, TT &out_value) const
Definition:
FitsImageSource.h:82
std::map
STL class.
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition:
MoffatModelFittingTask.cpp:94
SourceXtractor::FitsImageSource::getImageType
int getImageType() const
SourceXtractor::FitsImageSource::m_filename
std::string m_filename
Definition:
FitsImageSource.h:110
std::string
STL class.
ImageSourceWithMetadata.h
SourceXtractor::FitsImageSource::m_hdu_number
int m_hdu_number
Definition:
FitsImageSource.h:117
SourceXtractor
Definition:
Aperture.h:30
SourceXtractor::ImageTile
Definition:
ImageTile.h:57
SourceXtractor::FitsImageSource::switchHdu
void switchHdu(fitsfile *fptr, int hdu_number) const
Definition:
FitsImageSource.cpp:180
SourceXtractor::FitsImageSource::m_manager
std::shared_ptr< FitsFileManager > m_manager
Definition:
FitsImageSource.h:112
FitsFile.h
conf.filename
string filename
Definition:
conf.py:63
SourceXtractor::FitsImageSource::getImageTile
std::shared_ptr< ImageTile< T > > getImageTile(int x, int y, int width, int height) const override
Definition:
FitsImageSource.cpp:133
SourceXtractor::FitsImageSource::getMetadata
const std::map< std::string, MetadataEntry > & getMetadata() const override
Definition:
FitsImageSource.h:98
std::enable_shared_from_this
SourceXtractor::FitsImageSource::getHDU
int getHDU() const
Definition:
FitsImageSource.h:92
CoordinateSystem.h
std::unique_ptr
STL class.
VariantCast.h
SourceXtractor::FitsImageSource::saveTile
void saveTile(ImageTile< T > &tile) override
Definition:
FitsImageSource.cpp:157
SourceXtractor::ImageSourceWithMetadata
Definition:
ImageSourceWithMetadata.h:40
SourceXtractor::FitsImageSource::m_width
int m_width
Definition:
FitsImageSource.h:114
SourceXtractor::FitsImageSource
Definition:
FitsImageSource.h:43
SourceXtractor::FitsImageSource::FitsImageSource
FitsImageSource(const std::string &filename, int hdu_number=0, std::shared_ptr< FitsFileManager > manager=FitsFileManager::getInstance())
Definition:
FitsImageSource.cpp:45
SourceXtractor::FitsImageSource::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition:
FitsImageSource.h:70
Generated by
1.8.14