Boyer Research

Marching NumPy

Documentation on Read The Docs

The visualisation of numeric data is a key component of computer graphics.
Data is often encountered as numeric values distibuted over a regular space - sometimes volume data are called voxels data. Visualisation of this numeric data is key to the interpretation and/or appreciation of the data. For example:

An important method for the visualisation of volume data is to calculate an isosurface: a mesh surface that follows as closely as possible where the data crosses a certain level threshold.

This package includes an implementation of the Lorensen Marching Cubes isosurface calculation algorithm using only Python and NumPy methods: MarchingCubesLorensen.marching_cubes_lorensen(). The algorthimn follows these processes:

Example usage:

>>> import numpy
>>> volume = numpy.load("example_data/test_volume.npy")
>>> import MarchingNumPy
>>> vertices,triangles = MarchingNumPy.marching_cubes_lorensen(volume, level=0.05)
>>> vertices.shape
(4138, 3)
>>> triangles.shape
(8244, 3)

The image below - a molecular orbital of caffeine (pink and green wireframe) - was generated in Blender using the output of this function.

Molecular orbital wireframe for caffeine.

This volume data test_volume.npy is from the Cubefile package.


Documentation on Read The Docs

The MSHPro is low-cost hotplate stirrer.

MSH Pro Stirrer Hotplates

The hotplate has a RS232 9-pin connector on the rear that allows control of its functions. This package is a tool for control of these hotplates via serial interface.

This package is an interface to all commands provided by the Hotplates.MSHPro class.
Commands are avilable to get information and control the hotplate's speed and temperature.
All the formal communication structure is described by the Hotplates.MSHProCommunication module.

Example usage:

>>> import Hotplates
>>> hp = Hotplates.MSHPro(port="/dev/ttyUSB0")
>>> hp.status()
{'success': True, 'stir_set': 'Off', 'stir_actual': 0, 'heat_set': 'Off', 'heat_actual': 17.5, 'stir_on': False, 'heat_on': False, 'heat_limit': 340.0}
>>> hp.stir(400)  # Wait after command for hotplate to reach speed
>>> hp.status()
{'success': True, 'stir_set': 400, 'stir_actual': 399, 'heat_set': 'Off', 'heat_actual': 17.7, 'stir_on': True, 'heat_on': False, 'heat_limit': 340.0}
>>> hp.status()
{'success': True, 'stir_set': 'Off', 'stir_actual': 0, 'heat_set': 'Off', 'heat_actual': 1.1, 'stir_on': False, 'heat_on': False, 'heat_limit': 340.0}

Serial communication is full duplex and this is acheived using Hotplates.SerialThreadedDuplex.Serial, an extension of PySerial's serial.Serial.


Documentation on Read The Docs

.cube files are generated from quantum mechanical chemistry calculations. They contain data about the atoms of a molecule: their element, charge and position, as well as volume data from molecular orbital calculations - where you can expect to find electrons within a molecule.

This package is a tool for loading data into Python from a .cube file.
See MarchingNumPy for a method of converting this volume data to an isosurface.

Example usage:

>>> import Cubefile
>>> cf = Cubefile.Cubefile("_testfiles/caffeine_54.cube")
>>> cf.voxels.shape
(111, 98, 64)

The package includes some example .cube data calculated for caffeine that has been rendered as a point cloud below.

Molecular orbital pointcloud for caffeine.