mailRe: latex_mf_table.py


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

Header


Content

Posted by Sébastien Morin on March 10, 2009 - 19:26:
Hi Ed,

Your proposal works for not crashing when a spin is not selected.

However, for this not selected spin, the printout is something like:

    :3\&:LEU@N           & \


Hence, it doesn't compile with latex.

Something like this compiles without problem:

    :3\&:LEU@N           & \multicolumn{11}{c}{} \\


Hence, I would add the following change to you fix:

            # The spin is not selected.
            if not spin.select:
                self.file.write("\\multicolumn{11}{c}{} \\\\\n")
                continue


The same could fix things if a spin has no model...

                # The model-free model.
                if hasattr(spin, 'model'):
                    self.file.write("$%s$ & " % spin.model)
                else:
                    self.file.write("\\multicolumn{11}{c}{} \\\\\n")


What do you think ?


Séb  :)





Edward d'Auvergne wrote:
Hi,

I just looked at the sample script and noticed the bug.  Could you
submit a bug report for this one?  The solution could be quite simple:

Index: sample_scripts/latex_mf_table.py
===================================================================
--- sample_scripts/latex_mf_table.py    (revision 8911)
+++ sample_scripts/latex_mf_table.py    (working copy)
@@ -181,6 +181,7 @@
             # The spin is not selected.
             if not spin.select:
                 self.file.write("\\\n")
+                continue

             # The model-free model.
             self.file.write("$%s$ & " % spin.model)

This will skip all the rest of the table for that spin.  Could you
test if this solution produces a reasonable LaTeX table?

Cheers,

Edward


On Tue, Mar 10, 2009 at 6:43 PM, Sébastien Morin
<sebastien.morin.1@xxxxxxxxx> wrote:
Hi,

I tried to use the sample script "latex_mf_table.py" this morning and
faced some errors. I didn't submit any bug as I could fix the problem, I
think...

When a spin was not selected, the script would fail, trying to read, for
example, "spin.s2", which, as other model-free parameter, was non
existent for a not selected spin...

Hence, I made a slight change to test if the spin was selected. I also
corrected the printout for an not selected spin, so latex compiles
without error. A similar change was made for the model-free model.

           # The spin is not selected.
           if not spin.select:
               self.file.write("\\multicolumn{11}{c}{} \\\\\n")
           else:

               # The model-free model.
               if hasattr(spin, 'model'):
                   self.file.write("$%s$ & " % spin.model)
               else:
                   self.file.write("\\multicolumn{11}{c}{} \\\\\n")

These can be viewed in the attached file. As you will see, most changes
relate to indentation relative to the new "else" statement.

Additionally, to help reading of the table produced by latex, I added a
space both before and after the "$\pm$" signs.

If you agree with those changes, I will commit them in relax-1.3.

Regards,


Séb

--
Sébastien Morin
PhD Student
S. Gagné NMR Laboratory
Université Laval & PROTEO
Québec, Canada


--- 
/home/semor/pse-4/collaborations/relax/relax-1.3/sample_scripts/latex_mf_table.py
   2009-03-10 11:35:01.000000000 -0400
+++ ./latex_mf_table__SEMOR_3.py        2009-03-10 13:40:06.000000000 -0400
@@ -152,7 +152,7 @@

        # The longtable environment.
        self.file.write("% The longtable environment.\n")
-        self.file.write("\\begin{longtable}{l l r @{$\\pm$} l r @{$\\pm$} 
l r @{$\\pm$} l r @{$\\pm$} l r @{$\\pm$} l}\n\n")
+        self.file.write("\\begin{longtable}{l l r @{ $\\pm$ } l r @{ 
$\\pm$ } l r @{ $\\pm$ } l r @{ $\\pm$ } l r @{ $\\pm$ } l}\n\n")

        # The caption.
        self.file.write("% Caption.\n")
@@ -180,65 +180,66 @@

            # The spin is not selected.
            if not spin.select:
-                self.file.write("\\\n")
-
-            # The model-free model.
-            if hasattr(spin, 'model'):
-                self.file.write("$%s$ & " % spin.model)
+                self.file.write("\\multicolumn{11}{c}{} \\\\\n")
            else:
-                self.file.write("\\\n")

-            # S2.
-            if spin.s2 == None:
-                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))
+                # The model-free model.
+                if hasattr(spin, 'model'):
+                    self.file.write("$%s$ & " % spin.model)
+                else:
+                    self.file.write("\\multicolumn{11}{c}{} \\\\\n")

-            # S2f.
-            if spin.s2f == None:
-                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))
+                # S2.
+                if spin.s2 == None:
+                    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))

-            # Fast motion (te < 100 ps or tf).
-            if spin.te != None and spin.te <= 100 * 1e-12:
-                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:
-                if not hasattr(spin, 'tf_err'):
-                    self.file.write("%27s & " % 
("\\multicolumn{2}{c}{%.2f}" % (spin.tf * 1e12)))
+                # S2f.
+                if spin.s2f == None:
+                    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("%12.2f & %12.2f & " % (spin.tf * 
1e12, spin.tf_err * 1e12))
-            else:
-                self.file.write("%27s & " % "\\multicolumn{2}{c}{}")
+                    self.file.write("%11.3f & %11.3f & " % (spin.s2f, 
spin.s2f_err))

-            # Slow motion (te > 100 ps or ts).
-            if spin.te != None and spin.te > 100 * 1e-12:
-                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:
-                if not hasattr(spin, 'ts_err'):
-                    self.file.write("%27s & " % 
("\\multicolumn{2}{c}{%.2f}" % (spin.ts * 1e12)))
+                # Fast motion (te < 100 ps or tf).
+                if spin.te != None and spin.te <= 100 * 1e-12:
+                    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:
+                    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("%12.2f & %12.2f & " % (spin.ts * 
1e12, spin.ts_err * 1e12))
-            else:
-                self.file.write("%27s & " % "\\multicolumn{2}{c}{}")
+                    self.file.write("%27s & " % "\\multicolumn{2}{c}{}")

-            # Rex.
-            if spin.rex == None:
-                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))
+                # Slow motion (te > 100 ps or ts).
+                if spin.te != None and spin.te > 100 * 1e-12:
+                    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:
+                    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("%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")

_______________________________________________
relax (http://nmr-relax.com)

This is the relax-devel mailing list
relax-devel@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-devel





-- 
Sébastien Morin
PhD Student
S. Gagné NMR Laboratory
Université Laval & PROTEO
Québec, Canada




Related Messages


Powered by MHonArc, Updated Tue Mar 10 21:01:05 2009