How to open .fits file in paraview

Hello,

I have a .fits file I want to represent but Paraview does not give the option to open this type of file. Which would be the best option to do this?
I tried opening it in python to get a numpy ndarray but I still cannot find a way to visualize this. My data is 3D and I would like to represent a volume or isocontours.

Thanks!

Hi @ixakalabadie

I’m afraid there is no native .fits reader in ParaView.
Can you save your data to another format ?

Best,

Well, I’ll be getting the files in .fits and it won’t be possible to store them all in another format. I was trying to open the files in the paraview python shell, and entering them from there. I managed to enter a data cube with PolyPointSource but I can’t give a value to each point and create a surfaces. Is there a way to do this?
Back to creating files in another format; maybe it’d be possible if I delete them just after reading with paraview, but I don’t know what format would be appropriate for this purpose. I need the process to be efficient.

Thanks.

In that case you may want to use a ProgrammableSource to read your file in python.

In there, you will be able to create the VTK datastructure.

For conversion, I do not know which format you can convert to.

Thank you, using ProgrammableSource worked.
I add the code I used as the script inside ProgrammableSource in case someone has the same issue:

import numpy as np

# The variable scidata is a 3D numpy array, and it represents my dataset. 
# I previously converted the .fits file to numpy with astropy.io.fits
nx, ny, nz = scidata.shape

output.SetDimensions(nx,ny,nz)
output.SetOrigin(0,0,0)
output.SetSpacing(.01,.01,.01)
output.SetExtent(0,nx-1,0,ny-1,0,nz-1)
output.AllocateScalars(vtk.VTK_FLOAT,1)

flux = vtk.vtkFloatArray()
flux.SetName("Flux")
flux.SetNumberOfComponents(1)
flux.SetNumberOfTuples(nx*ny*nz)
point=0
for k in range(nz):
    for j in range(ny):
        for i in range(nx):
            flux.SetValue(point,scidata[i,j,k])
            point += 1
output.GetPointData().AddArray(flux)

After this, a filter has to be applied (I created Contours) to visualize the data.
Of course, I am new to Paraview and there might be some other way to do this, but, at least, I can get a decent representation of my data.

1 Like