Main Content

matlab.io.fits.setTscale

Set table column scaling

Syntax

matlab.io.fits.setTscale(fptr,colnum,tscale,tzero)

Description

matlab.io.fits.setTscale(fptr,colnum,tscale,tzero) sets the scaling factors for the specified table column. When you read data from the specified table column, the retrieved data is automatically scaled according to this equation:

readData = tscale*storedData + tzero

When you write data to the specified table column, the written data is automatically scaled according to the inverse equation:

writtenData = (specifiedData – tzero)/tscale

This function affects only the automatic scaling performed when the file data is read or written. The function does not change the TSCALE or TZERO keyword values.

Examples

collapse all

Open a sample FITS file, and read data from the third column of the table in the second HDU.

import matlab.io.*
fptr = fits.openFile("tst0012.fits");
fits.movAbsHDU(fptr,2);
data_scaled = fits.readCol(fptr,3)
data_scaled = 11×3 single matrix
104 ×

    0.0110    0.0234    0.0357
    0.2080    0.2203    0.2326
         0         0         0
    0.6019    0.6142    0.6265
    0.7989         0    0.8235
    0.9958    1.0082    1.0205
         0    1.2051    1.2174
    1.3898    1.4021    1.4144
    1.5867    1.5990         0
    1.7837    1.7960    1.8083
    1.9806    1.9930    2.0053
      ⋮

Set the tscale and tzero scaling factors to 1 and 0, respectively, and then reread the column data. The data is no longer scaled.

fits.setTscale(fptr,3,1,0)
data_unscaled = fits.readCol(fptr,3)
data_unscaled = 11×3 uint8 matrix

     1     2     3
    17    18    19
   237   237   237
    49    50    51
    65   237    67
    81    82    83
   237    98    99
   113   114   115
   129   130   237
   145   146   147
   161   162   163
      ⋮

Close the file.

fits.closeFile(fptr)

Tips

  • This function corresponds to the fits_set_tscale (fftscl) function in the CFITSIO library C API.

  • To use this function, you must be familiar with the CFITSIO C interface. You can access the CFITSIO documentation at the CFITSIO website.

Extended Capabilities

expand all

Version History

expand all