Currently what basically happens (IIRC) is that the image is saved to
disk in the temporary execution directory (in
sage.plot.plot.Graphics.save()). After the computation is done, the
notebook process looks through the files that were saved and sends links
to the browser (in sagenb.notebook.cell.Cell.files_html()). For
example, if it finds a jpg or png file, it sends an <img> tag to the
browser. The browser then requests the actual png file. If the file
hasn't been copied to the worksheet directory yet, then a symbolic link
is made to the temporary execution directory. At any rate, the notebook
server returns the actual image file.
Does that help? I think you would need to just get scilab to save the
image into the temporary execution directory and then Sage itself would
handle rendering the image, since Sage doesn't care who generated the
image. It just displays whatever images are in the temporary execution
directory.
Thanks,
Jason
This is a scilab question; I don't know scilab. You just need to figure
out how to access environment variables from within scilab.
As for saving to the right temporary directory for the image to be
picked up in the notebook, that should be the current working directory
when the code is executing. So just saving to the current directory
should work...
Thanks,
Jason
Tell scilab to save in the directory that is output in that cell when
you type "os.getcwd()" in Sage. This is probably in
/tmp on your computer...
> Any work arounds ? I save it with: "xs2jpg(0,string(pwd())+'/test.jpg');".
> Whats wrong ?
>
--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
William meant for you to run os.getcwd() in the notebook, probably in
the same cell, not in the command line before starting the noteobook.
when you do just:
xs2jpg(0,'test.jpg')
does the graphic not appear? I would think that that command would save
the graphic in the current working directory, which is exactly what you
want.
The pwd() function in scilab gets the current directory. If you put
print the result of pwd() in scilab, what directory does it give?
Thanks,
Jason
WARNING: Due to your configuration limitations, Scilab switched in a mode where mixing uicontrols and graphics is not avail able. Type "help usecanvas" for more information. |
>
> Now the main thing : Are the figures/graphs generated need to be stored
> in the /tmp/tmpXXXX directory ?
Yes. That is what I meant when I said that your code is run in a
temporary directory specific to that cell. Sage will copy any files
created (including images) from this temporary directory back into the
sage notebook worksheet directory after the cell finishes executing.
>
> I tried saving it with xs2jpg(0,'test,jpg') the image doesn't show up
> for the first time, what happens is I get a error message like:
>
>
>
> WARNING: Due to your configuration limitations, Scilab switched in a
> mode where mixing uicontrols and graphics is not avail
> able. Type"help usecanvas" for more information.
>
I have no clue what this error message is about or how to prevent it.
It sounds like the image isn't being generated, which would explain no
image showing up.
> which should not happen given I am calling with *'scilab-adv-cli -nb'
> . *Is it the reason?
>
> Also is their an equivalent in Scilab mode for "os.getcwd()" ?
>
That is the scilab pwd() command that I mentioned in my message (see below).
Thanks,
Jason
>
>
> On 3 September 2011 18:01, Jason Grout <jason...@creativetrax.com
> <mailto:jason...@creativetrax.com>> wrote:
>
> On 9/3/11 5:07 AM, Saket Choudhary wrote:
>
> I am kind of still stuck badly.
> I am probably stuck because of my failure to understand where
> should I
> be storing the "test.jpg" file for it to be rendered in the browser
> after Scilab computation.
>
> 1. I run SAGE and then do a "os.getcwd()" . The output for the
> follwoing is:
> *'/home/saket/Downloads/sage-__4.7-linux-32bit-ubuntu_10.04___lts-i686-Linux'*
> *
> *
> 2.I hardcode my Scilab code to save the image as follows in the SAGE
> notebook:
>
> x=[0:0.5;3.14];
> y=sin(x);
> scf(0);
> plot2d (x,y);
> *xs2jpg(0,'/home/saket/__Downloads/sage-4.7-linux-__32bit-ubuntu_10.04_lts-i686-__Linux/test.jpg')*
Each time the code in a cell is executed, the Python interpreter is
changed to a certain temporary directory. There are dozens of pexpect
interfaces, and it would be inefficient to *also* change their
directories to that same temporary directory.
There is an example of how to get the current Python directory and
output an image to it with the Mathematica interface. See the show()
function in
SAGE_ROOT/devel/sage/sage/interfaces/mathematica.py
-- William
--