@@ -290,16 +290,15 @@ def _read_result_header(self):
290290 return resultheader
291291
292292 def parse_coordinate_system (self ):
293- """Reads in coordinate system information from a binary result
294- file.
293+ """Reads in coordinate system information from a binary result file.
295294
296295 Returns
297296 -------
298297 c_systems : dict
299- Dictionary containing one entry for each defined
300- coordinate system. If no non-standard coordinate systems
301- have been defined, there will be only one None. First
302- coordinate system is assumed to be global cartesian.
298+ Dictionary containing one entry for each defined coordinate system.
299+ If no non-standard coordinate systems have been defined, an empty
300+ dictionary will be returned. First coordinate system is assumed to
301+ be global cartesian.
303302
304303 Notes
305304 -----
@@ -325,8 +324,9 @@ def parse_coordinate_system(self):
325324 - 1: Cylindrical (circular or elliptical)
326325 - 2: Spherical (or spheroidal)
327326 - 3: Toroidal
327+
328328 """
329- c_systems = [ None ]
329+ c_systems = {}
330330
331331 # load coordinate system index table
332332 ptr_csy = self ._geometry_header ["ptrCSY" ]
@@ -353,7 +353,7 @@ def parse_coordinate_system(self):
353353 # * Item 22 is the coordinate system reference number.
354354 for csys_record_pointer in csys_record_pointers :
355355 if not csys_record_pointer :
356- c_system = None
356+ continue
357357 else :
358358 data = self .read_record (ptr_csy + csys_record_pointer )
359359 c_system = {
@@ -365,11 +365,9 @@ def parse_coordinate_system(self):
365365 "theta singularity" : data [18 ],
366366 "phi singularity" : data [19 ],
367367 "type" : int (data [20 ]),
368- "reference num" : int (
369- data [21 ],
370- ),
368+ "reference num" : int (data [21 ]),
371369 }
372- c_systems . append ( c_system )
370+ c_systems [ c_system [ "reference num" ]] = c_system
373371
374372 return c_systems
375373
@@ -2882,8 +2880,48 @@ def plot_principal_nodal_stress(
28822880 )
28832881
28842882 def cs_4x4 (self , cs_cord , as_vtk_matrix = False ):
2885- """return a 4x4 transformation array for a given coordinate system"""
2886- # assemble 4 x 4 matrix
2883+ """Return a 4x4 transformation matrix for a given coordinate system.
2884+
2885+ Parameters
2886+ ----------
2887+ cs_cord : int
2888+ Coordinate system index.
2889+
2890+ as_vtk_matrix : bool, default: False
2891+ Return the transformation matrix as a ``vtkMatrix4x4``.
2892+
2893+ Returns
2894+ -------
2895+ np.ndarray | vtk.vtkMatrix4x4
2896+ Matrix or ``vtkMatrix4x4`` depending on the value of ``as_vtk_matrix``.
2897+
2898+ Notes
2899+ -----
2900+ Values 11 and greater correspond to local coordinate systems
2901+
2902+ Examples
2903+ --------
2904+ Return the transformation matrix for coordinate system 1.
2905+
2906+ >>> tmat = rst.cs_4x4(1)
2907+ >>> tmat
2908+ array([[1., 0., 0., 0.],
2909+ [0., 1., 0., 0.],
2910+ [0., 0., 1., 0.],
2911+ [0., 0., 0., 1.]])
2912+
2913+ Return the transformation matrix for coordinate system 5. This
2914+ corresponds to ``CSYS, 5``, the cylindrical with global Cartesian Y as
2915+ the axis of rotation.
2916+
2917+ >>> tmat = rst.cs_4x4(5)
2918+ >>> tmat
2919+ array([[ 1., 0., 0., 0.],
2920+ [ 0., 0., -1., 0.],
2921+ [ 0., 1., 0., 0.],
2922+ [ 0., 0., 0., 1.]])
2923+
2924+ """
28872925 csys = self ._c_systems [cs_cord ]
28882926 trans = np .hstack (
28892927 (csys ["transformation matrix" ], csys ["origin" ].reshape (- 1 , 1 ))
@@ -2892,7 +2930,6 @@ def cs_4x4(self, cs_cord, as_vtk_matrix=False):
28922930
28932931 if as_vtk_matrix :
28942932 return matrix
2895-
28962933 return pv .array_from_vtkmatrix (matrix )
28972934
28982935 def _plot_point_scalars (
0 commit comments