Author: tlinnet
Date: Mon Oct 13 11:48:05 2014
New Revision: 26252
URL: http://svn.gna.org/viewcvs/relax?rev=26252&view=rev
Log:
When issuing dx.map() function with points, implemented the writing out of
parameter file, with associated calculated chi2 values.
Modified:
trunk/pipe_control/opendx.py
trunk/test_suite/system_tests/relax_disp.py
Modified: trunk/pipe_control/opendx.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/opendx.py?rev=26252&r1=26251&r2=26252&view=diff
==============================================================================
--- trunk/pipe_control/opendx.py (original)
+++ trunk/pipe_control/opendx.py Mon Oct 13 11:48:05 2014
@@ -172,7 +172,15 @@
## Generate the file with parameters and associated chi2 value.
if create_par_file:
- self.create_par_chi2()
+ self.create_par_chi2(file_prefix=self.file_prefix,
par_chi2_vals=self.par_chi2_vals)
+
+ ## Generate the file with parameters and associated chi2 value for
the points send to dx.
+ if self.num_points >= 1 and create_par_file:
+ # Calculate the parameter and associated chi2 values for the
points.
+ par_chi2_vals = self.calc_point_par_chi2()
+
+ ## Generate the file with parameters and associated chi2 value.
+ self.create_par_chi2(file_prefix=self.point_file,
par_chi2_vals=par_chi2_vals)
# Default the chi2 surface values, for Innermost, Inner, Middle
and Outer Isosurface.
if chi_surface == None:
@@ -197,6 +205,44 @@
write_point(file_prefix=self.point_file, dir=self.dir,
inc=self.inc, point=self.point, num_points=self.num_points,
bounds=self.bounds, N=self.n)
+ def calc_point_par_chi2(self):
+ """Function for chi2 value for the points."""
+
+ # Print out.
+ print("\nCalculate chi2 value for the point parameters.")
+
+ # Define nested listed, which holds parameter values and chi2
value.
+ par_chi2_vals = []
+
+ # Loop over the points.
+ for i in range(self.num_points):
+ i_point = self.point[i]
+
+ # Set the parameter values.
+ if self.spin_id:
+ value.set(val=i_point, param=self.params,
spin_id=self.spin_id, force=True)
+ else:
+ value.set(val=i_point, param=self.params, force=True)
+
+ # Calculate the function values.
+ if self.spin_id:
+ self.api.calculate(spin_id=self.spin_id, verbosity=0)
+ else:
+ self.api.calculate(verbosity=0)
+
+ # Get the minimisation statistics for the model.
+ if self.spin_id:
+ k, n, chi2 =
self.api.model_statistics(spin_id=self.spin_id)
+ else:
+ k, n, chi2 = self.api.model_statistics(model_info=0)
+
+ # Assign value to nested list.
+ par_chi2_vals.append([i, i_point[0], i_point[1], i_point[2],
chi2])
+
+ # Return list
+ return par_chi2_vals
+
+
def create_map(self):
"""Function for creating the map."""
@@ -213,24 +259,24 @@
map_file.close()
- def create_par_chi2(self):
+ def create_par_chi2(self, file_prefix, par_chi2_vals):
"""Function for creating file with parameters and the chi2
value."""
# Print out.
print("\nCreating the file with parameters and the chi2 value.")
# Open the file.
- par_file = open_write_file(file_name=self.file_prefix+'.par',
dir=self.dir, force=True)
+ par_file = open_write_file(file_name=file_prefix+'.par',
dir=self.dir, force=True)
# Copy the nested list to sort it.
- par_chi2_vals_sort = deepcopy(self.par_chi2_vals)
+ par_chi2_vals_sort = deepcopy(par_chi2_vals)
# Then sort the value.
par_chi2_vals_sort.sort(key=lambda values: values[4])
# Collect the data structure, which is a list of list of strings.
data = []
- for i, line in enumerate(self.par_chi2_vals):
+ for i, line in enumerate(par_chi2_vals):
line_sort = par_chi2_vals_sort[i]
# Convert values to strings.
Modified: trunk/test_suite/system_tests/relax_disp.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/relax_disp.py?rev=26252&r1=26251&r2=26252&view=diff
==============================================================================
--- trunk/test_suite/system_tests/relax_disp.py (original)
+++ trunk/test_suite/system_tests/relax_disp.py Mon Oct 13 11:48:05 2014
@@ -2789,23 +2789,27 @@
cur_model = model_analyse.replace(' ', '_')
file_name_map = "%s_map%s" % (cur_model, cur_spin_id.replace('#',
'_').replace(':', '_').replace('@', '_'))
file_name_point = "%s_point%s" % (cur_model, cur_spin_id
.replace('#', '_').replace(':', '_').replace('@', '_'))
- self.interpreter.dx.map(params=ds.dx_params, map_type='Iso3D',
spin_id=cur_spin_id, inc=ds.dx_inc, lower=None, upper=None, axis_incs=10,
file_prefix=file_name_map, dir=ds.resdir, point=[ds.dx_set_val,
ds.dx_clust_val], point_file=file_name_point)
+ self.interpreter.dx.map(params=ds.dx_params, map_type='Iso3D',
spin_id=cur_spin_id, inc=ds.dx_inc, lower=None, upper=None, axis_incs=10,
file_prefix=file_name_map, dir=ds.resdir, point=[ds.dx_set_val,
ds.dx_clust_val], point_file=file_name_point, create_par_file=True)
## Check for file creation
# Set filepaths.
map_cfg = ds.tmpdir+sep+file_name_map+".cfg"
map_net = ds.tmpdir+sep+file_name_map+".net"
map_general = ds.tmpdir+sep+file_name_map+".general"
+ map_par = get_file_path(file_name=file_name_map+".par",
dir=ds.tmpdir)
point_general = ds.tmpdir+sep+file_name_point+".general"
point_point = ds.tmpdir+sep+file_name_point
+ point_par = get_file_path(file_name=file_name_point+".par",
dir=ds.tmpdir)
# Test the files exists.
self.assert_(access(map_cfg, F_OK))
self.assert_(access(map_net, F_OK))
self.assert_(access(map_general, F_OK))
+ self.assert_(access(map_par, F_OK))
self.assert_(access(point_general, F_OK))
self.assert_(access(point_point, F_OK))
+ self.assert_(access(point_par, F_OK))
# Open the files for testing.
# Check the cfg file.
@@ -2902,6 +2906,18 @@
# Skip time point
#if i == 2:
# continue
+ self.assertEqual(res_file[i], lines[i])
+
+ print("\nChecking the dx point point par file.")
+ res_file = [
+ '# i dw pA kex chi2
i_sort dw_sort pA_sort kex_sort chi2_sort '+"\n",
+ '0 2.00000 0.99000 1000.00000 6185.84926 0
2.00000 0.99000 1000.00000 6185.84926 '+"\n",
+ '1 1.92453 0.98961 1034.72206 6396.02770 1
1.92453 0.98961 1034.72206 6396.02770 '+"\n",
+ ]
+ file = open(point_par, 'r')
+ lines = file.readlines()
+ file.close()
+ for i in range(len(res_file)):
self.assertEqual(res_file[i], lines[i])
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
relax-commits@xxxxxxx
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits