@@ -88,7 +88,9 @@ def read_parameters(self, filename='parameters_rbf.prm'):
8888 for line , i in zip (lines , list (range (0 , self .n_control_points ))):
8989 values = line .split ()
9090 self .original_control_points [i ] = np .array (
91- [float (values [0 ]), float (values [1 ]), float (values [2 ])])
91+ [float (values [0 ]),
92+ float (values [1 ]),
93+ float (values [2 ])])
9294
9395 mod_points = config .get ('Control points' , 'deformed control points' )
9496 lines = mod_points .split ('\n ' )
@@ -103,7 +105,9 @@ def read_parameters(self, filename='parameters_rbf.prm'):
103105 for line , i in zip (lines , list (range (0 , self .n_control_points ))):
104106 values = line .split ()
105107 self .deformed_control_points [i ] = np .array (
106- [float (values [0 ]), float (values [1 ]), float (values [2 ])])
108+ [float (values [0 ]),
109+ float (values [1 ]),
110+ float (values [2 ])])
107111
108112 def write_parameters (self , filename = 'parameters_rbf.prm' ):
109113 """
@@ -116,55 +120,63 @@ def write_parameters(self, filename='parameters_rbf.prm'):
116120 if not isinstance (filename , str ):
117121 raise TypeError ("filename must be a string" )
118122
119- with open (filename , 'w' ) as output_file :
120- output_file .write ('\n [Radial Basis Functions]\n ' )
121- output_file .write (
122- '# This section describes the radial basis functions shape.\n ' )
123-
124- output_file .write (
125- '\n # basis funtion is the name of the basis functions to use in the transformation. The functions\n ' )
126- output_file .write (
127- '# implemented so far are: gaussian_spline, multi_quadratic_biharmonic_spline,\n ' )
128- output_file .write (
129- '# inv_multi_quadratic_biharmonic_spline, thin_plate_spline, beckert_wendland_c2_basis, polyharmonic_spline.\n ' )
130- output_file .write (
131- '# For a comprehensive list with details see the class RBF.\n ' )
132- output_file .write ('basis function: ' + str (self .basis ) + '\n ' )
133-
134- output_file .write (
135- '\n # radius is the scaling parameter r that affects the shape of the basis functions. See the documentation\n ' )
136- output_file .write ('# of the class RBF for details.\n ' )
137- output_file .write ('radius: ' + str (self .radius ) + '\n ' )
138- output_file .write (
139- '\n # The power parameter k for polyharmonic spline' )
140- output_file .write ('\n # See the documentation for details\n ' )
141- output_file .write ('power: ' + str (self .power ) + '\n ' )
142-
143- output_file .write ('\n \n [Control points]\n ' )
144- output_file .write (
145- '# This section describes the RBF control points.\n ' )
146-
147- output_file .write (
148- '\n # original control points collects the coordinates of the interpolation control points before the deformation.\n ' )
149- output_file .write ('original control points:' )
150- offset = 1
151- for i in range (0 , self .n_control_points ):
152- output_file .write (offset * ' ' + str (
153- self .original_control_points [i ][0 ]) + ' ' + str (
154- self .original_control_points [i ][1 ]) + ' ' + str (
155- self .original_control_points [i ][2 ]) + '\n ' )
156- offset = 25
157-
158- output_file .write (
159- '\n # deformed control points collects the coordinates of the interpolation control points after the deformation.\n ' )
160- output_file .write ('deformed control points:' )
161- offset = 1
162- for i in range (0 , self .n_control_points ):
163- output_file .write (offset * ' ' + str (
164- self .deformed_control_points [i ][0 ]) + ' ' + str (
165- self .deformed_control_points [i ][1 ]) + ' ' + str (
166- self .deformed_control_points [i ][2 ]) + '\n ' )
167- offset = 25
123+ output_string = ""
124+ output_string += '\n [Radial Basis Functions]\n '
125+ output_string += '# This section describes the radial basis functions'
126+ output_string += ' shape.\n '
127+
128+ output_string += '\n # basis funtion is the name of the basis functions'
129+ output_string += ' to use in the transformation. The functions\n '
130+ output_string += '# implemented so far are: gaussian_spline,'
131+ output_string += ' multi_quadratic_biharmonic_spline,\n '
132+ output_string += '# inv_multi_quadratic_biharmonic_spline,'
133+ output_string += ' thin_plate_spline, beckert_wendland_c2_basis,'
134+ output_string += ' polyharmonic_spline.\n '
135+ output_string += '# For a comprehensive list with details see the'
136+ output_string += ' class RBF.\n '
137+ output_string += 'basis function: {}\n ' .format (str (self .basis ))
138+
139+ output_string += '\n # radius is the scaling parameter r that affects'
140+ output_string += ' the shape of the basis functions. See the'
141+ output_string += ' documentation\n '
142+ output_string += '# of the class RBF for details.\n '
143+ output_string += 'radius: {}\n ' .format (str (self .radius ))
144+
145+ output_string += '\n # The power parameter k for polyharmonic spline'
146+ output_string += '\n # See the documentation for details\n '
147+ output_string += 'power: {}\n ' .format (self .power )
148+
149+ output_string += '\n \n [Control points]\n '
150+ output_string += '# This section describes the RBF control points.\n '
151+
152+ output_string += '\n # original control points collects the coordinates'
153+ output_string += ' of the interpolation control points before the'
154+ output_string += ' deformation.\n '
155+
156+ output_string += 'original control points:'
157+ offset = 1
158+ for i in range (0 , self .n_control_points ):
159+ output_string += offset * ' ' + str (
160+ self .original_control_points [i ][0 ]) + ' ' + str (
161+ self .original_control_points [i ][1 ]) + ' ' + str (
162+ self .original_control_points [i ][2 ]) + '\n '
163+ offset = 25
164+
165+ output_string += '\n # deformed control points collects the coordinates'
166+ output_string += ' of the interpolation control points after the'
167+ output_string += ' deformation.\n '
168+
169+ output_string += 'deformed control points:'
170+ offset = 1
171+ for i in range (0 , self .n_control_points ):
172+ output_string += offset * ' ' + str (
173+ self .deformed_control_points [i ][0 ]) + ' ' + str (
174+ self .deformed_control_points [i ][1 ]) + ' ' + str (
175+ self .deformed_control_points [i ][2 ]) + '\n '
176+ offset = 25
177+
178+ with open (filename , 'w' ) as f :
179+ f .write (output_string )
168180
169181 def __str__ (self ):
170182 """
0 commit comments