-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
def sortdict(points):
# Sort this dictionary by keys and returns 2 lists, the list of X
# and the list of Y, the whole ordered by X
- keys = sorted(list(points.keys()))
+ keys = sorted(points.keys())
return keys, [points[key] for key in keys]
import pylab
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
# Copyright (C) 2011-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# ... but also a more sophisticated callable object, for example to
# defines some parameters
-class Function(object):
+class Function:
def __init__(self, sizeX, sizeY, param):
self.sizeX = sizeX
self.sizeY = sizeY
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
# Copyright (C) 2011-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# as a field in a med file.
# (gboulant - 27/06/2011)
+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
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
# Copyright (C) 2011-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
print(list(fieldTree.keys()))
# _T3A
-for meshName in list(fieldTree.keys()):
+for meshName in fieldTree:
print("%s"%meshName)
- for fieldName in list(fieldTree[meshName].keys()):
+ for fieldName in fieldTree[meshName]:
print(" %s"%fieldName)
- for fieldType in list(fieldTree[meshName][fieldName].keys()):
+ for fieldType in fieldTree[meshName][fieldName]:
print(" %s"%fieldType)
- for itNumber in list(fieldTree[meshName][fieldName][fieldType].keys()):
- for itOrder in list(fieldTree[meshName][fieldName][fieldType][itNumber].keys()):
+ for itNumber in fieldTree[meshName][fieldName][fieldType]:
+ for itOrder in fieldTree[meshName][fieldName][fieldType][itNumber]:
print(" (%s,%s)"%(itNumber,itOrder))
print(fieldTree[meshName][fieldName][fieldType][itNumber][itOrder])
# _T3B
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
# Copyright (C) 2007-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
# Copyright (C) 2011-2016 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
#
# Author : Guillaume Boulant (EDF)
-from optparse import OptionParser
-parser = OptionParser()
-parser.add_option("-i", "--imagefile", dest="imagefile",
+from argparse import ArgumentParser
+parser = ArgumentParser()
+parser.add_agument("-i", "--imagefile", dest="imagefile",
help="image file to convert", metavar="FILE")
-parser.add_option("-m", "--medfile", dest="medfile", default=None,
+parser.add_agument("-m", "--medfile", dest="medfile", default=None,
help="output med file", metavar="FILE")
-(options, args) = parser.parse_args()
+args = parser.parse_args()
import sys, os
-if options.imagefile is None:
+if args.imagefile is None:
print("The image file must be specified")
sys.exit()
-imagefile = options.imagefile
+imagefile = args.imagefile
if not os.path.exists(imagefile):
print("The image file %s does not exists"%imagefile)
sys.exit()
-if options.medfile is None:
+if args.medfile is None:
basename = os.path.basename(imagefile)
medfile = basename[0:len(basename)-3] + "med"
else:
- medfile = options.medfile
+ medfile = args.medfile
print("Convert image file %s to a med field saved in %s"%(imagefile,medfile))
from xmedimages import FieldBuilder