Bug #3553
Read and writing a FITS table with scaled integer values modifies the integer values
Status: | Closed | Start date: | 02/25/2021 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assigned To: | Knödlseder Jürgen | % Done: | 100% | |
Category: | - | |||
Target version: | 2.0.0 | |||
Duration: |
Description
When reading and writing a FITS tables with scaled integer values the integer values are scaled in the written dataset. The integer values should be written without any scaling.
Recurrence
No recurrence.
History
#1 Updated by Knödlseder Jürgen almost 4 years ago
The following code
>>> import gammalib
>>> f=gammalib.GFits('/project-data/comptel/data/phase01/vp0001_0/m16992_evp.fits')
>>> f.saveto('m16992_evp.fits', True)
results in the following table content:
File | X_D1 | Y_D1 | L_D1 |
Original | 346.625 | 472.65625 | 0.0546875 |
Saved | 10.8215 | 14.75 | 0 |
#2 Updated by Knödlseder Jürgen almost 4 years ago
- File evp-original.png added
- File evp-saved.png added
- Status changed from New to Pull request
- % Done changed from 0 to 90
I added a m_tscale
to GFitsTableCol
that will hold the value of the optional TSCALn
keyword, if no keyword is found the value will be 1.
The member will be set in GFitsTable::data_open()
using the new GFitsTableCol::tscale()
method that was added for this purpose.
Before loading a FITS column in GFitsTableCol::load_column()
the internal FITS scaling will be disabled in case that m_tscale != 1
. This assures that no information is lost in reading the FITS file, and when the FITS file is saved the same information that was found in the input file is written. Note that the TSCALn
keywords are not affected by this operation, hence the same information exists in the saved FITS file.
If scaling of a FITS column is needed the scaling needs to be performed manually.
To validate the code, I checked the events in the original and saved COMPTEL EVP using show_evp.py
. Both plots look identical.
Original file | Save file |
#3 Updated by Knödlseder Jürgen almost 4 years ago
- Status changed from Pull request to Closed
- % Done changed from 90 to 100
Code merged into devel
.