[yt-users] Error with annotate_marker: Unknown property

Nathan Goldbaum nathan12343 at gmail.com
Thu Aug 1 20:55:07 PDT 2013


Hey Chao,

Sorry for not saying how I determined that.  If you look at the traceback
you posted, you'll see that the execution left yt and entered matplotlib on
line 777 of $YT_HG/yt/visualization/plot_window.py with a call to
axes.scatter().  I happened to know that axes in this context refers to a
matplotlib axes.Axes object, so that was what led me to the proper page in
the matplotlib documentation.

Whenever you see an error like that, it really pays to closely look at the
traceback to try and figure out exactly what broke.  One of the advantages
of using open source python tools like yt and matplotlib is that the source
code is on your computer and you can always take a look at it to get some
context for the traceback, even if you're unfamiliar with the codebase.
 Even better, you can modify the code, and, for example, insert calls to
debuggers like pdb to interactively figure out exactly what's happening.
 No matter how confusing a package's documentation, you can always be
certain that the most up do date and accurate documentation for a project
will be the source code its self.

Hope that was useful rather than just a mini-rant ;)

-Nathan


On Thu, Aug 1, 2013 at 8:04 PM, Chao Shi <shichao116 at gmail.com> wrote:

>
>
>
> On Thu, Aug 1, 2013 at 10:49 PM, <yt-users-request at lists.spacepope.org>wrote:
>
>> Send yt-users mailing list submissions to
>>         yt-users at 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 at lists.spacepope.org
>>
>> You can reach the person managing the list at
>>         yt-users-owner at 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: Error with annotate_marker: Unknown property (Nathan Goldbaum)
>>    2. ANN: matplotlib 1.3.0 released (Nathan Goldbaum)
>>    3. Re: MultiVariate volume rendering difficulties (Cameron Hummels)
>>
>>
>> ----------------------------------------------------------------------
>>
>
> Hi Nathan,
>
> Thanks. That's very informative. Would you mind tell me how you found
> that? I also tried to
> search for the allowed keywords for that callback but didn't find any
> useful information. Just in case
> next time I run into such kind of problems.
>
> Thank you very much.
>
> Chao
>
>> Message: 1
>> Date: Thu, 1 Aug 2013 16:35:55 -0700
>> From: Nathan Goldbaum <nathan12343 at gmail.com>
>> To: Discussion of the yt analysis package
>>         <yt-users at lists.spacepope.org>
>> Subject: Re: [yt-users] Error with annotate_marker: Unknown property
>> Message-ID:
>>         <CAJXewO=
>> bQbfRxAFjwR-2Q3Wsb5ZvGJPxwtRsk_Kfqc0zVa1cCg at mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>>
>> Hi Chao,
>>
>> For that callback, you're only allowed to specify keyword arguments
>> accepted by matplotlib.axes.Axes.scatter:
>> http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.scatter
>>
>> or Collection properties:
>>
>> http://matplotlib.org/api/collections_api.html#matplotlib.collections.Collection
>>
>> I'd have to look closer to figure out which keyword corresponds to what
>> you're looking for, but hopefully that leaves you enough information to
>> figure out how to do what you're trying to do.
>>
>> -Nathan
>>
>>
>> On Thu, Aug 1, 2013 at 3:53 PM, Chao Shi <shichao116 at gmail.com> wrote:
>>
>> > Hi all,
>> >
>> > I'm trying to mark some positions with circle on slice and projection
>> > plot. But it can't recognize arguments used for specifying the property
>> of
>> > the marker. For example:
>> >
>> >
>> > >>> p = SlicePlot(pf,'x','Density')
>> >
>> > >>> p.annotate_marker([0.5]*3,marker='o', plot_args={'color': 'red',
>> > 'mew': 5})
>> >
>> > Traceback (most recent call last):
>> >   File "<stdin>", line 1, in <module>
>> >   File
>> "/home/cshi31/yt-x86_64/src/yt-hg/yt/visualization/plot_window.py",
>> > line 100, in newfunc
>> >     args[0]._setup_plots()
>> >   File
>> "/home/cshi31/yt-x86_64/src/yt-hg/yt/visualization/plot_window.py",
>> > line 886, in _setup_plots
>> >     self.run_callbacks(f)
>> >   File
>> "/home/cshi31/yt-x86_64/src/yt-hg/yt/visualization/plot_window.py",
>> > line 896, in run_callbacks
>> >     callback(cbw)
>> >   File
>> >
>> "/home/cshi31/yt-x86_64/src/yt-hg/yt/visualization/plot_modifications.py",
>> > line 777, in __call__
>> >     plot._axes.scatter(x,y, marker = self.marker, **self.plot_args)
>> >   File
>> > "/home/cshi31/yt-x86_64/lib/python2.7/site-packages/matplotlib/axes.py",
>> > line 6123, in scatter
>> >     collection.update(kwargs)
>> >    File
>> >
>> "/home/cshi31/yt-x86_64/lib/python2.7/site-packages/matplotlib/artist.py",
>> > line 670, in update
>> >     raise AttributeError('Unknown property %s' % k)
>> > AttributeError: Unknown property mew
>> >
>> > mew is an alias for markeredgewidth. I also tried with 'markeredgewidth'
>> > but it gave the same error.
>> >
>> > Besides, 'mec', 'ms' also can't be recognized. Only 'color' works.
>> >
>> > Does anyone have a clue about this?
>> >
>> > Thanks very much.
>> >
>> > Chao
>> >
>> >
>> > _______________________________________________
>> > yt-users mailing list
>> > yt-users at lists.spacepope.org
>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>> >
>> >
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <
>> http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130801/fb8c7ad5/attachment-0001.htm
>> >
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Thu, 1 Aug 2013 18:24:41 -0700
>> From: Nathan Goldbaum <nathan12343 at gmail.com>
>> To: Discussion of the yt analysis package
>>         <yt-users at lists.spacepope.org>
>> Subject: [yt-users] ANN: matplotlib 1.3.0 released
>> Message-ID:
>>         <
>> CAJXewOkcnia2Y6gkO6QN9a2K-+Xr7_FGTGKLUySFQDjarbnf_w at mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> Hi all,
>>
>> Please see the matplotlib mailing list archives for the release notes and
>> official announcement e-mail:
>>
>> http://matplotlib.1069221.n5.nabble.com/ANN-matplotlib-1-3-0-released-td41670.html
>>
>> This big new feature for this version is the WebAGG backend, which is a
>> new
>> plotting interface specially made for the IPython notebook.  It also
>> includes a convenience function that alters the plotting settings to
>> generate xkcd-style plots.
>>
>> There may be some incompatibilities with yt - if anyone notices any issues
>> please report it on the issue tracker.
>>
>> Cheers,
>>
>> Nathan
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <
>> http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130801/a1715c6e/attachment-0001.htm
>> >
>>
>> ------------------------------
>>
>> Message: 3
>> Date: Thu, 1 Aug 2013 19:39:02 -0700
>> From: Cameron Hummels <chummels at gmail.com>
>> To: Discussion of the yt analysis package
>>         <yt-users at lists.spacepope.org>
>> Subject: Re: [yt-users] MultiVariate volume rendering difficulties
>> Message-ID:
>>         <
>> CACyTu7ERKuNSgCY3HMQGPXL3UPhRspyUG_r3V8L1-rzxTaPNeQ at mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> I agree with Stella's solution, as that's what I've done in the past.
>>  Obviously you can get some blending between the two CTFs, but that's the
>> point right?
>>
>> Cameron
>>
>>
>> On Thu, Aug 1, 2013 at 2:31 PM, Nathan Goldbaum <nathan12343 at gmail.com
>> >wrote:
>>
>> > Wow Noel, keep up the awesome work!
>> >
>> > I'm sure this will be helpful for Sam when he looks at this stuff next
>> > week.
>> >
>> >
>> > On Thu, Aug 1, 2013 at 1:53 PM, Noel Scudder <
>> noel.scudder at stonybrook.edu>wrote:
>> >
>> >> Hi all,
>> >>
>> >> Over the past few days I've been investigating the
>> >> MultiVariateTransferFunction and receiving feedback from Matt. Since it
>> >> needs some updating and the documentation is so vague, I thought I'd
>> try to
>> >> outline the basic flow and idea of an MVTF (thanks to Matt for his
>> >> outline), address a couple problems that have been noticed, and give an
>> >> example script with images. Please feel free to correct my mistakes,
>> ask
>> >> questions, and add your own knowledge!
>> >>
>> >> The code for the MVTF is
>> >> in yt/visualization/volume_rendering/transfer_functions.py . It's also
>> >> useful to check out the Planck and Color Transfer Functions in the same
>> >> file.
>> >>
>> >> With a CTF, you are limited to one field, which is linked identically
>> to
>> >> each of the RGB color channels and an alpha channel. However, an MVTF
>> >> allows you to set up different fields that control each channel and
>> each
>> >> channel's opacity through the use of standard Transfer Functions. For
>> >> instance, I could link the red color channel and the red alpha channel
>> to
>> >> Density, the blue and blue alpha channels to Temperature, and the
>> green and
>> >> green alpha channels to Kinetic Energy.
>> >> It is important to note that only *one* field (and associated transfer
>> >> function) may be linked to any channel. This limits the number of
>> variables
>> >> one can conceivably include to three.
>> >>
>> >> When an MVTF is created, it sets up a few variables:
>> >>
>> >> n_field_tables
>> >> tables
>> >> field_ids
>> >> weight_field_ids
>> >> field_table_ids
>> >> weight_table_ids
>> >> grad_field
>> >> light_source_v
>> >>
>> >> The important ones here are tables, field_ids, weight_field_ids,
>> >> field_table_ids, and weight_table_ids.
>> >> After creating your MVTF, the first thing you must do is create a
>> >> TransferFunction, which has some range and number of bins. This can
>> then be
>> >> added as a "table" to your MVTF using add_field_table, which accepts
>> the
>> >> table, the field_id used for interpolating on the x-axis of this
>> table, a
>> >> weight_field_id, and/or a weight_table id.
>> >> The field_id is *not* the field index you get from pf.h.field_indexes .
>> >> Here, the field_id actually specifies the index of a certain field in
>> the
>> >> field list you supply to the camera object. For instance, if I gave the
>> >> camera
>> >>
>> >> fields=['density', 'Temp']
>> >>
>> >> I would have previously called add_field_table using a field_id of 0
>> for
>> >> the TransferFunctions I wanted for density, and using a field_id of 1
>> for
>> >> the TransferFunctions I wanted for temperature.
>> >> The same specification with the field_id goes for weight_field_id,
>> which
>> >> is used if the field itself should be a weighting factor for the
>> >> emission/absorption (although this does not do scaling, so you will
>> likely
>> >> need to supply a pre-scaled field).
>> >> By supplying a weight_table_id, you are taking the results of
>> >> interpolation along the x-axis to get a y value from *another* field
>> table
>> >> and using that as a weight.
>> >>
>> >> *Apparently density is typically logged by default. If you want to use
>> it
>> >> as a weight, you probably want it un-logged.
>> >>
>> >> At this point you have added all of your field tables. The second step
>> is
>> >> to link the field tables to the channels you want. Right now, all you
>> have
>> >> is a set of "tables," TransferFunctions that describe how to get a
>> value
>> >> out as a combination of:
>> >>
>> >> 1) The y-value interpolated along the x-axis defined by the table
>> >> 2) The weighting from a given field
>> >> 3) The weighting from a given field_table (i.e., if you had some
>> scaling
>> >> that was a function of temperature)
>> >>
>> >> On its own, a table will do nothing--you must link it to a channel.
>> These
>> >> are, in order, RGB and aR, aG, aB. You use the link_channels function
>> for
>> >> this purpose, for instance linking table 0 to channel 0 (R). When
>> linking
>> >> channels, there are a couple things to keep in mind. The two arguments
>> you
>> >> supply are the  table_id and the channel, both *integers *(seems like a
>> >> common theme for MVTF stuff :-) ). The channel can be integers 0-5,
>> >> assigned in the order above. The table_id is a bit more nebulous: a
>> >> table_id is assigned to a table when it is created, meaning that the
>> first
>> >> table you create using add_field_table will have a table_id of 0, the
>> next
>> >> will have a table_id of 1, and so on. Although you cannot link more
>> than
>> >> one table to a channel, you can have more than one channel linked to a
>> >> single table--simply supply a list in place of an integer for the
>> channel
>> >> argument.
>> >>
>> >> Finally, don't leave your TransferFunctions empty! Add some gaussians,
>> >> keeping in mind the channel and field each TF uses. After that your
>> MVTF
>> >> will be ready, and you can supply it to the camera object like any
>> other
>> >> transfer function and take a snapshot.
>> >>
>> >> Here's a example script: http://pastebin.com/NC4pHPR7
>> >>
>> >> Which creates this image: http://i.imgur.com/EKv943G.png
>> >>
>> >> The main problem I've been noticing is with the grey_opacity, which was
>> >> already discussed--apparently the MVTF was never updated after opaque
>> >> volume rendering was implemented. Although by default an MVTF doesn't
>> have
>> >> a grey_opacity attribute and yt will complain about this, you can
>> placate
>> >> the beast by supplying
>> >>
>> >> mv.grey_opacity=False
>> >>
>> >> anyway. If you set grey_opacity to True, however, odd things will
>> happen,
>> >> which I suspect is simply due to the MVTF not having been updated for
>> >> opaque rendering yet: http://i.imgur.com/rrOnbgy.png
>> >> I think that about sums up my two cents on the MVTF.
>> >>
>> >>
>> >> Finally, my original desire was to have two different
>> >> ColorTransferFunctions with two different fields rendered by one
>> camera at
>> >> once. In other words, simultaneously render two different colormaps
>> applied
>> >> to two different fields. Right now this isn't possible in yt (although
>> Matt
>> >> thinks it may be somewhat straightforward to implement), so I came up
>> with
>> >> a makeshift way, where I render one TF for the first field without a
>> >> background and the second TF for the second field *with* a background,
>> >> and then overlay them using ImageMagick:
>> >>
>> >> im.write_png('transparent_temp.png', background=None)
>> >> ...
>> >> im2.write_png('dens_and_background.png')
>> >> os.system('composite transparent_temp.png dens_and_background.png
>> >> multi.png')
>> >>
>> >> However, it's expensive, and it goes outside yt. Does anyone know if
>> >> there's a way to combine these images without leaving yt?
>> >>
>> >> Thanks for reading!
>> >>
>> >> -Noel
>> >>
>> >>
>> >> On Tue, Jul 30, 2013 at 1:03 PM, Sam Skillman <samskillman at gmail.com
>> >wrote:
>> >>
>> >>> Hi all,
>> >>> The multivariate tf could use both some updating and documentation.
>> I'm
>> >>> offline for the next few days but if it hasn't been fixed by next
>> week I
>> >>> can take a look.
>> >>>
>> >>> Sam
>> >>> On Jul 30, 2013 8:40 AM, "Nathan Goldbaum" <nathan12343 at gmail.com>
>> >>> wrote:
>> >>>
>> >>>> Hi Noel,
>> >>>>
>> >>>> I believe this is a bug that needs to be fixed.  It seems
>> >>>> MultiVariateTransferFunction was never updated after opaque volume
>> >>>> rendering was added.
>> >>>>
>> >>>> Can you please open a new issue about this?
>> >>>>
>> >>>> Nathan
>>
>> >>>>
>> >>>> On Tuesday, July 30, 2013, Noel Scudder wrote:
>> >>>>
>> >>>>> Hi all,
>> >>>>>
>> >>>>> I'm attempting to visualize multiple variables in the same volume
>> >>>>> rendering. For instance, I'd like to show some density surfaces of
>> a star
>> >>>>> and then get temperature overlayed to show hotspots. I found the
>> >>>>> MultiVariateTransferFunction, but it is unfortunately not
>> particularly well
>> >>>>> documented yet, and I'm being repeatedly thwarted. I'm not sure if
>> I've set
>> >>>>> it up correctly, or how to go from the transfer function to an
>> image.
>> >>>>> Here's my current script, using just one variable for now:
>> >>>>>
>> >>>>> #----------------------------------
>> >>>>> from yt.mods import *
>> >>>>> pf = load('plt00100')
>> >>>>>
>> >>>>> #<some constants>
>> >>>>>
>> >>>>> pf.h
>> >>>>> pf.field_info['density'].take_log=True
>> >>>>>
>> >>>>> mv = MultiVariateTransferFunction()
>> >>>>>
>> >>>>> tf = TransferFunction((mi-1, ma+1), nbins=1.0e6)
>> >>>>> tf.add_gaussian(np.log10(9.0e5), 0.01, 1.0)
>> >>>>>
>> >>>>> mv.add_field_table(tf, 0)
>> >>>>> mv.link_channels(0, [0,1,2,3])
>> >>>>>
>> >>>>> c = [5.0e9, 5.0e9, 5.0e9]
>> >>>>> L = [0.15, 1.0, 0.40]
>> >>>>> W = wi*0.7
>> >>>>> Nvec = 1024
>> >>>>>
>> >>>>> cam = pf.h.camera(c, L, W, (Nvec,Nvec), transfer_function = mv,
>> >>>>>                              fields=['density'], pf=pf,
>> no_ghost=True)
>> >>>>>
>> >>>>> im = cam.snapshot(num_threads=4)
>> >>>>>
>> >>>>> im.write_png('plt00100.png' )
>> >>>>> #----------------------------------
>> >>>>>
>> >>>>> I checked to make sure density is indeed my 0-index field. I get the
>> >>>>> following error after ray casting:
>>
>> >>>>>
>> >>>>> Traceback (most recent call last):
>> >>>>>   File "<stdin>", line 1, in <module>
>> >>>>>   File "multivol.py", line 153, in <module>
>> >>>>>     im = cam.snapshot(num_threads=4)
>> >>>>>   File
>> >>>>>
>> "/home/noel/shocks/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/camera.py",
>> >>>>> line 742, in snapshot
>> >>>>>     image, sampler),
>> >>>>>   File
>> >>>>>
>> "/home/noel/shocks/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/camera.py",
>> >>>>> line 632, in _render
>> >>>>>     image = self.finalize_image(image)
>> >>>>>   File
>> >>>>>
>> "/home/noel/shocks/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/camera.py",
>> >>>>> line 611, in finalize_image
>> >>>>>     if self.transfer_function.grey_opacity is False:
>> >>>>> AttributeError: 'MultiVariateTransferFunction' object has no
>> attribute
>> >>>>> 'grey_opacity'
>> >>>>>
>> >>>>>
>> >>>>> Can I not use snapshot in this case, or is something else the matter
>> >>>>> entirely?
>> >>>>>
>> >>>>> Thanks,
>> >>>>> Noel Scudder
>>
>> >>>>>
>> >>>>
>> >>>> _______________________________________________
>> >>>> yt-users mailing list
>> >>>> yt-users at lists.spacepope.org
>> >>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>> >>>>
>> >>>>
>> >>> _______________________________________________
>> >>> yt-users mailing list
>> >>> yt-users at lists.spacepope.org
>> >>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>> >>>
>> >>>
>> >>
>> >> _______________________________________________
>> >> yt-users mailing list
>> >> yt-users at lists.spacepope.org
>> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>> >>
>> >>
>> >
>> > _______________________________________________
>> > yt-users mailing list
>> > yt-users at lists.spacepope.org
>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>> >
>> >
>>
>>
>> --
>> Cameron Hummels
>> Postdoctoral Researcher
>> Steward Observatory
>> University of Arizona
>> http://chummels.org
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <
>> http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130801/3eb8ad04/attachment.htm
>> >
>>
>> ------------------------------
>>
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>> End of yt-users Digest, Vol 66, Issue 3
>> ***************************************
>>
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130801/347ef848/attachment.htm>


More information about the yt-users mailing list