@@ -324,11 +324,11 @@ def __init__(self):
324324 self .deformed_control_points = None
325325
326326
327- def read_parameters (self , filename = 'parameters .prm' ):
327+ def read_parameters (self , filename = 'parameters_rbf .prm' ):
328328 """
329329 Reads in the parameters file and fill the self structure.
330330
331- :param string filename: parameters file to be read in.
331+ :param string filename: parameters file to be read in. Default value is parameters_rbf.prm.
332332 """
333333 if not isinstance (filename , basestring ):
334334 raise TypeError ('filename must be a string' )
@@ -344,7 +344,7 @@ def read_parameters(self, filename='parameters.prm'):
344344 0. , 1. , 1. , 1. , 0. , 1. , 1. , 1. , 0. , 1. , 1. , 1. ]).reshape ((8 , 3 ))
345345 self .deformed_control_points = np .array ([0. , 0. , 0. , 0. , 0. , 1. , 0. , 1. , 0. , 1. , 0. , 0. , \
346346 0. , 1. , 1. , 1. , 0. , 1. , 1. , 1. , 0. , 1. , 1. , 1. ]).reshape ((8 , 3 ))
347- # self.write_parameters(filename)
347+ self .write_parameters (filename )
348348 return
349349
350350 config = ConfigParser .RawConfigParser ()
@@ -374,6 +374,56 @@ def read_parameters(self, filename='parameters.prm'):
374374 self .deformed_control_points [i ] = np .array ([float (values [0 ]), float (values [1 ]), float (values [2 ])])
375375
376376
377+ def write_parameters (self , filename = 'parameters_rbf.prm' ):
378+ """
379+ This method writes a parameters file (.prm) called `filename` and fills it with all
380+ the parameters class members. Default value is parameters_rbf.prm.
381+
382+ :param string filename: parameters file to be written out.
383+ """
384+ if not isinstance (filename , basestring ):
385+ raise TypeError ("filename must be a string" )
386+
387+ with open (filename , 'w' ) as output_file :
388+ output_file .write ('\n [Radial Basis Functions]\n ' )
389+ output_file .write ('# This section describes the radial basis functions shape.\n ' )
390+
391+ output_file .write ('\n # basis funtion is the name of the basis functions to use in the transformation. ' + \
392+ 'The functions\n ' )
393+ output_file .write ('# implemented so far are: gaussian_spline, multi_quadratic_biharmonic_spline,\n ' )
394+ output_file .write ('# inv_multi_quadratic_biharmonic_spline, thin_plate_spline, beckert_wendland_c2_basis.\n ' )
395+ output_file .write ('# For a comprehensive list with details see the class RBF.\n ' )
396+ output_file .write ('basis function: ' + str (self .basis ) + '\n ' )
397+
398+ output_file .write ('\n # radius is the scaling parameter r that affects the shape of the basis functions. ' + \
399+ 'See the documentation\n ' )
400+ output_file .write ('# of the class RBF for details.\n ' )
401+ output_file .write ('radius: ' + str (self .radius ) + '\n ' )
402+
403+ output_file .write ('\n \n [Control points]\n ' )
404+ output_file .write ('# This section describes the RBF control points.\n ' )
405+
406+ output_file .write ('\n # original control points collects the coordinates of the interpolation ' + \
407+ 'control points before the deformation.\n ' )
408+ output_file .write ('original control points:' )
409+ offset = 1
410+ for i in range (0 , self .n_control_points ):
411+ output_file .write (offset * ' ' + str (self .original_control_points [i ][0 ]) + ' ' + \
412+ str (self .original_control_points [i ][1 ]) + ' ' + \
413+ str (self .original_control_points [i ][2 ]) + '\n ' )
414+ offset = 25
415+
416+ output_file .write ('\n # deformed control points collects the coordinates of the interpolation ' + \
417+ 'control points after the deformation.\n ' )
418+ output_file .write ('deformed control points:' )
419+ offset = 1
420+ for i in range (0 , self .n_control_points ):
421+ output_file .write (offset * ' ' + str (self .deformed_control_points [i ][0 ]) + ' ' + \
422+ str (self .deformed_control_points [i ][1 ]) + ' ' + \
423+ str (self .deformed_control_points [i ][2 ]) + '\n ' )
424+ offset = 25
425+
426+
377427 def print_info (self ):
378428 """
379429 This method prints all the RBF parameters on the screen. Its purpose is for debugging.
0 commit comments