def writeUBC(mesh, fileName, models=None):
        assert mesh.dim == 3
        s = ''
        s += '%i %i %i\n' %tuple(mesh.vnC)
        origin = mesh.x0 + np.array([0,0,mesh.hz.sum()]) # Have to it in the same operation or use mesh.x0.copy(), otherwise the mesh.x0 is updated.
        origin.dtype = float

        s += '%.2f %.2f %.2f\n' %tuple(origin)
        s += ('%.2f '*mesh.nCx+'\n')%tuple(mesh.hx)
        s += ('%.2f '*mesh.nCy+'\n')%tuple(mesh.hy)
        s += ('%.2f '*mesh.nCz+'\n')%tuple(mesh.hz[::-1])
        f = open(fileName, 'w')
        f.write(s)
        f.close()

        if models is None: return
        assert type(models) is dict, 'models must be a dict'
        for key in models:
            assert type(key) is str, 'The dict key is a file name'
            mesh.writeModelUBC(key, models[key])
Writes a SimPEG TensorMesh to a UBC-GIF format mesh file.
dataset/ETHPy150Open simpeg/simpeg/SimPEG/Mesh/MeshIO.py/TensorMeshIO.writeUBC