From b53acb4edc630d288dcf868c67fb36a18e8b0a0c Mon Sep 17 00:00:00 2001 From: Emanuele De Rubeis <ederubei@login01.m100.cineca.it> Date: Tue, 17 Jan 2023 17:35:55 +0100 Subject: [PATCH] Allows to plot fits files produced as output --- scripts/plotgrid_fits.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/plotgrid_fits.py diff --git a/scripts/plotgrid_fits.py b/scripts/plotgrid_fits.py new file mode 100644 index 0000000..0b4583e --- /dev/null +++ b/scripts/plotgrid_fits.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +import numpy as np +import matplotlib.pyplot as plt +from astropy.io import fits +real_fits = "/home/emanuele/hpc_imaging/test_fits_real.fits" +imag_fits = "/home/emanuele/hpc_imaging/test_fits_img.fits" +nplanes = 1 + + +with fits.open(real_fits) as hdu_real: + img_hdu_real = np.array(hdu_real[0].data) + +with fits.open(imag_fits) as hdu_imag: + img_hdu_imag = np.array(hdu_imag[0].data) + + +xaxis = int(np.sqrt(img_hdu_real.size)) +yaxes = xaxis +residual = np.vectorize(complex)(img_hdu_real, img_hdu_imag) + +cumul2d = residual.reshape((xaxis,yaxes,nplanes), order='F') + +for i in range(nplanes): + gridded = np.squeeze(cumul2d[:,:,i]) + ax = plt.subplot() + img = ax.imshow(np.abs(np.fft.fftshift(gridded)), aspect='auto', interpolation='none', origin='lower') + ax.set_xlabel('cell') + ax.set_ylabel('cell') + cbar = plt.colorbar(img) + cbar.set_label('norm(FFT)',size=18) + figname='fits_image_' + str(i) + '.png' + plt.savefig(figname) -- GitLab