Obtaining 3D plot data files (Jmol files)

110 views
Skip to first unread message

Paul Pearson

unread,
Dec 1, 2009, 2:00:39 PM12/1/09
to sage-edu
Hi,

Is there an easy way to get the plot data file (the file that is
displayed by Jmol) from SAGE (preferably from the free online SAGE
notebook)? I have figured out how to do get the plot data file (by
looking at the source code to get the appropriate URL for the
compressed plot data file), but would like to know if there is an
easier way.

Thanks!

Paul

mhampton

unread,
Dec 1, 2009, 9:47:17 PM12/1/09
to sage-edu
Hopefully in the near future there will be an "export as html" option
or something similar on jmol plots. Right now you have to somehow
extract the zipped script file manually. We were looking at Geogebra
as a model to some extent because it can do such exports quite nicely.

Unfortunately since the jmol applets in the notebook are a mix of
python, javascript, and java there are not tons of Sage developers who
can help.

-Marshall Hampton

Jonathan

unread,
Dec 2, 2009, 9:04:07 AM12/2/09
to sage-edu
Paul,

I'm a Jmol developer who is trying to help with the Jmol interface in
SAGE. Would the following server your needs?

Jmol can generate a file that the Jmol application can read to
regenerate the display on your local machine. I could add that kind
of export to the web interface I am working on. This would be in
addition to generating an image that can be saved (already in the
present interface). This proposed facility will involve changing to
the signed applet and will require the user to "trust" the applet, so
that it can write to their disk.

Let me know what you think, so that I can try to incorporate your
wishes in the new interface.

Jonathan
On Dec 1, 1:00 pm, Paul Pearson <paultpear...@gmail.com> wrote:

Paul Pearson

unread,
Dec 5, 2009, 6:47:53 PM12/5/09
to sage-edu
Dear Jonathan and Marshall,

Thank you for your help. My ultimate goal is to be able to include 3d
graphics generated by SAGE and displayed by JmolApplet.jar in the
online homework system WeBWorK. The main reason I wanted an easier
way to get the 3d plot data file is to make it easy for people (other
than me) to generate interactive graphics in SAGE and use them in
webwork homework questions they write.

Personally, I don't mind signed applets, but signed applets may be
utrusted by other SAGE users. Can a 3d plot data file generated by
the signed applet be displayed using the unsigned applet (I'm new to
this stuff)? The signed applet would cause issues for webwork users
and their professors (student's who don't know whether they should
trust a signed applet will probably email their professors and drive
them nuts). Actually, if a SAGE notebook user has a way to generate
a link to the zip file containing all of the 3d data plot info which
is as simple as the current "Get Image" link, that would probably be
as good as anything (it could even be a plot option, so that it is not
displayed unless the user wants it).

On an old message board, I found a slightly easier way than reading
the html source code to get the 3d plot data file. Here "easier"
doesn't mean easy, but at least this other method has a small number
of steps that can readily be described and followed by others. Search
for "a.txt" on the page

http://markmail.org/message/vznxl4j34mrwoxv4

I would like to make a suggestion to cut down on the "flicker" of the
screen when scrolling a page with a Jmol applet displaying 3d
graphics: set the applet background color to white (the default is
black). With a white background as the default state, as the applet
redraws it does not switch the background color from white (drawn
state) to black (default state) to white (drawn state). See the code
below.

<script type="text/javascript">
jmolSetAppletColor("white");
jmolApplet(["450","450"],"script cylinder-jmol.zip|SCRIPT")
</script>

Best Regards,

Paul

Jonathan

unread,
Dec 6, 2009, 6:34:58 PM12/6/09
to sage-edu
Paul,
1) Removing the flicker idea is good. We'll see about implementing
that.
2) Tell me if the following is what your envision.
*You want a link you can use to download the file generated for Jmol
in SAGE.
*You want that file to work in the Jmol application (or is it the
applet) no matter where you put it.

The first part is really easy. The second part is a bit harder. Jmol
can generate this kind of file from loaded data, but we will have to
rewrite the SAGE code that generates the files for Jmol to get those
kinds of files on the server. That is why I suggested the signed
applet. Since they are allowed to write to the local disc if the user
agrees, they can take whatever data is in them and generate a file you
can move around. If you are doing this all inside a web application,
there are other ways to do this from javascript. You would just have
to move data generated in javascript to the server. Jmol can generate
a "state" script, which would point to all the necessary data on the
server (assuming it is the same one, otherwise you have to use the
signed applet). That script is all that would have to be moved into
the homework. The other issue is getting Jmol to behave within the
WebWork framework. I don't know what those requirements are. I know
from discussions with other people that you have to be very careful
when embedding Jmol in things like Moodle and Wiki sites.

Jonathan

Jason Grout

unread,
Dec 7, 2009, 4:39:13 PM12/7/09
to sage...@googlegroups.com
Paul Pearson wrote:
> Dear Jonathan and Marshall,
>
> Thank you for your help. My ultimate goal is to be able to include 3d
> graphics generated by SAGE and displayed by JmolApplet.jar in the
> online homework system WeBWorK. The main reason I wanted an easier
> way to get the 3d plot data file is to make it easy for people (other
> than me) to generate interactive graphics in SAGE and use them in
> webwork homework questions they write.


This is fantastic. We have talked now and then about Webwork
integration. Do you know Webwork well? Do you have any other ideas
about integrating Sage and Webwork?

If you have some ideas, it might be best to start a new thread.

I think it's fantastic that people are working to get these two great
projects to work together. I think it's a natural next step for
Sage-in-the-classroom.

Thanks,

Jason

kcrisman

unread,
Dec 7, 2009, 4:56:25 PM12/7/09
to sage-edu
Incidentally, if you are going to the Joint Meetings, one of the
WebWorK developers will be speaking on precisely the issue of
embedding various kinds of applets in that system.

Ideally we'd be able to take the (coming soon) no-login interacts in
this way as well, but they aren't Java, so I'm not sure how that would
work.

- kcrisman

Paul Pearson

unread,
Dec 8, 2009, 6:18:20 PM12/8/09
to sage-edu
Dear Jonathan and others,

I am a webwork developer, though not one of the main developers. I
have been successful at displaying a SAGE generated 3d plot from
within webwork using the Jmol applet provided that the plot data file
uses no pmesh input files. Sage generates a zipped plot data file
sage0...stuff...zip which contains a SCRIPT file and may contain
several pmesh data files. I am able to get Jmol to read the SCRIPT
file, but the lines in the SCRIPT file that load the pmesh files are
not executing correctly. I have emailed Robert Hanson (the upstream
Jmol contact) about this, and his advice was as follows

---------- begin email correspondence --------------------

Jmol opens and reads selected files within a zip file. To do this,
just use "|" to specify directories within the zip file:

script cylinder-jmol.zip|SCRIPT

since the other files are in that zip file as well, you also have to
indicate a default path:

set defaultdirectory "cylinder-jmol.zip|"

Note the vertical line to indicate we want files within the zip file's
main directory.

then when you execute

script SCRIPT

it works.

---------- end email correspondence ----------------------

I am guessing that the SAGE developers have already figured out how to
make this "defaultdirectory" issue work for zip files in remote
directories, and if you would be able to describe to me how you make
it work, that would be greatly appreciated. I like your idea of
having a single input file for Jmol that is "portable" in the sense
that it can be put anywhere, read as input to Jmol, and it will work.
However, I also think that there ought to be a way to make the current
system of zip files work (even though I haven't fully figured it out
yet).

I have been able to get things to work correctly when loading the zip
file locally (from my own computer) but not remotely (from the webwork
server). Here's what I have done. Get the zip file with the SCRIPT
and pmesh files from

http://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/cylinder-jmol.zip

and save it to a local directory that contains "Jmol.js" and
"JmolApplet.jar". Notice that the first line of the SCRIPT file was
added by me and uses verbatim the advice from Robert Hanson about
setting the default directory. Create a html file in that same local
directory with the following code:


------------------- begin html ----------------------------

<html>
<head>
<script type="text/javascript" src="Jmol.js"></script>
</head>
<body>
<!--
<script>
jmolInitialize(".",useSignedApplet)
</script>
-->

<!-- read cylinder-jmol.zip locally -->
<script type="text/javascript">
jmolApplet(["450","450"],"script cylinder-jmol.zip|SCRIPT")
</script>

<!-- read cylinder-jmol.zip remotely -->
<script type="text/javascript">
jmolSetAppletColor("white");
jmolApplet(["400","400"],"script
http://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/cylinder-jmol.zip|SCRIPT")
</script>

</body>
</html>

--------------------- end html -------------------------

You should see a closed cylinder with some vectors on the left from
the local copy, and a blank Jmol applet (except for the word Jmol) on
the right from the remote copy. The output from the Java Console is
given below, in case you're interested in tracing the errors.


---------------------------------------- begin output from Java
Console -----------------------

Java Plug-in 1.6.0_17
Using JRE version 1.6.0_17-b04 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Pearson_p
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------


urlImage=jar:file:/C:/Durango/www/Jmol/JmolApplet.jar!/jmol75x29x8.gif
urlImage=jar:file:/C:/Durango/www/Jmol/JmolApplet.jar!/jmol75x29x8.gif
Jmol applet jmolApplet0__3128490663424304__ initializing
Jmol applet jmolApplet1__3128490663424304__ initializing
AppletRegistry.checkIn(jmolApplet1__3128490663424304__)
AppletRegistry.checkIn(jmolApplet0__3128490663424304__)
applet context: -applet
appletDocumentBase=file:/C:/Durango/www/Jmol/trial-local.html
appletCodeBase=file:/C:/Durango/www/Jmol/
applet context: -applet
appletDocumentBase=file:/C:/Durango/www/Jmol/trial-local.html
appletCodeBase=file:/C:/Durango/www/Jmol/
(C) 2008 Jmol Development
Jmol Version 11.6.16 2008-11-24 13:39
java.vendor:Sun Microsystems Inc.
java.version:1.6.0_17
os.name:Windows XP
memory:1.7/5.2
useCommandThread: false
appletId:jmolApplet1__3128490663424304__
(C) 2008 Jmol Development
Jmol Version 11.6.16 2008-11-24 13:39
java.vendor:Sun Microsystems Inc.
java.version:1.6.0_17
os.name:Windows XP
memory:1.7/5.2
useCommandThread: false
appletId:jmolApplet0__3128490663424304__
defaults = "Jmol"
defaults = "Jmol"
backgroundColor = "white"
backgroundColor = "white"
language=en_US
language=en_US
FileManager opening http://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/cylinder-jmol.zip
FileManager opening file:/C:/Durango/www/Jmol/cylinder-jmol.zip
FileManager.openStringInline()
The Resolver thinks Xyz
ModelSet: haveSymmetry:false haveUnitcells:false
haveFractionalCoord:false
1 model in this collection. Use getProperty "modelInfo" or getProperty
"auxiliaryInfo" to inspect them.
ModelSet: autobonding; use autobond=false to not generate bonds
automatically
data "model list"
13
empty
Xx 0.0 -6.0 -6.0
Xx 6.0 0.0 -6.0
Xx -6.0 -6.0 0.0
Xx -6.0 -7.0 -6.0
Xx 0.0 -7.0 -6.0
Xx 6.0 -7.0 -6.0
Xx 7.0 -6.0 -6.0
Xx 7.0 0.0 -6.0
Xx 7.0 6.0 -6.0
Xx -7.0 -6.0 -6.0
Xx -7.0 -6.0 0.0
Xx -7.0 -6.0 6.0
Xx 5.5 5.5 5.5

end "model list";
FileManager opening file:/C:/Durango/www/Jmol/cylinder-jmol.zip
reading pmesh data from file:/C:/Durango/www/Jmol/cylinder-jmol.zip|
obj_264530.pmesh
FileManager opening file:/C:/Durango/www/Jmol/cylinder-jmol.zip
reading pmesh data from file:/C:/Durango/www/Jmol/cylinder-jmol.zip|
obj_878432.pmesh
FileManager opening file:/C:/Durango/www/Jmol/cylinder-jmol.zip
reading pmesh data from file:/C:/Durango/www/Jmol/cylinder-jmol.zip|
obj_877928.pmesh
script ERROR: io error reading
http://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/cylinder-jmol.zip|SCRIPT:
java.security.AccessControlException: access denied
(java.net.SocketPermission math.webwork.rochester.edu:80
connect,resolve)
eval ERROR:
----line 1 command 1:
script >> "http://math.webwork.rochester.edu/
webwork2_course_files/fall08mth142/cylinder-jmol.zip|SCRIPT" <<


---------------- end output from Java console -------------------



Thank you for all of your help.

Best Regards,

Paul

Jonathan

unread,
Dec 9, 2009, 9:34:52 AM12/9/09
to sage-edu
Paul,
Jmol has already solved this problem. The issue is that we have to
convert the type of files that are produced for Jmol in SAGE. For the
time being you can use the same method that SAGE uses. In the
directory you will find two files:

1) A file with the extension .jmol. This is a short script that sets
the default directory to the zipped file and instructs Jmol to read
the SCRIPT inside of that.

2) The .zip file with all the surfaces and the script that sets up
Jmol.

What you need to do is generate a new .jmol file with the set
defaultdirectory command set to point to inside the .zip file where
ever you put it.

In theory you could also use Jmol.js and the scriptWait() call to do
the set defaultdirectory from javascript as well.

Hope this gives you some ideas.

Jonathan
> http://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/...
>
> and save it to a local directory that contains "Jmol.js" and
> "JmolApplet.jar".  Notice that the first line of the SCRIPT file was
> added by me and uses verbatim the advice from Robert Hanson about
> setting the default directory.  Create a html file in that same local
> directory with the following code:
>
> -------------------  begin html ----------------------------
>
> <html>
> <head>
> <script type="text/javascript" src="Jmol.js"></script>
> </head>
> <body>
> <!--
> <script>
> jmolInitialize(".",useSignedApplet)
> </script>
> -->
>
> <!-- read cylinder-jmol.zip locally -->
> <script type="text/javascript">
> jmolApplet(["450","450"],"script cylinder-jmol.zip|SCRIPT")
> </script>
>
> <!-- read cylinder-jmol.zip remotely -->
> <script type="text/javascript">
> jmolSetAppletColor("white");
> jmolApplet(["400","400"],"scripthttp://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/...SCRIPT")
> FileManager openinghttp://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/...
> script ERROR: io error readinghttp://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/...SCRIPT:
> ...
>
> read more »

Paul Pearson

unread,
Jan 5, 2010, 11:51:22 AM1/5/10
to sage-edu
Dear Jonathan,

I just talked with Bob Hanson (of the St. Olaf Chemistry department)
about setting the defaultdirectory. He pointed out that the .jmol
file you use to set the defaultdirectory is now unnecessary because it
is possible to set the defaultdirectory as a parameter to the Jmol.js
script since version 11.6.?? of the (unsigned) JmolApplet.jar. In
particular, the html code to do this is

-------- begin code ---------------

<script type="text/javascript" src="https://math.webwork.rochester.edu/
webwork2_course_files/fall08mth142/applets/Jmol.js"></script>

<script type="text/javascript">
jmolSetAppletColor("white");

jmolApplet(["450","450"],"set defaultdirectory \"https://
math.webwork.rochester.edu/webwork2_course_files/fall08mth142/sage.zip
\"; script SCRIPT")
</script>

--------- end code -----------------

where Jmol.js and JmolApplet.jar are in the coruseURL/applets
directory, and sage.zip in the courseURL directory is the zip file
that contains the SCRIPT file and any .pmesh files for plotting the
graph (this is usually named something like sage0-
size500-???????.zip). If the html file is in the same directory as
sage.zip, you can replace one line above with

---------- begin code -------------
jmolApplet(["450","450"],"set defaultdirectory \"sage.zip\"; script
SCRIPT")
---------- end code ---------------

Setting the defaultdirectory to a zip file tells Jmol to look for any
included files (such as .pmesh) inside that zip file. Perhaps SAGE
should upgrade to a newer version of the unsigned JmolApplet.jar file
(to 11.6 or higher) so that the trick above for setting the
defaultdirectory can be used instead of the .jmol file trick needed
for older versions of the java applet.

Thank you for all of your help.

Paul


On Dec 9 2009, 8:34 am, Jonathan <gu...@uwosh.edu> wrote:
> Paul,

>  Jmolhas already solved this problem.  The issue is that we have to
> convert the type of files that are produced forJmolin SAGE.  For the


> time being you can use the same method that SAGE uses.  In the
> directory you will find two files:
>
> 1) A file with the extension .jmol.  This is a short script that sets

> the default directory to the zipped file and instructsJmolto read


> the SCRIPT inside of that.
>
> 2) The .zip file with all the surfaces and the script that sets upJmol.
>

> What you need to do is generate a new .jmolfile with the set


> defaultdirectory command set to point to inside the .zip file where
> ever you put it.
>

> In theory you could also useJmol.js and the scriptWait() call to do


> the set defaultdirectory from javascript as well.
>
> Hope this gives you some ideas.
>
> Jonathan
>
> On Dec 8, 5:18 pm, Paul Pearson <paultpear...@gmail.com> wrote:
>
> > Dear Jonathan and others,
>
> > I am a webwork developer, though not one of the main developers.  I
> > have been successful at displaying a SAGE generated 3d plot from

> > within webwork using theJmolapplet provided that the plot data file


> > uses no pmesh input files.  Sage generates a zipped plot data file
> > sage0...stuff...zip which contains a SCRIPT file and may contain

> > several pmesh data files.  I am able to getJmolto read the SCRIPT


> > file, but the lines in the SCRIPT file that load the pmesh files are
> > not executing correctly.  I have emailed Robert Hanson (the upstream

> >Jmolcontact) about this, and his advice was as follows


>
> > ---------- begin email correspondence --------------------
>

> >Jmolopens and reads selected files within a zip file. To do this,


> > just use "|" to specify directories within the zip file:
>
> > script cylinder-jmol.zip|SCRIPT
>
> > since the other files are in that zip file as well, you also have to
> > indicate a default path:
>
> > set defaultdirectory "cylinder-jmol.zip|"
>
> > Note the vertical line to indicate we want files within the zip file's
> > main directory.
>
> > then when you execute
>
> > script SCRIPT
>
> > it works.
>
> > ---------- end email correspondence ----------------------
>
> > I am guessing that the SAGE developers have already figured out how to
> > make this "defaultdirectory" issue work for zip files in remote
> > directories, and if you would be able to describe to me how you make
> > it work, that would be greatly appreciated.  I like your idea of

> > having a single input file forJmolthat is "portable" in the sense
> > that it can be put anywhere, read as input toJmol, and it will work.

> > jmolApplet(["400","400"],"scripthttp://math.webwork.rochester.edu/webwork2_course_files/fall08mth142/...")


> > </script>
>
> > </body>
> > </html>
>
> > --------------------- end html -------------------------
>
> > You should see a closed cylinder with some vectors on the left from

> > the local copy, and a blankJmolapplet (except for the wordJmol) on

> >Jmolapplet jmolApplet1__3128490663424304__ initializing


> > AppletRegistry.checkIn(jmolApplet1__3128490663424304__)
> > AppletRegistry.checkIn(jmolApplet0__3128490663424304__)
> > applet context: -applet
> > appletDocumentBase=file:/C:/Durango/www/Jmol/trial-local.html
> > appletCodeBase=file:/C:/Durango/www/Jmol/
> > applet context: -applet
> > appletDocumentBase=file:/C:/Durango/www/Jmol/trial-local.html
> > appletCodeBase=file:/C:/Durango/www/Jmol/
> > (C) 2008JmolDevelopment

> >JmolVersion 11.6.16  2008-11-24 13:39


> > java.vendor:Sun Microsystems Inc.
> > java.version:1.6.0_17
> > os.name:Windows XP
> > memory:1.7/5.2
> > useCommandThread: false
> > appletId:jmolApplet1__3128490663424304__
> > (C) 2008JmolDevelopment

> >JmolVersion 11.6.16  2008-11-24 13:39

> > java.security.AccessControlException: access denied
> > (java.net.SocketPermission math.webwork.rochester.edu:80
> > connect,resolve)
> > eval ERROR:
> > ----line 1 command 1:
> >          script >> "http://math.webwork.rochester.edu/
> > webwork2_course_files/fall08mth142/cylinder-jmol.zip|SCRIPT" <<
>
> > ---------------- end output from Java console -------------------
>
> > Thank you for all of your help.
>
> > Best Regards,
>
> > Paul
>
> > On Dec 6, 4:34 pm, Jonathan <gu...@uwosh.edu> wrote:
>
> > > Paul,
> > >   1)  Removing the flicker idea is good.  We'll see about implementing
> > > that.
> > >   2) Tell me if the following is what your envision.
> > > *You want a link you can use to download the file generated forJmol
> > > in SAGE.

> > > *You want that file to work in theJmolapplication (or is it the


> > > applet) no matter where you put it.
>
> > > The first part is really easy.  The second part is a bit harder.  Jmol
> > > can generate this kind of file from loaded data, but we will have to

> > > rewrite the SAGE code that generates the files forJmolto get those


> > > kinds of files on the server.  That is why I suggested the signed
> > > applet.  Since they are allowed to write to the local disc if the user
> > > agrees, they can take whatever data is in them and generate a file you
> > > can move around.  If you are doing this all inside a web application,
> > > there are other ways to do this from javascript.  You would just have

> > > to move data generated in javascript to the server.  Jmolcan generate


> > > a "state" script, which would point to all the necessary data on the
> > > server (assuming it is the same one, otherwise you have to use the
> > > signed applet).  That script is all that would have to be moved into

> > > the homework.  The other issue is gettingJmolto behave within the


> > > WebWork framework.  I don't know what those requirements are.  I know
> > > from discussions with other people that you have to be very careful

> > > when embeddingJmolin things like Moodle and Wiki sites.
>
> > > Jonathan
>
> ...
>
> read more »

Jonathan

unread,
Jan 6, 2010, 9:31:58 AM1/6/10
to sage-edu
Paul,
This is correct and is they way I would like things to work. The
issue is that how SAGE knows that it should use Jmol will need to be
changed. SAGE will have to generate the new .jmol file format.
At present I am working on the web GUI part of this. I then intend
to help the SAGE people re-write the way they pre-process and save
data for Jmol. Bob has also finished coding the parts to make Jmol
handle raw unscaled surfaces better than it presently does. I think
we will be able to have SAGE do much less front-end work, but it is
going to take some time to get this all sorted out.

Presently we're looking at the best option for a color picker to
adjust the display. If you want to look and comment on that, please
see the links:

1) My testing code without Jmol, mostly designed to play with the look
and feel

http://www.uwosh.edu/faculty_staff/gutow/Jmol_Web_Page_Maker/JmolColorPicker/Test%20VSColorPicker.html

2) A simpler version attached to Jmol

http://www.uwosh.edu/faculty_staff/gutow/Jmol_Web_Page_Maker/JmolColorPicker/Jmol%20Color%20Picker%20Test.html

Jonathan

> ...
>
> read more »

Reply all
Reply to author
Forward
0 new messages