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 matplotlibmatplotlib.use('Agg')import ytimport matplotlib.pyplot as pltimport numpy as npnar = np.arrayimport timeimport copyfrom yt.analysis_modules.level_sets.api import * grav_min = []x_min = []y_min = []z_min = []loc = []loc_2 = []leaf_indices = []nbins = 20bin_high = 5e6bin_low_init=0.1def new_grav_potential(field,data): grav_old= data['gravitational_potential'] grav_max = data.get_field_parameter('max_grav') grav_new = -grav_old+grav_maxreturn grav_newyt.add_field('new_grav_potential',function=new_grav_potentia l,units = 'erg/g',validators = [yt.ValidateParameter('max_gra v')]) for frame in [120]:n_cl = 0fname = '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 = 100find_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_par ameters={'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 LeOn 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?BrittonOn 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