Hi Sushil,

Thanks for reporting this! I’ve filed an issue here: https://bitbucket.org/yt_analysis/yt/issues/1213/annotate_magnetic_field-fails-with-off

In the meanwhile, you could temporarily circumvent this problem by loading your dataset as velocity field and use “annotate_velocity”...

Best wishes,
--
Suoqing JI
Ph.D Candidate
Department of Physics
University of California, Santa Barbara

On Apr 26, 2016, at 6:31 AM, Sushilkumar <sushil.sush19us@gmail.com> wrote:

Dear Suoqing Ji:

I was able to implement the off axis in my script (drive link below, file is yt_magnetic_fields.py). But there seems to be a problem. For any off axis value like (1,1,0) I get an error which is given below.

I am trying to get a z-x plane and view it at an angle of 15,45,60 degrees respectively. It works for along the axis normal vector like (1,0,0) and so on but for off axis value it gives me the error.

Could you let me know if there is any error in the script or ways to overcome it?

Thanks in advance


https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc



Error:

Traceback (most recent call last):
  File "yt_magnetic_fields.py", line 39, in <module>
    slc.save()
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
    args[0]._setup_plots()
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 980, in _setup_plots
    self.run_callbacks()
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 1033, in run_callbacks
    sys.exc_info()[2])
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 1029, in run_callbacks
    callback(cbw)
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py", line 316, in __call__
    return qcb(plot)
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py", line 837, in __call__
    plot.data[self.field_x],
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py", line 246, in __getitem__
    f = self._determine_fields([key])[0]
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py", line 518, in _determine_fields
    finfo = self.ds._get_field_info("unknown", fname)
  File "/state/partition1/anaconda/lib/python2.7/site-packages/yt/data_objects/static_output.py", line 543, in _get_field_info
    raise YTFieldNotFound((ftype, fname), self)
yt.utilities.exceptions.YTPlotCallbackError: annotate_magnetic_field callback failed with the following error: Could not find field '('all', 'cutting_plane_bx')' in UniformGridData







On Thu, Apr 21, 2016 at 3:46 PM, <yt-users-request@lists.spacepope.org> wrote:
Send yt-users mailing list submissions to
        yt-users@lists.spacepope.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
or, via email, send a message with subject or body 'help' to
        yt-users-request@lists.spacepope.org

You can reach the person managing the list at
        yt-users-owner@lists.spacepope.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of yt-users digest..."


Today's Topics:

   1. Re: Camera Options (Suoqing Ji)


----------------------------------------------------------------------

Message: 1
Date: Thu, 21 Apr 2016 13:45:53 -0700
From: Suoqing Ji <suoqing@physics.ucsb.edu>
To: Discussion of the yt analysis package
        <yt-users@lists.spacepope.org>
Subject: Re: [yt-users] Camera Options
Message-ID: <AAE382DD-ADD2-4D85-BB1E-150B49CFBA40@physics.ucsb.edu>
Content-Type: text/plain; charset="utf-8"

Hi Sushi,

What you need to do this to make use of off-axis slice plot instead of camera; for example, in your code:

L = [1, 0, 0] # View along x axis
north_vector = [0, 0, 1]
slc = yt.SlicePlot(pf, L, ?magnetic_field_x", width=(100,'km?), north_vector=north_vector)
slc.annotate_magnetic_field(factor=40, normalize=True)

which gives you the view along x axis. And if you want to rotate the viewing angle by, say 45 degree, you could change the normal vector L to be L = [1, 1, 0], and redo the plotting.

Also, when you load the data, you probably need to change the name ?field_x? to be ?magnetic_field_x? and so on, so the annotate_magnetic_field function will recognize these names.

Best wishes,
--
Suoqing JI
Ph.D Candidate
Department of Physics
University of California, Santa Barbara
http://web.physics.ucsb.edu/~suoqing

> On Apr 21, 2016, at 1:28 PM, Sushilkumar <sushil.sush19us@gmail.com> wrote:
>
> Dear Suoqing Ji:
>
> The fields Bx,By and Bz are already calculated taking into account the rotation. So I am not sure if I need to calculate it again.
>
> What I would like is only change the camera view to a desired angle after I do a slice plot and that is where I am having trouble with?
>
> Thanks in advance.
>
>
>
>
>
>
> On Thu, Apr 21, 2016 at 3:20 PM, <yt-users-request@lists.spacepope.org <mailto:yt-users-request@lists.spacepope.org>> wrote:
> Send yt-users mailing list submissions to
>         yt-users@lists.spacepope.org <mailto:yt-users@lists.spacepope.org>
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org <http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org>
> or, via email, send a message with subject or body 'help' to
>         yt-users-request@lists.spacepope.org <mailto:yt-users-request@lists.spacepope.org>
>
> You can reach the person managing the list at
>         yt-users-owner@lists.spacepope.org <mailto:yt-users-owner@lists.spacepope.org>
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of yt-users digest..."
>
>
> Today's Topics:
>
>    1. Re: Camera Options (Suoqing Ji)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 21 Apr 2016 13:20:32 -0700
> From: Suoqing Ji <suoqing@physics.ucsb.edu <mailto:suoqing@physics.ucsb.edu>>
> To: Discussion of the yt analysis package
>         <yt-users@lists.spacepope.org <mailto:yt-users@lists.spacepope.org>>
> Subject: Re: [yt-users] Camera Options
> Message-ID: <FB001F5B-2521-4705-8D31-3166451BCA58@physics.ucsb.edu <mailto:FB001F5B-2521-4705-8D31-3166451BCA58@physics.ucsb.edu>>
> Content-Type: text/plain; charset="utf-8"
>
> I see ? that?s a smart way of doing this!
>
> Best wishes,
> Suoqing
>
> > On Apr 21, 2016, at 12:44 PM, Nathan Goldbaum <nathan12343@gmail.com <mailto:nathan12343@gmail.com>> wrote:
> >
> >
> >
> > On Thu, Apr 21, 2016 at 2:41 PM, Suoqing Ji <suoqing@physics.ucsb.edu <mailto:suoqing@physics.ucsb.edu> <mailto:suoqing@physics.ucsb.edu <mailto:suoqing@physics.ucsb.edu>>> wrote:
> > Hi Nathan,
> >
> > I do not have a 3D MHD data at hand, but I?ve tried one with slc.annotate_quiver('velocity_x', 'velocity_y'), which gives the following error:
> >
> >   File "off_axis.py", line 49, in <module>
> >     slc.save(pf.basename)
> >   File "/usr/local/yt3/yt-x86_64/src/yt-hg/yt/visualization/plot_container.py", line 76, in newfunc
> >     args[0].run_callbacks()
> >   File "/usr/local/yt3/yt-x86_64/src/yt-hg/yt/visualization/plot_window.py", line 1029, in run_callbacks
> >     sys.exc_info()[2])
> >   File "/usr/local/yt3/yt-x86_64/src/yt-hg/yt/visualization/plot_window.py", line 1025, in run_callbacks
> >     callback(cbw)
> >   File "/usr/local/yt3/yt-x86_64/src/yt-hg/yt/visualization/plot_modifications.py", line 352, in __call__
> >     (xi, yi) = (ds.coordinates.x_axis[ax],
> > yt.utilities.exceptions.YTPlotCallbackError: annotate_quiver callback failed with the following error: 4
> >
> >
> > Right, I bet it will work if you do `annotate_velocity()` though.
> >
> > You should take a look at the definition of the VelocityCallback to see how it handles off-axis slices.
> >
> > Best wishes,
> > --
> > Suoqing JI
> > Ph.D Candidate
> > Department of Physics
> > University of California, Santa Barbara
> > http://web.physics.ucsb.edu/~suoqing <http://web.physics.ucsb.edu/~suoqing> <http://web.physics.ucsb.edu/~suoqing <http://web.physics.ucsb.edu/~suoqing>>
> >> On Apr 21, 2016, at 12:35 PM, Nathan Goldbaum <nathan12343@gmail.com <mailto:nathan12343@gmail.com> <mailto:nathan12343@gmail.com <mailto:nathan12343@gmail.com>>> wrote:
> >>
> >>
> >>
> >> On Thu, Apr 21, 2016 at 2:30 PM, Suoqing Ji <suoqing@physics.ucsb.edu <mailto:suoqing@physics.ucsb.edu> <mailto:suoqing@physics.ucsb.edu <mailto:suoqing@physics.ucsb.edu>>> wrote:
> >> Hi Sushi,
> >>
> >> The quiver/streamline option you?ve used works for 2d plotting but not for volume rendering, so I might suggest to use off-axis slice plot: http://yt-project.org/doc/visualizing/plots.html#off-axis-slices <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices> <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices>>
> >>
> >> Unfortunately, quiver/streamline does not work (and/or does not work correctly) for off axis slice plot now, but your goal is still achievable via the following steps:
> >>
> >> Are you sure about that? There's a `CuttingQuiverCallback` for off-axis slices. If you do `annotate_magnetic_fields`, it will automatically choose the `CuttingQuiverCallback` for off-axis slices.
> >>
> >>
> >> 1. Use fixed resolution buffer to get the off-axis sliced field values including Bx, By and Bz (see this as an example, and replace SlicePlot with OffAxisSlicePlot: http://yt-project.org/docs/dev/cookbook/complex_plots.html?highlight=fixedresolutionbuffer#multi-plot-slice-and-projections <http://yt-project.org/docs/dev/cookbook/complex_plots.html?highlight=fixedresolutionbuffer#multi-plot-slice-and-projections> <http://yt-project.org/docs/dev/cookbook/complex_plots.html?highlight=fixedresolutionbuffer#multi-plot-slice-and-projections <http://yt-project.org/docs/dev/cookbook/complex_plots.html?highlight=fixedresolutionbuffer#multi-plot-slice-and-projections>>), then you get a 2D array for each field;
> >>
> >> 2. Compute the magnetic field vectors projected onto the rotated viewing plane (perpendicular to your normal vector), based on field values of Bx, By and Bz; now you have two 2D arrays for each components of B field vectors after rotation;
> >>
> >> 3. Use quiver function in matplotlib and plot the B field vectors after rotation, see: http://matplotlib.org/examples/pylab_examples/quiver_demo.html <http://matplotlib.org/examples/pylab_examples/quiver_demo.html> <http://matplotlib.org/examples/pylab_examples/quiver_demo.html <http://matplotlib.org/examples/pylab_examples/quiver_demo.html>>
> >>
> >> Hope this helps! Perhaps there?s an easier way that I do not know...
> >>
> >> Best wishes,
> >> --
> >> Suoqing JI
> >> Ph.D Candidate
> >> Department of Physics
> >> University of California, Santa Barbara
> >> http://web.physics.ucsb.edu/~suoqing <http://web.physics.ucsb.edu/~suoqing> <http://web.physics.ucsb.edu/~suoqing <http://web.physics.ucsb.edu/~suoqing>>
> >>> On Apr 21, 2016, at 10:31 AM, Sushilkumar <sushil.sush19us@gmail.com <mailto:sushil.sush19us@gmail.com> <mailto:sushil.sush19us@gmail.com <mailto:sushil.sush19us@gmail.com>>> wrote:
> >>>
> >>> Dear yt:
> >>>
> >>> I am having trouble with the camera option on yt.
> >>>
> >>> The google drive link is https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc <https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc> <https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc <https://drive.google.com/open?id=0B4g8shg4DL7oak5PLWVVdG5UMHc>>
> >>>
> >>> I want to change the view of the camera at an angle after the Slice (x-z plane) and Quiver option.
> >>>
> >>> My script is yt_cam_rot.py. Without the camera options I get the desired plot (UniformGridData_Slice.png) but when I use the camera  I get a empty screen. I am not sure where I am going wrong.
> >>>
> >>> I am using these links for my reference
> >>>
> >>> http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera> <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera>>
> >>> http://yt-project.org/doc/visualizing/volume_rendering.html#volume-rendering <http://yt-project.org/doc/visualizing/volume_rendering.html#volume-rendering> <http://yt-project.org/doc/visualizing/volume_rendering.html#volume-rendering <http://yt-project.org/doc/visualizing/volume_rendering.html#volume-rendering>>
> >>>
> >>> Thanks in advance
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> On Fri, Apr 15, 2016 at 4:49 PM, Sushilkumar <sushil.sush19us@gmail.com <mailto:sushil.sush19us@gmail.com> <mailto:sushil.sush19us@gmail.com <mailto:sushil.sush19us@gmail.com>>> wrote:
> >>> Dear Suoqing JI:
> >>>
> >>> Thank you
> >>>
> >>> On Fri, Apr 15, 2016 at 12:59 PM,  <yt-users-request@lists.spacepope.org <mailto:yt-users-request@lists.spacepope.org> <mailto:yt-users-request@lists.spacepope.org <mailto:yt-users-request@lists.spacepope.org>>> wrote:
> >>> Send yt-users mailing list submissions to
> >>>         yt-users@lists.spacepope.org <mailto:yt-users@lists.spacepope.org> <mailto:yt-users@lists.spacepope.org <mailto:yt-users@lists.spacepope.org>>
> >>>
> >>> To subscribe or unsubscribe via the World Wide Web, visit
> >>>         http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org <http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org> <http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org <http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org>>
> >>> or, via email, send a message with subject or body 'help' to
> >>>         yt-users-request@lists.spacepope.org <mailto:yt-users-request@lists.spacepope.org> <mailto:yt-users-request@lists.spacepope.org <mailto:yt-users-request@lists.spacepope.org>>
> >>>
> >>> You can reach the person managing the list at
> >>>         yt-users-owner@lists.spacepope.org <mailto:yt-users-owner@lists.spacepope.org> <mailto:yt-users-owner@lists.spacepope.org <mailto:yt-users-owner@lists.spacepope.org>>
> >>>
> >>> When replying, please edit your Subject line so it is more specific
> >>> than "Re: Contents of yt-users digest..."
> >>>
> >>>
> >>> Today's Topics:
> >>>
> >>>    1. Re: Camera Options (Suoqing Ji)
> >>>
> >>>
> >>> ----------------------------------------------------------------------
> >>>
> >>> Message: 1
> >>> Date: Fri, 15 Apr 2016 10:59:22 -0700
> >>> From: Suoqing Ji <suoqing@physics.ucsb.edu <mailto:suoqing@physics.ucsb.edu> <mailto:suoqing@physics.ucsb.edu <mailto:suoqing@physics.ucsb.edu>>>
> >>> To: Discussion of the yt analysis package
> >>>         <yt-users@lists.spacepope.org <mailto:yt-users@lists.spacepope.org> <mailto:yt-users@lists.spacepope.org <mailto:yt-users@lists.spacepope.org>>>
> >>> Subject: Re: [yt-users] Camera Options
> >>> Message-ID: <B885F215-5F0A-49D5-9712-2D8FCEAA1366@physics.ucsb.edu <mailto:B885F215-5F0A-49D5-9712-2D8FCEAA1366@physics.ucsb.edu> <mailto:B885F215-5F0A-49D5-9712-2D8FCEAA1366@physics.ucsb.edu <mailto:B885F215-5F0A-49D5-9712-2D8FCEAA1366@physics.ucsb.edu>>>
> >>> Content-Type: text/plain; charset="utf-8"
> >>>
> >>> Hi Sushi,
> >>>
> >>> I think the off-axis slice/projection plot will meet your requirement best, where the camera orientation is determined by the normal vector:
> >>>
> >>> http://yt-project.org/doc/visualizing/plots.html#off-axis-slices <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices> <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices>> <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices> <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices <http://yt-project.org/doc/visualizing/plots.html#off-axis-slices>>>
> >>> http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots> <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots>> <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots> <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots>>>
> >>>
> >>> And of course, if you?re interested in the features provided by volume rendering, it?s also worth a try. This cookbook gives an example of moving a camera; specifically you might want to use the camera.rotation:
> >>>
> >>> http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera> <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera>> <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera> <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera <http://yt-project.org/doc/cookbook/complex_plots.html#moving-a-volume-rendering-camera>>>
> >>>
> >>> Best wishes,
> >>> --
> >>> Suoqing JI
> >>> Ph.D Candidate
> >>> Department of Physics
> >>> University of California, Santa Barbara
> >>> http://web.physics.ucsb.edu/~suoqing <http://web.physics.ucsb.edu/~suoqing> <http://web.physics.ucsb.edu/~suoqing <http://web.physics.ucsb.edu/~suoqing>>
> >>>
> >>> > On Apr 15, 2016, at 8:38 AM, Sushilkumar <sushil.sush19us@gmail.com <mailto:sushil.sush19us@gmail.com> <mailto:sushil.sush19us@gmail.com <mailto:sushil.sush19us@gmail.com>>> wrote:
> >>> >
> >>> > Dear yt:
> >>> >
> >>> > I would like to change/customize/rotate my camera angle for my slice plots without rotating the axis.
> >>> >
> >>> > What options do I have using yt if I want to move my camera angle by say 45 degrees?
> >>> >
> >>> > Can I use the following link or can you suggest me something else
> >>> > http://yt-project.org/doc/visualizing/volume_rendering.html <http://yt-project.org/doc/visualizing/volume_rendering.html> <http://yt-project.org/doc/visualizing/volume_rendering.html <http://yt-project.org/doc/visualizing/volume_rendering.html>> <http://yt-project.org/doc/visualizing/volume_rendering.html <http://yt-project.org/doc/visualizing/volume_rendering.html> <http://yt-project.org/doc/visualizing/volume_rendering.html <http://yt-project.org/doc/visualizing/volume_rendering.html>>>
> >>> >
> >>> > Thanks in advance