[yt-users] Potential problem with the field_parameters dictionary in SlicePlot (and certainly others)

Antoine Strugarek strugarek at ASTRO.UMontreal.CA
Wed Sep 3 11:40:17 PDT 2014


Thank for your answers, it confirms what I understood.

After digging a bit deeper in the Python and Cython codes, I think I may have found another bug that adds up to the problem with ‘_set_center' I was mentioning before. In ‘geometric_fields.py’, when computing the geometric fields (take _cylindrical_r for instance, but it true for other fields as well), the center from the field_parameters dictionary is subtracted from the coords. Though, it appears that the coords are obtained from the obtain_rvec function defined in geometry_utils.pyx, and in there the center (from the field_parameters dictionary as well) is already subtracted. The center is hence subtracted twice, which leads to weird behaviours when using those geometrical fields. Please advise on what would be the best way to cope with this issue, in order to use the already defined geometrical fields (cylindrical and spherical).

Antoine


Le 2014-09-03 à 13:07 , Nathan Goldbaum <nathan12343 at gmail.com> a écrit :

> 
> 
> On Wed, Sep 3, 2014 at 10:05 AM, Chris Malone <chris.m.malone at gmail.com> wrote:
> Hi Antoine,
> 
> As you hinted, the field_parameters dictionary is mainly used for derived fields and defaults to the center of the domain.  For a SlicePlot (and others), the keyword variable 'center' is actually what determines where in the domain the slice should be taken - it is completely independent of the field_parameters['center'] value.
> 
> You can also adjust the plot center using the set_center function that hangs off of SlicePlot instances.
>  
> 
> Hope that helps.
> 
> Chris
> 
> 
> On Wed, Sep 3, 2014 at 10:45 AM, Antoine Strugarek <strugarek at astro.umontreal.ca> wrote:
> Hi Matthew,
> 
> Thank you for the quick answer. I’m on 3.0 (obtained with yt.__version__).
> 
> I’m not completely sure how to fix this since I’m discovering the code, but I’m suspecting something strange there. To my understanding, the field_parameters dictionary given in argument to SlicePlot should be used for derived fields only, and the center keyword to specify the location where the Slice should be taken, right?
> Also, if I specify in advance the center (doing ad = ds.all_data() ; ad.set_field_parameter("center", custom_center)), this new center does not seem to be used in the SlicePlot to compute, e.g., the cylindrical radius (in this latter case I try to do a SlicePlot without giving a field_parameters dictionary in argument).
> 
> Antoine
> 
> 
> Le 2014-09-03 à 12:27 , Matthew Turk <matthewturk at gmail.com> a écrit :
> 
> > Hi Antoine,
> >
> > Thanks for reporting this!  Which version of the code are you on?  "yt
> > instinfo" should be able to tell you this.
> >
> > -Matt
> >
> > On Wed, Sep 3, 2014 at 11:08 AM, Antoine Strugarek
> > <strugarek at astro.umontreal.ca> wrote:
> >> Hi,
> >>
> >> I’ve been trying to specify by hand the ‘center’ entry of the dictionary field_parameters to a SlicePlot so that the derived field can make use of another center to compute, e.g., cylindrical coordinates. After tracking why my specified center had no effect, I noticed that the function _set_center is called when a SlicePlot is created, and this function erases any ‘center’ entry in the field_parameters dictionary, putting there the ‘center’ keyword specified as an argument to SlicePlot. It appears to me this should not be the normal behaviour, but I may be misunderstanding something. I would naively suggest not to update the ‘field_parameters’ dictionary in the _set_center function, though I’m not completely sure?
> >>
> >> Thanks in advance for your help and suggestion about this issue!
> >>
> >> Antoine
> >> _______________________________________________
> >> 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
> 
> 
> _______________________________________________
> 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/20140903/8ce896b9/attachment.htm>


More information about the yt-users mailing list