<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Sushil,<div class=""><br class=""></div><div class="">I think so — here is an example of 3D streamline with mplot3d: <a href="http://yt-project.org/docs/dev/cookbook/complex_plots.html#plotting-streamlines" class="">http://yt-project.org/docs/dev/cookbook/complex_plots.html#plotting-streamlines</a>, and you could modify it for quiver plotting by adopting this example: <a href="http://matplotlib.org/examples/mplot3d/quiver3d_demo.html" class="">http://matplotlib.org/examples/mplot3d/quiver3d_demo.html</a></div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Best wishes,</div><div class="">--</div><div class="">Suoqing JI</div><div class="">Ph.D Candidate</div><div class="">Department of Physics</div><div class="">University of California, Santa Barbara</div><div class=""><a href="http://web.physics.ucsb.edu/~suoqing" class="">http://web.physics.ucsb.edu/~suoqing</a></div></div></div></div></div></div></div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Mar 16, 2016, at 1:56 PM, Sushilkumar <<a href="mailto:sushil.sush19us@gmail.com" class="">sushil.sush19us@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Dear Suoqing Ji and yt:<br class=""><br class=""></div>Thank you for your help. It worked<br class=""><br class=""></div>In addition, does yt support 3D quiver plots?<br class=""><br class=""></div>If not what is the equivalent for visualizing 3d magnetic fields. <br class=""><div class=""><br class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Mar 16, 2016 at 2:49 PM,  <span dir="ltr" class=""><<a href="mailto:yt-users-request@lists.spacepope.org" target="_blank" class="">yt-users-request@lists.spacepope.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send yt-users mailing list submissions to<br class="">
        <a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">
<br class="">
To subscribe or unsubscribe via the World Wide Web, visit<br class="">
        <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br class="">
or, via email, send a message with subject or body 'help' to<br class="">
        <a href="mailto:yt-users-request@lists.spacepope.org" class="">yt-users-request@lists.spacepope.org</a><br class="">
<br class="">
You can reach the person managing the list at<br class="">
        <a href="mailto:yt-users-owner@lists.spacepope.org" class="">yt-users-owner@lists.spacepope.org</a><br class="">
<br class="">
When replying, please edit your Subject line so it is more specific<br class="">
than "Re: Contents of yt-users digest..."<br class="">
<br class="">
<br class="">
Today's Topics:<br class="">
<br class="">
   1. Error while using annotate magnetic fields (Sushilkumar)<br class="">
   2. Re: Error while using annotate magnetic fields (Suoqing Ji)<br class="">
<br class="">
<br class="">
----------------------------------------------------------------------<br class="">
<br class="">
Message: 1<br class="">
Date: Wed, 16 Mar 2016 14:16:37 -0500<br class="">
From: Sushilkumar <<a href="mailto:sushil.sush19us@gmail.com" class="">sushil.sush19us@gmail.com</a>><br class="">
To: Discussion of the yt analysis package<br class="">
        <<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a>><br class="">
Subject: [yt-users] Error while using annotate magnetic fields<br class="">
Message-ID:<br class="">
        <<a href="mailto:CAKARaKWgFBsh7qZj8Px%2BOS0-tDUOuKcv2MrWyJh3NaGtj06-9g@mail.gmail.com" class="">CAKARaKWgFBsh7qZj8Px+OS0-tDUOuKcv2MrWyJh3NaGtj06-9g@mail.gmail.com</a>><br class="">
Content-Type: text/plain; charset="utf-8"<br class="">
<br class="">
Dear yt:<br class="">
<br class="">
I am trying to plot magnetic field lines using the annotate magnetic field<br class="">
call back from the link <a href="http://yt-project.org/doc/visualizing/callbacks.html" rel="noreferrer" target="_blank" class="">http://yt-project.org/doc/visualizing/callbacks.html</a><br class="">
link.<br class="">
<br class="">
However, after running the script it gives the error below. A google drive<br class="">
link to my script (yt_numpy_load_B.py) is also given below. When I use<br class="">
quiver annotate it works fine but issue comes when I am using<br class="">
slc.annotate_magnetic_field().<br class="">
Quiver plots are also available on the drive link.<br class="">
<br class="">
Thanks in advance<br class="">
<br class="">
===============<br class="">
Google drive link<br class="">
<a href="https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc" rel="noreferrer" target="_blank" class="">https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc</a><br class="">
===============<br class="">
<br class="">
===============<br class="">
Error while running the script<br class="">
<br class="">
  File "yt_numpy_load_B.py", line 47, in <module><br class="">
    slc.save()<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_container.py",<br class="">
line 77, in newfunc<br class="">
    args[0]._setup_plots()<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py",<br class="">
line 980, in _setup_plots<br class="">
    self.run_callbacks()<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py",<br class="">
line 1033, in run_callbacks<br class="">
    sys.exc_info()[2])<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py",<br class="">
line 1029, in run_callbacks<br class="">
    callback(cbw)<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py",<br class="">
line 316, in __call__<br class="">
    return qcb(plot)<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py",<br class="">
line 357, in __call__<br class="">
    fv_x = plot.data[self.field_x]<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py",<br class="">
line 246, in __getitem__<br class="">
    f = self._determine_fields([key])[0]<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py",<br class="">
line 518, in _determine_fields<br class="">
    finfo = self.ds._get_field_info("unknown", fname)<br class="">
  File<br class="">
"/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/static_output.py",<br class="">
line 543, in _get_field_info<br class="">
    raise YTFieldNotFound((ftype, fname), self)<br class="">
yt.utilities.exceptions.YTPlotCallbackError: annotate_magnetic_field<br class="">
callback failed with the following error: Could not find field '('all',<br class="">
'magnetic_field_x')' in UniformGridData.<br class="">
===============<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
On Wed, Mar 16, 2016 at 12:52 PM, <<a href="mailto:yt-users-request@lists.spacepope.org" class="">yt-users-request@lists.spacepope.org</a>><br class="">
wrote:<br class="">
<br class="">
> Send yt-users mailing list submissions to<br class="">
>         <a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">
><br class="">
> To subscribe or unsubscribe via the World Wide Web, visit<br class="">
>         <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br class="">
> or, via email, send a message with subject or body 'help' to<br class="">
>         <a href="mailto:yt-users-request@lists.spacepope.org" class="">yt-users-request@lists.spacepope.org</a><br class="">
><br class="">
> You can reach the person managing the list at<br class="">
>         <a href="mailto:yt-users-owner@lists.spacepope.org" class="">yt-users-owner@lists.spacepope.org</a><br class="">
><br class="">
> When replying, please edit your Subject line so it is more specific<br class="">
> than "Re: Contents of yt-users digest..."<br class="">
><br class="">
><br class="">
> Today's Topics:<br class="">
><br class="">
>    1. Re: Making averaged line plot. (Suoqing Ji)<br class="">
><br class="">
><br class="">
> ----------------------------------------------------------------------<br class="">
><br class="">
> Message: 1<br class="">
> Date: Tue, 15 Mar 2016 15:23:43 -0700<br class="">
> From: Suoqing Ji <<a href="mailto:suoqing@physics.ucsb.edu" class="">suoqing@physics.ucsb.edu</a>><br class="">
> To: Discussion of the yt analysis package<br class="">
>         <<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a>><br class="">
> Subject: Re: [yt-users] Making averaged line plot.<br class="">
> Message-ID: <<a href="mailto:70E5BA6C-7798-45F2-AE83-21233252E109@physics.ucsb.edu" class="">70E5BA6C-7798-45F2-AE83-21233252E109@physics.ucsb.edu</a>><br class="">
> Content-Type: text/plain; charset="utf-8"<br class="">
><br class="">
> Hi Yuxiao,<br class="">
><br class="">
> If you would like to start from your current code, the most<br class="">
> straightforward way is to write a loop to smooth over a certain distance by<br class="">
> each step, which also works for AMR data:<br class="">
><br class="">
> smooth_len = 100 # smoothing length of 100 kpc<br class="">
> SmoothedBMag = np.copy(ray[?ScaledBMag?]) # store the smoothed array<br class="">
> bin_num = np.ceiling((ray[?x?].max() - ray[?x?].min()) / smooth_len) #<br class="">
> make bins every 100 kpc<br class="">
><br class="">
> for step in range(bin_num):<br class="">
>     mask1 = (ray[?x?] >= ray[?x?].min() + step * smooth_len)<br class="">
>     mask2 = (ray[?x?] < ray[?x?].min() + (step + 1) * smooth_len)<br class="">
>     mask = np.logical_and(mask1, mask2) # mask the cells within a certain<br class="">
> length of 100 kpc<br class="">
>     SmoothedBMag[mask] = np.mean(ray[?ScaledBMag?][mask]) # take the<br class="">
> average and save<br class="">
><br class="">
> After that the array ?SmoothedBMag? is the smoothed one.<br class="">
><br class="">
> However, an easier way is to use the the 1D ProfilePlot function (<br class="">
> <a href="http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots" rel="noreferrer" target="_blank" class="">http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots</a> <<br class="">
> <a href="http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots" rel="noreferrer" target="_blank" class="">http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots</a>>),<br class="">
> and in this case you could do something like:<br class="">
><br class="">
> plot = ProfilePlot(pf.h.all_data(), ?x?, [?ScaledBMag?], n_bins=bin_num)<br class="">
><br class="">
> Note that this will do the average over entire y-z plane for each x bins,<br class="">
> which is different from averaging only an array of a ray object (so maybe<br class="">
> it?s not what you want). If you really want the data within a thin slit<br class="">
> only, you could define a region object pf.h.region() and do ProfilePlot. I<br class="">
> think it?s also doable to use the function ?load_uniform_grid? to create a<br class="">
> 1D dataset from the arrays in ray object and pass it to ProfilePlot.<br class="">
><br class="">
> Best wishes,<br class="">
> --<br class="">
> Suoqing JI<br class="">
> Ph.D Candidate<br class="">
> Department of Physics<br class="">
> University of California, Santa Barbara<br class="">
> <a href="http://web.physics.ucsb.edu/~suoqing" rel="noreferrer" target="_blank" class="">http://web.physics.ucsb.edu/~suoqing</a><br class="">
><br class="">
> > On Mar 14, 2016, at 10:57 PM, Yuxiao Dai <<a href="mailto:yuxiao.dai@nyu.edu" class="">yuxiao.dai@nyu.edu</a>> wrote:<br class="">
> ><br class="">
> > Dear all,<br class="">
> ><br class="">
> > I have a line plot of some parameter along an axis as a function of<br class="">
> distance. Now I would like to get another line plot of the same parameter<br class="">
> but averaged over a certain distance (say 100 kpc, the plot below is<br class="">
> supposed to be flat after this). I've been searching the document for some<br class="">
> time but haven't found a method. Is there a simple way to do this?<br class="">
> ><br class="">
> > I would very much appreciate it if anyone could help me on this.<br class="">
> ><br class="">
> ><br class="">
> > ===================================<br class="">
> > import ...<br class="">
> ><br class="">
> > def _ScaledBMag(field, data):<br class="">
> ><br class="">
> >     return ...<br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> > ....<br class="">
> ><br class="">
> > pf = load(filename)<br class="">
> ><br class="">
> >     add_field("ScaledBMag", function=_ScaledBMag)<br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> >     c = pf.h.find_max('ScaledBMag')[1]<br class="">
> ><br class="">
> >     ax = 0<br class="">
> ><br class="">
> >     ray = pf.h.ortho_ray(ax, (c[1], c[2]))<br class="">
> ><br class="">
> ><br class="">
> >     P.subplot(211)<br class="">
> ><br class="">
> >     P.semilogy(ray['x'], ray['ScaledBMag'])<br class="">
> ><br class="">
> >     P.xlabel('x')<br class="">
> ><br class="">
> >     P.ylabel('ScaledBMag')<br class="">
> ><br class="">
> >     print "works"<br class="">
> ><br class="">
> >     P.savefig("ScaledBMag_lineplot.png")<br class="">
> ><br class="">
> ><br class="">
> > <image.png><br class="">
> ><br class="">
> > ===================================<br class="">
> > I'm using yt<br class="">
> ><br class="">
> > Version = 2.6.1<br class="">
> ><br class="">
> ><br class="">
> > Changeset = c994959ed3be<br class="">
> ><br class="">
> > ===================================<br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> > Regards,<br class="">
> ><br class="">
> > Dai<br class="">
> ><br class="">
> > _______________________________________________<br class="">
> > yt-users mailing list<br class="">
> > <a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">
> > <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br class="">
><br class="">
> -------------- next part --------------<br class="">
> An HTML attachment was scrubbed...<br class="">
> URL: <<br class="">
> <a href="http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160315/8afc239c/attachment.html" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160315/8afc239c/attachment.html</a><br class="">
> ><br class="">
><br class="">
> ------------------------------<br class="">
><br class="">
> Subject: Digest Footer<br class="">
><br class="">
> _______________________________________________<br class="">
> yt-users mailing list<br class="">
> <a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">
> <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br class="">
><br class="">
><br class="">
> ------------------------------<br class="">
><br class="">
> End of yt-users Digest, Vol 97, Issue 19<br class="">
> ****************************************<br class="">
><br class="">
<br class="">
<br class="">
<br class="">
--<br class="">
*SK2*<br class="">
<br class="">
*"**Claiming that something can move faster than light is a good<br class="">
conversation-stopper in physics. People edge away from you in cocktail<br class="">
parties; friends never return phone calls. You just don?t mess with Albert<br class="">
Einstein.**"*<br class="">
-------------- next part --------------<br class="">
An HTML attachment was scrubbed...<br class="">
URL: <<a href="http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160316/9ea3afb5/attachment-0001.htm" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160316/9ea3afb5/attachment-0001.htm</a>><br class="">
<br class="">
------------------------------<br class="">
<br class="">
Message: 2<br class="">
Date: Wed, 16 Mar 2016 12:49:09 -0700<br class="">
From: Suoqing Ji <<a href="mailto:suoqing@physics.ucsb.edu" class="">suoqing@physics.ucsb.edu</a>><br class="">
To: Discussion of the yt analysis package<br class="">
        <<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a>><br class="">
Subject: Re: [yt-users] Error while using annotate magnetic fields<br class="">
Message-ID: <<a href="mailto:9CA99B80-FF30-44F0-B8C8-74EBC0A4E3CA@physics.ucsb.edu" class="">9CA99B80-FF30-44F0-B8C8-74EBC0A4E3CA@physics.ucsb.edu</a>><br class="">
Content-Type: text/plain; charset="utf-8"<br class="">
<br class="">
Hi Sushil,<br class="">
<br class="">
I think what you need to do is to assign the correct field name when loading the data. In your script, you have:<br class="">
<br class="">
data = dict(field1 = field1,<br class="">
            field2 = field2,<br class="">
            field3 = field3)<br class="">
<br class="">
which could be, say,<br class="">
<br class="">
data = dict(magnetic_field_x = field1,<br class="">
            magnetic_field_y = field2,<br class="">
            magnetic_field_z = field3)<br class="">
<br class="">
since annotate_magnetic_field will directly refer to these field names (in fact it's a specialized version of annotate_quiver).<br class="">
<br class="">
Best wishes,<br class="">
--<br class="">
Suoqing JI<br class="">
Ph.D Candidate<br class="">
Department of Physics<br class="">
University of California, Santa Barbara<br class="">
<a href="http://web.physics.ucsb.edu/~suoqing" rel="noreferrer" target="_blank" class="">http://web.physics.ucsb.edu/~suoqing</a><br class="">
<br class="">
> On Mar 16, 2016, at 12:16 PM, Sushilkumar <<a href="mailto:sushil.sush19us@gmail.com" class="">sushil.sush19us@gmail.com</a>> wrote:<br class="">
><br class="">
> Dear yt:<br class="">
><br class="">
> I am trying to plot magnetic field lines using the annotate magnetic field call back from the link <a href="http://yt-project.org/doc/visualizing/callbacks.html" rel="noreferrer" target="_blank" class="">http://yt-project.org/doc/visualizing/callbacks.html</a> <<a href="http://yt-project.org/doc/visualizing/callbacks.html" rel="noreferrer" target="_blank" class="">http://yt-project.org/doc/visualizing/callbacks.html</a>> link.<br class="">
><br class="">
> However, after running the script it gives the error below. A google drive link to my script (yt_numpy_load_B.py) is also given below. When I use quiver annotate it works fine but issue comes when I am using slc.annotate_magnetic_field().<br class="">
> Quiver plots are also available on the drive link.<br class="">
><br class="">
> Thanks in advance<br class="">
><br class="">
> ===============<br class="">
> Google drive link<br class="">
> <a href="https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc" rel="noreferrer" target="_blank" class="">https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc</a> <<a href="https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc" rel="noreferrer" target="_blank" class="">https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc</a>><br class="">
> ===============<br class="">
><br class="">
> ===============<br class="">
> Error while running the script<br class="">
><br class="">
>   File "yt_numpy_load_B.py", line 47, in <module><br class="">
>     slc.save()<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_container.py", line 77, in newfunc<br class="">
>     args[0]._setup_plots()<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 980, in _setup_plots<br class="">
>     self.run_callbacks()<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 1033, in run_callbacks<br class="">
>     sys.exc_info()[2])<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 1029, in run_callbacks<br class="">
>     callback(cbw)<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py", line 316, in __call__<br class="">
>     return qcb(plot)<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py", line 357, in __call__<br class="">
>     fv_x = plot.data[self.field_x]<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py", line 246, in __getitem__<br class="">
>     f = self._determine_fields([key])[0]<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py", line 518, in _determine_fields<br class="">
>     finfo = self.ds._get_field_info("unknown", fname)<br class="">
>   File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/static_output.py", line 543, in _get_field_info<br class="">
>     raise YTFieldNotFound((ftype, fname), self)<br class="">
> yt.utilities.exceptions.YTPlotCallbackError: annotate_magnetic_field callback failed with the following error: Could not find field '('all', 'magnetic_field_x')' in UniformGridData.<br class="">
> ===============<br class="">
><br class="">
><br class="">
><br class="">
><br class="">
> On Wed, Mar 16, 2016 at 12:52 PM, <<a href="mailto:yt-users-request@lists.spacepope.org" class="">yt-users-request@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users-request@lists.spacepope.org" class="">yt-users-request@lists.spacepope.org</a>>> wrote:<br class="">
> Send yt-users mailing list submissions to<br class="">
>         <a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a>><br class="">
><br class="">
> To subscribe or unsubscribe via the World Wide Web, visit<br class="">
>         <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a> <<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a>><br class="">
> or, via email, send a message with subject or body 'help' to<br class="">
>         <a href="mailto:yt-users-request@lists.spacepope.org" class="">yt-users-request@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users-request@lists.spacepope.org" class="">yt-users-request@lists.spacepope.org</a>><br class="">
><br class="">
> You can reach the person managing the list at<br class="">
>         <a href="mailto:yt-users-owner@lists.spacepope.org" class="">yt-users-owner@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users-owner@lists.spacepope.org" class="">yt-users-owner@lists.spacepope.org</a>><br class="">
><br class="">
> When replying, please edit your Subject line so it is more specific<br class="">
> than "Re: Contents of yt-users digest..."<br class="">
><br class="">
><br class="">
> Today's Topics:<br class="">
><br class="">
>    1. Re: Making averaged line plot. (Suoqing Ji)<br class="">
><br class="">
><br class="">
> ----------------------------------------------------------------------<br class="">
><br class="">
> Message: 1<br class="">
> Date: Tue, 15 Mar 2016 15:23:43 -0700<br class="">
> From: Suoqing Ji <<a href="mailto:suoqing@physics.ucsb.edu" class="">suoqing@physics.ucsb.edu</a> <mailto:<a href="mailto:suoqing@physics.ucsb.edu" class="">suoqing@physics.ucsb.edu</a>>><br class="">
> To: Discussion of the yt analysis package<br class="">
>         <<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a>>><br class="">
> Subject: Re: [yt-users] Making averaged line plot.<br class="">
> Message-ID: <<a href="mailto:70E5BA6C-7798-45F2-AE83-21233252E109@physics.ucsb.edu" class="">70E5BA6C-7798-45F2-AE83-21233252E109@physics.ucsb.edu</a> <mailto:<a href="mailto:70E5BA6C-7798-45F2-AE83-21233252E109@physics.ucsb.edu" class="">70E5BA6C-7798-45F2-AE83-21233252E109@physics.ucsb.edu</a>>><br class="">
> Content-Type: text/plain; charset="utf-8"<br class="">
><br class="">
> Hi Yuxiao,<br class="">
><br class="">
> If you would like to start from your current code, the most straightforward way is to write a loop to smooth over a certain distance by each step, which also works for AMR data:<br class="">
><br class="">
> smooth_len = 100 # smoothing length of 100 kpc<br class="">
> SmoothedBMag = np.copy(ray[?ScaledBMag?]) # store the smoothed array<br class="">
> bin_num = np.ceiling((ray[?x?].max() - ray[?x?].min()) / smooth_len) # make bins every 100 kpc<br class="">
><br class="">
> for step in range(bin_num):<br class="">
>     mask1 = (ray[?x?] >= ray[?x?].min() + step * smooth_len)<br class="">
>     mask2 = (ray[?x?] < ray[?x?].min() + (step + 1) * smooth_len)<br class="">
>     mask = np.logical_and(mask1, mask2) # mask the cells within a certain length of 100 kpc<br class="">
>     SmoothedBMag[mask] = np.mean(ray[?ScaledBMag?][mask]) # take the average and save<br class="">
><br class="">
> After that the array ?SmoothedBMag? is the smoothed one.<br class="">
><br class="">
> However, an easier way is to use the the 1D ProfilePlot function (<a href="http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots" rel="noreferrer" target="_blank" class="">http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots</a> <<a href="http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots" rel="noreferrer" target="_blank" class="">http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots</a>> <<a href="http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots" rel="noreferrer" target="_blank" class="">http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots</a> <<a href="http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots" rel="noreferrer" target="_blank" class="">http://yt-project.org/docs/2.6/visualizing/plots.html#d-profile-plots</a>>>), and in this case you could do something like:<br class="">
><br class="">
> plot = ProfilePlot(pf.h.all_data(), ?x?, [?ScaledBMag?], n_bins=bin_num)<br class="">
><br class="">
> Note that this will do the average over entire y-z plane for each x bins, which is different from averaging only an array of a ray object (so maybe it?s not what you want). If you really want the data within a thin slit only, you could define a region object pf.h.region() and do ProfilePlot. I think it?s also doable to use the function ?load_uniform_grid? to create a 1D dataset from the arrays in ray object and pass it to ProfilePlot.<br class="">
><br class="">
> Best wishes,<br class="">
> --<br class="">
> Suoqing JI<br class="">
> Ph.D Candidate<br class="">
> Department of Physics<br class="">
> University of California, Santa Barbara<br class="">
> <a href="http://web.physics.ucsb.edu/~suoqing" rel="noreferrer" target="_blank" class="">http://web.physics.ucsb.edu/~suoqing</a> <<a href="http://web.physics.ucsb.edu/~suoqing" rel="noreferrer" target="_blank" class="">http://web.physics.ucsb.edu/~suoqing</a>><br class="">
><br class="">
> > On Mar 14, 2016, at 10:57 PM, Yuxiao Dai <<a href="mailto:yuxiao.dai@nyu.edu" class="">yuxiao.dai@nyu.edu</a> <mailto:<a href="mailto:yuxiao.dai@nyu.edu" class="">yuxiao.dai@nyu.edu</a>>> wrote:<br class="">
> ><br class="">
> > Dear all,<br class="">
> ><br class="">
> > I have a line plot of some parameter along an axis as a function of distance. Now I would like to get another line plot of the same parameter but averaged over a certain distance (say 100 kpc, the plot below is supposed to be flat after this). I've been searching the document for some time but haven't found a method. Is there a simple way to do this?<br class="">
> ><br class="">
> > I would very much appreciate it if anyone could help me on this.<br class="">
> ><br class="">
> ><br class="">
> > ===================================<br class="">
> > import ...<br class="">
> ><br class="">
> > def _ScaledBMag(field, data):<br class="">
> ><br class="">
> >     return ...<br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> > ....<br class="">
> ><br class="">
> > pf = load(filename)<br class="">
> ><br class="">
> >     add_field("ScaledBMag", function=_ScaledBMag)<br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> >     c = pf.h.find_max('ScaledBMag')[1]<br class="">
> ><br class="">
> >     ax = 0<br class="">
> ><br class="">
> >     ray = pf.h.ortho_ray(ax, (c[1], c[2]))<br class="">
> ><br class="">
> ><br class="">
> >     P.subplot(211)<br class="">
> ><br class="">
> >     P.semilogy(ray['x'], ray['ScaledBMag'])<br class="">
> ><br class="">
> >     P.xlabel('x')<br class="">
> ><br class="">
> >     P.ylabel('ScaledBMag')<br class="">
> ><br class="">
> >     print "works"<br class="">
> ><br class="">
> >     P.savefig("ScaledBMag_lineplot.png")<br class="">
> ><br class="">
> ><br class="">
> > <image.png><br class="">
> ><br class="">
> > ===================================<br class="">
> > I'm using yt<br class="">
> ><br class="">
> > Version = 2.6.1<br class="">
> ><br class="">
> ><br class="">
> > Changeset = c994959ed3be<br class="">
> ><br class="">
> > ===================================<br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> ><br class="">
> > Regards,<br class="">
> ><br class="">
> > Dai<br class="">
> ><br class="">
> > _______________________________________________<br class="">
> > yt-users mailing list<br class="">
> > <a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a>><br class="">
> > <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a> <<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a>><br class="">
><br class="">
> -------------- next part --------------<br class="">
> An HTML attachment was scrubbed...<br class="">
> URL: <<a href="http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160315/8afc239c/attachment.html" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160315/8afc239c/attachment.html</a> <<a href="http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160315/8afc239c/attachment.html" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160315/8afc239c/attachment.html</a>>><br class="">
><br class="">
> ------------------------------<br class="">
><br class="">
> Subject: Digest Footer<br class="">
><br class="">
> _______________________________________________<br class="">
> yt-users mailing list<br class="">
> <a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a>><br class="">
> <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a> <<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a>><br class="">
><br class="">
><br class="">
> ------------------------------<br class="">
><br class="">
> End of yt-users Digest, Vol 97, Issue 19<br class="">
> ****************************************<br class="">
><br class="">
><br class="">
><br class="">
> --<br class="">
> SK2<br class="">
><br class="">
> "Claiming that something can move faster than light is a good conversation-stopper in physics. People edge away from you in cocktail parties; friends never return phone calls. You just don?t mess with Albert Einstein."<br class="">
><br class="">
> _______________________________________________<br class="">
> yt-users mailing list<br class="">
> <a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">
> <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br class="">
<br class="">
-------------- next part --------------<br class="">
An HTML attachment was scrubbed...<br class="">
URL: <<a href="http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160316/76eb7890/attachment.htm" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160316/76eb7890/attachment.htm</a>><br class="">
<br class="">
------------------------------<br class="">
<br class="">
Subject: Digest Footer<br class="">
<br class="">
_______________________________________________<br class="">
yt-users mailing list<br class="">
<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br class="">
<br class="">
<br class="">
------------------------------<br class="">
<br class="">
End of yt-users Digest, Vol 97, Issue 20<br class="">
****************************************<br class="">
</blockquote></div><br class=""><br clear="all" class=""><br class="">-- <br class=""><div class="gmail_signature"><span style="border-collapse:collapse" class=""><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px" class=""><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse" class=""><b class=""><i class="">SK<sup class="">2</sup></i></b></span></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px" class=""><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse" class=""><b class=""><i class=""><sup class=""><br class=""></sup></i></b></span></div><div class=""><span style="color:rgb(80,0,80);font-family:arial,sans-serif;border-collapse:collapse" class=""><b class=""><sup class="">"</sup></b></span><font face="arial, sans-serif" color="#500050" class=""><b class="">Claiming that something can move faster than light is a good conversation-stopper in physics. People edge away from you in cocktail parties; friends never return phone calls. You just don’t mess with Albert Einstein.</b></font><b style="color:rgb(80,0,80);font-family:arial,sans-serif" class=""><sup class="">"</sup></b></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px" class=""><br class=""></div></span></div>
</div></div></div></div>
_______________________________________________<br class="">yt-users mailing list<br class=""><a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org<br class=""></div></blockquote></div><br class=""></div></body></html>