117 if (
this != &cache) {
180 #if defined(G_DEBUG_VECTOR_CACHE)
181 std::cout <<
"GResponseVectorCache::set(";
182 std::cout << cache_id <<
"," << vector.
size() <<
"):";
186 double* values = NULL;
196 #if defined(G_DEBUG_VECTOR_CACHE)
198 std::cout <<
" entry found at index " << index;
200 std::cout <<
" Require " << entries <<
" elements.";
201 std::cout << std::endl;
204 std::cout <<
" no entry found.";
205 std::cout <<
" Require " << entries <<
" elements.";
206 std::cout << std::endl;
214 values =
new double[entries];
215 indices =
new int[entries];
229 values =
new double[entries];
230 indices =
new int[entries];
245 for (
int i = 0; i < vector.
size(); ++i) {
246 if (vector[i] != 0.0) {
247 *values++ = vector[i];
306 #if defined(G_DEBUG_VECTOR_CACHE)
307 std::cout <<
"GResponseVectorCache::contains(" << cache_id;
308 if (vector == NULL) {
309 std::cout <<
", NULL):";
312 std::cout <<
"," << vector->
size() <<
"):";
323 #if defined(G_DEBUG_VECTOR_CACHE)
325 std::cout <<
" entry found at index " << index;
327 std::cout << std::endl;
330 std::cout <<
" no entry found." << std::endl;
343 for (
int i = 0; i <
m_cache_entries[index]; ++i, ++values, ++indices) {
344 (*vector)[*indices] = *values;
371 GFits fits(filename);
374 for (
int i = 0; i < fits.
size(); ++i) {
409 const bool& clobber)
const
415 for (
int i = 0; i <
size(); ++i) {
421 if (extname.length() > 80) {
435 for (
int k = 0; k < entries; ++k, ++values, ++indices) {
436 col_values(k) = *values;
437 col_indices(k) = *indices;
443 table.
append(col_indices);
447 table.
card(
"HDUCLASS",
"OGIP",
"Format conforms to OGIP standard");
448 table.
card(
"HDUCLAS1",
"RESPONSE",
"Extension contains response data");
449 table.
card(
"HDUCLAS2",
"VECTOR_CACHE",
"Extension contains a response vector cache");
450 table.
card(
"HDUVERS",
"1.0.0",
"Version of the file format");
486 if (table.
has_card(
"HDUCLAS2") && table.
string(
"HDUCLAS2") ==
"VECTOR_CACHE") {
489 int entries = table.
nrows();
495 std::string cache_id = table.
extname();
502 double* values =
new double[entries];
503 int* indices =
new int[entries];
512 for (
int i = 0; i < entries; ++i) {
513 *values++ = col_values->
real(i);
514 *indices++ = col_indices->
integer(i);
541 result.append(
"=== GResponseVectorCache ===");
548 for (
int i = 0; i <
size(); ++i) {
595 for (
int i = 0; i <
size(); ++i) {
596 double* values = NULL;
621 for (
int i = 0; i <
size(); ++i) {
Filename class interface definition.
FITS binary table class definition.
FITS table double column class interface definition.
FITS table long integer column class interface definition.
FITS table string column class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Response vector cache class definition.
Vector class interface definition.
std::string url(void) const
Return Uniform Resource Locator (URL)
bool has_card(const int &cardno) const
Check existence of header card.
const std::string & extname(void) const
Return extension name.
std::string string(const std::string &keyname) const
Return card value as string.
GFitsHeaderCard & card(const int &cardno)
Return header card.
Abstract interface for FITS table column.
virtual int integer(const int &row, const int &inx=0) const =0
virtual double real(const int &row, const int &inx=0) const =0
FITS table double column.
FITS table long integer column.
Abstract interface for FITS table.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
const int & nrows(void) const
Return number of rows in table.
int size(void) const
Return number of HDUs in FITS file.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from FITS file.
void save(const bool &clobber=false)
Saves FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Response vector cache class.
std::string print(const GChatter &chatter=NORMAL) const
Print response cache.
bool contains(const std::string &cache_id, GVector *irfs=NULL) const
Check if cache contains a value for specific parameters.
void read(const GFitsTable &table)
Read response vector cache from FITS table.
void free_members(void)
Delete class members.
int size(void) const
Returns size of vector chache.
std::vector< int > m_cache_entries
virtual ~GResponseVectorCache(void)
Destructor.
std::vector< int * > m_cache_indices
GResponseVectorCache(void)
Void constructor.
void save(const GFilename &filename, const bool &clobber=false) const
Save the response vector cache into FITS file.
std::vector< double * > m_cache_values
void remove(const std::string &cache_id)
Remove cache.
void copy_members(const GResponseVectorCache &cache)
Copy class members.
void init_members(void)
Initialise class members.
void clear(void)
Clear response vector cache.
int find_cache(const std::string &cache_id) const
Find cache.
std::vector< std::string > m_cache_ids
void load(const GFilename &filename)
Load response vector cache from FITS file.
void set(const std::string &cache_id, const GVector &vector)
Set cache value.
GResponseVectorCache * clone(void) const
Clone response cache.
GResponseVectorCache & operator=(const GResponseVectorCache &cache)
Assignment operator.
const int & size(void) const
Return size of vector.
int non_zeros(void) const
Returns number of non-zero elements in vector.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.