Recent Releases of discretize

discretize - v0.11.3

What's Changed

  • Switches to libc math import by @jcapriot in https://github.com/simpeg/discretize/pull/396
  • Allow TreeMesh.__repr__ to run when non finalized by @santisoler in https://github.com/simpeg/discretize/pull/393
  • Add safeguards to TreeMesh properties by @santisoler in https://github.com/simpeg/discretize/pull/394
  • Python3.13 by @jcapriot in https://github.com/simpeg/discretize/pull/377
  • 0.11.3 staging by @jcapriot in https://github.com/simpeg/discretize/pull/397

Full Changelog: https://github.com/simpeg/discretize/compare/v0.11.2...v0.11.3

- Python
Published by jcapriot 12 months ago

discretize - v0.11.2

What's Changed

  • improve scalar test to handle arbitrary dimensional ndarrays by @jcapriot in https://github.com/simpeg/discretize/pull/388
  • Set no diagonal balance when reading UBC tree meshes by @santisoler in https://github.com/simpeg/discretize/pull/386
  • Fix small typos in diagonal_balance warning by @santisoler in https://github.com/simpeg/discretize/pull/387
  • Implement truthiness for Zero and Identity by @jcapriot in https://github.com/simpeg/discretize/pull/389
  • Fix formatting new warning by @prisae in https://github.com/simpeg/discretize/pull/390
  • v0.11.2 staging by @jcapriot in https://github.com/simpeg/discretize/pull/391

Full Changelog: https://github.com/simpeg/discretize/compare/v0.11.1...v0.11.2

- Python
Published by jcapriot over 1 year ago

discretize - v0.11.1

What's Changed

  • Outstanding bugfixes. by @jcapriot in https://github.com/simpeg/discretize/pull/382
  • Warn for non-repeatable random tests in a testing environment by @jcapriot in https://github.com/simpeg/discretize/pull/384
  • Staging for 0.11.1 by @jcapriot in https://github.com/simpeg/discretize/pull/385

Full Changelog: https://github.com/simpeg/discretize/compare/v0.11.0...v0.11.1

- Python
Published by jcapriot over 1 year ago

discretize - v0.11.0

What's Changed

  • Replace deprecated Numpy's product by prod by @prisae in https://github.com/simpeg/discretize/pull/347
  • Fix typo in tutorials by @xiaolongw1223 in https://github.com/simpeg/discretize/pull/353
  • Replace Slack links for Mattermost links by @santisoler in https://github.com/simpeg/discretize/pull/351
  • Update year in LICENSE by @lheagy in https://github.com/simpeg/discretize/pull/354
  • Set minimum to Python 3.10 (and general CI Maintenance) by @jcapriot in https://github.com/simpeg/discretize/pull/368
  • Replace hanging CurviMesh in docstring for CurvilinearMesh by @omid-b in https://github.com/simpeg/discretize/pull/358
  • Fix slicer re #363 by @prisae in https://github.com/simpeg/discretize/pull/364
  • Add version switcher to discretize docs by @santisoler in https://github.com/simpeg/discretize/pull/371
  • Deploy docs to a new folder named after their tagged version by @santisoler in https://github.com/simpeg/discretize/pull/372
  • display dev doc banner by @jcapriot in https://github.com/simpeg/discretize/pull/373
  • Update use of numpy's random number generators. by @jcapriot in https://github.com/simpeg/discretize/pull/360
  • Bump pydatasphinxtheme version to 0.15.4 by @jcapriot in https://github.com/simpeg/discretize/pull/374
  • Fix caching of internal projection matrices by @jcapriot in https://github.com/simpeg/discretize/pull/375
  • Fix macos-latest build by @jcapriot in https://github.com/simpeg/discretize/pull/376
  • Expose TreeMesh geometric intersections used for refine functions. by @jcapriot in https://github.com/simpeg/discretize/pull/356
  • Add TensorMesh.cell_bounds property by @santisoler in https://github.com/simpeg/discretize/pull/366
  • Add TreeCell.bounds and TreeMesh.cell_bounds methods by @santisoler in https://github.com/simpeg/discretize/pull/367
  • Create build_distributions.yml by @jcapriot in https://github.com/simpeg/discretize/pull/380
  • Numpy2.0 updates by @jcapriot in https://github.com/simpeg/discretize/pull/379
  • 0.11.0 Release Notes by @jcapriot in https://github.com/simpeg/discretize/pull/381

New Contributors

  • @xiaolongw1223 made their first contribution in https://github.com/simpeg/discretize/pull/353
  • @omid-b made their first contribution in https://github.com/simpeg/discretize/pull/358

Full Changelog: https://github.com/simpeg/discretize/compare/v0.10.0...v0.11.0

- Python
Published by jcapriot over 1 year ago

discretize - v0.10.0

What's Changed

  • Add black, flake8 and flake8 plugins to environment file by @santisoler in https://github.com/simpeg/discretize/pull/327
  • Use any Python 3 in pre-commit by @santisoler in https://github.com/simpeg/discretize/pull/328
  • Simplex stashing by @jcapriot in https://github.com/simpeg/discretize/pull/329
  • Add new TensorCell class by @santisoler in https://github.com/simpeg/discretize/pull/325
  • Configure pyvista for doc builds by @jcapriot in https://github.com/simpeg/discretize/pull/330
  • Add a noexcept clause to the wrapper function by @jcapriot in https://github.com/simpeg/discretize/pull/331
  • Face props mass matrices by @dccowan in https://github.com/simpeg/discretize/pull/326
  • Pin flake8 by @jcapriot in https://github.com/simpeg/discretize/pull/335
  • Add cell_nodes property to TensorMesh by @santisoler in https://github.com/simpeg/discretize/pull/333
  • Update a test expression to fix a logical short circuit by @munahaf in https://github.com/simpeg/discretize/pull/339
  • Add export config for git archives by @jcapriot in https://github.com/simpeg/discretize/pull/340
  • Pyproject.toml by @jcapriot in https://github.com/simpeg/discretize/pull/338
  • CIbuildwheel by @jcapriot in https://github.com/simpeg/discretize/pull/342
  • Add Release Notes for 0.10.0 by @jcapriot in https://github.com/simpeg/discretize/pull/343

New Contributors

  • @munahaf made their first contribution in https://github.com/simpeg/discretize/pull/339

Full Changelog: https://github.com/simpeg/discretize/compare/v0.9.0...v0.10.0

- Python
Published by jcapriot over 2 years ago

discretize - 0.9.0 Release

What's Changed

  • Add stacklevel to warnings by @jcapriot in https://github.com/simpeg/discretize/pull/309
  • Switch to try_emplace by @jcapriot in https://github.com/simpeg/discretize/pull/308
  • Assert tests by @jcapriot in https://github.com/simpeg/discretize/pull/310
  • Remove calls with deprecated dir argument by @jcapriot in https://github.com/simpeg/discretize/pull/312
  • change name and description of average edge to face by @jcapriot in https://github.com/simpeg/discretize/pull/314
  • update doc page style sheet by @jcapriot in https://github.com/simpeg/discretize/pull/315
  • Curvilinear vector boundary integral by @jcapriot in https://github.com/simpeg/discretize/pull/316
  • Cyl average edge by @jcapriot in https://github.com/simpeg/discretize/pull/317
  • Feat/simp boundary by @jcapriot in https://github.com/simpeg/discretize/pull/318
  • Add message to assertion error in tests. by @jcapriot in https://github.com/simpeg/discretize/pull/319
  • Nodal boundary example by @jcapriot in https://github.com/simpeg/discretize/pull/320
  • Capture scroll by @prisae in https://github.com/simpeg/discretize/pull/322
  • Cyl mesh generalization by @jcapriot in https://github.com/simpeg/discretize/pull/321
  • 0.9.0 staging by @jcapriot in https://github.com/simpeg/discretize/pull/323
  • Add total_nodes method to TreeMeshes by @santisoler in https://github.com/simpeg/discretize/pull/324

New Contributors

  • @santisoler made their first contribution in https://github.com/simpeg/discretize/pull/324

Full Changelog: https://github.com/simpeg/discretize/compare/v0.8.3...v0.9.0

- Python
Published by jcapriot almost 3 years ago

discretize - 0.8.3

What's Changed

  • Dark mode theme for documentation by @jcapriot in https://github.com/simpeg/discretize/pull/292
  • Testing environment updates by @jcapriot in https://github.com/simpeg/discretize/pull/294
  • Diagonal tree balance by @jcapriot in https://github.com/simpeg/discretize/pull/295
  • More tree refine functions by @jcapriot in https://github.com/simpeg/discretize/pull/296
  • Add new refine surface, bounding box, and point refine methods. by @jcapriot in https://github.com/simpeg/discretize/pull/297
  • Build maintenance by @jcapriot in https://github.com/simpeg/discretize/pull/299
  • implement zeros outside for interpolation function by @jcapriot in https://github.com/simpeg/discretize/pull/298
  • Add style testing by @jcapriot in https://github.com/simpeg/discretize/pull/300
  • Documentation updates by @jcapriot in https://github.com/simpeg/discretize/pull/301
  • 0.8.3 staging by @jcapriot in https://github.com/simpeg/discretize/pull/302

Full Changelog: https://github.com/simpeg/discretize/compare/v0.8.2...v0.8.3

- Python
Published by jcapriot about 3 years ago

discretize - Discretize restructure

This minor release is intended to bring consistent pep8 style naming across all of discretize's classes and functions.

There are two major types of renaming, aliases and deprecations. We have chosen to move to more descriptive property names for classes, generally. For example, mesh.area is deprecated and now is mesh.face_area. Also properties like mesh.vnC are now officially mesh.shape_cells due to the more descriptive name, but can also be accessed as mesh.vnC to speed up some code writing for users. We have included a full list of aliases and deprecations below. In PR #227 we have detailed our reasonings behind individual name choices.

The other big change that will likely cause previous code to break is that all of these mesh.shape_* type properties are now explicitly tuple-s, making them immutable. These properties could previously be modified which would result in undefined and unsafe behavoir. A side effect of this, is that any code that relied on these properties being numpy.ndarray-s, will break. This is intentional.

There's a few internal changes as well, to reorganize the file structure. importing items in discretize.utils from their individual module files is not recommended and might result in future broken code. Please only import these items from the discretize.utils module.

We have also separated the matplotlib plotting code into a separate module: discretize.utils.mixins.mpl_mod. At the same time we have further improved the plotting speed of discretize.TreeMesh and discretize.CurvilinearMesh. This also allows all of these functions to have a unified calling convention.

Finally, we have removed assert errors in favor of throwing the proper exception when checking inputs. We have removed all references to __future__ and six to clean up and drop python 2 compatibility.

Changes


For a full list of deprecations and aliases please visit the release notes in the documentation here.

- Python
Published by jcapriot over 5 years ago

discretize - Volume Average

discretize 0.5.0 Release Notes

This minor release has a few small bug fixes as well as a new volume averaging operator.

The Volume Averaging operator has been implemented for arbitrary TensorMesh, TreeMesh, and combinations of them. It is defined as being a mass conserving operation. More details can be found in its documentation discretize.utils.volume_average

There are also some updates for the new deprecations in matplotlib to hopefully throw less deprecation warnings internally. There are still a few left which are on our radar to fix in the next patch.

We are also dropping support for python 3.5 which will reach end-of-life within a few weeks.

Contributors

  • @jcapriot
  • @prisae
  • @bluetyson

Pull requests

  • #212: Volume average
  • #216: Update 2tensormesh.py
  • #217: Fix Slicer matplotlib-warning.
  • #220: 0.5.0 release notes and requirements update

- Python
Published by jcapriot over 5 years ago

discretize - NumPy Build & Bug Fixes

  • commits from: @jcapriot, @prisae, @thast
  • reviews from: @jcapriot, @lheagy

summary of changes

This is a patch to fix a few bugs that have popped up over the last few months, as well as a single function addition to output only the model for a TreeMesh.

Also we have dropped testing of discretize on Python 2.7 as it is officially in end-of-life stage (as of January 1st, 2020).

  • From #191: Enables discretize to be installed on a system without NumPy present beforehand (for example when pip installing discretize). It also contains a small update to the curvilinear mesh view that updates that function to be in line with the other plotImage functions.

  • From #189: Bugfix. Slicer failed if xslice was provided without a yslice, because of wrong comparison. Before, if you provided a homogenous model, it looked like this: Selection_002 So the colour in the xy- and xz-plots is wrong. As soon as you scroll, the colour in the yz-plot will change to the wrong colour too. With the bug-fix, they all get the right colour, and will remain correct if scrolling: Selection_001 The bug only affects homogeneous fullspaces, which caused an issue with the range used by colorbar().

  • From #187: We can output models through the writeUBC method of the TreeMesh. However, we might want, for symmetry with TensorMesh, also have the writeModelUBC function, which will only write out the model.

- Python
Published by jcapriot over 6 years ago

discretize - serialization of meshes

  • from pr: #182
  • commits from: @jcapriot, @lheagy
  • review from: @jcapriot

summary of changes

  • Update instantiation of basemesh so meshes can be formed from their serialized state, e.g. mesh = discretize.BaseMesh.deserialize(mesh_json) will have the value of _n stored, thus, n does not need to be provided on instantiation

  • Update the x0 property on the TreeMesh so that it goes through the

  • Allow complex scalars to return true in the isScalar util, as well as numpy.number (rather than specifically np.int, np.float)

  • Add testing on the serialization / deserialization of meshes

- Python
Published by lheagy almost 7 years ago

discretize - Tree functions

  • from pr #177
  • commits from @jcapriot
  • pr started by @micmitch
  • review from @lheagy

Updates

  • Several of the functions are used to integrate line source terms for FDEM.
  • The TreeCell object now exposes it's node/edge/face indices to python, a TreeCell object can be obtained by directly indexing the TreeMesh.
  • Added much documentation to the TreeMesh objects and their functions.
  • The TreeMesh plotSlice and plotGrid functions now have the same calling conventions as the respective TensorMesh functions

- Python
Published by lheagy almost 7 years ago

discretize -

  • from pr: #172
  • commits from: @dccowan
  • review from: @sarahgarre, @sgkang, @lheagy

Tutorials in the discretize docs

Addition of tutorials for: - Mesh generation (tensor, cyl and tree) - Averaging and differential operators - Discretized approximations to inner products using finite volume (basic, constitutive relations, differential operators and an advanced section) - Solving PDE examples

image

- Python
Published by lheagy almost 7 years ago

discretize - Update TensorMesh-OMF interface

  • from pr #174
  • commits from @banesullivan
  • review from @lheagy

Overview

This release adds full support for going back and forth between OMF and discretize.TensorMesh. The OMF support implemented in a previous release only went one way (disscretize :arrowright: OMF) and had a bug that messed up the spatial reference of the OMF mesh. This release makes it seamless to go back and forth (discretize :leftrightarrow: OMF). Give it a try with the new `toomf(models)method and load yourTensorMesh`s into other software that supports OMF (e.g. Leapfrog)!

Notes

  • At the moment, only TensorMeshs are supported by OMF
  • OMFv2 should bring more support for Curvilinear and Tree meshes. When that's released we can fill in the methods that currently raises a NotImplementedError
  • These changes makes updates to the TensorMesh-OMF interface to make going to/from OMF/discretize more fluid.

Example

```py import discretize import omf import numpy as np

Make a TensorMesh

h = np.ones(16) mesh = discretize.TensorMesh([h, 2h, 3h]) vec = np.arange(mesh.nC) models = {'arange': vec}

Make an OMF Element

omfelement = mesh.toomf(models)

Use OMF to save that element to an OMF project

proj = omf.Project( name='My project', description='The most awesome project I have ever worked '\ 'on and this is a lengthy description of how '\ 'awesome it is.', )

Add the volume element

proj.elements = [omf_element,]

Verify all is good

assert proj.validate()

Write it out

omf.OMFWriter(proj, 'myproject.omf') ```

And now you can use the .omf project file with your tensor mesh or many tensor meshes in your favorite software that supports OMF (e.g. Leapfrog).

Or you could verify this all worked with omfvista:

py import omfvista foo = omfvista.load_project('myproject.omf') foo.plot()

- Python
Published by lheagy almost 7 years ago

discretize - Make matplotlib a soft dependency

  • from pr #156
  • commits from @prisae
  • review from @rowanc1, @lheagy

Make matplotlib a soft dependency; reasoning: - it is "only" used for the plotting of meshes, which is sort of a relatively small (yet important) part of the whole discretize scope. - it would help to install discretize on minimal conda-environments for running models on a server, without having to install matplotlib.

This is achieved by - using a decorator on functions where matplotlib is required - removing matplotlib from the setup.py

- Python
Published by lheagy almost 7 years ago

discretize - `plot_3d_slicer` improvements; `refine_mesh_xyz` bug fix; `VTK` interaction improvements

Commits: @dccowan ; @prisae ; @banesullivan ; @lheagy Reviewers: @lheagy ; @thast

Merged from PR #159 #160 #163 #166

  • Add (x,y,z)lim to limit the axis. It works with the interactive tools and the home-button will reset to the provided limits. Resolves #165.

Peek 2019-05-21 08-25

  • Fix Broken Example: plot3dslicer

  • Fix refine_mesh_xyz for Tree mesh class

  • Change model array shape check for VTK mixin: It must be an array of size nC

- Python
Published by thast about 7 years ago

discretize - PyVista updates & deploy docs to GitHub Pages

  • from pr: #152
  • commits from: @banesullivan
  • review from: @lheagy

Changes

  • Update discretize to work with PyVista (previously vtki)
  • Enable the PyVista 3D visualization examples to be run when making the docs on CI services
  • Switch the documentation hosting service to GitHub Pages from Read The Docs
  • New InterfaceOMF mixin for converting discretize meshes to Open Mining Format (OMF) objects
  • pep8 refactoring of mixins
  • Drop Windows testing on Python 3.5

- Python
Published by lheagy about 7 years ago

discretize - Add representation methods for `TensorMesh`

  • from pr: #143
  • commits from: @prisae, @banesullivan
  • review from: @lheagy

This PR adds html and non-html representations which should be more generally applicable, for small and big TensorMesh's.

Based on work by @banesullivan on vtki and @prisae on the printversion-tool.

Selection_001

- Python
Published by lheagy about 7 years ago

discretize - Tree mesh refinement

  • from prs: #141, #146
  • commits from: @fourndo, @jcapriot, @lheagy, @prisae
  • review from: @prisae, @lheagy, @jcapriot

Tree Mesh updates

  • Add functionality for TreeMesh creation
  • General bug fix on refine function

Docs

  • typo fix in the installation from source

- Python
Published by lheagy about 7 years ago

discretize - Documentation refactor

  • From PR #134
  • commits from: @lheagy
  • review from: @dccowan

Improvements

Organization of base classes

  • move base classes to a base directory (closes #128)

Docs

  • use napoleon + numpy-style docs to compile the docs (closes #126)
    • convert existing docstrings to numpy-styled docs
  • separate the API documentation from user documentation (closes #127)

image

Testing

  • travis cleanup (previously it was confusing which version of python was being used. We used the python 3.6 image on travis but then downloaded the latest conda - which is python 3.7): now each test suite is clearly labeled
  • use pytest for testing instead of nose

Follow ups

  • content to be developed in the "User Guide" (see #149)
  • create a contributor guide (separate pr) that includes info on how we document classes, methods, functions and class attributes (e.g. https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard) (see #150)
  • pr on SimPEG to ensure it is up-to-date with the changes in the base-class don't cause upstream problems (see simpeg/simpeg#776)

Thanks:

  • @leouieda : for your beautiful repo-setup and docs to follow :)

- Python
Published by lheagy about 7 years ago

discretize - Add `fig`-parameter to `plot_3d_slicer`

  • from pr: #145
  • commits from: @prisae
  • review from: @fourndo

Add fig-parameter to plot_3d_slicer

Small change to provide more flexibility for plot_3d_slicer. It now takes an optional fig-parameter (100% backwards compatible), in which one can provide an existing figure handle. The figure is cleared at every call, but no new figure is created. This can give some more flexibility, for instance in the use together with widgets.

Initiated upon an idea by @fourndo, who uses it for a Mag Tutorial: Peek 2019-03-25 20-24 where he used the figure handle to replace the YZ-plot with a data plot, and wrap it into a widget.

Code example: Now you can call fig = plt.figure() mesh.plot_3d_slicer(model, fig=fig) where fig is an existing figure. And then you can do more funky stuff with your figure handle. It is sort of a convenience addition, as the same would be possible with: fig = plt.figure() tracker = discretize.View.Slicer(mesh, model, **kwargs) fig.canvas.mpl_connect('scroll_event', tracker.onscroll)

- Python
Published by lheagy about 7 years ago

discretize - Add access for vtkToTensorMesh function

Add access for vtkToTensorMesh function

  • from pr #140
  • commits from: @banesullivan

This patch makes available a feature that was tucked away in the vtkModule enabling users to back convert vtkRectilinearGrids or vtki.UnstructuredGrids to TensorMesh objects. This new feature is the discretize.TensorMesh.vtkToTensorMesh() function.

These changes are motivated by a need to easily and interactively create meshes in vtki then send those meshes back to discretize for use in SimPEG.

Example

The following example allows a user to repeatedly tweak a mesh with interactive visualization before deciding on a final mesh structure before sending that mesh to discretize:

Note: the needs to be done in IPython

Necessary imports py import vtki from vtki import examples import discretize import numpy as np

Create a background plotting window that can be interacted with throughout a Jupyter notebook ```py

Create a plotting window

p = vtki.BackgroundPlotter() p.show_grid() ```

Download a sample topography dataset using vtki to surround with a mesh ```py

Get a sample topo surface from vtki

Note: this requires vtki>=0.17.1

topo = examples.downloadsthelens().warpbyscalar()

p.add_mesh(topo, name='topo') ```

Repeatedly change this cell and rerun to decide on your mesh discretization ```py

Create the mesh interactively

tweak these parameters and rerun this cell until satisfied

b = topo.bounds xcoords = np.linspace(b[0], b[1], 50) ycoords = np.linspace(b[2], b[3], 50) zcoords = np.linspace(b[4]-5000, b[5], 50)

mesh = vtki.RectilinearGrid(xcoords, ycoords, zcoords)

p.addmesh(mesh, name='mesh', opacity=0.5, showedges=True)

output the mesh

mesh ```

RectilinearGridInformation
N Cells117649
N Points125000
X Bounds5.579e+05, 5.677e+05
Y Bounds5.108e+06, 5.122e+06
Z Bounds-3.636e+03, 3.225e+03
Volume9.381e+11
N Scalars0

Finally, send the mesh to discretize for use in other processing routines ```py

Once satisfied, convert to discretize:

dmesh, _ = discretize.TensorMesh.vtkToTensorMesh(mesh) dmesh ```

And a GIF to demo

ezgif com-video-to-gif

- Python
Published by lheagy about 7 years ago

discretize - Pure Python 3D Viz Example

  • from pr #135
  • commits from: @banesullivan
  • review from: @lheagy

This provides updates to the vtkModule documentation that reflect recent development in vtki and a new example for 3D visualization. Check out the new example and the types of 3D renderings that are now possible in a pure Python environment (also its Python 3 friendly!):

vtki_laguna_del_maule

Example in Brief

Using vtki, any discretize mesh can now be immediately rendered using the toVTK() method. Be sure to check out the vtki docs to learn more about using vtki!

```py import discretize import numpy as np import vtki vtki.setplottheme('document')

Create a TensorMesh

h1 = np.linspace(.1, .5, 3) h2 = np.linspace(.1, .5, 5) h3 = np.linspace(.1, .8, 3) mesh = discretize.TensorMesh([h1, h2, h3])

Get a VTK data object

dataset = mesh.toVTK()

Defined a rotated reference frame

mesh.axisu = (1,-1,0) mesh.axisv = (-1,-1,0) mesh.axis_w = (0,0,1)

Check that the reference frame is valid

mesh.validateorientation()

Yield the rotated vtkStructuredGrid

dataset_r = mesh.toVTK()

p = vtki.BackgroundPlotter() p.addmesh(dataset, color='green', showedges=True) p.addmesh(datasetr, color='maroon', showedges=True) p.showgrid() p.screenshot('vtk-rotated-example.png')

```

vtk-rotated-example

- Python
Published by lheagy over 7 years ago

discretize - Add vtki support to make using VTK data objects more Pythonic

  • from pr #130
  • commits from: @banesullivan
  • review from: @lheagy

Add vtki support to make using VTK data objects more Pythonic

@banesullivan recently added a ton of new features to vtki (the VTK interface Python package) that help make using just about any VTK data objects more intuitive/Pythonic. If vtki is available in your Python environment then these changes make using VTK data objects way easier. Here's a screenshot of what this currently looks like in a Jupyter notebook (creates static renderings but can also be interactive in a separate pop-up window).

Also check out this notebook to see more ways to use PVGeo, discretize, and vtki. Below is a screenshot of a simple use case:

ezgif com-video-to-gif

screen shot 2018-12-28 at 2 27 21 pm

Simple example

```py import discretize import numpy as np

Create a simple TensorMesh

h1 = np.linspace(.1, .5, 3) h2 = np.linspace(.1, .5, 5) h3 = np.linspace(.1, .5, 3) mesh = discretize.TensorMesh([h1, h2, h3])

Convert to VTK object and use vtki to render it

mesh.toVTK().plot(notebook=False) ```

Fancy example

Here we load the Laguna del Maule Bouguer Gravity example from the SimPEG docs.

This data scene was produced from the Laguna del Maule Bouguer Gravity example provided by Craig Miller (Maule volcanic field, Chile. Refer to Miller et al 2016 EPSL for full details.)

Miller, C. A., Williams-Jones, G., Fournier, D., & Witter, J. (2017). 3D gravity inversion and thermodynamic modelling reveal properties of shallow silicic magma reservoir beneath Laguna del Maule, Chile. Earth and Planetary Science Letters, 459, 14–27. https://doi.org/10.1016/j.epsl.2016.11.007

```py import shelve import tarfile import discretize

f = discretize.utils.download( "https://storage.googleapis.com/simpeg/lagunadelmaule_slicer.tar.gz" ) tar = tarfile.open(f, "r") tar.extractall() tar.close()

with shelve.open('./lagunadelmauleslicer/lagunadel_maule-result') as db: mesh = db['mesh'] Lpout = db['Lpout']

mesh = discretize.TensorMesh.copy(mesh) models = {'Lpout':Lpout} mesh.toVTK(models).plot() ```

Usage Notes

Since vtk and vtki are not required dependencies you'll need to make sure you install them to your Python environment. Pip install for vtki should do the trick but Windows folks might need to install vtk from conda seperately. Also this is Python 3 friendly!

sh pip installl vtki

- Python
Published by lheagy over 7 years ago

discretize - Stream thickness

  • from pr #95
  • commits from @micmitch
  • review from @lheagy

Description

Added streamthickness keyword argument to plotSlice and _plotImage2D functions so that it is possible to scale the thickness of streamlines to reflect the amplitude of the vector field. This functionality was added in a manner similar to the streamthreshold keyword.

stream_thickness keyword currently takes a float which acts as a scaling factor for the streamline thickness. Bounds are hardwired to fix the thickness of the 10% largest and smallest vector amplitudes. Provides good results with the DC current density plots I've made but could probably be generalized in the future for more flexibility.

e.g. python mesh.plotSlice( u, ax=ax, normal='X', vType='F', view='vec', stream_threshold=1e-8, stream_thickness=3 )

image

- Python
Published by lheagy over 7 years ago

discretize - Expand the `plot_3d_slicer` to other `vTypes` and `views`

  • from pr: #121
  • commits from: @prisae
  • review from: @lheagy

Expand plot_3d_slicer

Addresses #116 .

Bug fix

First, it contains a minor bug-fix in the scrolling behavior (last element in each direction was not acceptable, only noticeable in small grids).

vType

Included all non-vector vType's: CC, Ex, Ey, Ez, Fx, Fy, Fz.

view

Included all view's except vec (real [default]; imag; abs; tested them all, seems to be fine).

Name-clash
There is a problem with the view-parameter, which I stupidly used to switch the x-y-axis. I changed the previous view-parameter to axis (hence axis='xy' or 'yx'). It is better to change this than to have different parameters as, for instance, in plotSlice. I added a switch for backwards-compatibility (if view in ['xy', 'yx'] => it sets axis = view; view = 'real').

- Python
Published by lheagy over 7 years ago

discretize - Add VTK object interface

  • from pr: #114
  • commits from: @banesullivan
  • review from: @rowanc1, @lheagy

Description

These new features enable discretize to have a direct interface for VTK base software by implementing toVTK() methods on all the mesh types (excluding CylMesh at this time). Notably, @banesullivan will be using this to provide interoperability with PVGeo to provide direct file IO into ParaView using discretize as well as ways to interactively create discretize meshes in ParaView similar to this example in the PVGeo docs. This new interface also enables discretize meshes to be passed on directly to VTK algorithms for post-processing analysis (note if you couple the interface with PVGeo like shown in this notebook, the process is somewhat simplified).

To learn more about the new VTK object interface, see the docs for the vtkInterface.

Example Usage

The VTK object interface can be used on TensorMesh, TreeMesh, and CurvilinearMesh objects to yield a VTK object in your active Python environment or used to save VTK files for easy sharing.

```py import discretize import numpy as np h1 = np.linspace(.1, .5, 3) h2 = np.linspace(.1, .5, 5) h3 = np.linspace(.1, .5, 3) mesh = discretize.TensorMesh([h1, h2, h3])

Yield a VTK data object for passing this mesh onto VTK algorithms

vtkobj = mesh.toVTK()

Or save out the tree mesh for sharing with others

mesh.writeVTK('sample_mesh') ```

Note that these new features also give users the ability to specify the axes orientation of any given mesh. For example, the above TensorMesh is oriented on the traditional Cartesian reference frame by default but we could change this. To define what that orientation is, we can use the new axis_* properties:

```py

Defined a rotated reference frame

mesh.axisu = (1,-1,0) mesh.axisv = (-1,-1,0) mesh.axis_w = (0,0,1)

Check that the reference frame is valid

mesh.validateorientation() ```

Now we have a TensorMesh explicitly defined on a rotated reference frame! This is quite useful for when we want to convert this to a VTK data object that must have its location in a traditional XYZ Cartesian space defined.

Please take a look at the docs to learn more about using these new features!

- Python
Published by lheagy over 7 years ago

discretize - plot_3d_slicer

  • from pr #104
  • commits from @prisae
  • review from @lheagy

plot3dslicer

Add an interactive slicer for 3D volumes. At the moment only implemented for tensor meshes.

plot3dslicer-2

Features

  • Mouse wheel scroll while hovering over a subplot scrolls through the third axis (e.g., hovering over the xy-slice and scrolling your mouse wheel will go through the z-axis).
  • The three subplots are synced, also for zooming and moving.
  • The initial slices can be provided via the xslice, yslice, and zslice parameters (default is in the middle of the volume).
  • Transparency values and ranges can be provided (a list of floats and tuples/lists of two values), e.g. to hide the seawater or to focus on an interesting part, e.g., [0.3, [1, 4], [-np.infty, -10]] to remove all values equal to 0.3, all values between 1 and 4, and all values smaller than -10. For interactive range selection set transparency='slider'.
  • Takes clim and pcolorOpts as other mesh-plotting functions, which will be passed to pcolormesh.
  • By default the horizontal axis is x, and the vertical axis is y; this can be flipped by setting view='yx'.

By default, the aspect ratio of the three subplots is set to 'auto'. You can change this with the aspect parameter, however, expect the unexpected by doing this. Most importantly, the three subplots won't be nicely aligned, and zooming might result in funny arrangements. Two parameters can be used in this respect: - aspect takes 'auto', 'equal', or num. A list of two of them can be provided, in which case the first element is for the xy-slice, and the second element for the xz- and zy-slices. E.g., aspect=['equal', 2] sets the xy-slice to equal, and in the other two the vertical dimension is exaggerated by a factor of 2. - The plot_3d_slicer is on a subplot2grid-grid, by default on a 3x3 grid, where 2x2 are used for the xy-slice, 2x1 for the xz-slice, and 1x2 for the zy-slice. You can provide a list of three integers via the grid-parameter, which stand for the number of grid-units occupied for the x-, y-, and z-dimension (default is [2, 2, 1]).

Usage

mesh.plot_3d_slicer(data) It requires %matplotlib notebook in Jupyter. In regular IPython shells it should just work.

- Python
Published by lheagy over 7 years ago

discretize - options on plotSlice, grid=True

  • allow kwargs for color and linewidth in the plotgrid function
  • helpful when plotting the mesh and model on a highly discretized mesh. e.g. commer_model

- Python
Published by lheagy over 7 years ago

discretize - Include tree.pxd in source distribution

  • from #102
  • commits from: @cgohlke
  • review from: @jcapriot, @lheagy

  • Include tree.pxd in source distribution

- Python
Published by lheagy almost 8 years ago

discretize - Minor update: plotGrid - linestyle

  • from pr #101
  • ".-" is no longer valid for a linestyle input in matplotlib, it should instead be "-." (however, a solid line looks better anyways for the 1d).

image

- Python
Published by lheagy almost 8 years ago

discretize - TreeMesh Re-write

  • originally from pr #94
  • commits from: @jcapriot
  • review from: @rowanc1, @fourndo, @lheagy

New Implementation of the TreeMesh

At this point consider this branch as EXPERIMENTAL. There are many possible unsafe operations that could arise, so be careful (which will need to be enforced at a later time). The code is certainly not completely up to format standards, but at this point, just wanted to get a pull request going and allow anyone who wants to use it to test it out to find any bugs.

There are many changes to the TreeMesh implementation within this pull request, However it is mostly feature complete compared to the previous implementation with regards to the public members of the class.

It was mostly rewritten in a way that made the construction of the mesh and construction of the operators all done in c++/cython, which resulted in dramatic speedups. As a reference, the 97 nosetests on the tree in the previous implementation took 238.476s on my personal computer. This implementation took 20.281s.

The basic idea is that each object, (node, edge, etc.) is aware of the structure of the TreeMesh as each is a cpp class that contains references to other objects.

A few key differences:

  • All tree construction is balanced (no need to call tree.balance, or pass balance=True to functions)

  • tree.refine should only be called once (at this point) as it "finalizes" the tree. It might be good to add a flag to the tree initialization that would allow incremental additions (similar to scipy.spatial.ConvexHull) and then require a finalization operation to be done before any other operations.

  • Interpolation is "lazy" 2nd order now for all E, CC, and F interpolation, meaning we triangulate the grid points to interpolate. Interpolating without triangulation on the TreeMesh is still a point of research. This is not as fast as it could be, but still faster than previously.

  • Both face and edge operations are defined for 2D, (basically a re-ording of x-edges -> y-faces)

  • Do not expect any ordering for the faces, edges, and nodes. They are whatever they have decided to be.

  • Do not expect any of the private members of the class to have remained consistent between implementations.

  • There are many other changes which should hopefully be apparent as you look through the code.

Big things that still need to be implemented

  • Serialization, (do not expect to pickle this object and have it work, however with construction being much faster, this shouldn't slow down anyone too much while it is being worked on).

  • PlotImage and PlotSlice.

There are also many areas that this code could be extended to handle different types of underlying meshs, as well as support for differing sizes of axes, but as I said before, the initial goal of this pull request is to mimic the behavior of the current implementation.

Other than that, I hope this speeds up the operations for those who need them.

Update

  • Serialization should be implemented now (the TreeMesh is pickle-able)
  • PlotImage and PlotSlice are also implemented.
  • It also now support differing dimensions of the underlying TensorMesh
  • Interpolation is now NOT triangulated, so do there is no longer 2nd order convergence of the non-node interpolation matrices.
  • the refine and insert_cells function now have a finalize keyword arg that can be set to false if you want to do multiple steps of tree building

- Python
Published by lheagy almost 8 years ago

discretize - pypi deploys

  • from pr #97
  • update pypi credentials
  • update appveyor and travis to auto-deploy to pypi on tags
    • includes upload of wheel files from appveyor

- Python
Published by lheagy almost 8 years ago

discretize - 3D cyl mesh

  • originally from pr: #36
  • commits from: @lheagy
  • review from: @rowanc1

3D Cyl Mesh

First implementation of a 3D cylindrical mesh. We discretize in r, theta and z. image

Operators

  • edgeCurl
  • faceDiv
  • aveF2CC
  • aveF2CCV
  • aveE2CC
  • aveE2CCV

are all implemented and tested for second order convergence

Examples

There are some examples running this code in http://github.com/lheagy/casingResearch image - added a simple example that plots a 3D cyl mesh

Plotting

  • add plot capabilities for plotSlice (and I think two slices through the mesh for plotGrid())

Testing

  • basic elements like the grids, counting of things.
  • operator tests for mimetic properties

Other updates

Cell Grad Stencils are properties

  • cell grad stencils are properties rather than methods. This pr will need to be followed by an update in the SimPEG regularization (addressed in simpeg/simpeg#699)

minor updates

  • plotting now uses the C0, C1, ... colors in matplotlib
  • added *.ipynb to .gitignore

- Python
Published by lheagy almost 8 years ago

discretize - plotSlice upgrades

  • from pr #92
  • commits from @micmitch
  • review from @lheagy

upgrades in plotSlice

  • Added rangex, rangey, and sample_grid input arguments to plotSlice function.

- Python
Published by lheagy about 8 years ago

discretize - stream thresholds

  • from pr #91
  • make the stream_threshold compatible with plotslice

- Python
Published by lheagy about 8 years ago

discretize - VTK updates

Just a few small changes for vtk mesh IO in python 3 - from pr #89 - commits from @jcapriot - review from @lheagy

- Python
Published by lheagy over 8 years ago

discretize - Tree mesh cell grad

Cell grad operators for TreeMesh inversion

  • from pr #72
  • commits from: @fourndo, @micmitch, @sgkang, @lheagy
  • review from: @rowanc1, @lheagy, @jiajiasun

  • First pass implementation for stencil operators Initial implementation without hanging faces image

  • Second implementation with hanging faces image

Smoother gradients on Octree change.

  • Create gradient operators with dimensions for PDE problems.
  • Add unit tests for operators. Thanks @micmitch and @sgkang

Solve DC problem in mine tunnels. Tree mesh examples will follow shortly on SimPEG ... stay tuned. image

- Python
Published by lheagy over 8 years ago

discretize - aveCCV2F

  • commits from @sgkang
  • review from @rowanc1, @lheagy
  • originally from pr #88 and discussed in issue #87

create aveCCV2F, which averages a cell centered vector to faces and is useful for self-potential problems

- Python
Published by lheagy over 8 years ago

discretize - Option to mask streamlines

From pr: #86 Commits from: @lheagy Review from: @thast, @rowanc1

add the ability to mask streamlines if the amplitude is below a given threshold (stream_threshold).

image

- Python
Published by lheagy over 8 years ago

discretize - add IO functionalities to write DCIP2D mesh and models

From pr #84 - commits from @thast - review from @lheagy

add IO functionalities to write DCIP2D mesh and models

  • the MeshIO functions writeUBC and writeModelUBC are now compatible with 2D meshes and models.

  • We now make sure that mesh and model get saved at the same place by giving the option to specify the folder outside of the filename (before the folder was given by the dict.keys, not very practical)

  • The upgrade is backward compatible

- Python
Published by lheagy over 8 years ago

discretize - h_gridded

New mesh property: h_gridded

  • From pr #77
    • commits from: @dccowan, @lheagy
    • review from: @lheagy, @rowanc1

This function works for TensorMesh and TreeMesh types. Much like gridCC, h_gridded returns [hx,hy,hz] as a nCxdim numpy array. This function is important for multiple potential fields problems (Mag, VRM, grav) in 3D.

- Python
Published by lheagy over 8 years ago

discretize - dependency management

Changes from #80 - properties >=0.3.6b0 is required for running this version of discretize - properties and vectormath are installed separately so versions can be managed explicitly

- Python
Published by lheagy over 8 years ago

discretize - properties and serialization

Implement properties in discretize

  • from pr #70
  • commits from: @lheagy, reviews from: @rowanc1, @fwkoch

Use properties to define the properties of a class that are necessary to completely define the object. This allows us to serialize, save and load meshes (also copy!)

untitled 2017-09-19 10-41-46

Related issues and discussion

  • private properties: aranzgeo/properties#191
  • arrays with arbitrary shape: aranzgeo/properties#192

- Python
Published by lheagy over 8 years ago

discretize - implement properties in discretize

Implement properties in discretize

  • from pr #70
  • commits from: @lheagy, reviews from: @rowanc1, @fwkoch

Use properties to define the properties of a class that are necessary to completely define the object. This allows us to serialize, save and load meshes (also copy!)

untitled 2017-09-19 10-41-46

Related issues and discussion

  • private properties: aranzgeo/properties#191
  • arrays with arbitrary shape: aranzgeo/properties#192

- Python
Published by lheagy over 8 years ago

discretize - Extract Core Mesh Util

originally from pr #67, with commits from @thast, @lheagy, review from @rowanc1 - port over fixes that were made in SimPEG extract core mesh - add testing on the 1D and 2D extract core mesh util

- Python
Published by lheagy almost 9 years ago

discretize - cleanup imports

Clean up Tree Mesh imports

  • pr #63. commits from @lheagy, review from @rowanc1

Try / except the import of TreeMesh in Tests. This should remove all dependence that the cython code be properly set up in order to import discretize (continues to be an issue on windows...)

- Python
Published by lheagy almost 9 years ago

discretize - numpy upgrades, IO for UBC meshes

IO: UBC meshes

contributions from: @thast, @micmitch, review from @lheagy from pr #54

  • discretize.TensorMesh.readUBC is now a wrapper for loading either 2D or 3D mesh
  • discretize.TensorMesh.readUBC can take care of recognizing if the file is a 2D or 3D UBC mesh, or it can be an input given by the user (arg: meshdim)
  • the original functions are now hidden class function under discretize.TensorMesh.readUBC3DMesh and discretize.TensorMesh.readUBC2DMesh
  • comments in UBC files are assumed to be marked with "!" in front

utils.Zero: Numpy upgrades

contributions from: @lheagy, review and comments from @rowanc1, @jcapriot
from pr #61 - Updates to Identity() and Zero() so that they are consistent with numpy upgrades in numpy=1.13.0 (https://github.com/charris/numpy/blob/master/doc/source/reference/arrays.classes.rst) - use scipy.sparse.dia_matrix for spzeros (closed #60)

- Python
Published by lheagy almost 9 years ago

discretize - Install Cleanup

Noteworthy Changes

  • use a try / except pair when importing the TreeMesh in the main init
  • have efficiency warnings state that the user should use python setup.py install if cython code is not there in the interp utils
  • use a try / except in the setup.py when importing numpy to tell the user to install numpy if it fails.

Minor Changes

  • add codacy, quantified code badges to docs
  • pinning to sphinx==1.5.6 for sphinx gallery to build. This is stated in #57 and will be released when upstream changes are made

- Python
Published by lheagy about 9 years ago

discretize - MeshIO, PyPi deploy, Cache averaging operators

Minor Updates

  • bug fix in MeshIO for UBC mesh (and associated test)
  • deploy to pypi from appveyor, travis on tag
  • cache the averaging operator

Contributors

  • @grosenkj
  • @lheagy
  • @rowanc1

- Python
Published by lheagy about 9 years ago

discretize - Interpolation improvements

Interpolation Improvements

implementing the bisection algorithm without the GIL. Gets rid of a lot of python overhead for speed-ups. If using Cython, might as well use it to get down to C-like code.

All of the for loops are executed without any calls to the python interpreter, and the bisection algorithm is equivalent to the np.searchsorted without the python overhead. Also, since we know how big the inds and vals array will be, might as well pre-allocate them.

At least 2x-3x speed on decent sized arrays.

Should address #23

Ints

  • bug fix to ensure we are using ints as indices and to create numpy arrays

Utils

  • Zero and Identity have a transpose

- Python
Published by lheagy over 9 years ago

discretize - pypi distribution

  • include *.pyx files in the MANIFEST.in so they get included in the pypi distribution

- Python
Published by lheagy over 9 years ago

discretize - Windows and Mesh View

  • add down-sampling capability to _plot2DImage as per simpeg/simpeg#537
  • Changes for windows compatibility:
    • long changed to long long
  • Changes for appveyor testing:
    • needed to cd into a different directory to do the tests
  • Setup.py changes:
    • Used numpy's distutils for package management
  • This can now be built and installed without any special arguments to the setup.py file. For example, python setup.py build and python setup.py install both work.
  • The setup.py files within each subpackage take care of cythonizing and attaching the extensions, making the main setup.py file a little cleaner.
  • This version was able to be pip installed on my Windows machine, should consider building wheels for distribution without compilation.

- Python
Published by lheagy over 9 years ago

discretize - Updates to testing and pypi

This should be slightly smoother to install on pypi, and is now tested on windows.

- Python
Published by rowanc1 over 9 years ago

discretize - Initial release to PYPI

Includes meshes for: - tensor product mesh - cylindrically symmetric mesh - curvilinear mesh - octree and quadtree meshes

This is the initial prot from the SimPEG code base.

- Python
Published by rowanc1 over 9 years ago