Hi Sean,

Unfortunately, the comment there is not a full description of what's going on!  It copies it because it reads the original field directly from disk.  All that should happen afterward is the unit conversion.

Before we go too far down, the first thing that I am wondering about is if there's a selection issue.  yt selects by cell centers, which may not be what your collaborator is doing.  Can you compute the total number of cells in each sphere, and compare that?  If you have access to the sphere objects, it should be `.sum("ones")` on each sphere object.  If you can verify that the total number of cells selected is identical, then we should look at differences in unit conversions, but my gut says thati t's in the selection.

On Thu, Oct 22, 2020 at 8:43 PM Sean Larkin via yt-users <yt-users@python.org> wrote:
Hello All,

I have a question regarding how yt finds the cell_mass of a sphere in ART simulations. I am currently doing an analysis of the mass profiles within the virial radius of a galaxy, finding the masses using these commands:

            sp_new_rvir = ds.sphere(center, (float(new_rvir.in_units('kpc')), 'kpc'))
            sp_new_rvir_010 = ds.sphere(center, (float(new_rvir.in_units('kpc'))*.1, 'kpc'))
            sp_new_rvir_015 = ds.sphere(center, (float(new_rvir.in_units('kpc'))*.15, 'kpc'))
            sp_new_rvir_020 = ds.sphere(center, (float(new_rvir.in_units('kpc'))*.2, 'kpc'))



            stellar_mass_rvir, darkmatter_mass_rvir, gas_mass_rvir = sp_new_rvir.quantities.total_quantity([('stars', 'particle_mass'),\
                                                                                               ('darkmatter', 'particle_mass'),\
                                                                                               ('gas', 'cell_mass')])
            stellar_mass_010, gas_mass_010 = sp_new_rvir_010.quantities.total_quantity([('stars', 'particle_mass'),\
                                                                                               ('gas', 'cell_mass')])

            stellar_mass_015, gas_mass_015 = sp_new_rvir_015.quantities.total_quantity([('stars', 'particle_mass'),\
                                                                                               ('gas', 'cell_mass')])

            stellar_mass_020, gas_mass_020 = sp_new_rvir_020.quantities.total_quantity([('stars', 'particle_mass'),\
                                                                                               ('gas', 'cell_mass')])

These work just fine, and return results, but when I compare these values to ones collected by a collaborator, I disagree on the total masses within each sphere by a small amount. I imagine that there might be a difference in how yt calculates these quantities compared to the other methodology, which I would like to understand, as both are probably acceptable methods, but understanding the difference seems important. I have a gut feeling that gas mass is probably the cause of this difference, as I dont see how a difference in the particle fields could arise. I was looking through the yt fields list page (https://yt-project.org/doc/reference/field_list.html) to see how the cell_mass paramater was defined to compare to this other method, and saw that it is multiplying the density and cell volume field. On that page, it lists the method for the density field as follows:

def _TranslationFunc(field, data):
    # We do a bunch of in-place modifications, so we will copy this.
    return data[field_name].copy()

I am not sure where to look to see where the method for the density field calculation is stored. I looked a bit around the ART frontend here https://github.com/yt-project/yt/tree/master/yt/frontends/art but could not find anything. I was wondering if anyone could point me to where this is?
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
https://mail.python.org/mailman3/lists/yt-users.python.org/
Member address: matthewturk@gmail.com