Author: bugman Date: Tue Oct 21 15:17:46 2008 New Revision: 7879 URL: http://svn.gna.org/viewcvs/relax?rev=7879&view=rev Log: Merged revisions 7876-7877 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r7876 | bugman | 2008-10-21 11:50:12 +0200 (Tue, 21 Oct 2008) | 11 lines Fixes for the model-free LaTeX table generation sample script. These fixes do not affect the system test result yet - as LaTeX compilation will not be part of the test suite - but fix the LaTeX compilation. These will be ported back to the sample script. The docstring has been modified as the booktabs package is needed for this table. The '&' characters in the spin_id string have been escaped to avoid this being interpreted as a column separator. The 'Residue' column has been renamed to 'Spin'. And finally missing model-free parameter errors can be handled. ........ r7877 | bugman | 2008-10-21 11:53:58 +0200 (Tue, 21 Oct 2008) | 24 lines Ported the changes of r7876 from the test suite to the sample script. The command used was: svn merge -r7875:7876 test_suite/system_tests/scripts/latex_mf_table.py sample_scripts/latex_mf_table.py The LaTeX document starting and ending commands have been removed from this revision! ..... r7876 | bugman | 2008-10-21 11:50:12 +0200 (Tue, 21 Oct 2008) | 11 lines Changed paths: M /1.3/test_suite/system_tests/scripts/latex_mf_table.py Fixes for the model-free LaTeX table generation sample script. These fixes do not affect the system test result yet - as LaTeX compilation will not be part of the test suite - but fix the LaTeX compilation. These will be ported back to the sample script. The docstring has been modified as the booktabs package is needed for this table. The '&' characters in the spin_id string have been escaped to avoid this being interpreted as a column separator. The 'Residue' column has been renamed to 'Spin'. And finally missing model-free parameter errors can be handled. ..... ........ Modified: branches/multi_processor_merge/ (props changed) branches/multi_processor_merge/sample_scripts/latex_mf_table.py branches/multi_processor_merge/test_suite/system_tests/scripts/latex_mf_table.py Propchange: branches/multi_processor_merge/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Oct 21 15:17:46 2008 @@ -1,1 +1,1 @@ -/1.3:1-7873 +/1.3:1-7877 Modified: branches/multi_processor_merge/sample_scripts/latex_mf_table.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/sample_scripts/latex_mf_table.py?rev=7879&r1=7878&r2=7879&view=diff ============================================================================== --- branches/multi_processor_merge/sample_scripts/latex_mf_table.py (original) +++ branches/multi_processor_merge/sample_scripts/latex_mf_table.py Tue Oct 21 15:17:46 2008 @@ -22,16 +22,22 @@ """Script for converting the model-free results into a LaTeX table. -The longtable LaTeX package is necessary to allow the table to span multiple pages. The package -can be included using the LaTeX command: +The longtable LaTeX package is necessary to allow the table to span multiple pages. This table also +uses the more elegant booktable format. The packages can be included using the LaTeX preamble +commands: \usepackage{longtable} +\usepackage{booktabs} Assuming the file name 'results.tex', the resultant table can be placed into a LaTeX manuscript with the command: \input{results} """ + +# Python module imports. +from string import replace +import sys # relax module imports. from generic_fns.mol_res_spin import spin_loop @@ -98,7 +104,7 @@ # Headings. self.file.write("% Headings.\n") - self.file.write("Residue &%\n") + self.file.write("Spin &%\n") self.file.write("Model &%\n") self.file.write("\multicolumn{2}{c}{$S^2$} &%\n") self.file.write("\multicolumn{2}{c}{$S^2_f$} &%\n") @@ -170,6 +176,7 @@ # Loop over the spin systems. for spin, spin_id in spin_loop(return_id=True): # The spin ID string. + spin_id = replace(spin_id, '&', '\&') self.file.write("%-20s & " % (spin_id)) # The spin is not selected. @@ -181,37 +188,55 @@ # S2. if spin.s2 == None: - self.file.write("%21s & " % "\\multicolumn{2}{c}{}") - else: - self.file.write("%9.3f & %9.3f & " % (spin.s2, spin.s2_err)) + self.file.write("%25s & " % "\\multicolumn{2}{c}{}") + elif not hasattr(spin, 's2_err'): + self.file.write("%24s & " % "\\multicolumn{2}{c}{%.3f}" % spin.s2) + else: + self.file.write("%11.3f & %11.3f & " % (spin.s2, spin.s2_err)) # S2f. if spin.s2f == None: - self.file.write("%21s & " % "\\multicolumn{2}{c}{}") - else: - self.file.write("%9.3f & %9.3f & " % (spin.s2f, spin.s2f_err)) + self.file.write("%25s & " % "\\multicolumn{2}{c}{}") + elif not hasattr(spin, 's2f_err'): + self.file.write("%24s & " % "\\multicolumn{2}{c}{%.3f}" % spin.s2f) + else: + self.file.write("%11.3f & %11.3f & " % (spin.s2f, spin.s2f_err)) # Fast motion (te < 100 ps or tf). if spin.te != None and spin.te <= 100 * 1e-12: - self.file.write("%9.2f & %9.2f & " % (spin.te * 1e12, spin.te_err * 1e12)) + if not hasattr(spin, 'te_err'): + self.file.write("%27s & " % ("\\multicolumn{2}{c}{%.2f}" % (spin.te * 1e12))) + else: + self.file.write("%12.2f & %12.2f & " % (spin.te * 1e12, spin.te_err * 1e12)) elif spin.tf != None: - self.file.write("%9.2f & %9.2f & " % (spin.tf * 1e12, spin.tf_err * 1e12)) - else: - self.file.write("%21s & " % "\\multicolumn{2}{c}{}") + if not hasattr(spin, 'tf_err'): + self.file.write("%27s & " % ("\\multicolumn{2}{c}{%.2f}" % (spin.tf * 1e12))) + else: + self.file.write("%12.2f & %12.2f & " % (spin.tf * 1e12, spin.tf_err * 1e12)) + else: + self.file.write("%27s & " % "\\multicolumn{2}{c}{}") # Slow motion (te > 100 ps or ts). if spin.te != None and spin.te > 100 * 1e-12: - self.file.write("%9.2f & %9.2f & " % (spin.te * 1e12, spin.te_err * 1e12)) + if not hasattr(spin, 'te_err'): + self.file.write("%27s & " % ("\\multicolumn{2}{c}{%.2f}" % (spin.te * 1e12))) + else: + self.file.write("%12.2f & %12.2f & " % (spin.te * 1e12, spin.te_err * 1e12)) elif spin.ts != None: - self.file.write("%9.2f & %9.2f & " % (spin.ts * 1e12, spin.ts_err * 1e12)) - else: - self.file.write("%21s & " % "\\multicolumn{2}{c}{}") + if not hasattr(spin, 'ts_err'): + self.file.write("%27s & " % ("\\multicolumn{2}{c}{%.2f}" % (spin.ts * 1e12))) + else: + self.file.write("%12.2f & %12.2f & " % (spin.ts * 1e12, spin.ts_err * 1e12)) + else: + self.file.write("%27s & " % "\\multicolumn{2}{c}{}") # Rex. if spin.rex == None: - self.file.write("%21s \\\\\n" % "\\multicolumn{2}{c}{}") - else: - self.file.write("%9.3f & %9.3f \\\\\n" % (spin.rex * (2.0 * pi * spin.frq[0])**2, spin.rex_err * (2.0 * pi * spin.frq[0])**2)) + self.file.write("%27s \\\\\n" % "\\multicolumn{2}{c}{}") + elif not hasattr(spin, 'rex_err'): + self.file.write("%27s \\\\\n" % ("\\multicolumn{2}{c}{%.3f}" % (spin.rex * (2.0 * pi * spin.frq[0])**2))) + else: + self.file.write("%12.3f & %12.3f \\\\\n" % (spin.rex * (2.0 * pi * spin.frq[0])**2, spin.rex_err * (2.0 * pi * spin.frq[0])**2)) # Start a new line. self.file.write("\n") Modified: branches/multi_processor_merge/test_suite/system_tests/scripts/latex_mf_table.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/test_suite/system_tests/scripts/latex_mf_table.py?rev=7879&r1=7878&r2=7879&view=diff ============================================================================== --- branches/multi_processor_merge/test_suite/system_tests/scripts/latex_mf_table.py (original) +++ branches/multi_processor_merge/test_suite/system_tests/scripts/latex_mf_table.py Tue Oct 21 15:17:46 2008 @@ -22,10 +22,12 @@ """Script for converting the model-free results into a LaTeX table. -The longtable LaTeX package is necessary to allow the table to span multiple pages. The package -can be included using the LaTeX command: +The longtable LaTeX package is necessary to allow the table to span multiple pages. This table also +uses the more elegant booktable format. The packages can be included using the LaTeX preamble +commands: \usepackage{longtable} +\usepackage{booktabs} Assuming the file name 'results.tex', the resultant table can be placed into a LaTeX manuscript with the command: @@ -34,6 +36,7 @@ """ # Python module imports. +from string import replace import sys # relax module imports. @@ -101,7 +104,7 @@ # Headings. self.file.write("% Headings.\n") - self.file.write("Residue &%\n") + self.file.write("Spin &%\n") self.file.write("Model &%\n") self.file.write("\multicolumn{2}{c}{$S^2$} &%\n") self.file.write("\multicolumn{2}{c}{$S^2_f$} &%\n") @@ -137,12 +140,25 @@ # End the font size. self.file.write("\\end{small}\n") + # Terminate the document. + self.file.write("\\end{document}\n") + def latex_header(self): """Create the LaTeX header. This function will need to be heavily modified to suit your needs. """ + + # Document class - to allow for compilation tests. + self.file.write("\documentclass[a4paper, 12pt, twoside]{book}\n\n") + + # Package inclusion. + self.file.write("\usepackage{longtable}\n") + self.file.write("\usepackage{booktabs}\n\n") + + # Start the document. + self.file.write("\\begin{document}\n\n") # Font size. self.file.write("% Small font.\n") @@ -173,6 +189,7 @@ # Loop over the spin systems. for spin, spin_id in spin_loop(return_id=True): # The spin ID string. + spin_id = replace(spin_id, '&', '\&') self.file.write("%-20s & " % (spin_id)) # The spin is not selected. @@ -184,37 +201,55 @@ # S2. if spin.s2 == None: - self.file.write("%21s & " % "\\multicolumn{2}{c}{}") - else: - self.file.write("%9.3f & %9.3f & " % (spin.s2, spin.s2_err)) + self.file.write("%25s & " % "\\multicolumn{2}{c}{}") + elif not hasattr(spin, 's2_err'): + self.file.write("%24s & " % "\\multicolumn{2}{c}{%.3f}" % spin.s2) + else: + self.file.write("%11.3f & %11.3f & " % (spin.s2, spin.s2_err)) # S2f. if spin.s2f == None: - self.file.write("%21s & " % "\\multicolumn{2}{c}{}") - else: - self.file.write("%9.3f & %9.3f & " % (spin.s2f, spin.s2f_err)) + self.file.write("%25s & " % "\\multicolumn{2}{c}{}") + elif not hasattr(spin, 's2f_err'): + self.file.write("%24s & " % "\\multicolumn{2}{c}{%.3f}" % spin.s2f) + else: + self.file.write("%11.3f & %11.3f & " % (spin.s2f, spin.s2f_err)) # Fast motion (te < 100 ps or tf). if spin.te != None and spin.te <= 100 * 1e-12: - self.file.write("%9.2f & %9.2f & " % (spin.te * 1e12, spin.te_err * 1e12)) + if not hasattr(spin, 'te_err'): + self.file.write("%27s & " % ("\\multicolumn{2}{c}{%.2f}" % (spin.te * 1e12))) + else: + self.file.write("%12.2f & %12.2f & " % (spin.te * 1e12, spin.te_err * 1e12)) elif spin.tf != None: - self.file.write("%9.2f & %9.2f & " % (spin.tf * 1e12, spin.tf_err * 1e12)) - else: - self.file.write("%21s & " % "\\multicolumn{2}{c}{}") + if not hasattr(spin, 'tf_err'): + self.file.write("%27s & " % ("\\multicolumn{2}{c}{%.2f}" % (spin.tf * 1e12))) + else: + self.file.write("%12.2f & %12.2f & " % (spin.tf * 1e12, spin.tf_err * 1e12)) + else: + self.file.write("%27s & " % "\\multicolumn{2}{c}{}") # Slow motion (te > 100 ps or ts). if spin.te != None and spin.te > 100 * 1e-12: - self.file.write("%9.2f & %9.2f & " % (spin.te * 1e12, spin.te_err * 1e12)) + if not hasattr(spin, 'te_err'): + self.file.write("%27s & " % ("\\multicolumn{2}{c}{%.2f}" % (spin.te * 1e12))) + else: + self.file.write("%12.2f & %12.2f & " % (spin.te * 1e12, spin.te_err * 1e12)) elif spin.ts != None: - self.file.write("%9.2f & %9.2f & " % (spin.ts * 1e12, spin.ts_err * 1e12)) - else: - self.file.write("%21s & " % "\\multicolumn{2}{c}{}") + if not hasattr(spin, 'ts_err'): + self.file.write("%27s & " % ("\\multicolumn{2}{c}{%.2f}" % (spin.ts * 1e12))) + else: + self.file.write("%12.2f & %12.2f & " % (spin.ts * 1e12, spin.ts_err * 1e12)) + else: + self.file.write("%27s & " % "\\multicolumn{2}{c}{}") # Rex. if spin.rex == None: - self.file.write("%21s \\\\\n" % "\\multicolumn{2}{c}{}") - else: - self.file.write("%9.3f & %9.3f \\\\\n" % (spin.rex * (2.0 * pi * spin.frq[0])**2, spin.rex_err * (2.0 * pi * spin.frq[0])**2)) + self.file.write("%27s \\\\\n" % "\\multicolumn{2}{c}{}") + elif not hasattr(spin, 'rex_err'): + self.file.write("%27s \\\\\n" % ("\\multicolumn{2}{c}{%.3f}" % (spin.rex * (2.0 * pi * spin.frq[0])**2))) + else: + self.file.write("%12.3f & %12.3f \\\\\n" % (spin.rex * (2.0 * pi * spin.frq[0])**2, spin.rex_err * (2.0 * pi * spin.frq[0])**2)) # Start a new line. self.file.write("\n")