1

I am attempting to read in a FITS file and convert the data into a multidimensional numpy array (So i can easily index the data).

The FITS data is structured like:

FITS_rec([(time, [rate, rate,  rate,  rate], [ERROR, ERROR, ERROR, ERROR], TOTCOUNTS, fraxexp.)]

that is one 'row' (IE = data[0] of data = hdul[1].data), in my case the number of 'rate' (or error) is varies, for different FITS files.

I wish to make this data into a numpy array, but when I do: arr = np.asarray(data), I get a 1D object out which I cannot index easily. IE arr[:][0] is just equal to data[0]. I have also tried to do a np.split with no benifit.

  • *"I get a 1D object..."* What is `arr.dtype`? – Warren Weckesser Jul 22 '22 at 00:47
  • @WarrenWeckesser 'arr.dtype' is a 'np.record': The full return is dtype((numpy.record, [('TIME', '>f8'), ('RATE', '>f8', (4,)), ('ERROR', '>f8', (4,)), ('TOTCOUNTS', '>i4'), ('FRACEXP', '>f8')]) – Maxwell A. Fine Jul 22 '22 at 00:58
  • This is a FITS table and it's represented as a souped up [NumPy structured array](https://numpy.org/doc/stable/user/basics.rec.html). So you can access individual columns like `data['TIME']`. – Iguananaut Jul 25 '22 at 15:38

0 Answers0