ACCESSING GAS FILEDS THROUGH ARBITRARY_GRID

Hi,
I am using arbitrary_grid to access my data without flattening:
dd=ds.arbitrary_grid(left_edge=[(com_x_1.value-30), (com_y_1.value-30), (com_z_1.value-30)]*kpc, right_edge=[(com_x_1.value+30), (com_y_1.value+30), (com_z_1.value+30)]*kpc, dims=[128, 128, 128])
and as I attempt to get the gas fields for this object,
print(dd['gas', 'velocity_x'])
but end up getting the error: (which isn't the case for deposit fields)
yt.units.unit_registry.UnitParseError: Code units have not been defined.
Try creating the array or quantity using ds.arr or ds.quan instead.
If I'm thinking right, is it because the arbitrary_grid is only applied to the particles. In that case, is there any equivalent for gas fields where I can access my 3D data for the gas as it is , without flattening? Thanks

Hi,
I think this is happening due to the way you’re defining the left_edge and right_edge arguments. In the future if you could send along the traceback python prints out along with the error message that would make it easier to see exactly where the trouble is coming from.
If it's as I suspect, ultimately this is happening because yt.units.kpc is a "generic" unit that doesn't know about units particular to any given dataset. However, internally yt needs to convert the length arguments you're passing in to code_length units, which are different from dataset to dataset, so the unit ultimately needs to have some "knowledge" of the dataset you're dealing with for that conversion to be possible. We could append that metadata to the data being passed in to the arbitrary_grid initializer, but it looks like that's not the case at the moment. All that said, you should be able to get something working like this:
left_edge= ds.arr([(com_x_1.value-30), (com_y_1.value-30), (com_z_1.value-30)], 'kpc')
And similarly for right_edge. And then pass those two variables as the left_edge and right_edge arguments to the arbitrary_grid initializer.
Let us know if that fixes it. If it does please open an issue on github so we don't lose track and future users won't need to use the workaround I suggested.
-Nathan
On Tue, Oct 30, 2018 at 6:20 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi,
I am using arbitrary_grid to access my data without flattening:
dd=ds.arbitrary_grid(left_edge=[(com_x_1.value-30), (com_y_1.value-30), (com_z_1.value-30)]*kpc, right_edge=[(com_x_1.value+30), (com_y_1.value+ 30), (com_z_1.value+30)]*kpc, dims=[128, 128, 128])
and as I attempt to get the gas fields for this object,
print(dd['gas', 'velocity_x'])
but end up getting the error: (which isn't the case for deposit fields)
yt.units.unit_registry.UnitParseError: Code units have not been defined.
Try creating the array or quantity using ds.arr or ds.quan instead.
If I'm thinking right, is it because the arbitrary_grid is only applied to the particles. In that case, is there any equivalent for gas fields where I can access my 3D data for the gas as it is , without flattening? Thanks _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

Thanks! This works.
On Tue, Oct 30, 2018 at 3:47 PM Nathan Goldbaum nathan12343@gmail.com wrote:
Hi,
I think this is happening due to the way you’re defining the left_edge and right_edge arguments. In the future if you could send along the traceback python prints out along with the error message that would make it easier to see exactly where the trouble is coming from.
If it's as I suspect, ultimately this is happening because yt.units.kpc is a "generic" unit that doesn't know about units particular to any given dataset. However, internally yt needs to convert the length arguments you're passing in to code_length units, which are different from dataset to dataset, so the unit ultimately needs to have some "knowledge" of the dataset you're dealing with for that conversion to be possible. We could append that metadata to the data being passed in to the arbitrary_grid initializer, but it looks like that's not the case at the moment. All that said, you should be able to get something working like this:
left_edge= ds.arr([(com_x_1.value-30), (com_y_1.value-30), (com_z_1.value-30)], 'kpc')
And similarly for right_edge. And then pass those two variables as the left_edge and right_edge arguments to the arbitrary_grid initializer.
Let us know if that fixes it. If it does please open an issue on github so we don't lose track and future users won't need to use the workaround I suggested.
-Nathan
On Tue, Oct 30, 2018 at 6:20 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi,
I am using arbitrary_grid to access my data without flattening:
dd=ds.arbitrary_grid(left_edge=[(com_x_1.value-30), (com_y_1.value-30), (com_z_1.value-30)]*kpc, right_edge=[(com_x_1.value+30), (com_y_1.value+ 30), (com_z_1.value+30)]*kpc, dims=[128, 128, 128])
and as I attempt to get the gas fields for this object,
print(dd['gas', 'velocity_x'])
but end up getting the error: (which isn't the case for deposit fields)
yt.units.unit_registry.UnitParseError: Code units have not been defined.
Try creating the array or quantity using ds.arr or ds.quan instead.
If I'm thinking right, is it because the arbitrary_grid is only applied to the particles. In that case, is there any equivalent for gas fields where I can access my 3D data for the gas as it is , without flattening? Thanks _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
participants (2)
-
Nathan Goldbaum
-
Vadlamani Samhitha