plask.
Data
¶Data returned by field providers.
This class is returned by field providers and receivers and cointains the values of the computed field at specified mesh points. It can be passed to the field plotting and saving functions or even feeded to some receivers. Also, if the mesh is a rectangular one, the data can be converted into an multidimensional numpy array.
You may access the data by indexing the Data
object, where the
index always corresponds to the index of the mesh point where the particular
value is specified. Hence, you may also iterate Data
objects as
normal Python sequences.
You may construct the data object manually from a numpy array and a mesh. The constructor always take two argumentsa as specified below:
Parameters: 


Returns:  Data based on the specified mesh and array. 
Return type:  plask._Data 
Examples
To create the data from the flat sequential array:
>>> msh = plask.mesh.Rectangular2D([1, 2, 3], [10, 20])
>>> Data(array([1., 2., 3., 4., 5., 6.]), msh)
<plask.Data at 0x4698938>
As the msh
is a rectangular mesh, the data can be created from
a structured array with the shape (3, 2), as the first and second mesh
dimensions are 3 and 2, respectively:
>>> dat = Data(array([[1., 2.], [3., 4.], [5., 6.]]), msh)
>>> dat[0]
1.0
By adding one more dimension, you can create an array of vectors:
>>> d = Data(array([[[1.,0.], [2.,0.]], [[3.,0.], [4.,1.]],
... [[5.,1.], [6.,1.]]]), msh)
>>> d.dtype
plask.vec
>>> d[1]
plask.vec(2, 0)
>>> d.array[:,:,0] # retrieve first components of all the vectors
array([[1., 2.], [3., 4.], [5., 6.]])
Construction of the data objects is efficient i.e. no data is copied in the memory from the provided array.
interpolate (mesh, interpolation[, geometry]) 
Interpolate data to a different mesh. 
Data.
interpolate
(mesh, interpolation, geometry=None)¶Interpolate data to a different mesh.
This method interpolated data into a different mesh using specified interpolation method. This is exactly the same interpolation that is usually done by solvers in their providers.
Parameters: 


Returns:  Interpolated data. 
Return type:  plask._Data 
Data.
array
¶Array formatted by the mesh.
This attribute is available only if the :attr:~plask.Data.mesh` is a rectangular one. It
contains the held data reshaped to match the shape of the mesh (i.e. the first
dimension is equal the size of the first mesh axis and so on). If the data type
is plask.vec
then the array has one additional dimention equal to 2 for
2D vectors and 3 for 3D vectors. The vector components are stored in this
dimention.
Example
>>> msh = plask.mesh.Rectangular2D(plask.mesh.Rectilinear([1, 2]),
... plask.mesh.Rectilinear([10, 20]))
>>> dat = Data(array([[[1., 0.], [2., 0.]], [[3., 1.], [4., 1.]]]), msh)
>>> dat.array[:,:,0]
array([[1., 2.],
[3., 4.]])
Accessing this field is efficient, as only the numpy array view is created and no data is copied in the memory.
Data.
mesh
¶The mesh at which the data was obtained.
The sequential points of this mesh always correspond to the sequential points of
the data. This implies that len(data.mesh) == len(data)
is always True.