DAMASK_EICMD/python/tests/resources/Rotation/Visualize_hybridIA_sampling...

277 lines
8.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import damask\n",
"\n",
"from pathlib import Path"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"orientations,rODF = damask.Rotation.from_ODF('hybridIA_ODF.txt',\n",
" 2**14,\n",
" degrees=True,\n",
" reconstruct=True,\n",
" fractions=True,\n",
" seed=0)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"VTK = damask.VTK.from_rectilinearGrid([36,36,36],[90,90,90])\n",
"VTK.add(damask.Table.from_ASCII('hybridIA_ODF.txt').get('intensity'),'intensity')\n",
"VTK.add(rODF.flatten(order='F'),'rODF')\n",
"VTK.to_file('hybridIA_ODF.vtr')"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on class VTK in module damask._vtk:\n",
"\n",
"class VTK(builtins.object)\n",
" | VTK(geom)\n",
" | \n",
" | Spatial visualization (and potentially manipulation).\n",
" | \n",
" | High-level interface to VTK.\n",
" | \n",
" | Methods defined here:\n",
" | \n",
" | __init__(self, geom)\n",
" | Set geometry and topology.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | geom : subclass of vtk.vtkDataSet\n",
" | Description of geometry and topology. Valid types are vtk.vtkRectilinearGrid,\n",
" | vtk.vtkUnstructuredGrid, or vtk.vtkPolyData.\n",
" | \n",
" | __repr__(self)\n",
" | ASCII representation of the VTK data.\n",
" | \n",
" | add(self, data, label=None)\n",
" | Add data to either cells or points.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | data : numpy.ndarray\n",
" | Data to add. First dimension need to match either\n",
" | number of cells or number of points\n",
" | label : str\n",
" | Data label.\n",
" | \n",
" | add_comments(self, comments)\n",
" | Add Comments.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | comments : str or list of str\n",
" | Comments to add.\n",
" | \n",
" | get(self, label)\n",
" | Get either cell or point data.\n",
" | \n",
" | Cell data takes precedence over point data, i.e. this\n",
" | function assumes that labels are unique among cell and\n",
" | point data.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | label : str\n",
" | Data label.\n",
" | \n",
" | get_comments(self)\n",
" | Return the comments.\n",
" | \n",
" | set_comments(self, comments)\n",
" | Set Comments.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | comments : str or list of str\n",
" | Comments.\n",
" | \n",
" | show(self)\n",
" | Render.\n",
" | \n",
" | See http://compilatrix.com/article/vtk-1 for further ideas.\n",
" | \n",
" | write(self, fname, parallel=True)\n",
" | Write to file.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | fname : str or pathlib.Path\n",
" | Filename for writing.\n",
" | parallel : boolean, optional\n",
" | Write data in parallel background process. Defaults to True.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Static methods defined here:\n",
" | \n",
" | from_file(fname, dataset_type=None)\n",
" | Create VTK from file.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | fname : str or pathlib.Path\n",
" | Filename for reading. Valid extensions are .vtr, .vtu, .vtp, and .vtk.\n",
" | dataset_type : str, optional\n",
" | Name of the vtk.vtkDataSet subclass when opening an .vtk file. Valid types are vtkRectilinearGrid,\n",
" | vtkUnstructuredGrid, and vtkPolyData.\n",
" | \n",
" | from_polyData(points)\n",
" | Create VTK of type vtk.polyData.\n",
" | \n",
" | This is the common type for point-wise data.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | points : numpy.ndarray of shape (:,3)\n",
" | Spatial position of the points.\n",
" | \n",
" | from_rectilinearGrid(grid, size, origin=array([0., 0., 0.]))\n",
" | Create VTK of type vtk.vtkRectilinearGrid.\n",
" | \n",
" | This is the common type for results from the grid solver.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | grid : numpy.ndarray of shape (3) of np.dtype = int\n",
" | Number of cells.\n",
" | size : numpy.ndarray of shape (3)\n",
" | Physical length.\n",
" | origin : numpy.ndarray of shape (3), optional\n",
" | Spatial origin.\n",
" | \n",
" | from_unstructuredGrid(nodes, connectivity, cell_type)\n",
" | Create VTK of type vtk.vtkUnstructuredGrid.\n",
" | \n",
" | This is the common type for results from FEM solvers.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | nodes : numpy.ndarray of shape (:,3)\n",
" | Spatial position of the nodes.\n",
" | connectivity : numpy.ndarray of np.dtype = int\n",
" | Cell connectivity (0-based), first dimension determines #Cells, second dimension determines #Nodes/Cell.\n",
" | cell_type : str\n",
" | Name of the vtk.vtkCell subclass. Tested for TRIANGLE, QUAD, TETRA, and HEXAHEDRON.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data descriptors defined here:\n",
" | \n",
" | __dict__\n",
" | dictionary for instance variables (if defined)\n",
" | \n",
" | __weakref__\n",
" | list of weak references to the object (if defined)\n",
"\n"
]
}
],
"source": [
"help(damask.VTK)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"a,b=np.radians(([90,90],[45,45]))"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1.57079633, 1.57079633])"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.78539816, 0.78539816])"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}