possible difference between sphere and cut_region selections
Hi yt-users! I have a list of positions that I call xwclump, ywclump, and zwclump. I have been selecting regions in a loop using ds.sphere and the center: data_source = ds.sphere([xwclump[j]/(300.*3.086e21),ywclump[j]/(300.*3.086e21),zwclump[j]/(300.*3.086e21)],(1000,'pc')) (the divisor is to put the center into code units). This works fine. But, when I try to use cut_region: data_source = ad.cut_region(["(obj['temperature'] > 1.0e6) & (obj['z'] < (zwclump[j]/(300.*3.086e21)))"]) I get an error: NameError: name 'zwclump' is not defined Is this something anyone else has dealt with? If it doesn't ring any bells I will try and break IsolatedGalaxy and send the code snippet... Thanks, Stephanie -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com
Hi Stephanie, I think this is because you can't access the zwclump *variable* inside the scope that the cut region is within. You can try passing it in as a "local" variable by supplying it in the "locals" dictionary, but my *guess* is that unless the j index is also defined it won't work. On Mon, Jul 20, 2020 at 1:45 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi yt-users!
I have a list of positions that I call xwclump, ywclump, and zwclump. I have been selecting regions in a loop using ds.sphere and the center: data_source = ds.sphere([xwclump[j]/(300.*3.086e21),ywclump[j]/(300.*3.086e21),zwclump[j]/(300.*3.086e21)],(1000,'pc')) (the divisor is to put the center into code units). This works fine.
But, when I try to use cut_region: data_source = ad.cut_region(["(obj['temperature'] > 1.0e6) & (obj['z'] < (zwclump[j]/(300.*3.086e21)))"]) I get an error:
NameError: name 'zwclump' is not defined
Is this something anyone else has dealt with? If it doesn't ring any bells I will try and break IsolatedGalaxy and send the code snippet...
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 https://mail.python.org/mailman3/lists/yt-users.python.org/ Member address: matthewturk@gmail.com
Thanks! Okay, well, I can get around that by just making a variable "zuse" defined in each iteration of the loop. But I must be missing something, because I have never done this locals dictionary thing. Based on this: https://yt-project.org/doc/reference/api/yt.data_objects.construction_data_c... I tried locals={zuse} in the cut_region call, which I wrote like this: zuse = zwclump[j]/(300.*3.086e21) data_s = ds.sphere([xwclump[j]/(300.*3.086e21),ywclump[j]/(300.*3.086e21),zwclump[j]/(300.*3.086e21)],(1000,'pc')) data_source = data_s.cut_region(["(obj['temperature'] > 1.0e6) & (obj['z'] < zuse)"],locals={zuse}) but got told: File "yt_clump_icmvalsltlzbig.py", line 82, in <module> data_source = data_s.cut_region(["(obj['temperature'] > 1.0e6) & (obj['z'] < zuse)"],locals={zuse}) TypeError: cut_region() got an unexpected keyword argument 'locals' Are there any examples of using the locals dictionary? Thanks, Stephanie -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com On Mon, Jul 20, 2020 at 2:55 PM Matthew Turk <matthewturk@gmail.com> wrote:
Hi Stephanie,
I think this is because you can't access the zwclump *variable* inside the scope that the cut region is within. You can try passing it in as a "local" variable by supplying it in the "locals" dictionary, but my *guess* is that unless the j index is also defined it won't work.
On Mon, Jul 20, 2020 at 1:45 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi yt-users!
I have a list of positions that I call xwclump, ywclump, and zwclump. I have been selecting regions in a loop using ds.sphere and the center: data_source = ds.sphere([xwclump[j]/(300.*3.086e21),ywclump[j]/(300.*3.086e21),zwclump[j]/(300.*3.086e21)],(1000,'pc')) (the divisor is to put the center into code units). This works fine.
But, when I try to use cut_region: data_source = ad.cut_region(["(obj['temperature'] > 1.0e6) & (obj['z'] < (zwclump[j]/(300.*3.086e21)))"]) I get an error:
NameError: name 'zwclump' is not defined
Is this something anyone else has dealt with? If it doesn't ring any bells I will try and break IsolatedGalaxy and send the code snippet...
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 https://mail.python.org/mailman3/lists/yt-users.python.org/ Member address: matthewturk@gmail.com
_______________________________________________ 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: stonnes@gmail.com
participants (2)
-
Matthew Turk
-
Stephanie Tonnesen