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;
336 if (contains && vector != NULL) {
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");
454 if (fits.contains(extname)) {
455 fits.remove(extname);
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;
600 indices =
new int[m_cache_entries[i]];
601 for (
int k = 0; k < m_cache_entries[i]; ++k) {
621 for (
int i = 0; i <
size(); ++i) {
void save(const GFilename &filename, const bool &clobber=false) const
Save the response vector cache into FITS file.
FITS table double column class interface definition.
GResponseVectorCache(void)
Void constructor.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
bool has_card(const int &cardno) const
Check existence of header card.
Response vector cache class.
std::vector< int > m_cache_entries
std::string print(const GChatter &chatter=NORMAL) const
Print response cache.
void set(const std::string &cache_id, const GVector &vector)
Set cache value.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
virtual ~GResponseVectorCache(void)
Destructor.
void init_members(void)
Initialise class members.
FITS file class interface definition.
std::vector< double * > m_cache_values
int size(void) const
Returns size of vector chache.
int find_cache(const std::string &cache_id) const
Find cache.
void read(const GFitsTable &table)
Read response vector cache from FITS table.
void free_members(void)
Delete class members.
GResponseVectorCache * clone(void) const
Clone response cache.
int non_zeros(void) const
Returns number of non-zero elements in vector.
Abstract interface for FITS table column.
GResponseVectorCache & operator=(const GResponseVectorCache &cache)
Assignment operator.
Response vector cache class definition.
void remove(const std::string &cache_id)
Remove cache.
FITS table string column class interface definition.
Abstract interface for FITS table.
Vector class interface definition.
const std::string & extname(void) const
Return extension name.
void copy_members(const GResponseVectorCache &cache)
Copy class members.
FITS table long integer column.
const int & nrows(void) const
Return number of rows in table.
std::string url(void) const
Return Uniform Resource Locator (URL)
virtual int integer(const int &row, const int &inx=0) const =0
void clear(void)
Clear response vector cache.
virtual double real(const int &row, const int &inx=0) const =0
int size(void) const
Return number of HDUs in FITS file.
bool contains(const std::string &cache_id, GVector *irfs=NULL) const
Check if cache contains a value for specific parameters.
std::string string(const std::string &keyname) const
Return card value as string.
FITS table long integer column class interface definition.
FITS binary table class definition.
std::vector< int * > m_cache_indices
const int & size(void) const
Return size of vector.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::vector< std::string > m_cache_ids
GFitsHeaderCard & card(const int &cardno)
Return header card.
void load(const GFilename &filename)
Load response vector cache from FITS file.
void close(void)
Close FITS file.
FITS table double column.
Filename class interface definition.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.