Exa Analytics Framework¶
An ecosystem for data processing, analytics, and visualization.
This package provides a framework for building packages tailored to specific industry or academic applications. Data objects, such as arrays and matrices are organized into “containers”. Containers provide methods for manipulating, processing, organizing, analyzing, and visualizing their data. The package is built with minimal external dependencies, on top of established open-source software, and uses the Jupyter notebook environment for interactive data exploration.
Exa¶
This package creates a systematic infrastructure for an ecosystem of packages, tailored to specific industry or academic displines, for organizing, processing, analyzing, and visualizing data. It is built with minimal dependencies, leverages established open-source packages, is itself extensible, and is targeted at both industry and academic applications.
At a high level, data objects such as series or dataframes (i.e. pandas like objects) are organized into containers which track relationships between these objects and provide methods for computation, conversion to other formats, analysis, and visualization within the Jupyter notebook environment.
Executables¶
Exa provides two executables; “exa” and “exw”. For the graphical user interface, built on top of the Jupyter notebook environment, run “exa” on the command line.
Installation¶
Python’s external libraries are maintained as packages in repositories. There are two main repositories, pypi and anaconda and two corresponding Python applications that interact with them (pip and conda respectively).
This project recommends using conda because it is both a package manager and a Python virtual environment manager. Anaconda also provides better cross platform support especially for Python packages that require compiled external dependences.
Pypi¶
Using pip...
# sudo apt-get install llvm-3.7 or sudo yum install ... etc.
sudo pip install numba exa
CUDA¶
If working on a system with CUDA supported Nvidia GPUs...
conda install cudatoolkit # or via apt-get or yum etc.
Repository¶
Manually...
# install llvm, numba, cudatoolkit, and CPython3.x
git clone https://github.com/exa-analytics/exa
cd exa
pip install .
What’s Next?¶
- Users should check out the User Introduction
- Contributors should check out the Developer Introduction
- The API contains usage and extension examples, and developer notes
API¶
Configuration¶
This module generates the “~/.exa” directory where all databases, logs, notebooks, and data reside. This configuration may be altered by editing the items below:
- paths:
- data: Path to the data directory (default ~/.exa/data)
- notebooks: Path to the notebooks directory (default ~/.exa/notebooks)
- log:
- nlogs: Number of log files to rotate
- nbytes: Max log file size (in bytes)
- syslog: System log file path
- dblog: Database log file path (if necessary)
- level: Logging level, 0: normal, 1: extra info, 2: debug
- db:
- uri: String URI for database connection
- update: If 1, refresh static database data (e.g. unit conversions)
- js:
- update: If 1, update JavaScript notebook extensions
Warning
The configuration file (~/.exa/config) should only be altered when no exa notebooks are running (i.e. exa or any of its related packages are imported).
-
exa._config.
save
()[source]¶ Save the configuration file to disk on exit, resetting update flags.
Warning
This is a bit unsafe because we are not guarenteed to hit the updating function during execution (that is what well written tests are for - use mock), but it is advantageous in the case that multiple packages that use exa are running simultaneously.
Exceptions¶
All base level exceptions are defined here.
Logging¶
There are two log files that exa writes to, the system log and the database log. The database log is used when the database backend does not provide its own logging solution.
- Levels:
- 0: default (>= WARNING messages are logged)
- 1: info (>= INFO messages are logged)
- 2: debug (all messages are logged)
Editor¶
Text-editor-like functionality for programatically manipulating raw text input and output data and converting this data into container objects. This class does not behave like a fully fledged text editor but does have some basic find, replace, insert, etc. functionality.
-
class
exa.editor.
Editor
(path_stream_or_string, as_interned=False, nprint=30, name=None, description=None, meta={})[source]¶ An editor is a representation of a text file on disk that can be programmatically manipulated.
Text lines are stored in memory; no files remain open. This class does not strive to be a fully fledged text editor rather a base class for converting input and output data from text on disk to some type of (exa framework) container object (and vice versa).
>>> template = "Hello World!\nHello {user}" >>> editor = Editor(template) >>> editor[0] 'Hello World!' >>> len(editor) 2 >>> del editor[0] >>> len(editor) 1 >>> editor.write(fullpath=None, user='Alice') Hello Alice
- Tip:
- Editor line numbers use a 0 base index. To increase the number of lines displayed by the repr, increase the value of the nprint attribute.
Warning
For large text with repeating strings be sure to use the as_interned argument.
-
name
¶ str
Data/file/misc name
-
description
¶ str
Data/file/misc description
-
meta
¶ dict
Additional metadata as key, value pairs
-
nrpint
¶ int
Number of lines to display when printing
-
cursor
¶ int
Line number position of the cusor (see
find_next_any()
andfind_next_string()
)
-
write
(path=None, *args, **kwargs)[source]¶ Perform formatting and write the formatted string to a file or stdout.
Optional arguments can be used to format the editor’s contents. If no file path is given, prints to standard output.
Parameters: - path (str) – Full file path (default None, prints to stdout)
- *args – Positional arguments to format the editor with
- **kwargs – Keyword arguments to format the editor with
-
format
(*args, inplace=False, **kwargs)[source]¶ Format the string representation of the editor.
Parameters: inplace (bool) – If True, overwrite editor’s contents with formatted contents
-
append
(lines)[source]¶ Parameters: lines (list) – List of line strings to append to the end of the editor
-
prepend
(lines)[source]¶ Parameters: lines (list) – List of line strings to insert at the beginning of the editor
-
insert
(lines={})[source]¶ Insert lines into the editor.
Note
To insert before the first line, use
preappend()
(or key 0); to insert after the last line useappend()
.Parameters: lines (dict) – Dictionary of lines of form (lineno, string) pairs
-
delete_lines
(lines)[source]¶ Delete all lines with given line numbers.
Parameters: lines (list) – List of integers corresponding to line numbers to delete
-
find
(*strings)[source]¶ Search the entire editor for lines that match the string.
Parameters: *strings – Any number of strings to search for Returns: results (dict) – Dictionary of string key, line values.
-
find_next
(string)[source]¶ From the editor’s current cursor position find the next instance of the given string.
Parameters: Returns: tup (tuple) – Tuple of cursor position and line or None if not found
Note
This function cycles the entire editor (i.e. cursor to length of editor to zero and back to cursor position).
-
regex
(*patterns, line=False)[source]¶ Search the editor for lines matching the regular expression.
Parameters: - *patterns – Regular expressions to search each line for
- line (bool) – Return the whole line or the matched groups (groups default)
Returns: results (dict) – Dictionary of pattern keys, line values (or groups - default)
-
replace
(pattern, replacement)[source]¶ Replace all instances of a pattern with a replacement.
Parameters:
-
pandas_dataframe
(start, stop, ncol)[source]¶ Returns the result of tab-separated pandas.read_csv on a subset of the file.
Parameters: Returns: pd.DataFrame – structured data
-
variables
¶ Display a list of templatable variables present in the file.
Templating is accomplished by creating a bracketed object in the same way that Python performs string formatting. The editor is able to replace the placeholder value of the template. Integer templates are positional arguments.
-
exa.editor.
lines_from_file
(path, as_interned=False)[source]¶ Create a list of file lines from a given filepath.
Parameters: Returns: strings (list) – File line list
Trait Supporting Data Objects¶
The DataFrame
is an extension of the
DataFrame
object. It provides additional methods for creating
traits.
Note
For further information on traits, see widget
.
Additionally, DataFrame
and related objects (e.g
Field
) provide attributes for defining their index and
column names. This has the effect of creating relationships between different
dataframes. They can be grouped into three types:
- index name (df1) matches index name (df2)
- index name (df1) matches column name (df2)
- column name (df1) matches column name (df2)
Note
These types correspond to one to one, one to many, and many to many relational types, respectively.
Finally, the objects contained in this module provide convenience methods for handling categorical data.
See also
For information about traits and how they allow enable dynamic visualizations
see widget
. For usage of numerical objects see container
.
-
class
exa.numerical.
Numerical
[source]¶ Base class for
Series
,DataFrame
, andField
objects, providing default trait functionality, shortened string representation, and in memory copying support.
-
class
exa.numerical.
Series
(*args, **kwargs)[source]¶ Trait supporting analogue of
Series
.import numpy as np class MySeries(Series): """Example usage of the exa.Series object.""" _sname = 'data' _iname = 'data_index' _precision = 2 s = MySeries(np.random.rand(10**5)) traits = s._update_traits() type(traits) # dict containing "myseries_values" as a Unicode trait
-
class
exa.numerical.
Field
(*args, field_values=None, **kwargs)[source]¶ A field is composed of the field definition (“field_data”) and values ( “field_values”). Field data define the shape and discretization of a field. Field values are scalar magnitudes (or vectors) that describe the field at each discretized point in space.
-
class
exa.numerical.
Field3D
(*args, field_values=None, **kwargs)[source]¶ Dataframe for storing dimensions of a scalar or vector field of 3D space.
Column Type Description nx int number of grid points in x ny int number of grid points in y nz int number of grid points in z ox float field origin point in x oy float field origin point in y oz float field origin point in z xi float First component in x xj float Second component in x xk float Third component in x yi float First component in y yj float Second component in y yk float Third component in y zi float First component in z zj float Second component in z zk float Third component in z Note
Each field should be flattened into an N x 1 (scalar) or N x 3 (vector) series or dataframe respectively. The orientation of the flattening should have x as the outer loop and z values as the inner loop (for both cases). This is sometimes called C-major order, C-style order, and has the last index changing the fastest and the first index changing the slowest.
See also
Container¶
The BaseContainer
class is the primary object for
data processing, analysis, and visualization. Containers are composed of
n-dimensional spreadsheet-like (see numerical
) objects whose
columns contain data for 2D and 3D visualization.
The BaseContainer
is akin to a HDFStore
in that it is a container for dataframes (and saves to an HDF5 file). It is
different in that it provides visualization tools access to the data contained
via automated JSON strings, transferrable between languages.
See also
container
and widget
-
class
exa.container.
Container
(name=None, description=None, meta=None, **kwargs)[source]¶ Container class responsible for all features related to data management.
-
concat
(*args, **kwargs)[source]¶ Concatenate any number of container objects with the current object into a single container object.
See also
For argument description, see
concat()
.
-
slice_by_indices
(key)[source]¶ Slice the container by series or dataframe index.
Warning
Does not make a copy, must call the .copy() method on the resulting container if a copy is needed.
-
slice_by_cardinal_axis
(key)[source]¶ Slice the container according to its cardinal axis.
See also
Note the warning in
slice_by_indices()
.
-
info
()[source]¶ Display information about the container’s objects.
Note
Sizes are reported in bytes.
-
network
()[source]¶ Display information about the container’s object relationships.
Note
Due to quirks of plotting, rerunning this command until a “pleasing” visual is generated may be useful.
-
-
class
exa.container.
TypedMeta
[source]¶ This metaclass creates statically typed class attributes using the property framework.
class TestMeta(TypedMeta): attr1 = (int, float) attr2 = DataFrame class TestClass(metaclass=TestMeta): def __init__(self, attr1, attr2): self.attr1 = attr1 self.attr2 = attr2
The above code dynamically creates code that looks like the following:
class TestClass: @property def attr1(self): return self._attr1 @attr1.setter def attr1(self, obj): if not isinstance(obj, (int, float)): raise TypeError('attr1 must be int') self._attr1 = obj @attr1.deleter def attr1(self): del self._attr1 @property def attr2(self): return self._attr2 @attr2.setter def attr2(self, obj): if not isinstance(obj, DataFrame): raise TypeError('attr2 must be DataFrame') self._attr2 = obj @attr2.deleter def attr2(self): del self._attr2 def __init__(self, attr1, attr2): self.attr1 = attr1 self.attr2 = attr2
-
static
create_property
(name, ptype)[source]¶ Creates a custom property with a getter that performs computing functionality (if available) and raise a type error if setting with the wrong type.
Note
By default, the setter attempts to convert the object to the correct type; a type error is raised if this fails.
-
static
Widget¶
Functionality for using Jupyter notebook extensions to visualize data speficic containers. This module requires the infrastructure provided by the traitlets and ipywidgets packages.
-
class
exa.widget.
Widget
(*pargs, **kwargs)[source]¶ Base widget class for Jupyter notebook widgets provided by exa. Standardizes bidirectional communication handling between notebook extensions’ frontend JavaScript and backend Python.
-
class
exa.widget.
ContainerWidget
(container, *args, **kwargs)[source]¶ Jupyter notebook widget representation of an exa Container. The widget accepts a (reference to a) container and parameters and creates a suitable display. By default a container displays an interactive graphic containing information provided by
info()
andnetwork()
.See also
container
,container
Matplotlib Utilities¶
TeX Utilities¶
Utilities¶
Commonly used functions (primarily for convenience and repetition reduction).
-
exa.utility.
datetime_header
(title='')[source]¶ Creates a simple header string containing the current date/time stamp delimited using “=”.
-
exa.utility.
mkp
(*args, mk=False)[source]¶ Generate a directory path, and create it if requested.
filepath = mkp('base', 'folder', 'file') dirpath = mkp('root', 'path', 'folder', mk=True)
Parameters: - *args – File or directory path segments to be concatenated
- mk (bool) – Make the directory (if it doesn’t exist)
Returns: path (str) – File or directory path
Tester¶
Custom tester class for running interactive (i.e. within the Jupyter notebook environment) tests.
-
class
exa.test.tester.
UnitTester
(methodName='runTest')[source]¶ The custom tester class which provides an alternative test runner.
Basic Tests¶
Tests for _config
, log
, and the suite of modules in the
test subpackage, tester
, etc.
-
class
exa.test.test_base.
TestConfig
(methodName='runTest')[source]¶ Tests for
_config
.-
test_type
()[source]¶ Check that the config is a
ConfigParser
object.
-
Relational¶
This (sub)package is provides the content management framework for container objects and a collection of static data for reference and unit conversions.
-
exa.relational.__init__.
load_isotope_data
()[source]¶ Load isotope data into the database (replacing existing).
Database Engine Configuration¶
This module provides the base classes and metaclasses for relational tables created by exa. It also provides the database engine configuration and session class factory.
-
class
exa.relational.base.
BaseMeta
(classname, bases, dict_)[source]¶ This is the base metaclass for all relational tables. It provides convient lookup methods, bulk insert methods, and conversions to other formats.
-
bulk_insert
(mappings)[source]¶ Perform a bulk insert into a specific table.
mappings = [{'column1': 'foo', 'column2': 42, 'column3': 'bar'}, {'column1': 'fop', 'column2': 43, 'column3': 'baz'}] Table.bulk_insert(mappings)
-
Project Table¶
A project represents a continuous or finite study of a subject matter. It is the highest level of categorical organization for the content management system.
Job Table¶
A job is a single experiment, typically resulting in a number of “raw” data files (inputs and outputs) that can be represented in memory by a single container. Since this is not always the case, jobs have a many to many relationship with container files.
File Tables¶
There are two types of file tables, one for “raw” data files (those coming from third party software for example) and container objects on disk (stored as HDF5 files). Because a container is typically comprised of multiple raw data files, there is a many to many relationship between raw data files and container files.
Table of Isotopes¶
This module provides an interface for interacting with isotopes of atoms; the extended periodic table. For convenience, functions are provided for obtaining traditionally used elements. This module also provides mappers for commonly used dataframe manipulations.
-
class
exa.relational.isotope.
Meta
(classname, bases, dict_)[source]¶ Provides lookup methods for
Isotope
.Isotope['1H'] # Returns
-
class
exa.relational.isotope.
Isotope
(**kwargs)[source]¶ A variant of a chemical element with a specific proton and neutron count.
>>> h = Isotope['1H'] >>> h.A 1 >>> h.Z 1 >>> h.mass 1.0078250321 >>> Isotope['C'] [8C, 9C, 10C, 11C, 12C, 13C, 14C, 15C, 16C, 17C, 18C, 19C, 20C, 21C, 22C] >>> Isotope['13C'].szuid 175 >>> c = Isotope[57] >>> c.A 13 >>> c.Z 6 >>> c.strid '13C'
-
exa.relational.isotope.
symbol_to_z
()[source]¶ Create a “mapper” (
Series
) from element symbol to proton number (“Z”). This object can be used to quickly transform element symbols to proton number via:mapper = symbol_to_z() z_series = symbol_series.map(mapper)
-
exa.relational.isotope.
z_to_symbol
()[source]¶ Create a mapper from proton number to element symbol.
See also
Opposite mapper of
symbol_to_z()
.
Physical Constants¶
Table of reference physical constants in SI units.
Unit Conversions¶
This module provides relational classes for unit conversion tables.
-
class
exa.relational.unit.
Meta
(classname, bases, dict_)[source]¶ Special metaclass for unit objects supporting aliases. Aliases are alternative names for standard symbols for units.
-
class
exa.relational.unit.
Dimension
[source]¶ Descriptive class for units.
-
from_unit
¶ str
Unit to convert from
-
to_unit
¶ str
Unit to convert to
-
factor
¶ float
Conversion factor
-
-
class
exa.relational.unit.
Length
(**kwargs)[source]¶ >>> Length['angstrom', 'au'] 1.88971616463 >>> Length['A', 'au'] 1.88971616463 >>> Length['A', 'a0'] 1.88971616463
-
class
exa.relational.unit.
Mass
(**kwargs)[source]¶ >>> Mass['kg', 'lb'] 2.2046226218 >>> Mass['Da', 'kg'] 1.660538921000011e-27 >>> Mass['u', 'kg'] 1.660538921000011e-27
-
class
exa.relational.unit.
Time
(**kwargs)[source]¶ >>> Time['min', 's'] 60.0000000000024 >>> Time['hr', 's'] 3599.999712000023 >>> Time['weeks', 'days'] 6.999999999955003
-
class
exa.relational.unit.
Current
(**kwargs)[source]¶ >>> Current['A', 'C_s'] 1.0 >>> Current['A', 'Bi'] 0.1
-
class
exa.relational.unit.
Amount
(**kwargs)[source]¶ >>> Amount['gmol', 'mol'] 1.0 >>> Amount['lbmol', 'mol'] 453.5923744952991
-
class
exa.relational.unit.
Luminosity
(**kwargs)[source]¶ >>> Luminosity['cp', 'cd'] 0.9810000000433602
-
class
exa.relational.unit.
Dose
(**kwargs)[source]¶ >>> Dose['Gy', 'rd'] 100.0 >>> Dose['J_kg', 'rd'] 100.0
-
class
exa.relational.unit.
Acceleration
(**kwargs)[source]¶ >>> Acceleration['m_s2', 'cm_s2'] 100.0 >>> Acceleration['m_s2', 'stdgrav'] 0.10197162130000001
Tests for isotope
¶
Distributed¶
Provides the Workflow
class which systematizes
remote and distributed computing.
Workflow¶
Math¶
Discrete and symbolic mathematical functions and algorithms. Many of the modules in this sub-package attempt to compile Python source code down to machine code (for CPU and GPU instruction as available).
Note
If a module compiles its functions to machine code, access to original (typically numpy supporting) functions is done via the same function name with a leading underscore. CUDA compiled functions have a trailing “_cuda”.
See also
Warning
Performance is guarenteed if numba is installed. If it is missing, performance will be affected and distributed/parallel computing features will not be available.
Tests for Math Modules¶
Cartesian Vector Operations¶
This module provides common operations for vectors in cartesian space:
Repeat¶
Functions for repeating arrays of varying dimensions.
Summations¶
Fast algorithms for various types of (commonly used) summations.
Tests for summation
¶
-
class
exa.math.misc.test.test_summation.
TestSumProductPair
(methodName='runTest')[source]¶ Tests for all functions name sum_product_pair*
-
test_sum_product_pair
()[source]¶ Test
sum_product_pair()
. This function should work regardless of types.
-
test_sum_product_pair_f8
()[source]¶ Test
sum_product_pair_f8()
. This function only works on 64-bit floating point numbers.
-
Filetypes¶
Editors for common file types.
Generic CSV Support¶
Provides an editor with convenience methods tailored specifically for comma separated value (CSV) files.
Frontend Container¶
================= container.js ================= JavaScript “frontend” counterpart of exa’s Container object for use within the Jupyter notebook interface. This “module” standardizes bidirectional communication logic for all container widget views.
The structure of the frontend is to generate an HTML widget (“container” - see create_container) and then populate its canvas with an application (“app”) appropriate to the type of container. If the (backend) container is empty, then populate the HTML widget with the test application. If the container is not empty but doesn’t have a dedicated application, the info application (info.js) is used.
ContainerView¶
Base view for creating data specific container widgets used within the Jupyter notebook. All logic related to communication (between Python and JavaScript) should be located here. This class provides a number of commonly used functions for such logic.
- Warning:
- Do not override the DOMWidgetView constructor (“initialize”).
render¶
Main entry point (called immediately after initialize) for (ipywidgets) DOMWidgetView objects.
- Note:
- This function can be overwritten by container specific code, but it is more common to overwrite the init function.
- See Also:
- init()
init¶
Container view classes that extend this class can overwrite this method to customize the behavior of their data specific view.
get_trait¶
Wrapper around the DOMWidgetView (Backbone.js) “model.get” function, that attempts to convert JSON strings to objects.
set_trait¶
Wrapper around the DOMWidgetView “model.set” function to correctly set json strings.
if_empty¶
If the (exa) container object is empty, render the test application widget.
default_listeners¶
Set up listeners for basic variables related to the window dimensions and system settings.
create_container¶
Create a resizable container.
create_canvas¶
Create a canvas for WebGL.
Applications¶
================ info.js ================ The default container view; displays container information (number of data objects, size, and relationships) in a dynamic fashion.
============= test.js ============= A test application called when an empty container widget is rendered in a Jupyter notebook environment.
Third Party Library Support¶
3D Visualization¶
App3D¶
A 3D visualization application built on top of threejs
test_mesh¶
Example of a render
render¶
Render the 3D application
animate¶
Start the animation.
resize¶
Resizing of the renderer and controls
remove_meshes¶
Iterates over the meshes and removes each from the scene.
add_points¶
Create a point cloud from x, y, z coordinates and colors and radii (optional).
- Args:
- x (array-like): Array like object of x values y (array-like): Array like object of y values z (array-like): Array like object of z values colors (object): List like colors corresponding to every object radii (object): List like radii corresponding to every object
- Returns:
- points (THREE.Points): Reference to added points object
- Tip:
- By tracking the returned object, one can create animations.
- Warning:
- On a modern machine attempting to render >5 million (approximately) objects can cause a slowdown of the browser and framerate of the application.
add_spheres¶
Create a point cloud from x, y, z coordinates and colors and radii (optional).
- Args:
- x (array-like): Array like object of x values y (array-like): Array like object of y values z (array-like): Array like object of z values colors (object): List like colors corresponding to every object radii (object): List like radii corresponding to every object
- Returns:
- spheres (list): List of THREE.Mesh objects
add_lines¶
Add lines between pairs of points.
- Args:
- v0 (array): Array of first vertex in pair v1 (array): Array of second vertex x (array): Position in x of vertices y (array): Position in y of vertices z (array): Position in z of vertices colors (array): Colors of vertices
- Returns:
- linesegs (THREE.LineSegments): Line segment objects
add_lines¶
Add lines between pairs of points.
- Args:
- v0 (array): Array of first vertex in pair v1 (array): Array of second vertex x (array): Position in x of vertices y (array): Position in y of vertices z (array): Position in z of vertices colors (array): Colors of vertices
- Returns:
- linesegs (THREE.LineSegments): Line segment objects
add_wireframe¶
Create a wireframe object
flatten_color¶
set_camera¶
Set the camera in the default position and have it look at the origin.
- Args:
- kwargs: {‘x’: x, ‘y’: y, ..., ‘ox’: ox, ...}
set_camera_from_scene¶
add_scalar_field¶
Create an isosurface of a scalar field.
When given a scalar field, creating a surface requires selecting a set of vertices that intersect the provided field magnitude (isovalue). There are a couple of algorithms that do this.
add_unit_axis¶
Adds a unit length coordinate axis at the origin
march_cubes1¶
Run the marching cubes algorithm finding the volumetric shell that is smaller than the isovalue.
The marching cubes algorithm takes a scalar field and for each field vertex looks at the nearest indices (in an evenly space field this forms a cube), determines along what edges the scalar field is less than the isovalue, and creates new vertices along the edges of the field’s cube. The at each point in the field, a cube is created with vertices numbered:
4——-5/ | / |
7——-6 | | 0—-|–1 | / | / 3——-2
Field values are given for each field vertex. Edges are labeled as follows (see the lookup table below).
4o——-o o——-o
/ | / | 7 / | 6 / | 5
o——-o | o——-o | | o—-|–o | o—-|–o
- 3 | / 0 | / 1 | / | /
- o——-o o——-o
- 2
Edges 8, 9, 10, and 11 wrap around (clockwise looking from the top as drawn) the vertical edges of the cube, with 8 being the vertical edge between vertex 0 and 4 (see above).
- Note:
- Scalar fields are assumed to be in row major order (also known C style, and implies that the last index is changing the fastest).
- See Also:
- field.js
march_cubes2¶
Similar to the above but for finding positive and negative surfaces.
============ gui.js ============ Basic gui for container views.
ContainerGUI ===============
Misc.¶
field.js¶
This module provides infrastructure for storing and manipulating 3D fields. By standardizing how field data is stored, marching cubes (or other surface computing algorithms) are easier to work with.
Field¶
Base class for dealing with scalar and vector field data
- Args:
- dimensions: {‘ox’: ox, ‘nx’: nx, ‘dxi’: dxi, ‘dxj’: dxj, ‘dxk’: dxk,
- ‘oy’: oy, ‘ny’: ny, ‘dyi’: dyi, ‘dyj’: dyj, ‘dyk’: dyk, ‘oz’: oz, ‘nz’: nz, ‘dzi’: dzi, ‘dzj’: dzj, ‘dzk’: dzk}
- Note:
- The dimensions argument can alternatively be {‘x’: xarray, ‘y’: yarray, ‘z’: zarray} if they have already been constructed but in this case the arrays should form cubic discrete points
update¶
Updates the field after establishing new x, y, z arrays
ScalarField¶
Representation of a scalar field.
num.js¶
Numerical utilities
fac2¶
hstack¶
Horizontally concatenate a list of arrays.
minspace¶
Creates a linearly spaced array with knowledge of the length, origin and spacing of the array.
- Args:
- min (number): origin space (number): spacing n (number): length of array
linspace¶
Create a linearly spaced array of the form [min, max] with n linearly spaced elements.
- Args:
- min (number): Starting number max (number): Ending number (inclusive) n (number): Number of elements
- Returns:
- array (array): Array of values
arange¶
meshgrid3d¶
From three discrete dimensions, create a set of 3d gridpoints
ellipsoid¶
sphere¶
gen_array¶
Generates discrete spatial points in space. Used to generate x, y, z spatial values for the cube field. In most cases, for the x basis vector, dy and dz are zero (“cube-like”).
================ utility.js ================ Helper functions used by custom notebook JS.
flatten_to_array ================== Flattens an array-like object into a 1-D Float32Array object.
- Args:
- obj (object): Array like object to be flattened
create_float_array_xyz ========================== Create a 1D array from 3D data.
repeat_float ================== Repeat a value n times.
repeat_float ================== Repeat a value n times.
repeat_object ============== Repeat an object n time.
mapper ——–