From c6c2713461343d9684c0d79bdaf18166df21cf7a Mon Sep 17 00:00:00 2001 From: Gudni UBC-Talva Date: Thu, 5 Feb 2015 14:56:47 -0800 Subject: [PATCH] Fixed the __init__.py for meshutils to include read/writeVTRFile functions. Fixed order of inputs in write mesh functions to all be the same. --- SimPEG/Utils/__init__.py | 2 +- SimPEG/Utils/meshutils.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/SimPEG/Utils/__init__.py b/SimPEG/Utils/__init__.py index 85effc55..6b04e042 100644 --- a/SimPEG/Utils/__init__.py +++ b/SimPEG/Utils/__init__.py @@ -1,6 +1,6 @@ from matutils import * from codeutils import * -from meshutils import exampleLrmGrid, meshTensor, closestPoints, writeUBCTensorMesh, writeUBCTensorModel +from meshutils import exampleLrmGrid, meshTensor, closestPoints, readUBCTensorMesh, writeUBCTensorMesh, writeUBCTensorModel, readVTRFile, writeVTRFile from lrmutils import volTetra, faceInfo, indexCube from interputils import interpmat from ipythonutils import easyAnimate as animate diff --git a/SimPEG/Utils/meshutils.py b/SimPEG/Utils/meshutils.py index 21c47642..98627f34 100644 --- a/SimPEG/Utils/meshutils.py +++ b/SimPEG/Utils/meshutils.py @@ -158,12 +158,13 @@ def readUBCTensorModel(fileName, mesh): return model -def writeUBCTensorMesh(mesh, fileName): +def writeUBCTensorMesh(fileName, mesh): """ Writes a SimPEG TensorMesh to a UBC-GIF format mesh file. - :param simpeg.Mesh.TensorMesh mesh: The mesh :param str fileName: File to write to + :param simpeg.Mesh.TensorMesh mesh: The mesh + """ assert mesh.dim == 3 s = '' @@ -179,14 +180,14 @@ def writeUBCTensorMesh(mesh, fileName): f.write(s) f.close() -def writeUBCTensorModel(mesh, model, fileName): +def writeUBCTensorModel(fileName, mesh, model): """ Writes a model associated with a SimPEG TensorMesh to a UBC-GIF format model file. + :param str fileName: File to write to :param simpeg.Mesh.TensorMesh mesh: The mesh :param numpy.ndarray model: The model - :param str fileName: File to write to """ # Reshape model to a matrix @@ -199,9 +200,9 @@ def writeUBCTensorModel(mesh, model, fileName): np.savetxt(fileName, modelMatTR.ravel()) -def readVTRFile(vtrFileName): +def readVTRFile(fileName): """ - Read VTK vtr (Rectilinear xml file) and return SimPEG Tensor mesh + Read VTK Rectilinear (vtr xml file) and return SimPEG Tensor mesh and model Input: :param vtrFileName, path to the vtr model file @@ -217,7 +218,7 @@ def readVTRFile(vtrFileName): # Read the file vtrReader = vtrFileReader() - vtrReader.SetFileName(vtrFileName) + vtrReader.SetFileName(fileName) vtrReader.Update() vtrGrid = vtrReader.GetOutput() # Sort information @@ -254,14 +255,14 @@ def readVTRFile(vtrFileName): # Return the data return tensMsh, modelDict -def writeVTRFile(mesh,fileName,model=None): +def writeVTRFile(fileName,mesh,model=None): """ Makes and saves a VTK rectilinear file (vtr) for a simpeg Tensor mesh and model. Input: + :param str, path to the output vtk file :param mesh, SimPEG TensorMesh object - mesh to be transfer to VTK :param model, dictionary of numpy.array - Name('s) and array('s). Match number of cells - :param model, path to the output vtk file """ # Import