viscid.field module¶
Fields are the basis of Viscid’s data abstration
Fields belong in grids, or by themselves as a result of a calculation.
They can belong to a Grid
as the result of a file load, or
by themselves as the result of a calculation. This module has some
convenience functions for creating fields similar to Numpy.
-
viscid.field.
arrays2field
(crd_arrs, dat_arr, name='NoName', center=None, crd_type=None, crd_names='xyzuvw')[source]¶ Turn arrays into fields so they can be used in viscid.plot, etc.
This is a convenience function that takes care of making coordnates and the like. If the default behavior doesn’t work for you, you’ll need to make your own coordnates and call
viscid.field.wrap_field()
.Parameters: - crd_arrs (list of ndarrays) – xyz list of ndarrays that describe the node centered coordnates of the field
- dat_arr (ndarray) – data with len(crd_arrs) or len(crd_arrs) + 1 dimensions
- name (str) – some name
- center (str, None) – If not None, translate field to this centering (node or cell)
-
viscid.field.
dat2field
(dat_arr, name='NoName', fldtype='scalar', center=None, layout='flat')[source]¶ Makes np.arange coordnate arrays and calls arrays2field
Parameters: - dat_arr (ndarray) – data
- name (str) – name of field
- fldtype (str, optional) – ‘scalar’ / ‘vector’
- center (str, None) – If not None, translate field to this centering (node or cell)
- layout (TYPE, optional) – Description
-
viscid.field.
full
(crds, fill_value, dtype='f8', name='NoName', center='cell', layout='flat', nr_comps=0, crd_type=None, crd_names='xyzuvw', **kwargs)[source]¶ Analogous to numpy.full
Parameters: - crds (Coordinates, list, or tuple) – Can be a coordinates
object. Can also be a list of ndarrays describing
coordinate arrays. Or, if it’s just a list or tuple of
integers, those integers are taken to be the nz,ny,nx shape
and the coordinates will be fill with
np.arange()
. - fill_value (number, None) – Initial value of array. None indicates uninitialized (i.e., numpy.empty)
- dtype (optional) – some way to describe numpy dtype of data
- name (str) – a way to refer to the field programatically
- center (str, optional) – cell or node, there really isn’t support for edge / face yet
- layout (str, optional) – how data is stored, is in “flat” or “interlaced” (interlaced == AOS)
- nr_comps (int, optional) – for vector fields, nr of components
- **kwargs – passed through to Field constructor
- crds (Coordinates, list, or tuple) – Can be a coordinates
object. Can also be a list of ndarrays describing
coordinate arrays. Or, if it’s just a list or tuple of
integers, those integers are taken to be the nz,ny,nx shape
and the coordinates will be fill with
-
viscid.field.
empty
(crds, dtype='f8', name='NoName', center='cell', layout='flat', nr_comps=0, **kwargs)[source]¶ Analogous to numpy.empty
Returns: new uninitialized Field
See Also:
full()
-
viscid.field.
zeros
(crds, dtype='f8', name='NoName', center='cell', layout='flat', nr_comps=0, **kwargs)[source]¶ Analogous to numpy.zeros
Returns: new Field
initialized to 0See Also:
full()
-
viscid.field.
ones
(crds, dtype='f8', name='NoName', center='cell', layout='flat', nr_comps=0, **kwargs)[source]¶ Analogous to numpy.ones
Returns: new Field
initialized to 1See Also:
full()
-
viscid.field.
full_like
(fld, fill_value, name='NoName', **kwargs)[source]¶ Analogous to numpy.full_like
Makes a new
Field
initialized to fill_value. Copies as much meta data as it can from fld.Parameters: - fld – field to get coordinates / metadata from
- fill_value (number, None) – initial value, or None to leave data uninitialized
- name – name for this field
- **kwargs – passed through to
Field
constructor
Returns: new
Field
-
viscid.field.
empty_like
(fld, **kwargs)[source]¶ Analogous to numpy.empty_like
Returns: new uninitialized Field
See Also:
full_like()
-
viscid.field.
zeros_like
(fld, **kwargs)[source]¶ Analogous to numpy.zeros_like
Returns: new Field
filled with zerosSee Also:
full_like()
-
viscid.field.
ones_like
(fld, **kwargs)[source]¶ Analogous to numpy.ones_like
Returns: new Field
filled with onesSee Also:
full_like()
-
viscid.field.
scalar_fields_to_vector
(fldlist, name='NoName', **kwargs)[source]¶ Convert scalar fields to a vector field
Parameters: - name (str) – name for the vector field
- fldlist – list of
ScalarField
- **kwargs – passed to
VectorField
constructor
Returns: A new
VectorField
.
-
viscid.field.
wrap_field
(data, crds, name='NoName', fldtype='scalar', center='node', **kwargs)[source]¶ Convenience script for wrapping ndarrays
Parameters: - data – Some data container, most likely a
numpy.ndarray
- crds (Coordinates) – coordinates that describe the shape / grid of the field
- fldtype (str) – ‘scalar’ / ‘Vector’
- name (str) – a way to refer to the field programatically
- **kwargs – passed through to
Field
constructor
Returns: A
Field
instance.- data – Some data container, most likely a