Hello,
I read the slides and checked out the app, and it's great to see more
matplotlib/web2py examples. However, this does not address my use of
web2py for dynamically monitoring a system, which I am having some
trouble with. For example, suppose you wanted to create a "master
view" for your double-slit application, which would present a page
where each time someone ran a new double slit experiment with the
application, the page would update and show some plots from the result
of the double slit. Or perhaps some real-time statistics about all of
the experiments run so far. How would you implement something like
that? The code I posted below seems like it should work for this sort
of real time monitoring, but as I mentioned, I cannot get the images
to dynamically update.

I appreciate any suggestions anyone has.
Thanks,
G

On Nov 16, 10:17 am, mdipierro <[email protected]> wrote:
> I just gave a talk at Supercomputing about it. I will post the app and
> slides later today.
>
> On Nov 16, 10:06 am, G <[email protected]> wrote:
>
> > Hello again,
> > Is anyone else using matplotlib to generate dynamic plots for use with
> > web2py. Any pointers on a better way to do it that will allow dynamic
> > refreshing?
> > Thanks for any help,
> > G
>
> > On Nov 14, 3:42 pm, G <[email protected]> wrote:
>
> > > Hello,
> > > I am using web2py to monitor and control an instrument. I am
> > > dynamically generating plots using matplotlib following the DNA
> > > application example from SC2009 (http://www.web2py.com/examples/static/
> > > sc/sc_dna_talk.pdf)
>
> > > I was able to get the basic aspects working based on that example.
> > > However, I want to automatically display new plots as new data is
> > > available. I am using the following code in the view:
>
> > > <script>
> > > var auto_refresh = setInterval(
> > > function()
> > > {
> > > $('#loaddiv').load('statusbox.load');
> > > $('#threshpng').html('<img src="/myapp/default/dataThreshPlot.png">');}, 
> > > 5000);
>
> > > </script>
> > > <div id="loaddiv">loading...</div>
> > > <div id="threshpng">png loading</div>
>
> > > The statusbox.load generates a table with some statistics about the
> > > data, and this successfully updates every 5 seconds as desired.
> > > However, the dataThreshPlot never gets refreshed, only the initial
> > > version is displayed. (a timestamp is written to the plot when it is
> > > generated so I can verify this fact).
>
> > > If I simply browse to localhost:8000/myapp/default/dataThreshPlot.png
> > > the plot is properly generated and displayed each time I refresh the
> > > page.
>
> > > I have tried adding this code to the dataThreshPlot function in the
> > > controller:
>
> > > response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S
> > > +0000", time.gmtime(time.time()+1))
>
> > > to try to avoid caching, but still no luck.
>
> > > I also tried making a very simple controller function as follows:
>
> > > def dataThreshPage():
> > >     return dict(threshim= URL(r=request,f=dataThreshPlot))
>
> > > and view:
> > > <img src={{=threshim}}>
>
> > > and tested that localhost:8000/myapp/default/dataThreshPage  presents
> > > the plot as expected.
>
> > > I then modified the jquery refresh code to:
>
> > > <script>
> > > var auto_refresh = setInterval(
> > > function()
> > > {
> > > $('#loaddiv').load('statusbox.load');
> > > $('#threshpng').load('/myapp/default/dataThreshPage');}, 5000);
>
> > > </script>
> > > <div id="loaddiv">loading...</div>
> > > <div id="threshpng">png loading</div>
>
> > > but still no luck.
>
> > > Any suggestions for how to get these plots to refresh?
> > > Thank you,
> > > G
>
>

Reply via email to