<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
Hi Britton,
<div><br>
</div>
<div>Thanks for the reply.</div>
<div><br>
</div>
<div>I have tried to implement what you have suggest. But I get the following error:</div>
<div><br>
</div>
<div>
<div> File "profiles2.py", line 7, in <module></div>
<div> r_max = sp['Radius'][sp['Density'] == sp['Density'].max()]</div>
<div>NameError: name 'sp' is not defined.</div>
<div><br>
</div>
<div>To be honest I don’t quite follow the r_max = sp…etc line. could you explain that a little?</div>
<div><br>
</div>
<div>Thanks</div>
<div><br>
</div>
<div>Kearn</div>
<div>
<div>On 4 Nov 2013, at 15:21, Britton Smith <<a href="mailto:brittonsmith@gmail.com">brittonsmith@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div dir="ltr">Hi Kearn,
<div><br>
</div>
<div>I recommend doing something like the following:</div>
<div><br>
</div>
<div>Create a sphere on you're own with</div>
<div>sphere = pf.h.sphere(center, (radius, units))</div>
<div><br>
</div>
<div>Then, calculate the maximum density and position of that with some numpy array operations and set it as a "field parameter":</div>
<div>r_max = sp['Radius'][sp['Density'] == sp['Density'].max()]<br>
</div>
<div>sp.set_field_parameter('r_max', r_max)</div>
<div><br>
</div>
<div>Then, in your field definition, you can do:</div>
<div>r_max = data.get_field_parameter('rmax')</div>
<div><br>
</div>
<div>and then do the rest of the field definition just as you described.</div>
<div><br>
</div>
<div>Finally, instead of add_profile_sphere, you can you add_profile_object which will take the sphere you just created as an argument.</div>
<div><br>
</div>
<div>That should do what you want. Feel free to write back if you have more questions.</div>
<div><br>
</div>
<div>Britton</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Nov 4, 2013 at 2:49 PM, <span dir="ltr"><<a href="mailto:k.grisdale@surrey.ac.uk" target="_blank">k.grisdale@surrey.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi yt-users<br>
<br>
I’m attempting to plot some profiles as a function of radius/radiusSH, where radiusSh is the radius of a shock. However I am not sure what the simplest way of getting yt to plot this. I have been using the following commands to produce the profiles.<br>
:<br>
<br>
pc = PlotCollection(p6, center = cen)<br>
pc.add_profile_sphere(0.5, "cm", ["Radius", "Density"], weight = "Denin”)<br>
<br>
I have also tried to define a new field:<br>
<br>
<br>
@derived_field(name = "RRsh", take_log = False, validators = [ValidateParameter("rsh")])<br>
def RRshunits(field, data):<br>
value, rsh = p6.h.find_max("Density")<br>
return(data["Radius"]/rsh)<br>
<br>
but this leads to the following error:<br>
<br>
Traceback (most recent call last):<br>
File "profiles.py", line 21, in <module><br>
pc.add_profile_sphere(0.5, "cm", ["RRsh", "Denin"], weight = "Denin")<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/visualization/plot_collection.py", line 1058, in add_profile_sphere<br>
figure=figure, axes=axes)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/visualization/plot_collection.py", line 961, in add_profile_object<br>
lazy_reader=lazy_reader)[0]<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py", line 92, in __call__<br>
return self._call_func_lazy(args, kwargs)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py", line 99, in _call_func_lazy<br>
rv = self.func(GridChildMaskWrapper(g, self._data_source), *args, **kwargs)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py", line 615, in _Extrema<br>
if data[field].size < 1:<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py", line 60, in __getitem__<br>
data = self.data_source._get_data_from_grid(self.grid, item)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 95, in save_state<br>
tr = func(self, grid, field, *args, **kwargs)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 2645, in _get_data_from_grid<br>
tr = grid[field]<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 157, in __getitem__<br>
self.get_data(key)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 200, in get_data<br>
self._generate_field(field)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 132, in _generate_field<br>
self.pf.field_info[field].check_available(self)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/field_info_container.py", line 366, in check_available<br>
validator(data)<br>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/field_info_container.py", line 442, in __call__<br>
raise NeedsParameter(doesnt_have)<br>
yt.data_objects.field_info_container.NeedsParameter: (['rsh’])<br>
<br>
Am I missing something in my field definition or is their a simpler way to go about this?<br>
<br>
Thanks<br>
<br>
Kearn<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</blockquote>
</div>
<br>
</div>
_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org<br>
</blockquote>
</div>
<br>
</div>
</body>
</html>