plot with source region and field parameters

Hi, Everybody-- I have a field that I have defined that uses a field_parameter, but I don't seem to be able to get it to work with a projection.
region AMRRegion (time0050): center=[ 0.5 0.03369141 0.68457031], left_edge=[ 0. 0.00195312 0.63378906], right_edge=[ 1. 0.06542969 0.73535156]
def linewidth(field,data): avg_vx = data.get_field_parameter('avg_vx') return (data['x-velocity']-avg_vx)**2 add_field('linewidth',function=linewidth, validators=[ValidateParameter('avg_vx')]) avg_vx = 7 region.set_field_parameter('avg_vx',avg_vx) print region['linewidth'].min() print region.get_field_parameter('avg_vx') which yields expected output, 1.15751883639e-07 7 But trying to make a projection of that source gives the error below. Is it obvious what I'm doing wrong? I can plot 'Density' just fine. Thanks!
proj = oober.pf.h.proj(2,'linewidth',source=region) Initializing tree 0 / 4100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 00:00:00 Traceback (most recent call last):
| ETA: --:--:-- File "<stdin>", line 1, in <module> File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1758, in __init__ self._refresh_data() File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 318, in _refresh_data self.get_data() File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1859, in get_data self._add_level_to_tree(tree, level, fields) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1981, in _add_level_to_tree self._add_grid_to_tree(tree, grid, fields, zero_out, dls) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1925, in _add_grid_to_tree for fd in self._get_data_from_grid(grid, fields)] File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 93, in save_state tr = func(self, grid, field, *args, **kwargs) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 2003, in _get_data_from_grid return [grid[field] * bad_points for field in fields] File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 157, in __getitem__ self.get_data(key) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 200, in get_data self._generate_field(field) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 132, in _generate_field self.pf.field_info[field].check_available(self) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py", line 364, in check_available validator(data) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py", line 440, in __call__ raise NeedsParameter(doesnt_have) yt.data_objects.field_info_container.NeedsParameter: (['avg_vx'])

Hey Dave, If you do the projection of the region, it correctly gets the region right? If so, file a bug, assign it to me, and I will correct it when I can get back to the computer. I think I know what's going on -- I suspect during the _get_data_from_grid call (or whatever it is in the quadtree) it's not passing field parameters through. As a backup for the moment you might be able to use overlap_proj, but this is 100% a bug and needs to be fixed, so file a bug assigned to me and I'll get at it asap. -Matt On Thu, May 9, 2013 at 6:20 PM, david collins <dcollins4096@gmail.com> wrote:
Hi, Everybody--
I have a field that I have defined that uses a field_parameter, but I don't seem to be able to get it to work with a projection.
region AMRRegion (time0050): center=[ 0.5 0.03369141 0.68457031], left_edge=[ 0. 0.00195312 0.63378906], right_edge=[ 1. 0.06542969 0.73535156]
def linewidth(field,data): avg_vx = data.get_field_parameter('avg_vx') return (data['x-velocity']-avg_vx)**2 add_field('linewidth',function=linewidth, validators=[ValidateParameter('avg_vx')]) avg_vx = 7 region.set_field_parameter('avg_vx',avg_vx) print region['linewidth'].min() print region.get_field_parameter('avg_vx')
which yields expected output, 1.15751883639e-07 7
But trying to make a projection of that source gives the error below. Is it obvious what I'm doing wrong? I can plot 'Density' just fine.
Thanks!
proj = oober.pf.h.proj(2,'linewidth',source=region) Initializing tree 0 / 4100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 00:00:00 Traceback (most recent call last): | ETA: --:--:-- File "<stdin>", line 1, in <module> File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1758, in __init__ self._refresh_data() File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 318, in _refresh_data self.get_data() File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1859, in get_data self._add_level_to_tree(tree, level, fields) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1981, in _add_level_to_tree self._add_grid_to_tree(tree, grid, fields, zero_out, dls) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1925, in _add_grid_to_tree for fd in self._get_data_from_grid(grid, fields)] File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 93, in save_state tr = func(self, grid, field, *args, **kwargs) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 2003, in _get_data_from_grid return [grid[field] * bad_points for field in fields] File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 157, in __getitem__ self.get_data(key) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 200, in get_data self._generate_field(field) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 132, in _generate_field self.pf.field_info[field].check_available(self) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py", line 364, in check_available validator(data) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py", line 440, in __call__ raise NeedsParameter(doesnt_have) yt.data_objects.field_info_container.NeedsParameter: (['avg_vx'])
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

If you do the projection of the region, it correctly gets the region right?
pf.h.proj(2,'Density',source=region) does the correct thing for that region, if that's what you mean. d.
If so, file a bug, assign it to me, and I will correct it when I can get back to the computer. I think I know what's going on -- I suspect during the _get_data_from_grid call (or whatever it is in the quadtree) it's not passing field parameters through. As a backup for the moment you might be able to use overlap_proj, but this is 100% a bug and needs to be fixed, so file a bug assigned to me and I'll get at it asap.
-Matt
On Thu, May 9, 2013 at 6:20 PM, david collins <dcollins4096@gmail.com> wrote:
Hi, Everybody--
I have a field that I have defined that uses a field_parameter, but I don't seem to be able to get it to work with a projection.
region AMRRegion (time0050): center=[ 0.5 0.03369141 0.68457031], left_edge=[ 0. 0.00195312 0.63378906], right_edge=[ 1. 0.06542969 0.73535156]
def linewidth(field,data): avg_vx = data.get_field_parameter('avg_vx') return (data['x-velocity']-avg_vx)**2 add_field('linewidth',function=linewidth, validators=[ValidateParameter('avg_vx')]) avg_vx = 7 region.set_field_parameter('avg_vx',avg_vx) print region['linewidth'].min() print region.get_field_parameter('avg_vx')
which yields expected output, 1.15751883639e-07 7
But trying to make a projection of that source gives the error below. Is it obvious what I'm doing wrong? I can plot 'Density' just fine.
Thanks!
proj = oober.pf.h.proj(2,'linewidth',source=region) Initializing tree 0 / 4100%
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Time: 00:00:00 Traceback (most recent call last): | ETA: --:--:-- File "<stdin>", line 1, in <module> File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py",
line 1758, in __init__ self._refresh_data() File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py",
line 318, in _refresh_data self.get_data() File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py",
line 1859, in get_data self._add_level_to_tree(tree, level, fields) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py",
line 1981, in _add_level_to_tree self._add_grid_to_tree(tree, grid, fields, zero_out, dls) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py",
line 1925, in _add_grid_to_tree for fd in self._get_data_from_grid(grid, fields)] File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py",
line 93, in save_state tr = func(self, grid, field, *args, **kwargs) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py",
line 2003, in _get_data_from_grid return [grid[field] * bad_points for field in fields] File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py",
line 157, in __getitem__ self.get_data(key) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py",
line 200, in get_data self._generate_field(field) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py",
line 132, in _generate_field self.pf.field_info[field].check_available(self) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py",
line 364, in check_available validator(data) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py",
line 440, in __call__ raise NeedsParameter(doesnt_have) yt.data_objects.field_info_container.NeedsParameter: (['avg_vx'])
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Hey Dave, Have you tried passing the field_parameters in as a kwargs dict? Something like this: field_parameters = {'avg_vx',7} proj = oober.pf.h.proj(2,'linewidth',source=region, **field_parameters) Although as Matt notes, ideally it should be possible to avoid the kwargs construction. -Nathan On May 9, 2013, at 3:20 PM, david collins <dcollins4096@gmail.com> wrote:
Hi, Everybody--
I have a field that I have defined that uses a field_parameter, but I don't seem to be able to get it to work with a projection.
region AMRRegion (time0050): center=[ 0.5 0.03369141 0.68457031], left_edge=[ 0. 0.00195312 0.63378906], right_edge=[ 1. 0.06542969 0.73535156]
def linewidth(field,data): avg_vx = data.get_field_parameter('avg_vx') return (data['x-velocity']-avg_vx)**2 add_field('linewidth',function=linewidth, validators=[ValidateParameter('avg_vx')]) avg_vx = 7 region.set_field_parameter('avg_vx',avg_vx) print region['linewidth'].min() print region.get_field_parameter('avg_vx')
which yields expected output, 1.15751883639e-07 7
But trying to make a projection of that source gives the error below. Is it obvious what I'm doing wrong? I can plot 'Density' just fine.
Thanks!
proj = oober.pf.h.proj(2,'linewidth',source=region) Initializing tree 0 / 4100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 00:00:00 Traceback (most recent call last): | ETA: --:--:-- File "<stdin>", line 1, in <module> File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1758, in __init__ self._refresh_data() File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 318, in _refresh_data self.get_data() File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1859, in get_data self._add_level_to_tree(tree, level, fields) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1981, in _add_level_to_tree self._add_grid_to_tree(tree, grid, fields, zero_out, dls) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1925, in _add_grid_to_tree for fd in self._get_data_from_grid(grid, fields)] File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 93, in save_state tr = func(self, grid, field, *args, **kwargs) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 2003, in _get_data_from_grid return [grid[field] * bad_points for field in fields] File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 157, in __getitem__ self.get_data(key) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 200, in get_data self._generate_field(field) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 132, in _generate_field self.pf.field_info[field].check_available(self) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py", line 364, in check_available validator(data) File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py", line 440, in __call__ raise NeedsParameter(doesnt_have) yt.data_objects.field_info_container.NeedsParameter: (['avg_vx'])
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

That seems to work for now, thanks! I'll file a bug report on this. Thanks a ton! On Thu, May 9, 2013 at 4:36 PM, Nathan Goldbaum <nathan12343@gmail.com>wrote:
Hey Dave,
Have you tried passing the field_parameters in as a kwargs dict? Something like this:
field_parameters = {'avg_vx',7} proj = oober.pf.h.proj(2,'linewidth',source=region, **field_parameters)
Although as Matt notes, ideally it should be possible to avoid the kwargs construction.
-Nathan
On May 9, 2013, at 3:20 PM, david collins <dcollins4096@gmail.com> wrote:
Hi, Everybody--
I have a field that I have defined that uses a field_parameter, but I don't seem to be able to get it to work with a projection.
region AMRRegion (time0050): center=[ 0.5 0.03369141 0.68457031], left_edge=[ 0. 0.00195312 0.63378906], right_edge=[ 1. 0.06542969 0.73535156]
def linewidth(field,data): avg_vx = data.get_field_parameter('avg_vx') return (data['x-velocity']-avg_vx)**2 add_field('linewidth',function=linewidth, validators=[ValidateParameter('avg_vx')]) avg_vx = 7 region.set_field_parameter('avg_vx',avg_vx) print region['linewidth'].min() print region.get_field_parameter('avg_vx')
which yields expected output, 1.15751883639e-07 7
But trying to make a projection of that source gives the error below. Is it obvious what I'm doing wrong? I can plot 'Density' just fine.
Thanks!
proj = oober.pf.h.proj(2,'linewidth',source=region) Initializing tree 0 / 4100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 00:00:00 Traceback (most recent call last):
File "<stdin>", line 1, in <module> File "/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py",
| ETA: --:--:-- line 1758, in __init__
self._refresh_data() File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 318, in _refresh_data
self.get_data() File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1859, in get_data
self._add_level_to_tree(tree, level, fields) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1981, in _add_level_to_tree
self._add_grid_to_tree(tree, grid, fields, zero_out, dls) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 1925, in _add_grid_to_tree
for fd in self._get_data_from_grid(grid, fields)] File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 93, in save_state
tr = func(self, grid, field, *args, **kwargs) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/data_containers.py", line 2003, in _get_data_from_grid
return [grid[field] * bad_points for field in fields] File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 157, in __getitem__
self.get_data(key) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 200, in get_data
self._generate_field(field) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/grid_patch.py", line 132, in _generate_field
self.pf.field_info[field].check_available(self) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py", line 364, in check_available
validator(data) File
"/nics/b/home/collins/local_2013_03_12/src/yt-hg/yt/data_objects/field_info_container.py", line 440, in __call__
raise NeedsParameter(doesnt_have) yt.data_objects.field_info_container.NeedsParameter: (['avg_vx'])
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (4)
-
david collins
-
David Collins
-
Matthew Turk
-
Nathan Goldbaum