Hi Dan,

The problem seems to be that the field_parameters were not getting passed down to the grid objects that extract the field data in the contour finder.  I've issued a pull request to fix this.  You can see it here:
https://github.com/yt-project/yt/pull/1732

Please, feel free to check it out and comment on the PR if you like.

Britton

On Tue, Mar 20, 2018 at 2:52 PM, Britton Smith <brittonsmith@gmail.com> wrote:
Returning this conversation back to the list.


---------- Forwarded message ----------
From: Le Dan <le.dan33@yahoo.com>
Date: Tue, Mar 20, 2018 at 11:47 AM
Subject: Re: [yt-users] clump find
To: Britton Smith <brittonsmith@gmail.com>


my code looks like:

import matplotlib
matplotlib.use('Agg')
import yt
import matplotlib.pyplot as plt
import numpy as np
nar = np.array
import time
import copy
from yt.analysis_modules.level_sets.api import *
grav_min = []
x_min = []
y_min = []
z_min = []
loc = []
loc_2 = []
leaf_indices = []
nbins = 20
bin_high = 5e6
bin_low_init=0.1
def new_grav_potential(field,data):
    grav_old= data['gravitational_potential']
    grav_max = data.get_field_parameter('max_grav')
    grav_new = -grav_old+grav_max
    return grav_new
yt.add_field('new_grav_potential',function=new_grav_potential,units = 'erg/g',validators = [yt.ValidateParameter('max_grav')])
for frame in [120]:
    n_cl = 0
    fname = 'DD%04d/data%04d'%(frame,frame)
    ds = yt.load(fname)
    ad = ds.all_data()
    a = ad['gravitational_potential'].max()
    b = -ad['gravitational_potential']+a
    ad.set_field_parameter('max_grav',a)
    master_clump = Clump(ad,('gas','new_grav_potential'))
    master_clump.add_validator("min_cells", 8)
    c_min = ad["gas", "new_grav_potential"].min()
    c_max = ad["gas", "new_grav_potential"].max()
    step = 100
    find_clumps(master_clump, c_min, c_max, step)
    # Write a text file of only the leaf nodes.
    write_clumps(master_clump,0, "%s_clumps.txt" % ds)
    leaf_clumps = get_lowest_clumps(master_clump)
    proj = yt.ProjectionPlot(ds,2,('gas','new_grav_potential'),center = 'c',width=(20,'kpc'),field_parameters={'grav_max':a})
    proj.annotate_clumps(leaf_clumps)
    proj.save('clumps')


The error occurs in the find_clumps function.  The error I am receiving is:

 yt.fields.field_exceptions.NeedsParameter: (['max_grav'])

Dan Le


On Tuesday, March 20, 2018 1:29 PM, Britton Smith <brittonsmith@gmail.com> wrote:


Hi Dan Le,

Can you post the code you've written and the error you're seeing?

Britton

On Tue, Mar 20, 2018 at 9:57 AM, Le Dan via yt-users <yt-users@python.org> wrote:
Hi all,

I've created a new field and trying to get clump find to work on that field.  When running my program, I received the error saying that a parameter used to define my new field could not be accessed by the function,  find_clumps(master_clump, c_min, c_max, step).  How would I go about getting rid of this error?


Dan Le


______________________________ _________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org