SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
SEFramework
FITS
FitsWriter.h
Go to the documentation of this file.
1
17
/*
18
* FitsWriter.h
19
*
20
* Created on: May 23, 2017
21
* Author: mschefer
22
*/
23
24
#ifndef _SEFRAMEWORK_IMAGE_FITSWRITER_H_
25
#define _SEFRAMEWORK_IMAGE_FITSWRITER_H_
26
27
#include "ElementsKernel/Logging.h"
28
#include "
SEFramework/CoordinateSystem/CoordinateSystem.h
"
29
#include "
SEFramework/Image/Image.h
"
30
#include "
SEFramework/Image/ImageAccessor.h
"
31
#include "
SEFramework/Image/WriteableBufferedImage.h
"
32
#include "
SEFramework/FITS/FitsImageSource.h
"
33
#include "
SEFramework/FITS/TemporaryFitsImageSource.h
"
34
35
namespace
SourceXtractor
{
36
37
static
Elements::Logging
fitsWriterLogger
=
Elements::Logging::getLogger
(
"FitsWriter"
);
38
44
class
FitsWriter
{
45
46
public
:
47
51
virtual
~FitsWriter
() =
default
;
52
53
template
<
typename
T>
54
static
void
writeFile
(
const
Image<T>
&
image
,
const
std::string
&filename,
55
const
std::shared_ptr<CoordinateSystem>
coord_system
=
nullptr
,
bool
append
=
false
) {
56
auto
target_image
=
newImage<T>
(filename,
image
.getWidth(),
image
.getHeight(),
coord_system
,
append
);
57
58
// FIXME optimize the copy by using tile boundaries, image chunks, etc
59
ImageAccessor<T>
accessor
(
image
);
60
for
(
int
y
= 0;
y
<
image
.getHeight();
y
++) {
61
for
(
int
x
= 0;
x
<
image
.getWidth();
x
++) {
62
target_image
->setValue(
x
,
y
,
accessor
.getValue(
x
,
y
));
63
}
64
}
65
}
66
67
template
<
typename
T>
68
static
std::shared_ptr<WriteableImage<T>
>
newImage
(
const
std::string
&filename,
int
width,
int
height,
69
const
std::shared_ptr<CoordinateSystem>
coord_system
=
nullptr
,
bool
append
=
false
) {
70
fitsWriterLogger
.debug() <<
"Creating file "
<< filename;
71
72
auto
image_source
=
std::make_shared<FitsImageSource>
(filename, width, height, ImageTile::getTypeValue(T()),
coord_system
,
append
);
73
return
WriteableBufferedImage<T>::create
(
image_source
);
74
}
75
76
template
<
typename
T>
77
static
std::shared_ptr<WriteableImage<T>
>
newTemporaryImage
(
const
std::string
&pattern,
int
width,
int
height) {
78
fitsWriterLogger
.debug() <<
"Creating temporary fits file"
;
79
80
auto
image_source
=
std::make_shared<TemporaryFitsImageSource>
(pattern, width, height, ImageTile::getTypeValue(T()));
81
return
WriteableBufferedImage<T>::create
(
image_source
);
82
}
83
84
85
};
/* End of FitsReader class */
86
87
}
/* namespace SourceXtractor */
88
89
90
91
92
93
#endif
/* _SEFRAMEWORK_IMAGE_FITSWRITER_H_ */
CoordinateSystem.h
FitsImageSource.h
ImageAccessor.h
Image.h
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition
MoffatModelFittingTask.cpp:94
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition
MoffatModelFittingTask.cpp:94
TemporaryFitsImageSource.h
WriteableBufferedImage.h
std::string
Elements::Logging
Elements::Logging::getLogger
static Logging getLogger(const std::string &name="")
Euclid::Table::FitsWriter
Euclid::Table::FitsWriter::append
void append(const Table &table) override
SourceXtractor::FitsWriter::~FitsWriter
virtual ~FitsWriter()=default
Destructor.
SourceXtractor::FitsWriter::newTemporaryImage
static std::shared_ptr< WriteableImage< T > > newTemporaryImage(const std::string &pattern, int width, int height)
Definition
FitsWriter.h:77
SourceXtractor::FitsWriter::writeFile
static void writeFile(const Image< T > &image, const std::string &filename, const std::shared_ptr< CoordinateSystem > coord_system=nullptr, bool append=false)
Definition
FitsWriter.h:54
SourceXtractor::FitsWriter::newImage
static std::shared_ptr< WriteableImage< T > > newImage(const std::string &filename, int width, int height, const std::shared_ptr< CoordinateSystem > coord_system=nullptr, bool append=false)
Definition
FitsWriter.h:68
SourceXtractor::WriteableBufferedImage
Definition
WriteableBufferedImage.h:33
std::function
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::fitsWriterLogger
static Elements::Logging fitsWriterLogger
Definition
FitsWriter.h:37
Generated by
1.10.0