Hi Paco,

Unfortunately this isn't possible right now. It is possible to define a field function that can use data from more than one zone, but the sampling has to be local in the sense that you're only getting information from at most a few neighboring zones. You're looking to produce a field which needs data from, at least in principle, arbitrarily far away. That's something we're planning to add support for (in fact we have funding from an NSF grant to work on this) but right now that functionality isn't ready yet.

Depending on the sort of analysis you're like to do and the geometry of your data, you can get pretty far doing this sort of analysis using either a covering_grid or arbitrary_grid data object (see e.g. http://yt-project.org/doc/analyzing/objects.html#arbitrary-grids-objects and http://yt-project.org/doc/cookbook/constructing_data_objects.html?highlight=covering_grid#extracting-fixed-resolution-data). Both of these data objects interpolate data onto a single uniform resolution grid, they just differ in how the grid is defined. For AMR data covering_grid is often more natural to use, as it won't interpolate data that is more coarse than the grid you want to interpolate onto, while arbitrary_grid has a more easy-to-understand API and is often more natural to think about.

The idea would be to interpolate your data onto a uniform resolution grid, then calculate the line-integrated field data you're looking to calculate using the interpolated data. I used 2048x2048x256 "grid slabs" in my thesis to the Toomre Q analysis of my galaxy simulations, which must be done in terms of projected quantities. See Appendix A of my 2015 paper (http://adsabs.harvard.edu/abs/2015ApJ...814..131G) for all the gory details.

-Nathan

On Thu, Jan 3, 2019 at 12:41 AM Paco Holguin <opaco450@gmail.com> wrote:
Hi,

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()

 def _sigma_n_z(field,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!

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