I've been trying to get this derived field to work, but it's more complicated to define than anything I've done before.
I am working in a plane parallel geometry. I want to make a field that contains gas surface density below (i.e. from z=0 to z=current cell) the given cell. I naively thought I could filter the whole data set 'ad' inside of the function def (field, data) definition using ad['z'] < data['z'], but data['z'] is not a single value from cell.
What I can think of right now is to find a gas density profile (accumulated) and then interpolate that function when I want to use it in a derived field.
Maybe I'm missing something here.
ad = ds.all_data()
current_z = np.absolute(data['z'])
all_z = np.absolute(ad['z'])
z_cut = (all_z < current_z)
m_tot = np.sum( ad[('gas','cell_mass')]*z_cut)
return (m_tot / (area)**2).in_units('Msun/pc**2')
Thanks for the help!