# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Display the images resulting from tests

# +
# %matplotlib inline

import os
import sys

sys.path.append(os.path.join('..', '..'))

from matplotlib import pylab
import numpy
from matplotlib import pyplot as plt

from data_models.parameters import arl_path
from wrappers.serial.image.operations import show_image, qa_image, import_image_from_fits

import logging

log = logging.getLogger()
log.setLevel(logging.INFO)
log.addHandler(logging.StreamHandler(sys.stdout))

# +
pylab.rcParams['figure.figsize'] = (12.0, 12.0)
pylab.rcParams['image.cmap'] = 'rainbow'


fits_files = []
results_dir = './results/mpi'
for file in os.listdir(results_dir):
    if file.endswith(".fits"):
        fits_files.append(file)
        
fits_files = numpy.sort(fits_files)

empty = list()
for file in fits_files:
    im = import_image_from_fits('%s/%s' % (results_dir,file))
    if numpy.max(numpy.abs(im.data)) == 0.0:
        empty.append(file)

import pprint
p=pprint.PrettyPrinter()
print("The following files are empty:")  
p.pprint(empty)   

# +
for file in fits_files:
    print('******************************************************************')

    im = import_image_from_fits('%s/%s' % (results_dir,file))
    print(qa_image(im, context=file))
    try:
        show_image(im, title=file)
        plt.show()
    except IndexError:
        pass


# -



StarcoderdataJupyterScriptsDedupFiltered