Hi, I have some FLASH data from a 2-D simulation (cylindrical symmetry, R-Z) and I was trying to get point objects following the approach on the web page: https://yt-project.org/doc/analyzing/objects.html?highlight=interpolate There it indicates that you can do something like: ds = yt.load(file) pt = ds.r[(10.0, "km"), (200, "m"), (1.0, "km")] In my case I just give 0 for the last value since it doesn't matter in 2D. However if I try that I get the error message: --------------------------------------------------------------------------- YTDimensionalityError Traceback (most recent call last) Cell In [4], line 1 ----> 1 pt = ds.r[(rinit,'pc'), (zinit,'pc'), (0.,'pc')] File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/data_objects/region_expression.py:67, in RegionExpression.__getitem__(self, item) 61 item.insert(idx, slice(None)) 63 if len(item) != self.ds.dimensionality: 64 # Not the right specification, and we don't want to do anything 65 # implicitly. Note that this happens *after* the implicit expansion 66 # of a single slice. ---> 67 raise YTDimensionalityError(len(item), self.ds.dimensionality) 69 # OK, now we need to look at our slices. How many are a specific 70 # coordinate? 72 nslices = sum(isinstance(v, slice) for v in item) YTDimensionalityError: Dimensionality specified was 3 but we need 2 So I thought this might be due to the data being 2D. Then I tried pt = ds.r[(rinit,'pc'), (zinit,'pc')] but that leads to a TypeError - the message ends with: File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/funcs.py:1119, in validate_3d_array(obj) 1117 def validate_3d_array(obj): 1118 if not is_sequence(obj) or len(obj) != 3: -> 1119 raise TypeError( 1120 "Expected an array of size (3,), received '%s' of " 1121 "length %s" % (str(type(obj)).split("'")[1], len(obj)) 1122 ) TypeError: Expected an array of size (3,), received 'list' of length 2 So is there any way around this? (By the way, I'm using yt 4.1.1 and got the same issue with 4.0.5.) Thanks in advance for any help. Regards, Jon -- Jonathan D. Slavin (he/him) Astrophysicist - High Energy Astrophysics Division Center for Astrophysics | Harvard & Smithsonian Office: (617) 496-7981 | Cell: (781) 363-0035 60 Garden Street | MS 04 | Cambridge, MA 02138
Hi Slavin, I hate to be the bringer of bad news but this problem was reported already https://github.com/yt-project/yt/issues/3429 The fundamental issue is that YTArbitraryGrid does not support reduced dimensionality, and unfortunately I don’t know of a workaround. See https://github.com/yt-project/yt/issues/3437 To be clear, what you’re doing should work, and a patch would be very welcome, it’s just that no one has dedicated the time to do it yet. If anyone seeing this wants to give it a try, by all means, go ahead, and do not hesitate with any questions ! Sorry I could not be of more help Clément
On 18 Oct 2022, at 21:23, Slavin, Jonathan via yt-users <yt-users@python.org> wrote:
Hi,
I have some FLASH data from a 2-D simulation (cylindrical symmetry, R-Z) and I was trying to get point objects following the approach on the web page: https://yt-project.org/doc/analyzing/objects.html?highlight=interpolate
There it indicates that you can do something like: ds = yt.load(file) pt = ds.r[(10.0, "km"), (200, "m"), (1.0, "km")]
In my case I just give 0 for the last value since it doesn't matter in 2D. However if I try that I get the error message: --------------------------------------------------------------------------- YTDimensionalityError Traceback (most recent call last) Cell In [4], line 1 ----> 1 pt = ds.r[(rinit,'pc'), (zinit,'pc'), (0.,'pc')]
File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/data_objects/region_expression.py:67, in RegionExpression.__getitem__(self, item) 61 item.insert(idx, slice(None)) 63 if len(item) != self.ds.dimensionality: 64 # Not the right specification, and we don't want to do anything 65 # implicitly. Note that this happens *after* the implicit expansion 66 # of a single slice. ---> 67 raise YTDimensionalityError(len(item), self.ds.dimensionality) 69 # OK, now we need to look at our slices. How many are a specific 70 # coordinate? 72 nslices = sum(isinstance(v, slice) for v in item)
YTDimensionalityError: Dimensionality specified was 3 but we need 2
So I thought this might be due to the data being 2D. Then I tried pt = ds.r[(rinit,'pc'), (zinit,'pc')] but that leads to a TypeError - the message ends with:
File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/funcs.py:1119, in validate_3d_array(obj) 1117 def validate_3d_array(obj): 1118 if not is_sequence(obj) or len(obj) != 3: -> 1119 raise TypeError( 1120 "Expected an array of size (3,), received '%s' of " 1121 "length %s" % (str(type(obj)).split("'")[1], len(obj)) 1122 )
TypeError: Expected an array of size (3,), received 'list' of length 2
So is there any way around this? (By the way, I'm using yt 4.1.1 and got the same issue with 4.0.5.) Thanks in advance for any help.
Regards, Jon --
Jonathan D. Slavin (he/him) Astrophysicist - High Energy Astrophysics Division Center for Astrophysics | Harvard & Smithsonian Office: (617) 496-7981 | Cell: (781) 363-0035 60 Garden Street | MS 04 | Cambridge, MA 02138
Isn't it the case that this is not an arbitrary grid though? As far as yt cares for plotting, it is Cartesian. For analysis, it would need the volume factors that come with axisymmetry, but the zones are still squares. If you don't care about the volume factors for the plot, you might be able to just change the geometry to Cartesian. On Tue, Oct 18, 2022, 4:16 PM Clément Robert via yt-users < yt-users@python.org> wrote:
Hi Slavin, I hate to be the bringer of bad news but this problem was reported already https://github.com/yt-project/yt/issues/3429 The fundamental issue is that YTArbitraryGrid does not support reduced dimensionality, and unfortunately I don’t know of a workaround. See https://github.com/yt-project/yt/issues/3437
To be clear, what you’re doing* should* work, and a patch would be very welcome, it’s just that no one has dedicated the time to do it yet. If anyone seeing this wants to give it a try, by all means, go ahead, and do not hesitate with any questions ! Sorry I could not be of more help Clément
On 18 Oct 2022, at 21:23, Slavin, Jonathan via yt-users < yt-users@python.org> wrote:
Hi,
I have some FLASH data from a 2-D simulation (cylindrical symmetry, R-Z) and I was trying to get point objects following the approach on the web page: https://yt-project.org/doc/analyzing/objects.html?highlight=interpolate
There it indicates that you can do something like: ds = yt.load(file) pt = ds.r[(10.0, "km"), (200, "m"), (1.0, "km")]
In my case I just give 0 for the last value since it doesn't matter in 2D. However if I try that I get the error message: --------------------------------------------------------------------------- YTDimensionalityError Traceback (most recent call last) Cell In [4], line 1 ----> 1 pt = ds.r[(rinit,'pc'), (zinit,'pc'), (0.,'pc')]
File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/data_objects/region_expression.py:67, in RegionExpression.__getitem__(self, item) 61 item.insert(idx, slice(None)) 63 if len(item) != self.ds.dimensionality: 64 # Not the right specification, and we don't want to do anything 65 # implicitly. Note that this happens *after* the implicit expansion 66 # of a single slice. ---> 67 raise YTDimensionalityError(len(item), self.ds.dimensionality) 69 # OK, now we need to look at our slices. How many are a specific 70 # coordinate? 72 nslices = sum(isinstance(v, slice) for v in item)
YTDimensionalityError: Dimensionality specified was 3 but we need 2
So I thought this might be due to the data being 2D. Then I tried pt = ds.r[(rinit,'pc'), (zinit,'pc')] but that leads to a TypeError - the message ends with:
File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/funcs.py:1119, in validate_3d_array(obj) 1117 def validate_3d_array(obj): 1118 if not is_sequence(obj) or len(obj) != 3: -> 1119 raise TypeError( 1120 "Expected an array of size (3,), received '%s' of " 1121 "length %s" % (str(type(obj)).split("'")[1], len(obj)) 1122 )
TypeError: Expected an array of size (3,), received 'list' of length 2
So is there any way around this? (By the way, I'm using yt 4.1.1 and got the same issue with 4.0.5.) Thanks in advance for any help.
Regards, Jon -- Jonathan D. Slavin (he/him) Astrophysicist - High Energy Astrophysics Division Center for Astrophysics | Harvard & Smithsonian Office: (617) 496-7981 | Cell: (781) 363-0035 60 Garden Street | MS 04 | Cambridge, MA 02138
_______________________________________________ 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: michael.zingale@stonybrook.edu
I don’t think the geometry of the data is the issue, rather, the dimensionality (2D) is. Though, you’re right that here we care about YTPoint, not YTArbitraryGrid, so I got this wrong. Unfortunately the issue is the same: YTPoint does not support reduced dimensionality yet (that’s where the second error message pops up). Clément
On 18 Oct 2022, at 22:25, Michael Zingale via yt-users <yt-users@python.org> wrote:
Isn't it the case that this is not an arbitrary grid though? As far as yt cares for plotting, it is Cartesian. For analysis, it would need the volume factors that come with axisymmetry, but the zones are still squares. If you don't care about the volume factors for the plot, you might be able to just change the geometry to Cartesian.
On Tue, Oct 18, 2022, 4:16 PM Clément Robert via yt-users <yt-users@python.org> wrote:
Hi Slavin, I hate to be the bringer of bad news but this problem was reported already https://github.com/yt-project/yt/issues/3429 The fundamental issue is that YTArbitraryGrid does not support reduced dimensionality, and unfortunately I don’t know of a workaround. See https://github.com/yt-project/yt/issues/3437
To be clear, what you’re doing should work, and a patch would be very welcome, it’s just that no one has dedicated the time to do it yet. If anyone seeing this wants to give it a try, by all means, go ahead, and do not hesitate with any questions ! Sorry I could not be of more help Clément
On 18 Oct 2022, at 21:23, Slavin, Jonathan via yt-users <yt-users@python.org> wrote:
Hi,
I have some FLASH data from a 2-D simulation (cylindrical symmetry, R-Z) and I was trying to get point objects following the approach on the web page: https://yt-project.org/doc/analyzing/objects.html?highlight=interpolate
There it indicates that you can do something like: ds = yt.load(file) pt = ds.r[(10.0, "km"), (200, "m"), (1.0, "km")]
In my case I just give 0 for the last value since it doesn't matter in 2D. However if I try that I get the error message: --------------------------------------------------------------------------- YTDimensionalityError Traceback (most recent call last) Cell In [4], line 1 ----> 1 pt = ds.r[(rinit,'pc'), (zinit,'pc'), (0.,'pc')]
File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/data_objects/region_expression.py:67, in RegionExpression.__getitem__(self, item) 61 item.insert(idx, slice(None)) 63 if len(item) != self.ds.dimensionality: 64 # Not the right specification, and we don't want to do anything 65 # implicitly. Note that this happens *after* the implicit expansion 66 # of a single slice. ---> 67 raise YTDimensionalityError(len(item), self.ds.dimensionality) 69 # OK, now we need to look at our slices. How many are a specific 70 # coordinate? 72 nslices = sum(isinstance(v, slice) for v in item)
YTDimensionalityError: Dimensionality specified was 3 but we need 2
So I thought this might be due to the data being 2D. Then I tried pt = ds.r[(rinit,'pc'), (zinit,'pc')] but that leads to a TypeError - the message ends with:
File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/funcs.py:1119, in validate_3d_array(obj) 1117 def validate_3d_array(obj): 1118 if not is_sequence(obj) or len(obj) != 3: -> 1119 raise TypeError( 1120 "Expected an array of size (3,), received '%s' of " 1121 "length %s" % (str(type(obj)).split("'")[1], len(obj)) 1122 )
TypeError: Expected an array of size (3,), received 'list' of length 2
So is there any way around this? (By the way, I'm using yt 4.1.1 and got the same issue with 4.0.5.) Thanks in advance for any help.
Regards, Jon --
Jonathan D. Slavin (he/him) Astrophysicist - High Energy Astrophysics Division Center for Astrophysics | Harvard & Smithsonian Office: (617) 496-7981 | Cell: (781) 363-0035 60 Garden Street | MS 04 | Cambridge, MA 02138
_______________________________________________ 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: michael.zingale@stonybrook.edu
Hi Clement, Thanks for telling me about this. I don't think I have the time to work on a bug fix right now, though maybe in a few weeks. One odd thing is that rays work fine for me with the construction ds.r[start:end], start and end are three element tuples, whereas points don't work, for example pt = ds.[start]. Jon On Tue, Oct 18, 2022 at 4:16 PM Clément Robert < clement.robert@protonmail.com> wrote:
Hi Slavin, I hate to be the bringer of bad news but this problem was reported already https://github.com/yt-project/yt/issues/3429 The fundamental issue is that YTArbitraryGrid does not support reduced dimensionality, and unfortunately I don’t know of a workaround. See https://github.com/yt-project/yt/issues/3437
To be clear, what you’re doing* should* work, and a patch would be very welcome, it’s just that no one has dedicated the time to do it yet. If anyone seeing this wants to give it a try, by all means, go ahead, and do not hesitate with any questions ! Sorry I could not be of more help Clément
On 18 Oct 2022, at 21:23, Slavin, Jonathan via yt-users < yt-users@python.org> wrote:
Hi,
I have some FLASH data from a 2-D simulation (cylindrical symmetry, R-Z) and I was trying to get point objects following the approach on the web page: https://yt-project.org/doc/analyzing/objects.html?highlight=interpolate
There it indicates that you can do something like: ds = yt.load(file) pt = ds.r[(10.0, "km"), (200, "m"), (1.0, "km")]
In my case I just give 0 for the last value since it doesn't matter in 2D. However if I try that I get the error message: --------------------------------------------------------------------------- YTDimensionalityError Traceback (most recent call last) Cell In [4], line 1 ----> 1 pt = ds.r[(rinit,'pc'), (zinit,'pc'), (0.,'pc')]
File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/data_objects/region_expression.py:67, in RegionExpression.__getitem__(self, item) 61 item.insert(idx, slice(None)) 63 if len(item) != self.ds.dimensionality: 64 # Not the right specification, and we don't want to do anything 65 # implicitly. Note that this happens *after* the implicit expansion 66 # of a single slice. ---> 67 raise YTDimensionalityError(len(item), self.ds.dimensionality) 69 # OK, now we need to look at our slices. How many are a specific 70 # coordinate? 72 nslices = sum(isinstance(v, slice) for v in item)
YTDimensionalityError: Dimensionality specified was 3 but we need 2
So I thought this might be due to the data being 2D. Then I tried pt = ds.r[(rinit,'pc'), (zinit,'pc')] but that leads to a TypeError - the message ends with:
File /export/slavin/anaconda3/envs/py38/lib/python3.8/site-packages/yt/funcs.py:1119, in validate_3d_array(obj) 1117 def validate_3d_array(obj): 1118 if not is_sequence(obj) or len(obj) != 3: -> 1119 raise TypeError( 1120 "Expected an array of size (3,), received '%s' of " 1121 "length %s" % (str(type(obj)).split("'")[1], len(obj)) 1122 )
TypeError: Expected an array of size (3,), received 'list' of length 2
So is there any way around this? (By the way, I'm using yt 4.1.1 and got the same issue with 4.0.5.) Thanks in advance for any help.
Regards, Jon -- Jonathan D. Slavin (he/him) Astrophysicist - High Energy Astrophysics Division Center for Astrophysics | Harvard & Smithsonian Office: (617) 496-7981 | Cell: (781) 363-0035 60 Garden Street | MS 04 | Cambridge, MA 02138
participants (3)
-
Clément Robert
-
Michael Zingale
-
Slavin, Jonathan