Finding the temperature of cell with maximum density

Hi all, I feel like this should be relatively straightforward, but I have a lot of rather small clouds that I have identified already. I can get info about them by using their position and then creating a sphere around it. I already have the maximum density and minimum temperature values for these clouds. All I want to do is see if these are the same cell, and if not, what the difference in temp (or density) is. So I know how to find a maximum quantity, but not how to then find values of other variables in that cell. I was thinking that I basically want an array with max density, min temperature, density at min temperature, temperature at max density. So can anyone point me to how to find the temperature of the cell with the highest density in a sphere object? Thanks! Stephanie -- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com

I think you want to use argmax: https://yt-project.org/doc/analyzing/objects.html#quickly-processing-data On Thu, Jan 23, 2020 at 3:21 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi all,
I feel like this should be relatively straightforward, but I have a lot of rather small clouds that I have identified already. I can get info about them by using their position and then creating a sphere around it.
I already have the maximum density and minimum temperature values for these clouds. All I want to do is see if these are the same cell, and if not, what the difference in temp (or density) is. So I know how to find a maximum quantity, but not how to then find values of other variables in that cell. I was thinking that I basically want an array with max density, min temperature, density at min temperature, temperature at max density.
So can anyone point me to how to find the temperature of the cell with the highest density in a sphere object?
Thanks! Stephanie -- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

Hi Stephanie, You can do this with the "argmax" call on a data object. https://yt-project.org/doc/analyzing/objects.html#quickly-processing-data -Matt On Thu, Jan 23, 2020 at 4:22 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi all,
I feel like this should be relatively straightforward, but I have a lot of rather small clouds that I have identified already. I can get info about them by using their position and then creating a sphere around it.
I already have the maximum density and minimum temperature values for these clouds. All I want to do is see if these are the same cell, and if not, what the difference in temp (or density) is. So I know how to find a maximum quantity, but not how to then find values of other variables in that cell. I was thinking that I basically want an array with max density, min temperature, density at min temperature, temperature at max density.
So can anyone point me to how to find the temperature of the cell with the highest density in a sphere object?
Thanks! Stephanie -- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

Perfect, this was just what I need! Thank you both! Best, Stephanie On Thu, Jan 23, 2020 at 5:25 PM Matthew Turk <matthewturk@gmail.com> wrote:
Hi Stephanie,
You can do this with the "argmax" call on a data object.
https://yt-project.org/doc/analyzing/objects.html#quickly-processing-data
-Matt
On Thu, Jan 23, 2020 at 4:22 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi all,
I feel like this should be relatively straightforward, but I have a lot
of rather small clouds that I have identified already. I can get info about them by using their position and then creating a sphere around it.
I already have the maximum density and minimum temperature values for
these clouds. All I want to do is see if these are the same cell, and if not, what the difference in temp (or density) is. So I know how to find a maximum quantity, but not how to then find values of other variables in that cell. I was thinking that I basically want an array with max density, min temperature, density at min temperature, temperature at max density.
So can anyone point me to how to find the temperature of the cell with
the highest density in a sphere object?
Thanks! Stephanie -- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com

Okay, I am running into a strange problem I don't think I have seen before, specifically the "axis" argument in argmax is not reading in the variable name correctly. in the example I am showing you, the problematic line is: dattmin[j] = data_source.argmin("temperature", axis=("density")) for which thee error says it can't find '('io', 'd')' But I have tried data_source.argmin("temperature", axis="density"), data_source.argmin('temperature', axis='density'), data_source.argmin("temperature", axis=("gas","density"))--which said it couldn't find ('io','gas'), and also capitalizing the variable names. As always, any help is MUCH appreciated. Thanks, Stephanie So, a longish snippet from my code: ds = yt.load('/dev/shm/DD%s/JO201cwg%s'%(l, l)) for k in sorted(ds.field_list): print(k) ad = ds.all_data() clumparr = np.loadtxt('JO201cwg'+loop[i]+'_leafclumpinfo_rho26_12to18kpc_nov.txt') xclump = clumparr[0,:] xwclump = clumparr[1,:] yclump = clumparr[2,:] ywclump = clumparr[3,:] zclump = clumparr[4,:] zwclump = clumparr[5,:] rhomaxclump = clumparr[17,:] tminclump = clumparr[19,:] dmax = np.zeros(len(xwclump),float) tmin = np.zeros(len(xwclump),float) dattmin = np.zeros(len(xwclump),float) tatdmax = np.zeros(len(xwclump),float) ctarr = np.zeros((9,len(xwclump)),float) for j in range(0,len(xclump)): data_source = ds.sphere([xwclump[j]/(300.*3.086e21),ywclump[j]/(300.*3.086e21),zwclump[j]/(300.*3.086e21)],(160,'pc')) dmax[j] = data_source.max("density") tmin[j] = data_source.min("temperature") dattmin[j] = data_source.argmin("temperature", axis=("density")) tatdmax[j] = data_source.argmax("density", axis=("temperature")) ctarr[:,j] = [xwclump[j],ywclump[j],zwclump[j],rhomaxclump[j],dmax[j],dattmin[j],tminclump[j],tmin[j],tatdmax[j]] np.savetxt('JO201cwg'+loop[i]+'_leafclump_rho26_12to18kpc_denstempcheck.txt',ctarr,delimiter=' ',newline='\n') ############ and then the output file with the error: yt : [INFO ] 2020-01-24 11:57:54,526 Copying 0016 data to /dev/shm yt : [INFO ] 2020-01-24 12:00:01,744 Checking size of /dev/shm 12G /dev/shm/ yt : [INFO ] 2020-01-24 12:00:03,492 Parameters: current_time = 159.99990026845 yt : [INFO ] 2020-01-24 12:00:03,492 Parameters: domain_dimensions = [256 256 256] yt : [INFO ] 2020-01-24 12:00:03,493 Parameters: domain_left_edge = [ 0. 0. 0.] yt : [INFO ] 2020-01-24 12:00:03,493 Parameters: domain_right_edge = [ 1. 1. 1.] yt : [INFO ] 2020-01-24 12:00:03,494 Parameters: cosmological_simulation = 0.0 Parsing Hierarchy : 0%| | 0/22796 [00:00<?, ?it/s] Parsing Hierarchy : 2%|▏ | 513/22796 [00:00<00:04, 5129.81it/s] Parsing Hierarchy : 7%|▋ | 1562/22796 [00:00<00:03, 6737.72it/s] Parsing Hierarchy : 10%|█ | 2338/22796 [00:00<00:02, 7042.75it/s] Parsing Hierarchy : 15%|█▌ | 3420/22796 [00:00<00:02, 8174.24it/s] Parsing Hierarchy : 19%|█▊ | 4272/22796 [00:00<00:02, 7894.54it/s] Parsing Hierarchy : 23%|██▎ | 5352/22796 [00:00<00:01, 8762.80it/s] Parsing Hierarchy : 27%|██▋ | 6213/22796 [00:00<00:02, 8162.89it/s] Parsing Hierarchy : 32%|███▏ | 7297/22796 [00:00<00:01, 8965.85it/s] Parsing Hierarchy : 37%|███▋ | 8330/22796 [00:00<00:01, 8303.76it/s] Parsing Hierarchy : 41%|████▏ | 9411/22796 [00:01<00:01, 9054.24it/s] Parsing Hierarchy : 46%|████▌ | 10497/22796 [00:01<00:01, 9594.51it/s] Parsing Hierarchy : 50%|█████ | 11447/22796 [00:01<00:01, 8536.31it/s] Parsing Hierarchy : 55%|█████▍ | 12529/22796 [00:01<00:01, 9219.92it/s] Parsing Hierarchy : 60%|█████▉ | 13615/22796 [00:01<00:00, 9710.13it/s] Parsing Hierarchy : 64%|██████▍ | 14583/22796 [00:01<00:00, 8501.02it/s] Parsing Hierarchy : 69%|██████▊ | 15666/22796 [00:01<00:00, 9198.34it/s] Parsing Hierarchy : 74%|███████▎ | 16757/22796 [00:01<00:00, 9709.93it/s] Parsing Hierarchy : 78%|███████▊ | 17838/22796 [00:02<00:00, 10038.51it/s] Parsing Hierarchy : 83%|████████▎ | 18842/22796 [00:02<00:00, 8612.77it/s] Parsing Hierarchy : 87%|████████▋ | 19923/22796 [00:02<00:00, 9269.68it/s] Parsing Hierarchy : 92%|█████████▏| 20990/22796 [00:02<00:00, 9689.34it/s] Parsing Hierarchy : 97%|█████████▋| 22088/22796 [00:02<00:00, 10075.97it/s] Parsing Hierarchy : 100%|██████████| 22796/22796 [00:02<00:00, 8829.84it/s] yt : [INFO ] 2020-01-24 12:00:06,927 Gathering a field list (this may take a moment.) ('enzo', 'Density') ('enzo', 'Electron_Density') ('enzo', 'External_Acceleration_x') ('enzo', 'External_Acceleration_y') ('enzo', 'External_Acceleration_z') ('enzo', 'GasEnergy') ('enzo', 'HII_Density') ('enzo', 'HI_Density') ('enzo', 'HeIII_Density') ('enzo', 'HeII_Density') ('enzo', 'HeI_Density') ('enzo', 'Metal_Density') ('enzo', 'Temperature') ('enzo', 'TotalEnergy') ('enzo', 'x-velocity') ('enzo', 'y-velocity') ('enzo', 'z-velocity') Traceback (most recent call last): File "yt_clump_denstempcheck.py", line 84, in <module> dattmin[j] = data_source.argmin("temperature", axis=("density")) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/data_containers.py", line 744, in argmin rv = self.quantities.sample_at_min_field_values(field, axis) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/derived_quantities.py", line 591, in __call__ rv = super(SampleAtMaxFieldValues, self).__call__(field, sample_fields) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/derived_quantities.py", line 69, in __call__ sto.result = self.process_chunk(ds, *args, **kwargs) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/derived_quantities.py", line 598, in process_chunk vals = [array_like_field(data, -1, sf) for sf in sample_fields] File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/derived_quantities.py", line 598, in <listcomp> vals = [array_like_field(data, -1, sf) for sf in sample_fields] File "/mnt/home/stonnesen/yt-conda/yt/yt/units/yt_array.py", line 1701, in array_like_field field = data._determine_fields(field)[0] File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/data_containers.py", line 1165, in _determine_fields finfo = self.ds._get_field_info("unknown", fname) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/static_output.py", line 798, in _get_field_info raise YTFieldNotFound((ftype, fname), self) yt.utilities.exceptions.YTFieldNotFound: Could not find field '('io', 'd')' in JO201cwg0016. -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com On Fri, Jan 24, 2020 at 7:43 AM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Perfect, this was just what I need! Thank you both! Best, Stephanie
On Thu, Jan 23, 2020 at 5:25 PM Matthew Turk <matthewturk@gmail.com> wrote:
Hi Stephanie,
You can do this with the "argmax" call on a data object.
https://yt-project.org/doc/analyzing/objects.html#quickly-processing-data
-Matt
On Thu, Jan 23, 2020 at 4:22 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi all,
I feel like this should be relatively straightforward, but I have a lot
of rather small clouds that I have identified already. I can get info about them by using their position and then creating a sphere around it.
I already have the maximum density and minimum temperature values for
these clouds. All I want to do is see if these are the same cell, and if not, what the difference in temp (or density) is. So I know how to find a maximum quantity, but not how to then find values of other variables in that cell. I was thinking that I basically want an array with max density, min temperature, density at min temperature, temperature at max density.
So can anyone point me to how to find the temperature of the cell with
the highest density in a sphere object?
Thanks! Stephanie -- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com

I think you want to say: dattmin[j] = data_source.argmin("temperature", axis=("density",)) ("density") is the same as "density" to python, you need to add the comma to make it a tuple. Can you file this as a bug? We should probably be checking if axis is a single field instead of a list or tuple of fields. Looking at the tests all of the usages use a list of fields. On Fri, Jan 24, 2020 at 12:02 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Okay, I am running into a strange problem I don't think I have seen before, specifically the "axis" argument in argmax is not reading in the variable name correctly. in the example I am showing you, the problematic line is:
dattmin[j] = data_source.argmin("temperature", axis=("density")) for which thee error says it can't find '('io', 'd')'
But I have tried data_source.argmin("temperature", axis="density"), data_source.argmin('temperature', axis='density'), data_source.argmin("temperature", axis=("gas","density"))--which said it couldn't find ('io','gas'), and also capitalizing the variable names.
As always, any help is MUCH appreciated.
Thanks, Stephanie
So, a longish snippet from my code:
ds = yt.load('/dev/shm/DD%s/JO201cwg%s'%(l, l)) for k in sorted(ds.field_list): print(k) ad = ds.all_data()
clumparr = np.loadtxt('JO201cwg'+loop[i]+'_leafclumpinfo_rho26_12to18kpc_nov.txt')
xclump = clumparr[0,:] xwclump = clumparr[1,:] yclump = clumparr[2,:] ywclump = clumparr[3,:] zclump = clumparr[4,:] zwclump = clumparr[5,:] rhomaxclump = clumparr[17,:] tminclump = clumparr[19,:] dmax = np.zeros(len(xwclump),float) tmin = np.zeros(len(xwclump),float) dattmin = np.zeros(len(xwclump),float) tatdmax = np.zeros(len(xwclump),float)
ctarr = np.zeros((9,len(xwclump)),float)
for j in range(0,len(xclump)): data_source = ds.sphere([xwclump[j]/(300.*3.086e21),ywclump[j]/(300.*3.086e21),zwclump[j]/(300.*3.086e21)],(160,'pc')) dmax[j] = data_source.max("density") tmin[j] = data_source.min("temperature") dattmin[j] = data_source.argmin("temperature", axis=("density")) tatdmax[j] = data_source.argmax("density", axis=("temperature")) ctarr[:,j] = [xwclump[j],ywclump[j],zwclump[j],rhomaxclump[j],dmax[j],dattmin[j],tminclump[j],tmin[j],tatdmax[j]]
np.savetxt('JO201cwg'+loop[i]+'_leafclump_rho26_12to18kpc_denstempcheck.txt',ctarr,delimiter=' ',newline='\n')
############ and then the output file with the error:
yt : [INFO ] 2020-01-24 11:57:54,526 Copying 0016 data to /dev/shm yt : [INFO ] 2020-01-24 12:00:01,744 Checking size of /dev/shm 12G /dev/shm/ yt : [INFO ] 2020-01-24 12:00:03,492 Parameters: current_time = 159.99990026845 yt : [INFO ] 2020-01-24 12:00:03,492 Parameters: domain_dimensions = [256 256 256] yt : [INFO ] 2020-01-24 12:00:03,493 Parameters: domain_left_edge = [ 0. 0. 0.] yt : [INFO ] 2020-01-24 12:00:03,493 Parameters: domain_right_edge = [ 1. 1. 1.] yt : [INFO ] 2020-01-24 12:00:03,494 Parameters: cosmological_simulation = 0.0
Parsing Hierarchy : 0%| | 0/22796 [00:00<?, ?it/s] Parsing Hierarchy : 2%|▏ | 513/22796 [00:00<00:04, 5129.81it/s] Parsing Hierarchy : 7%|▋ | 1562/22796 [00:00<00:03, 6737.72it/s] Parsing Hierarchy : 10%|█ | 2338/22796 [00:00<00:02, 7042.75it/s] Parsing Hierarchy : 15%|█▌ | 3420/22796 [00:00<00:02, 8174.24it/s] Parsing Hierarchy : 19%|█▊ | 4272/22796 [00:00<00:02, 7894.54it/s] Parsing Hierarchy : 23%|██▎ | 5352/22796 [00:00<00:01, 8762.80it/s] Parsing Hierarchy : 27%|██▋ | 6213/22796 [00:00<00:02, 8162.89it/s] Parsing Hierarchy : 32%|███▏ | 7297/22796 [00:00<00:01, 8965.85it/s] Parsing Hierarchy : 37%|███▋ | 8330/22796 [00:00<00:01, 8303.76it/s] Parsing Hierarchy : 41%|████▏ | 9411/22796 [00:01<00:01, 9054.24it/s] Parsing Hierarchy : 46%|████▌ | 10497/22796 [00:01<00:01, 9594.51it/s] Parsing Hierarchy : 50%|█████ | 11447/22796 [00:01<00:01, 8536.31it/s] Parsing Hierarchy : 55%|█████▍ | 12529/22796 [00:01<00:01, 9219.92it/s] Parsing Hierarchy : 60%|█████▉ | 13615/22796 [00:01<00:00, 9710.13it/s] Parsing Hierarchy : 64%|██████▍ | 14583/22796 [00:01<00:00, 8501.02it/s] Parsing Hierarchy : 69%|██████▊ | 15666/22796 [00:01<00:00, 9198.34it/s] Parsing Hierarchy : 74%|███████▎ | 16757/22796 [00:01<00:00, 9709.93it/s] Parsing Hierarchy : 78%|███████▊ | 17838/22796 [00:02<00:00, 10038.51it/s] Parsing Hierarchy : 83%|████████▎ | 18842/22796 [00:02<00:00, 8612.77it/s] Parsing Hierarchy : 87%|████████▋ | 19923/22796 [00:02<00:00, 9269.68it/s] Parsing Hierarchy : 92%|█████████▏| 20990/22796 [00:02<00:00, 9689.34it/s] Parsing Hierarchy : 97%|█████████▋| 22088/22796 [00:02<00:00, 10075.97it/s] Parsing Hierarchy : 100%|██████████| 22796/22796 [00:02<00:00, 8829.84it/s] yt : [INFO ] 2020-01-24 12:00:06,927 Gathering a field list (this may take a moment.) ('enzo', 'Density') ('enzo', 'Electron_Density') ('enzo', 'External_Acceleration_x') ('enzo', 'External_Acceleration_y') ('enzo', 'External_Acceleration_z') ('enzo', 'GasEnergy') ('enzo', 'HII_Density') ('enzo', 'HI_Density') ('enzo', 'HeIII_Density') ('enzo', 'HeII_Density') ('enzo', 'HeI_Density') ('enzo', 'Metal_Density') ('enzo', 'Temperature') ('enzo', 'TotalEnergy') ('enzo', 'x-velocity') ('enzo', 'y-velocity') ('enzo', 'z-velocity') Traceback (most recent call last): File "yt_clump_denstempcheck.py", line 84, in <module> dattmin[j] = data_source.argmin("temperature", axis=("density")) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/data_containers.py", line 744, in argmin rv = self.quantities.sample_at_min_field_values(field, axis) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/derived_quantities.py", line 591, in __call__ rv = super(SampleAtMaxFieldValues, self).__call__(field, sample_fields) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/derived_quantities.py", line 69, in __call__ sto.result = self.process_chunk(ds, *args, **kwargs) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/derived_quantities.py", line 598, in process_chunk vals = [array_like_field(data, -1, sf) for sf in sample_fields] File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/derived_quantities.py", line 598, in <listcomp> vals = [array_like_field(data, -1, sf) for sf in sample_fields] File "/mnt/home/stonnesen/yt-conda/yt/yt/units/yt_array.py", line 1701, in array_like_field field = data._determine_fields(field)[0] File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/data_containers.py", line 1165, in _determine_fields finfo = self.ds._get_field_info("unknown", fname) File "/mnt/home/stonnesen/yt-conda/yt/yt/data_objects/static_output.py", line 798, in _get_field_info raise YTFieldNotFound((ftype, fname), self) yt.utilities.exceptions.YTFieldNotFound: Could not find field '('io', 'd')' in JO201cwg0016. -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com
On Fri, Jan 24, 2020 at 7:43 AM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Perfect, this was just what I need! Thank you both! Best, Stephanie
On Thu, Jan 23, 2020 at 5:25 PM Matthew Turk <matthewturk@gmail.com> wrote:
Hi Stephanie,
You can do this with the "argmax" call on a data object.
https://yt-project.org/doc/analyzing/objects.html#quickly-processing-data
-Matt
On Thu, Jan 23, 2020 at 4:22 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi all,
I feel like this should be relatively straightforward, but I have a
lot of rather small clouds that I have identified already. I can get info about them by using their position and then creating a sphere around it.
I already have the maximum density and minimum temperature values for
these clouds. All I want to do is see if these are the same cell, and if not, what the difference in temp (or density) is. So I know how to find a maximum quantity, but not how to then find values of other variables in that cell. I was thinking that I basically want an array with max density, min temperature, density at min temperature, temperature at max density.
So can anyone point me to how to find the temperature of the cell with
the highest density in a sphere object?
Thanks! Stephanie -- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
participants (3)
-
Matthew Turk
-
Nathan
-
Stephanie Tonnesen