44
55import numpy as np
66
7+
78class AxisymmetricWall :
89 def __init__ (self , Rs , Zs ):
910 """
@@ -34,8 +35,9 @@ def __iter__(self):
3435
3536 These pairs define wall segment.
3637 """
37- return iter (zip (zip (self .Rs , self .Zs ),
38- zip (np .roll (self .Rs , - 1 ), np .roll (self .Zs , - 1 ))))
38+ return iter (
39+ zip (zip (self .Rs , self .Zs ), zip (np .roll (self .Rs , - 1 ), np .roll (self .Zs , - 1 )))
40+ )
3941
4042 def to_polygon (self ):
4143 """
@@ -45,7 +47,7 @@ def to_polygon(self):
4547 """
4648 return np .stack ((self .Rs , self .Zs ), axis = - 1 )
4749
48- def plot (self , linestyle = 'k-' , ax = None ):
50+ def plot (self , linestyle = "k-" , ax = None ):
4951 """
5052 Plot the wall on given axis. If no axis
5153 is given then a new figure is created.
@@ -64,6 +66,7 @@ def plot(self, linestyle='k-', ax = None):
6466 ax .plot (self .Rs , self .Zs , linestyle )
6567 return ax
6668
69+
6770def read_geqdsk (filehandle ):
6871 """
6972 Read wall geometry from a GEQDSK file.
@@ -86,31 +89,31 @@ def read_geqdsk(filehandle):
8689 return AxisymmetricWall (data ["rlim" ], data ["zlim" ])
8790
8891
89- def read_csv (filehandle , delimiter = ',' ):
92+ def read_csv (filehandle , delimiter = "," ):
9093 """
9194 Parameters
9295 ----------
9396
9497 filehandle: File handle
9598 Must contain two columns, for R and Z coordinates [meters]
96-
99+
97100 delimier : character
98101 A single character that separates fields
99102
100103 Notes:
101- - Uses the python `csv` module
104+ - Uses the python `csv` module
102105 """
103106 import csv
107+
104108 reader = csv .reader (filehandle , delimiter = delimiter )
105109 Rs = []
106110 Zs = []
107111 for row in reader :
108112 if len (row ) == 0 :
109- continue # Skip empty rows
113+ continue # Skip empty rows
110114 if len (row ) != 2 :
111115 raise ValueError (f"CSV row should contain two columns: { row } " )
112116 Rs .append (float (row [0 ]))
113117 Zs .append (float (row [1 ]))
114118
115119 return AxisymmetricWall (Rs , Zs )
116-
0 commit comments