mailr5016 - /1.3/sample_scripts/cv.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on February 19, 2008 - 11:44:
Author: bugman
Date: Tue Feb 19 11:44:42 2008
New Revision: 5016

URL: http://svn.gna.org/viewcvs/relax?rev=5016&view=rev
Log:
Converted the cv.py sample script to the new relax design.


Modified:
    1.3/sample_scripts/cv.py

Modified: 1.3/sample_scripts/cv.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/sample_scripts/cv.py?rev=5016&r1=5015&r2=5016&view=diff
==============================================================================
--- 1.3/sample_scripts/cv.py (original)
+++ 1.3/sample_scripts/cv.py Tue Feb 19 11:44:42 2008
@@ -5,55 +5,55 @@
 frq_labels = ['600', '600', '600', '500', '500', '500']
 frqs = [600.0 * 1e6, 600.0 * 1e6, 600.0 * 1e6, 500.0 * 1e6, 500.0 * 1e6, 
500.0 * 1e6]
 file_names = ['r1.600.out', 'r2.600.out', 'noe.600.out', 'r1.500.out', 
'r2.500.out', 'noe.500.out']
-runs = ['m1', 'm2', 'm3', 'm4', 'm5']
+pipes = ['m1', 'm2', 'm3', 'm4', 'm5']
 
-# Construct the CV runs.
-cv_runs = []
-for i in xrange(len(runs)):
-    cv_runs.append([])
+# Construct the CV pipes.
+cv_pipes = []
+for i in xrange(len(pipes)):
+    cv_pipes.append([])
     for j in xrange(len(ri_labels)):
-        cv_runs[i].append(runs[i] + "_" + ri_labels[j] + "_" + frq_labels[j])
+        cv_pipes[i].append(pipes[i] + "_" + ri_labels[j] + "_" + 
frq_labels[j])
 
 print "\n\n\n\n"
 print "# Calibration set."
 print "##################"
 print "\n"
 
-# Loop over the runs for single-item-out cross-validation.
-for i in xrange(len(runs)):
+# Loop over the pipes for single-item-out cross-validation.
+for i in xrange(len(pipes)):
     # Loop over the relaxation data.
     for j in xrange(len(ri_labels)):
         # Nuclei type
         nuclei('N')
 
-        # Create the run.
-        run.create(cv_runs[i][j], 'mf')
+        # Create the data pipe.
+        pipe.create(cv_pipes[i][j], 'mf')
 
         # Load the sequence.
-        sequence.read(cv_runs[i][j], 'noe.500.out')
+        sequence.read('noe.500.out')
 
         # Create the calibration set by loading all relaxation data except 
the index 'i'.
         for k in xrange(len(ri_labels)):
             if k == i:
                 continue
-            relax_data.read(cv_runs[i][j], ri_labels[k], frq_labels[k], 
frqs[k], file_names[k])
+            relax_data.read(ri_labels[k], frq_labels[k], frqs[k], 
file_names[k])
 
         # Set up the global rotational correlation time.
-        diffusion_tensor.init(cv_runs[i][j], 1e-8)
+        diffusion_tensor.init(1e-8)
 
         # Set the bond length and CSA values.
-        value.set(cv_runs[i][j], 1.02 * 1e-10, 'bond_length')
-        value.set(cv_runs[i][j], -172 * 1e-6, 'csa')
+        value.set(1.02 * 1e-10, 'bond_length')
+        value.set(-172 * 1e-6, 'csa')
 
         # Select the preset model-free models.
-        model_free.select_model(run=cv_runs[i][j], model=runs[i])
+        model_free.select_model(model=pipes[i])
 
         # Minimisation of the calibration set.
-        grid_search(cv_runs[i][j], inc=11)
-        minimise('newton', 'chol', run=cv_runs[i][j])
+        grid_search(inc=11)
+        minimise('newton', 'chol')
 
         # Write the results.
-        results.write(run=cv_runs[i][j], force=1)
+        results.write(force=1)
 
 
 print "\n\n\n\n"
@@ -61,21 +61,24 @@
 print "#################"
 print "\n"
 
-# Load all the runs.
-for i in xrange(len(runs)):
+# Load all the pipes.
+for i in xrange(len(pipes)):
     # Loop over the relaxation data.
     for j in xrange(len(ri_labels)):
+        # Switch to the relevent data pipe.
+        pipe.switch(cv_pipes[i][j])
+
         # Delete the relaxation data from the calibration set.
-        delete(cv_runs[i][j], data_type='relax_data')
+        delete(data_type='relax_data')
 
         # Create the validation set by loading the relaxation data excluded 
from the calibration set.
-        relax_data.read(cv_runs[i][j], ri_labels[j], frq_labels[j], frqs[j], 
file_names[j])
+        relax_data.read(ri_labels[j], frq_labels[j], frqs[j], file_names[j])
 
         # Reload the model-free results.
-        read.results(run=cv_runs[i][j], data_type='mf')
+        read.results(data_type='mf')
 
         # Calculate the chi-squared value for the validation set.
-        calc(cv_runs[i][j])
+        calc()
 
 
 print "\n\n\n\n"
@@ -83,7 +86,7 @@
 print "##################"
 print "\n"
 
-model_selection('CV', 'cv', cv_runs)
+model_selection('CV', 'cv', cv_pipes)
 
 
 print "\n\n\n\n"
@@ -91,14 +94,17 @@
 print "###############################################"
 print "\n"
 
+# Switch to the 'cv' data pipe.
+pipe.switch('cv')
+
 # Delete the relaxation data copied over to the run 'cv' and then load all 
the data.
-delete('cv', data_type='relax_data')
+delete(data_type='relax_data')
 for i in xrange(len(ri_labels)):
-    relax_data.read('cv', ri_labels[i], frq_labels[i], frqs[i], 
file_names[i])
+    relax_data.read(ri_labels[i], frq_labels[i], frqs[i], file_names[i])
 
 # Minimise the selected model using all relaxation data.
-minimise('newton', run='cv')
+minimise('newton')
 
 # Finish.
-results.write(run='cv', file='results', force=1)
+results.write(file='results', force=1)
 state.save('save', force=1)




Related Messages


Powered by MHonArc, Updated Tue Feb 19 12:00:45 2008