-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2011-2016 CEA/DEN, EDF R&D
+#!/usr/bin/env python3
+# Copyright (C) 2011-2020 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# as a field in a med file.
# (gboulant - 27/06/2011)
-import MEDCoupling as MC
+import os
+
+import medcoupling as MC
import MEDLoader as ML
#
#image = scipy.lena()
# We could either read a real image using the PIL python package.
from scipy.misc import pilutil
-image = pilutil.imread("images/avatar.png",True)
+CURDIR = os.path.dirname(__file__)
+image = pilutil.imread(os.path.join(CURDIR, "images", "avatar.png"),True)
#from PIL import Image
#im=Image.open("images/lena.png")
#image=pilutil.fromimage(im,True)
#image=numpy.asarray(im)
-#print image
+# print(image)
dim = len(image.shape)
-print "Image space dimension = %d"%dim
+print("Image space dimension = %d"%dim)
sizeX = image.shape[1]
sizeY = image.shape[0]
# double as required by the MEDCoupling field specification.
import numpy
imageDataNArray = image.reshape(1,sizeX*sizeY)[0]
-print imageDataNArray
+print(imageDataNArray)
imageDataNArrayDouble = numpy.array(imageDataNArray, dtype='float64')
imageDataArrayDouble = list(imageDataNArrayDouble)
coordsY.setValues(arrY,nbNodesY,1)
cmesh.setCoords(coordsX,coordsY)
-print "Imagem mesh dimension: %d"%cmesh.getSpaceDimension()
+print("Imagem mesh dimension: %d"%cmesh.getSpaceDimension())
# WARN: In the current state of development of MEDLoader, only
-# unstructured meshes are supported for writting function in med
+# unstructured meshes are supported for writing function in med
# files. We just have to convert the cartesian mesh in an unstructured
# mesh before creating the field.
umesh=cmesh.buildUnstructured();