Hi Matthieu,<br><br>If you already have arrays that you are ready to plot, you are probably better going straight to matplotlib from here.  You can find their documentation here: <a href="http://matplotlib.sourceforge.net/">http://matplotlib.sourceforge.net/</a><br>
This is the package used for most of the plotting and visualization that yt does.<br><br>For example, you would probably want to use pcolormesh to plot up a 2D numpy array:<br><a href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.pcolormesh">http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.pcolormesh</a><br>
<br>Britton<br><br><div class="gmail_quote">On Tue, Nov 8, 2011 at 8:50 AM, Matthieu Dorier <span dir="ltr"><<a href="mailto:matthieu.dorier@gmail.com">matthieu.dorier@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<div><br></div><div>I come back to this discussion, as I have instrumented my simulation to wrap the C++ arrays into NumPy arrays and call a python script in each process.</div><div>This currently works and now I would like to actually do something with these NumPy arrays. I can't find any tutorial on the YT homepage on how to create an image from a NumPy array.</div>

<div>(I'm not only new to YT, I'm also new to Python and learned the basic syntax while coding the wrapper).</div><div><br></div><div>Let's imagine I have a 2D NumPy array of floating point values, and I want to plot it as an image, how would the python code look like?</div>

<div><br></div><div>Thanks</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Matthieu</div></font></span><div class="HOEnZb"><div class="h5"><div><br><div class="gmail_quote">2011/10/5 Matthew Turk <span dir="ltr"><<a href="mailto:matthewturk@gmail.com" target="_blank">matthewturk@gmail.com</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Matthieu,<br>
<div><br>
On Wed, Oct 5, 2011 at 11:45 AM, Matthieu Dorier<br>
<<a href="mailto:matthieu.dorier@gmail.com" target="_blank">matthieu.dorier@gmail.com</a>> wrote:<br>
> Hello Matthew,<br>
><br>
> Thank you for your answer.<br>
><br>
> Can YT work in parallel?<br>
<br>
</div>Yup.<br>
<div><br>
> I intend to embed a python interpreter within my simulation in order to<br>
> allow<br>
> some simple data analysis to be performed without having to re-compile the<br>
> application every time this analysis changes, so maybe it would be possible<br>
> to call YT from an embedded python interpreter? I guess the problem is<br>
> transferring raw data from the simulation to the interpreter without too<br>
> much<br>
> overhead...<br>
<br>
</div>That's actually how Enzo works as well.  We then construct numpy array<br>
wrappers around the already-allocated data, and then feed those to yt<br>
in a dict.<br>
<div><br>
><br>
> My output is actually very simple, consisting in 2D arrays, each MPI rank<br>
> being responsible for several chunks (equally sized, but not necessarily<br>
> contiguous). I would like to avoid writing these 2D arrays into HDF5 file<br>
> and perform visualization on these files, but automatically make the<br>
> processes<br>
> synchronize to compute a single image from all these parts.<br>
<br>
</div>That's what we do with Enzo, except with 3D.  There may be some<br>
oddities to work out with 2D data.<br>
<div><br>
><br>
> Do you think it is worth investigating the use of YT for that or should I<br>
> try other<br>
> softwares?<br>
> Thanks<br>
><br>
> Matthieu<br>
<br>
</div>I think you should give a look at yt -- but also guide your views by<br>
reading how we do in situ with Enzo.  If you look in the Enzo source<br>
code at InitializePythonInterface.C and ExposeDataHierarchy.C you can<br>
see our current method, although I believe in the future with better<br>
memory-pool allocations in Enzo we'll make this a bit more<br>
streamlined.<br>
<br>
Please don't hesitate to write back with more questions!<br>
<br>
Best,<br>
<br>
Matt<br>
<div><div><br>
><br>
> 2011/10/5 Matthew Turk <<a href="mailto:matthewturk@gmail.com" target="_blank">matthewturk@gmail.com</a>><br>
>><br>
>> Hi Matthieu,<br>
>><br>
>> The short answer is that for some codes, yes, yt works as an embedding<br>
>> system.  The only code that this has been used extensively in is Enzo,<br>
>> and it will likely take a bit of work to get it to work.  We're eager<br>
>> to test it out on other codes, however; the first and easiest<br>
>> application would be a non-Enzo, patch-based AMR code.<br>
>><br>
>> The current state is:<br>
>><br>
>>  * In-memory between Enzo and yt works (Britton Smith can speak more to<br>
>> this)<br>
>>  * Creation of arbitrary sources (using the Stream frontend) currently<br>
>> works, which can be used from within any Python code<br>
>>  * No protocol exists (yet) for MPI inter-communicator data loading<br>
>><br>
>> Our strategies for the future:<br>
>><br>
>>  * We're working to create simple C libraries that can create the<br>
>> necessary in-memory data objects to link against yt directly<br>
>>  * The Stream frontend is usable and should be used by non-Enzo codes<br>
>> as a prototyping mechanism<br>
>>  * ParaView can call yt for serial calculations, and we are working to<br>
>> utilize its CoProcessing facilities to analyze and visualize in<br>
>> parallel from running simulations<br>
>><br>
>> So I think you should be able to add a code to in situ viz/analysis,<br>
>> but it will likely take a bit of work at the current time to make sure<br>
>> everything correctly passes.  I'd be able to help you and send you<br>
>> demo code if you would like.  Alternately, we intend to instrument yt<br>
>> to use ParaView as a data loader, which will enable the CoProcessing<br>
>> techniques from ParaView to be used as well.<br>
>><br>
>> Let me know what you think,<br>
>><br>
>> Matt<br>
>><br>
>> On Tue, Oct 4, 2011 at 1:28 PM, Matthieu Dorier<br>
>> <<a href="mailto:matthieu.dorier@gmail.com" target="_blank">matthieu.dorier@gmail.com</a>> wrote:<br>
>> > Hello,<br>
>> ><br>
>> > I'm trying to make in-situ visualization available for a simulation,<br>
>> > and I'm considering different softwares for that (VisIt, YT,...).<br>
>> > I've never used YT, so my question is: is it possible to add<br>
>> > some code in a simulation (written in C++) to have some kind of<br>
>> > distributed rendering engine using YT, just like VisIt does with<br>
>> > code-instrumentation?<br>
>> > Thanks,<br>
>> ><br>
>> > Matthieu<br>
>> ><br>
>> > --<br>
>> > Matthieu Dorier<br>
>> > ENS Cachan, antenne de Bretagne<br>
>> > Département informatique et télécommunication<br>
>> > <a href="http://perso.eleves.bretagne.ens-cachan.fr/%7Emdori307/wiki/" target="_blank">http://perso.eleves.bretagne.ens-cachan.fr/~mdori307/wiki/</a><br>
>> ><br>
>> > _______________________________________________<br>
>> > yt-users mailing list<br>
>> > <a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
>> > <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
>> ><br>
>> ><br>
>> _______________________________________________<br>
>> yt-users mailing list<br>
>> <a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
>> <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
><br>
><br>
><br>
> --<br>
> Matthieu Dorier<br>
> ENS Cachan, antenne de Bretagne<br>
> Département informatique et télécommunication<br>
> <a href="http://perso.eleves.bretagne.ens-cachan.fr/%7Emdori307/wiki/" target="_blank">http://perso.eleves.bretagne.ens-cachan.fr/~mdori307/wiki/</a><br>
><br>
> _______________________________________________<br>
> yt-users mailing list<br>
> <a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
> <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
><br>
><br>
_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Matthieu Dorier<br>ENS Cachan, antenne de Bretagne<br>Département informatique et télécommunication<br><a href="http://perso.eleves.bretagne.ens-cachan.fr/%7Emdori307/wiki" target="_blank">http://perso.eleves.bretagne.ens-cachan.fr/~mdori307/wiki/</a><br>


</div>
</div></div><br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br>