Commit 221f9ea1 authored by Pierre Augier's avatar Pierre Augier

serieofarrays (cine)

parent f30bc7627880
......@@ -11,4 +11,4 @@ http://legacy.python.org/dev/peps/pep-0386/
'a' or 'alpha' means alpha version (internal testing),
'b' or 'beta' means beta version (external testing).
"""
__version__ = '0.1.6.post2'
__version__ = '0.1.6.post3'
......@@ -115,7 +115,8 @@ def imsave(path, array, format=None, as_int=False):
if format == 'TIFF':
if any([path.endswith(ext) for ext in ('.png', '.PNG')]) and\
np.issubdtype(array.dtype, np.floating):
print('warning: can not save float image as png. Using tif format.')
print('warning: can not save float image as png. '
'Using tif format.')
if not any([path.endswith(ext) for ext in ('.tif', '.tiff')]):
path += '.tiff'
......
......@@ -87,18 +87,19 @@ def imsave(path, arrays, as_int=False):
if PIL.__version__ < '4.2.0':
from warnings import warn
warn('imsave for multiframe TIFF uses an intermediate GIF workaround.',
DeprecationWarning)
DeprecationWarning)
gif = im_list.pop(0)
with io.BytesIO() as output:
gif.save(output, format='GIF', save_all=True, append_images=im_list)
gif.save(output, format='GIF', save_all=True,
append_images=im_list)
gif.close()
with Image.open(output) as im:
im.save(path, format='TIFF', save_all=True)
else:
im_list[0].save(path, compression='tiff_deflate', save_all=True,
append_images=im_list[1:])
append_images=im_list[1:])
def reorganize_single_frame_3Dscannedpiv_data(files, nb_levels, outputdir='.',
......
......@@ -319,12 +319,12 @@ if __name__ == '__main__':
'nu=0.0001266_N=2.0_Tend=400_2015-01-09_19-18-52'
)
ff0 = NS3DFieldFile(path_file=path_dir +
'/velo_rho_vort.t=0400.045')
# ff0 = NS3DFieldFile(path_file=path_dir +
# '/velo_rho_vort.t=0400.045')
ff1 = NS3DFieldFile(path_file=path_dir +
'/velo_rho_vort.t=0400.045_64x64x32')
# ff1 = NS3DFieldFile(path_file=path_dir +
# '/velo_rho_vort.t=0400.045_64x64x32')
# ff2 = NS3DFieldFile(path_file=path_dir
# + '/velo_rho_vort.t=0005.010_128x128x32')
# ff2 = NS3DFieldFile(path_file=path_dir +
# '/velo_rho_vort.t=0005.010_128x128x32')
......@@ -66,7 +66,7 @@ class TestImage(unittest.TestCase):
as_int = bool(_type.endswith('f'))
try:
imsave(path, image, _format, as_int)
image2 = imread(path, flatten=True)
image2 = imread(path)
except Exception as e:
raise_from(Exception(err), e)
......
......@@ -2,7 +2,7 @@
Default parameters for Matplotlib figures
=========================================
.. currentmodule:: fluiddyn.output.rcparams
.. autofunction:: set_rcparams
"""
......@@ -11,6 +11,7 @@ import matplotlib.pyplot as plt
def set_rcparams(fontsize=18, for_article=True, for_beamer=False,
fontsize_pad=9):
"""Set the rcparams for articles or presentation"""
params = {
'axes.labelsize': fontsize,
......
......@@ -48,6 +48,8 @@ import os
from glob import glob
from copy import copy, deepcopy
import itertools
from math import ceil, log10
try:
import pims
......@@ -218,10 +220,12 @@ class SerieOfArraysFromFiles(SerieOfArrays):
else:
self._nb_arrays_file = {}
self._nb_arrays_file[paths[0]] = self.nb_arrays_in_one_file = \
get_nb_arrays_in_file(paths[0])
get_nb_arrays_in_file(paths[0])
self._format_index = '[{' + ':0{}d'.format(
int(ceil(log10(self.nb_arrays_in_one_file)))) + '}]'
str_internal_index = [
'[{}]'.format(i)
self._format_index.format(i)
for i in range(self.nb_arrays_in_one_file)]
names = []
for fname in file_names:
......@@ -390,7 +394,7 @@ class SerieOfArraysFromFiles(SerieOfArrays):
name += '.' + self.extension_file
if self._from_movies:
name += '[{}]'.format(indices[-1])
name += self._format_index.format(indices[-1])
return name
......@@ -464,9 +468,12 @@ class SerieOfArraysFromFiles(SerieOfArrays):
self._index_slices = index_slices
def get_nb_files(self):
def get_nb_arrays(self):
return len([i for i in self.iter_indices()])
def get_nb_files(self):
return len(self.get_name_files())
class SeriesOfArrays(object):
"""Series of arrays.
......@@ -474,8 +481,8 @@ class SeriesOfArrays(object):
This class can be used to produce series of arrays from a
:class:`SerieOfArrays`.
Arguments
---------
Parameters
----------
serie: SerieOfArrays or str
......@@ -576,7 +583,7 @@ class SeriesOfArrays(object):
print('serie={},\nindslices_from_indserie={}, '.format(
serie0, indslices_from_indserie0) +
'ind_start={}, ind_stop={}, ind_step={}.'.format(
ind_start, ind_stop, ind_step))
ind_start, ind_stop, ind_step))
def __iter__(self):
......
......@@ -63,5 +63,6 @@ class TestSeriesOfArrays(unittest.TestCase):
serie.get_nb_files()
serie.set_index_slices(0, 1)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment