Commit f59a463b0e654d8bf8fd7fde1d85dada147c2f64

Authored by Jürgen Knödlseder
1 parent 872f5bc8

Correct bug in inserting elements in empty FITS columns.

ChangeLog
... ... @@ -3,6 +3,7 @@
3 3 * Version 1.1.0 released
4 4 =========================
5 5  
  6 + Correct GFitsTableCol::insert method for empty columns
6 7 Correct GCTAEdisp2D::compute_ebounds methods (#1662)
7 8 Use GFilename in GFits to store filename (#1649)
8 9 Load CTA GTI extension from the HDU name provided by the DSS keyword (#1598)
... ...
... ... @@ -34,6 +34,11 @@ None
34 34  
35 35 6. FITS I/O Interface
36 36 ---------------------
  37 +The GFitsTableCol::insert() method did not work corretly for an empty column
  38 +since it de-allocated memory without having necessarily memory on disk. This
  39 +was corrected by allocating now memory after inserting elements into an empty
  40 +FITS column.
  41 +
37 42 GFits now uses the GFilename class to store the FITS filename (fixes #1649).
38 43  
39 44  
... ...
src/fits/GFitsTableBitCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableBitCol.cpp - FITS table Bit column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -320,8 +320,8 @@ int GFitsTableBitCol::integer(const int& row, const int& inx) const
320 320 * @exception GException::fits_invalid_row
321 321 * Specified row is invalid.
322 322 *
323   - * This method inserts rows into a FITS table. This implies that the column
324   - * will be loaded into memory.
  323 + * Inserts rows into a FITS table. This implies that the column will be
  324 + * loaded into memory.
325 325 ***************************************************************************/
326 326 void GFitsTableBitCol::insert(const int& row, const int& nrows)
327 327 {
... ... @@ -337,6 +337,9 @@ void GFitsTableBitCol::insert(const int& row, const int& nrows)
337 337 // number of rows to be inserted
338 338 if (m_length == 0) {
339 339 m_length = nrows;
  340 + m_size = m_number * m_length;
  341 + alloc_data();
  342 + init_data();
340 343 }
341 344  
342 345 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableBoolCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableBoolCol.cpp - FITS table boolean column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -295,8 +295,8 @@ int GFitsTableBoolCol::integer(const int& row, const int& inx) const
295 295 * @exception GException::fits_invalid_row
296 296 * Specified row is invalid.
297 297 *
298   - * This method inserts rows into a FITS table. This implies that the column
299   - * will be loaded into memory.
  298 + * Inserts rows into a FITS table. This implies that the column will be
  299 + * loaded into memory.
300 300 ***************************************************************************/
301 301 void GFitsTableBoolCol::insert(const int& row, const int& nrows)
302 302 {
... ... @@ -312,6 +312,9 @@ void GFitsTableBoolCol::insert(const int& row, const int& nrows)
312 312 // number of rows to be inserted
313 313 if (m_length == 0) {
314 314 m_length = nrows;
  315 + m_size = m_number * m_length;
  316 + alloc_data();
  317 + init_data();
315 318 }
316 319  
317 320 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableByteCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableByteCol.cpp - FITS table Byte column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -292,8 +292,8 @@ int GFitsTableByteCol::integer(const int& row, const int& inx) const
292 292 * @exception GException::fits_invalid_row
293 293 * Specified row is invalid.
294 294 *
295   - * This method inserts rows into a FITS table. This implies that the column
296   - * will be loaded into memory.
  295 + * Inserts rows into a FITS table. This implies that the column will be
  296 + * loaded into memory.
297 297 ***************************************************************************/
298 298 void GFitsTableByteCol::insert(const int& row, const int& nrows)
299 299 {
... ... @@ -309,6 +309,9 @@ void GFitsTableByteCol::insert(const int& row, const int& nrows)
309 309 // number of rows to be inserted
310 310 if (m_length == 0) {
311 311 m_length = nrows;
  312 + m_size = m_number * m_length;
  313 + alloc_data();
  314 + init_data();
312 315 }
313 316  
314 317 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableCDoubleCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableCDoubleCol.cpp - FITS table double precision complex column *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -297,8 +297,8 @@ int GFitsTableCDoubleCol::integer(const int& row, const int& inx) const
297 297 * @exception GException::fits_invalid_row
298 298 * Specified row is invalid.
299 299 *
300   - * This method inserts rows into a FITS table. This implies that all columns
301   - * will be loaded into memory.
  300 + * Inserts rows into a FITS table. This implies that all columns will be
  301 + * loaded into memory.
302 302 ***************************************************************************/
303 303 void GFitsTableCDoubleCol::insert(const int& row, const int& nrows)
304 304 {
... ... @@ -314,6 +314,9 @@ void GFitsTableCDoubleCol::insert(const int& row, const int& nrows)
314 314 // number of rows to be inserted
315 315 if (m_length == 0) {
316 316 m_length = nrows;
  317 + m_size = m_number * m_length;
  318 + alloc_data();
  319 + init_data();
317 320 }
318 321  
319 322 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableCFloatCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableCFloatCol.cpp - FITS table single precision complex column *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -297,8 +297,8 @@ int GFitsTableCFloatCol::integer(const int& row, const int& inx) const
297 297 * @exception GException::fits_invalid_row
298 298 * Specified row is invalid.
299 299 *
300   - * This method inserts rows into a FITS table. This implies that all columns
301   - * will be loaded into memory.
  300 + * Inserts rows into a FITS table. This implies that all columns will be
  301 + * loaded into memory.
302 302 ***************************************************************************/
303 303 void GFitsTableCFloatCol::insert(const int& row, const int& nrows)
304 304 {
... ... @@ -314,6 +314,9 @@ void GFitsTableCFloatCol::insert(const int& row, const int& nrows)
314 314 // number of rows to be inserted
315 315 if (m_length == 0) {
316 316 m_length = nrows;
  317 + m_size = m_number * m_length;
  318 + alloc_data();
  319 + init_data();
317 320 }
318 321  
319 322 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableDoubleCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableDoubleCol.cpp - FITS table double column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -292,8 +292,8 @@ int GFitsTableDoubleCol::integer(const int& row, const int& inx) const
292 292 * @exception GException::fits_invalid_row
293 293 * Specified row is invalid.
294 294 *
295   - * This method inserts rows into a FITS table. This implies that the column
296   - * will be loaded into memory.
  295 + * Inserts rows into a FITS table. This implies that the column will be
  296 + * loaded into memory.
297 297 ***************************************************************************/
298 298 void GFitsTableDoubleCol::insert(const int& row, const int& nrows)
299 299 {
... ... @@ -309,6 +309,9 @@ void GFitsTableDoubleCol::insert(const int& row, const int& nrows)
309 309 // number of rows to be inserted
310 310 if (m_length == 0) {
311 311 m_length = nrows;
  312 + m_size = m_number * m_length;
  313 + alloc_data();
  314 + init_data();
312 315 }
313 316  
314 317 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableFloatCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableFloatCol.cpp - FITS table float column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -292,8 +292,8 @@ int GFitsTableFloatCol::integer(const int& row, const int& inx) const
292 292 * @exception GException::fits_invalid_row
293 293 * Specified row is invalid.
294 294 *
295   - * This method inserts rows into a FITS table. This implies that all columns
296   - * will be loaded into memory.
  295 + * Inserts rows into a FITS table. This implies that all columns will be
  296 + * loaded into memory.
297 297 ***************************************************************************/
298 298 void GFitsTableFloatCol::insert(const int& row, const int& nrows)
299 299 {
... ... @@ -309,6 +309,9 @@ void GFitsTableFloatCol::insert(const int& row, const int& nrows)
309 309 // number of rows to be inserted
310 310 if (m_length == 0) {
311 311 m_length = nrows;
  312 + m_size = m_number * m_length;
  313 + alloc_data();
  314 + init_data();
312 315 }
313 316  
314 317 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableLongCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableLongCol.cpp - FITS table long integer column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -292,8 +292,8 @@ int GFitsTableLongCol::integer(const int& row, const int& inx) const
292 292 * @exception GException::fits_invalid_row
293 293 * Specified row is invalid.
294 294 *
295   - * This method inserts rows into a FITS table. This implies that all columns
296   - * will be loaded into memory.
  295 + * Inserts rows into a FITS table. This implies that all columns will be
  296 + * loaded into memory.
297 297 ***************************************************************************/
298 298 void GFitsTableLongCol::insert(const int& row, const int& nrows)
299 299 {
... ... @@ -309,6 +309,9 @@ void GFitsTableLongCol::insert(const int& row, const int& nrows)
309 309 // number of rows to be inserted
310 310 if (m_length == 0) {
311 311 m_length = nrows;
  312 + m_size = m_number * m_length;
  313 + alloc_data();
  314 + init_data();
312 315 }
313 316  
314 317 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableLongLongCol.cpp
... ... @@ -292,8 +292,8 @@ int GFitsTableLongLongCol::integer(const int& row, const int& inx) const
292 292 * @exception GException::fits_invalid_row
293 293 * Specified row is invalid.
294 294 *
295   - * This method inserts rows into a FITS table. This implies that all columns
296   - * will be loaded into memory.
  295 + * Inserts rows into a FITS table. This implies that all columns will be
  296 + * loaded into memory.
297 297 ***************************************************************************/
298 298 void GFitsTableLongLongCol::insert(const int& row, const int& nrows)
299 299 {
... ... @@ -309,6 +309,9 @@ void GFitsTableLongLongCol::insert(const int& row, const int& nrows)
309 309 // number of rows to be inserted
310 310 if (m_length == 0) {
311 311 m_length = nrows;
  312 + m_size = m_number * m_length;
  313 + alloc_data();
  314 + init_data();
312 315 }
313 316  
314 317 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableShortCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableShortCol.cpp - FITS table short integer column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -292,8 +292,8 @@ int GFitsTableShortCol::integer(const int& row, const int& inx) const
292 292 * @exception GException::fits_invalid_row
293 293 * Specified row is invalid.
294 294 *
295   - * This method inserts rows into a FITS table. This implies that all columns
296   - * will be loaded into memory.
  295 + * Inserts rows into a FITS table. This implies that all columns will be
  296 + * loaded into memory.
297 297 ***************************************************************************/
298 298 void GFitsTableShortCol::insert(const int& row, const int& nrows)
299 299 {
... ... @@ -309,6 +309,9 @@ void GFitsTableShortCol::insert(const int& row, const int& nrows)
309 309 // number of rows to be inserted
310 310 if (m_length == 0) {
311 311 m_length = nrows;
  312 + m_size = m_number * m_length;
  313 + alloc_data();
  314 + init_data();
312 315 }
313 316  
314 317 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableStringCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableStringCol.cpp - FITS table string column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -295,8 +295,8 @@ int GFitsTableStringCol::integer(const int& row, const int& inx) const
295 295 * @exception GException::fits_invalid_row
296 296 * Specified row is invalid.
297 297 *
298   - * This method inserts rows into a FITS table. This implies that all columns
299   - * will be loaded into memory.
  298 + * Inserts rows into a FITS table. This implies that all columns will be
  299 + * loaded into memory.
300 300 ***************************************************************************/
301 301 void GFitsTableStringCol::insert(const int& row, const int& nrows)
302 302 {
... ... @@ -312,6 +312,9 @@ void GFitsTableStringCol::insert(const int& row, const int& nrows)
312 312 // number of rows to be inserted
313 313 if (m_length == 0) {
314 314 m_length = nrows;
  315 + m_size = m_number * m_length;
  316 + alloc_data();
  317 + init_data();
315 318 }
316 319  
317 320 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableULongCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableULongCol.cpp - FITS table unsigned long integer column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -291,8 +291,8 @@ int GFitsTableULongCol::integer(const int& row, const int& inx) const
291 291 * @exception GException::fits_invalid_row
292 292 * Specified row is invalid.
293 293 *
294   - * This method inserts rows into a FITS table. This implies that all columns
295   - * will be loaded into memory.
  294 + * Inserts rows into a FITS table. This implies that all columns will be
  295 + * loaded into memory.
296 296 ***************************************************************************/
297 297 void GFitsTableULongCol::insert(const int& row, const int& nrows)
298 298 {
... ... @@ -308,6 +308,9 @@ void GFitsTableULongCol::insert(const int& row, const int& nrows)
308 308 // number of rows to be inserted
309 309 if (m_length == 0) {
310 310 m_length = nrows;
  311 + m_size = m_number * m_length;
  312 + alloc_data();
  313 + init_data();
311 314 }
312 315  
313 316 // ... otherwise fetch data, allocate new data and copy over
... ...
src/fits/GFitsTableUShortCol.cpp
1 1 /***************************************************************************
2 2 * GFitsTableUShortCol.cpp - FITS table unsigned short integer column class*
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -291,8 +291,8 @@ int GFitsTableUShortCol::integer(const int& row, const int& inx) const
291 291 * @exception GException::fits_invalid_row
292 292 * Specified row is invalid.
293 293 *
294   - * This method inserts rows into a FITS table. This implies that all columns
295   - * will be loaded into memory.
  294 + * Inserts rows into a FITS table. This implies that all columns will be
  295 + * loaded into memory.
296 296 ***************************************************************************/
297 297 void GFitsTableUShortCol::insert(const int& row, const int& nrows)
298 298 {
... ... @@ -308,6 +308,9 @@ void GFitsTableUShortCol::insert(const int& row, const int& nrows)
308 308 // number of rows to be inserted
309 309 if (m_length == 0) {
310 310 m_length = nrows;
  311 + m_size = m_number * m_length;
  312 + alloc_data();
  313 + init_data();
311 314 }
312 315  
313 316 // ... otherwise fetch data, allocate new data and copy over
... ...