# HG changeset patch
# User Karl-Dieter Crisman <kcrisman@gmail.com>
# Date 1339899573 14400
# Node ID 86c00a0d5159f37127be7b89c3e351e566698ddc
# Parent 441da014640a81abc78847965a5ce89edbcb2d81
Trac 12299 - reviewer patch in formatting and temp files, add to ref manual
diff --git a/doc/en/reference/interfaces.rst b/doc/en/reference/interfaces.rst
|
a
|
b
|
|
| 78 | 78 | sage/interfaces/sage0 |
| 79 | 79 | sage/interfaces/singular |
| 80 | 80 | sage/interfaces/tachyon |
| | 81 | sage/interfaces/jmoldata |
diff --git a/sage/interfaces/jmoldata.py b/sage/interfaces/jmoldata.py
|
a
|
b
|
|
| 5 | 5 | reads and for generating image files. |
| 6 | 6 | |
| 7 | 7 | AUTHORS: |
| 8 | | Jonathan Gutow (2012-06-14): complete doctest coverage |
| 9 | | Jonathan Gutow (2012-03-21): initial version |
| | 8 | |
| | 9 | - Jonathan Gutow (2012-06-14): complete doctest coverage |
| | 10 | - Jonathan Gutow (2012-03-21): initial version |
| | 11 | """ |
| 10 | 12 | |
| 11 | 13 | #******************************************************************************* |
| 12 | 14 | # Copyright (C) 2012 Jonathan Gutow (gutow@uwosh.edu) |
| … |
… |
|
| 16 | 18 | # the License, or (at your option) any later version. |
| 17 | 19 | # http://www.gnu.org/licenses/ |
| 18 | 20 | #******************************************************************************* |
| 19 | | """ |
| | 21 | |
| 20 | 22 | from sage.structure.sage_object import SageObject |
| 21 | 23 | |
| 22 | 24 | from sage.misc.misc import tmp_filename |
| … |
… |
|
| 28 | 30 | class JmolDataError(Exception): |
| 29 | 31 | |
| 30 | 32 | def __init__(self, value): |
| 31 | | """ |
| 32 | | EXAMPLES: |
| | 33 | """ |
| | 34 | TEST:: |
| 33 | 35 | |
| 34 | | JmolDataError __init__ test:: |
| 35 | | sage: from sage.interfaces.jmoldata import JmolDataError |
| 36 | | sage: print(JmolDataError("test of init").value) |
| 37 | | test of init |
| 38 | | """ |
| | 36 | sage: from sage.interfaces.jmoldata import JmolDataError |
| | 37 | sage: print(JmolDataError("test of init").value) |
| | 38 | test of init |
| | 39 | """ |
| 39 | 40 | self.value = value |
| | 41 | |
| 40 | 42 | def __str__(self): |
| 41 | | """ |
| 42 | | EXAMPLES: |
| | 43 | """ |
| | 44 | TEST:: |
| 43 | 45 | |
| 44 | | JmolDataError __str__ test:: |
| 45 | | |
| 46 | | sage: from sage.interfaces.jmoldata import JmolDataError |
| 47 | | sage: print str(JmolDataError("test of error")) |
| 48 | | 'test of error' |
| 49 | | """ |
| | 46 | sage: from sage.interfaces.jmoldata import JmolDataError |
| | 47 | sage: print str(JmolDataError("test of error")) |
| | 48 | 'test of error' |
| | 49 | """ |
| 50 | 50 | return repr(self.value) |
| 51 | 51 | |
| 52 | 52 | class JmolData(SageObject): |
| 53 | 53 | r""" |
| 54 | | .. TODO:: |
| 55 | | DONE 1) create an image file (user choosable JPG, PNG, GIF) |
| 56 | | DONE 1.5) function to check if jvm is available |
| 57 | | DONE 1.75) raise exception if export_image is called without JVM being available. |
| 58 | | 2) create an animated image file if spin is on (GIF) |
| 59 | | 3) Put data extracted from a file into a variable/string/structure to return |
| | 54 | .. todo:: |
| | 55 | |
| | 56 | Create an animated image file (GIF) if spin is on and put data |
| | 57 | extracted from a file into a variable/string/structure to return |
| 60 | 58 | """ |
| 61 | 59 | def __init__(self): |
| 62 | 60 | """ |
| 63 | 61 | EXAMPLES: |
| 64 | 62 | |
| 65 | | Create a JmolData object |
| 66 | | :: |
| | 63 | Create a JmolData object:: |
| 67 | 64 | |
| 68 | 65 | sage: from sage.interfaces.jmoldata import JmolData |
| 69 | 66 | sage: JData = JmolData() |
| … |
… |
|
| 108 | 105 | This executes JmolData.jar to make an image file. |
| 109 | 106 | |
| 110 | 107 | INPUT: |
| 111 | | targetfile -- the full path to the file where the image should be written. |
| 112 | | datafile -- full path to the data file Jmol can read or text of a script |
| 113 | | telling Jmol what to read or load. |
| 114 | | datafile_cmd -- "script" or "load" defaults to "script", should be load for a data file. |
| 115 | | image_type -- "PNG" "JPG" or "GIF" defaults to "PNG" |
| 116 | | figsize -- number = (pixels/side)/100 defaults to 5. |
| | 108 | |
| | 109 | - targetfile -- the full path to the file where the image |
| | 110 | should be written. |
| | 111 | |
| | 112 | - datafile -- full path to the data file Jmol can read or |
| | 113 | text of a script telling Jmol what to read or load. |
| | 114 | |
| | 115 | - datafile_cmd -- (default ``'script'``) ``'load'`` or ``'script'`` |
| | 116 | should be ``"load"`` for a data file. |
| | 117 | |
| | 118 | - image_type -- (default ``"PNG"``) ``'PNG'`` ``'JPG'`` or ``'GIF'`` |
| | 119 | |
| | 120 | - figsize -- number (default 5) equal to (pixels/side)/100 |
| 117 | 121 | |
| 118 | 122 | OUTPUT: |
| 119 | | image file , .png, .gif or .jpg (default .png) |
| 120 | 123 | |
| 121 | | .. NOTE:: |
| 122 | | Examples will generate an error message if a functional Java Virtual Machine (JVM) is not installed |
| 123 | | on the machine the Sage instance is running on. |
| | 124 | Image file , .png, .gif or .jpg (default .png) |
| 124 | 125 | |
| 125 | | .. WARNING:: |
| 126 | | Programmers using this module should check that the JVM is available before making calls to |
| 127 | | avoid the user getting error messages. Check for the JVM using the function |
| 128 | | is_jvm_available(), which returns True if a JVM is available. |
| | 126 | .. note:: |
| | 127 | |
| | 128 | Examples will generate an error message if a functional Java Virtual Machine (JVM) |
| | 129 | is not installed on the machine the Sage instance is running on. |
| | 130 | |
| | 131 | .. warning:: |
| | 132 | |
| | 133 | Programmers using this module should check that the JVM is |
| | 134 | available before making calls to avoid the user getting |
| | 135 | error messages. Check for the JVM using the function |
| | 136 | :meth:`is_jvm_available`, which returns True if a JVM is available. |
| 129 | 137 | |
| 130 | 138 | EXAMPLES: |
| 131 | 139 | |
| 132 | | Use Jmol to load a pdb file containing some DNA from a web data base and make an image of the DNA. |
| 133 | | If you execute this in the notebook, the image will appear in the output cell. |
| 134 | | :: |
| | 140 | Use Jmol to load a pdb file containing some DNA from a web data |
| | 141 | base and make an image of the DNA. If you execute this in the |
| | 142 | notebook, the image will appear in the output cell:: |
| 135 | 143 | |
| 136 | 144 | sage: from sage.interfaces.jmoldata import JmolData |
| 137 | 145 | sage: JData = JmolData() |
| 138 | 146 | sage: script = "load =1lcd;display DNA;moveto 0.0 { -473 -713 -518 59.94} 100.0 0.0 0.0 {21.17 26.72 27.295} 27.544636 {0.0 0.0 0.0} -25.287832 64.8414 0.0;" |
| 139 | | sage: testfile = "DNA.png" |
| 140 | | sage: JData.export_image(targetfile=testfile,datafile=script,image_type="PNG") |
| 141 | | sage: print os.path.exists(testfile) |
| | 147 | sage: testfile = tmp_filename()+"DNA.png" |
| | 148 | sage: JData.export_image(targetfile=testfile,datafile=script,image_type="PNG") # optional -- internet |
| | 149 | sage: print os.path.exists(testfile) # optional -- internet |
| 142 | 150 | True |
| 143 | 151 | |
| 144 | | Use Jmol to save an image of a 3-D object created in Sage. This method is used internally |
| 145 | | by plot3d to generate static images. This example doesn't have correct scaling. |
| 146 | | :: |
| | 152 | Use Jmol to save an image of a 3-D object created in Sage. |
| | 153 | This method is used internally by plot3d to generate static images. |
| | 154 | This example doesn't have correct scaling:: |
| 147 | 155 | |
| 148 | 156 | sage: from sage.interfaces.jmoldata import JmolData |
| 149 | 157 | sage: JData = JmolData() |
| … |
… |
|
| 152 | 160 | sage: archive_name=os.path.join(SAGE_TMP, "archive.jmol.zip") |
| 153 | 161 | sage: D.export_jmol(archive_name) #not scaled properly...need some more steps. |
| 154 | 162 | sage: testfile = os.path.join(SAGE_TMP, "testimage.png") |
| 155 | | sage: script = 'set defaultdirectory "'+archive_name+'"\n script SCRIPT\n' |
| | 163 | sage: script = 'set defaultdirectory "%s"\\n script SCRIPT\\n'%archive_name |
| 156 | 164 | sage: JData.export_image(targetfile =testfile,datafile = script, image_type="PNG") |
| 157 | 165 | sage: print os.path.exists(testfile) |
| 158 | 166 | True |