How to pass value of the field corresponds to the index to the scalar function!!!
Dear Yt-users, I need to pass the value of the available/derived field corresponds to the index selected based on some criterion (using numpy.where()) to a scalar function. It should list out the indexes wheres the condition satisfies. It happens when this has been done outside the field but instead of getting 3D indexes it gives 1D YT_Array indexes I think. But I need to pass this value of field corresponds to the selected index to scalar function inside the field, which may give some problem (please find the attachment to see what exactly I am trying to do). The attached script can run on the ENZO test data set, enzo_tiny_cosmology. Many thanks and regards -Prateek
Hi Prateek, Instead of using your "check" function and trying to set values one-by-one, you can use numpy's fancy indexing to do the conditional setting of values in your _norm function. I've modified your script to do what I think you were trying to do here: https://gist.github.com/ngoldbaum/b3ed70139faf6da89f37ae56cb965faf This script produces this image: https://i.imgur.com/6Fgpf53.png Hope that helps! If there's something else that you were trying to do that your script wasn't illustrating and my solution won't work for, please do write back with additional details. -Nathan On Thu, Oct 31, 2019 at 4:05 AM Prateek Gupta <prateekgidolia@gmail.com> wrote:
Dear Yt-users,
I need to pass the value of the available/derived field corresponds to the index selected based on some criterion (using numpy.where()) to a scalar function. It should list out the indexes wheres the condition satisfies. It happens when this has been done outside the field but instead of getting 3D indexes it gives 1D YT_Array indexes I think. But I need to pass this value of field corresponds to the selected index to scalar function inside the field, which may give some problem (please find the attachment to see what exactly I am trying to do).
The attached script can run on the ENZO test data set, enzo_tiny_cosmology.
Many thanks and regards -Prateek
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Dear Nathan, Many thanks for your reply. Actually I took the simplest case in which this can be done, and usually, I did it in this way. I was thinking that the provided test script may lead to an alternative solution. But I actually need to pass the value of the field to the function for the current task. I try to illustrate my task, actually, I have two distribution functions. One is Maxwell-Juttner (MJ) distribution and power-law distribution in momentum space. I have to find the intersection point (say p_int) between these two distributions on each cell. Now the thing is that MJ distribution needs the value of Temperature and density field of the cell and power-law distribution needs the value of density and Mach number field of the same cell to compute the intersection point of the said distribution functions on that cell which I will select based on some criteria. Hope this will illustrate you what exactly I am looking for. Many thanks and regards, -Prateek On Fri, Nov 1, 2019 at 1:44 AM Nathan <nathan.goldbaum@gmail.com> wrote:
Hi Prateek,
Instead of using your "check" function and trying to set values one-by-one, you can use numpy's fancy indexing to do the conditional setting of values in your _norm function. I've modified your script to do what I think you were trying to do here: https://gist.github.com/ngoldbaum/b3ed70139faf6da89f37ae56cb965faf
This script produces this image: https://i.imgur.com/6Fgpf53.png
Hope that helps!
If there's something else that you were trying to do that your script wasn't illustrating and my solution won't work for, please do write back with additional details.
-Nathan
On Thu, Oct 31, 2019 at 4:05 AM Prateek Gupta <prateekgidolia@gmail.com> wrote:
Dear Yt-users,
I need to pass the value of the available/derived field corresponds to the index selected based on some criterion (using numpy.where()) to a scalar function. It should list out the indexes wheres the condition satisfies. It happens when this has been done outside the field but instead of getting 3D indexes it gives 1D YT_Array indexes I think. But I need to pass this value of field corresponds to the selected index to scalar function inside the field, which may give some problem (please find the attachment to see what exactly I am trying to do).
The attached script can run on the ENZO test data set, enzo_tiny_cosmology.
Many thanks and regards -Prateek
_______________________________________________ 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
Dear yt-users, Please tell me how to pass the value of the field to the scaler function for the selective/non-selective indexes. Many thanks -Prateek On Fri, Nov 1, 2019 at 10:34 AM Prateek Gupta <prateekgidolia@gmail.com> wrote:
Dear Nathan,
Many thanks for your reply. Actually I took the simplest case in which this can be done, and usually, I did it in this way. I was thinking that the provided test script may lead to an alternative solution. But I actually need to pass the value of the field to the function for the current task.
I try to illustrate my task, actually, I have two distribution functions. One is Maxwell-Juttner (MJ) distribution and power-law distribution in momentum space. I have to find the intersection point (say p_int) between these two distributions on each cell. Now the thing is that MJ distribution needs the value of Temperature and density field of the cell and power-law distribution needs the value of density and Mach number field of the same cell to compute the intersection point of the said distribution functions on that cell which I will select based on some criteria.
Hope this will illustrate you what exactly I am looking for.
Many thanks and regards, -Prateek
On Fri, Nov 1, 2019 at 1:44 AM Nathan <nathan.goldbaum@gmail.com> wrote:
Hi Prateek,
Instead of using your "check" function and trying to set values one-by-one, you can use numpy's fancy indexing to do the conditional setting of values in your _norm function. I've modified your script to do what I think you were trying to do here: https://gist.github.com/ngoldbaum/b3ed70139faf6da89f37ae56cb965faf
This script produces this image: https://i.imgur.com/6Fgpf53.png
Hope that helps!
If there's something else that you were trying to do that your script wasn't illustrating and my solution won't work for, please do write back with additional details.
-Nathan
On Thu, Oct 31, 2019 at 4:05 AM Prateek Gupta <prateekgidolia@gmail.com> wrote:
Dear Yt-users,
I need to pass the value of the available/derived field corresponds to the index selected based on some criterion (using numpy.where()) to a scalar function. It should list out the indexes wheres the condition satisfies. It happens when this has been done outside the field but instead of getting 3D indexes it gives 1D YT_Array indexes I think. But I need to pass this value of field corresponds to the selected index to scalar function inside the field, which may give some problem (please find the attachment to see what exactly I am trying to do).
The attached script can run on the ENZO test data set, enzo_tiny_cosmology.
Many thanks and regards -Prateek
_______________________________________________ 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
-
Prateek Gupta