From 25b3fa44272bb2ddfd5db7f07bb6be1e08d02cda Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 17 Mar 2020 11:53:59 +0100 Subject: [PATCH] image data seems to work in general with python3 ... ... after fix for colormaps imageDataDeformed is based on the core module, i.e. it has not been used for years. Either update soon or remove --- processing/post/imageData.py | 6 ++---- processing/post/imageDataDeformed.py | 11 ++++------- processing/post/imageDataRGB.py | 9 +++------ python/damask/colormaps.py | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/processing/post/imageData.py b/processing/post/imageData.py index 2ca3ef6e7..51547d4eb 100755 --- a/processing/post/imageData.py +++ b/processing/post/imageData.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 import os import sys @@ -102,6 +102,7 @@ parser.set_defaults(label = None, ) (options,filenames) = parser.parse_args() +if filenames == []: filenames = [None] if options.pixelsize > 1: (options.pixelsizex,options.pixelsizey) = [options.pixelsize]*2 @@ -112,9 +113,6 @@ if options.invert: theMap = theMap.invert() theColors = np.uint8(np.array(theMap.export(format = 'list',steps = 256))*255) # --- loop over input files ------------------------------------------------------------------------- - -if filenames == []: filenames = [None] - for name in filenames: try: table = damask.ASCIItable(name = name, labeled = options.label is not None, readonly = True) diff --git a/processing/post/imageDataDeformed.py b/processing/post/imageDataDeformed.py index 79f81e29e..b9219ac47 100755 --- a/processing/post/imageDataDeformed.py +++ b/processing/post/imageDataDeformed.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 import os import sys @@ -95,6 +95,7 @@ parser.set_defaults(label = None, ) (options,filenames) = parser.parse_args() +if filenames == []: filenames = [None] options.size = np.array(options.size) options.dimension = np.array(options.dimension) @@ -109,16 +110,12 @@ if options.invert: theMap = theMap.invert() theColors = np.uint8(np.array(theMap.export(format='list',steps=256))*255) # --- loop over input files ------------------------------------------------------------------------- - -if filenames == []: filenames = [None] - for name in filenames: try: - table = damask.ASCIItable(name = name, readonly = True, - labeled = options.label is not None) + table = damask.ASCIItable(name = name, labeled = options.label is not None, readonly = True) except IOError: continue - table.report_name(scriptName,name) + damask.util.report(scriptName,name) # ------------------------------------------ read header ------------------------------------------ diff --git a/processing/post/imageDataRGB.py b/processing/post/imageDataRGB.py index 4a1d521b2..a34a48f4f 100755 --- a/processing/post/imageDataRGB.py +++ b/processing/post/imageDataRGB.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 import os import sys @@ -72,18 +72,15 @@ parser.set_defaults(label = None, ) (options,filenames) = parser.parse_args() +if filenames == []: filenames = [None] if options.dimension == []: parser.error('dimension of data array missing') if options.pixelsize > 1: (options.pixelsizex,options.pixelsizey) = [options.pixelsize]*2 # --- loop over input files ------------------------------------------------------------------------- - -if filenames == []: filenames = [None] - for name in filenames: try: - table = damask.ASCIItable(name = name, readonly = True, - labeled = options.label is not None) + table = damask.ASCIItable(name = name, labeled = options.label is not None, readonly = True) except IOError: continue damask.util.report(scriptName,name) diff --git a/python/damask/colormaps.py b/python/damask/colormaps.py index 9c27da147..2117b0b57 100644 --- a/python/damask/colormaps.py +++ b/python/damask/colormaps.py @@ -218,7 +218,7 @@ class Color: if (self.color[i] > 0.04045): RGB_lin[i] = ((self.color[i]+0.0555)/1.0555)**2.4 else: RGB_lin[i] = self.color[i] /12.92 XYZ = np.dot(convert,RGB_lin) - XYZ = np.clip(XYZ,0.0) + XYZ = np.clip(XYZ,0.0,None) converted = Color('XYZ', XYZ) self.model = converted.model