Note
Go to the end to download the full example code.
Input/Output of dat files for FLCT#
This example demonstrates the use of functions in pyflct.utils
to read and write arrays to binary dat files.
import numpy as np
import pyflct.utils as utils
The original FLCT C code uses dat files for both input and
output. So these functions can be used to read pre-existing dat files
and write new files which keeps any previous calculations compatible with the
existing implementation.
First, we will demonstrate writing to a dat file.
We can get back these arrays by using the read functions in pyflct.utils
It should be noted that these read functions can only read dat
files, the ones which were written using pyflct.utils.write_2_images,
pyflct.utils.read_3_images and the IDL IO routines as given on the
FLCT website.
# Reading two arrays from a dat file
one, two = utils.read_2_images("two.dat")
# We verify that the arrays are the same.
assert np.allclose(one, a)
assert np.allclose(two, b)
# Reading three arrays from a dat file
one, two, three = utils.read_3_images("three.dat")
# We verify that the arrays are the same.
assert np.allclose(one, a)
assert np.allclose(two, b)
assert np.allclose(three, c)
Total running time of the script: (0 minutes 0.002 seconds)