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