Error when attempting to call surface object
Hi all, I've been trying to do some preliminary experimentation with YT's surface object. I have the following snippet of code: sphere = ds.sphere(center, radius) surf = ds.surface(sphere, ('gas', 'density'), 1e-23) ratio = (surf.volume() / surf.surface_area).in_units('pc') However when trying to run the code I get the following error: File "my_analysis.py", line 107, in contours ratio = (surf.volume() / surf.surface_area).in_units('pc') File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 1394, in volume return self.quantities.total_quantity(("index", "cell_volume")) File "/home/brs/stack/yt/yt/data_objects/derived_quantities.py", line 172, in __call__ rv = super().__call__(fields) File "/home/brs/stack/yt/yt/data_objects/derived_quantities.py", line 55, in __call__ for sto, ds in parallel_objects(chunks, -1, storage=storage): File "/home/brs/stack/yt/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 527, in parallel_objects for result_id, obj in oiter: File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 94, in chunks for ci, chunk in enumerate(self.index._chunk(self, chunking_style, **kwargs)): File "/home/brs/stack/yt/yt/geometry/geometry_handler.py", line 233, in _chunk self._identify_base_chunk(dobj) File "/home/brs/stack/yt/yt/geometry/grid_geometry_handler.py", line 335, in _identify_base_chunk gi = dobj.selector.select_grids( File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 73, in selector raise YTDataSelectorNotImplemented(self._type_name) P019 yt : [ERROR ] 2021-09-13 12:14:32,552 YTDataSelectorNotImplemented: Data selector 'surface' not implemented. I was hoping someone could help with this. My yt version is 4.1.dev0 and my Python version is 3.8.5 Many thanks, Sam Patrick
Hi Sam, This might be because the surface object works for datasets defined by continuous fields, rather than discretely sampled (i.e., grid vs particle/SPH). What type of dataset are you using? We might be able to work around it, though, by sampling to a regular mesh and then "surface"-ing... On Tue, Sep 14, 2021 at 5:51 AM Sam Patrick <sam.patrick@ed.ac.uk> wrote:
Hi all,
I've been trying to do some preliminary experimentation with YT's surface object. I have the following snippet of code:
sphere = ds.sphere(center, radius) surf = ds.surface(sphere, ('gas', 'density'), 1e-23) ratio = (surf.volume() / surf.surface_area).in_units('pc')
However when trying to run the code I get the following error:
File "my_analysis.py", line 107, in contours ratio = (surf.volume() / surf.surface_area).in_units('pc') File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 1394, in volume return self.quantities.total_quantity(("index", "cell_volume")) File "/home/brs/stack/yt/yt/data_objects/derived_quantities.py", line 172, in __call__ rv = super().__call__(fields) File "/home/brs/stack/yt/yt/data_objects/derived_quantities.py", line 55, in __call__ for sto, ds in parallel_objects(chunks, -1, storage=storage): File "/home/brs/stack/yt/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 527, in parallel_objects for result_id, obj in oiter: File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 94, in chunks for ci, chunk in enumerate(self.index._chunk(self, chunking_style, **kwargs)): File "/home/brs/stack/yt/yt/geometry/geometry_handler.py", line 233, in _chunk self._identify_base_chunk(dobj) File "/home/brs/stack/yt/yt/geometry/grid_geometry_handler.py", line 335, in _identify_base_chunk gi = dobj.selector.select_grids( File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 73, in selector raise YTDataSelectorNotImplemented(self._type_name) P019 yt : [ERROR ] 2021-09-13 12:14:32,552 YTDataSelectorNotImplemented: Data selector 'surface' not implemented.
I was hoping someone could help with this. My yt version is 4.1.dev0 and my Python version is 3.8.5 Many thanks, Sam Patrick _______________________________________________ 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
Hi Matthew, I'm using a typical Enzo dataset so the field should be continuous. Thanks, Sam ________________________________ From: Matthew Turk <matthewturk@gmail.com> Sent: 15 September 2021 16:02 To: Discussion of the yt analysis package <yt-users@python.org> Subject: [yt-users] Re: Error when attempting to call surface object This email was sent to you by someone outside the University. You should only click on links or attachments if you are certain that the email is genuine and the content is safe. Hi Sam, This might be because the surface object works for datasets defined by continuous fields, rather than discretely sampled (i.e., grid vs particle/SPH). What type of dataset are you using? We might be able to work around it, though, by sampling to a regular mesh and then "surface"-ing... On Tue, Sep 14, 2021 at 5:51 AM Sam Patrick <sam.patrick@ed.ac.uk> wrote:
Hi all,
I've been trying to do some preliminary experimentation with YT's surface object. I have the following snippet of code:
sphere = ds.sphere(center, radius) surf = ds.surface(sphere, ('gas', 'density'), 1e-23) ratio = (surf.volume() / surf.surface_area).in_units('pc')
However when trying to run the code I get the following error:
File "my_analysis.py", line 107, in contours ratio = (surf.volume() / surf.surface_area).in_units('pc') File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 1394, in volume return self.quantities.total_quantity(("index", "cell_volume")) File "/home/brs/stack/yt/yt/data_objects/derived_quantities.py", line 172, in __call__ rv = super().__call__(fields) File "/home/brs/stack/yt/yt/data_objects/derived_quantities.py", line 55, in __call__ for sto, ds in parallel_objects(chunks, -1, storage=storage): File "/home/brs/stack/yt/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 527, in parallel_objects for result_id, obj in oiter: File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 94, in chunks for ci, chunk in enumerate(self.index._chunk(self, chunking_style, **kwargs)): File "/home/brs/stack/yt/yt/geometry/geometry_handler.py", line 233, in _chunk self._identify_base_chunk(dobj) File "/home/brs/stack/yt/yt/geometry/grid_geometry_handler.py", line 335, in _identify_base_chunk gi = dobj.selector.select_grids( File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 73, in selector raise YTDataSelectorNotImplemented(self._type_name) P019 yt : [ERROR ] 2021-09-13 12:14:32,552 YTDataSelectorNotImplemented: Data selector 'surface' not implemented.
I was hoping someone could help with this. My yt version is 4.1.dev0 and my Python version is 3.8.5 Many thanks, Sam Patrick _______________________________________________ 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: sam.patrick@ed.ac.uk The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th' ann an Oilthigh Dh?n ?ideann, cl?raichte an Alba, ?ireamh cl?raidh SC005336.
Oh! I see now. I think the usage of volume might be the bit that's tricky. I'm not totally sure how to address this, because surface does not assume continuous volumes, even though they may be monotonic fields. You may need to identify it using clumps. On Thu, Sep 16, 2021 at 7:37 AM PATRICK Samuel <sam.patrick@ed.ac.uk> wrote:
Hi Matthew,
I'm using a typical Enzo dataset so the field should be continuous.
Thanks, Sam ________________________________ From: Matthew Turk <matthewturk@gmail.com> Sent: 15 September 2021 16:02 To: Discussion of the yt analysis package <yt-users@python.org> Subject: [yt-users] Re: Error when attempting to call surface object
This email was sent to you by someone outside the University. You should only click on links or attachments if you are certain that the email is genuine and the content is safe.
Hi Sam,
This might be because the surface object works for datasets defined by continuous fields, rather than discretely sampled (i.e., grid vs particle/SPH). What type of dataset are you using?
We might be able to work around it, though, by sampling to a regular mesh and then "surface"-ing...
On Tue, Sep 14, 2021 at 5:51 AM Sam Patrick <sam.patrick@ed.ac.uk> wrote:
Hi all,
I've been trying to do some preliminary experimentation with YT's surface object. I have the following snippet of code:
sphere = ds.sphere(center, radius) surf = ds.surface(sphere, ('gas', 'density'), 1e-23) ratio = (surf.volume() / surf.surface_area).in_units('pc')
However when trying to run the code I get the following error:
File "my_analysis.py", line 107, in contours ratio = (surf.volume() / surf.surface_area).in_units('pc') File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 1394, in volume return self.quantities.total_quantity(("index", "cell_volume")) File "/home/brs/stack/yt/yt/data_objects/derived_quantities.py", line 172, in __call__ rv = super().__call__(fields) File "/home/brs/stack/yt/yt/data_objects/derived_quantities.py", line 55, in __call__ for sto, ds in parallel_objects(chunks, -1, storage=storage): File "/home/brs/stack/yt/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 527, in parallel_objects for result_id, obj in oiter: File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 94, in chunks for ci, chunk in enumerate(self.index._chunk(self, chunking_style, **kwargs)): File "/home/brs/stack/yt/yt/geometry/geometry_handler.py", line 233, in _chunk self._identify_base_chunk(dobj) File "/home/brs/stack/yt/yt/geometry/grid_geometry_handler.py", line 335, in _identify_base_chunk gi = dobj.selector.select_grids( File "/home/brs/stack/yt/yt/data_objects/selection_objects/data_selection_objects.py", line 73, in selector raise YTDataSelectorNotImplemented(self._type_name) P019 yt : [ERROR ] 2021-09-13 12:14:32,552 YTDataSelectorNotImplemented: Data selector 'surface' not implemented.
I was hoping someone could help with this. My yt version is 4.1.dev0 and my Python version is 3.8.5 Many thanks, Sam Patrick _______________________________________________ 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: sam.patrick@ed.ac.uk The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th’ ann an Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh clàraidh SC005336. _______________________________________________ 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
Hi Matthew, I've modified the code so that the surface method is performed on a clump object: clump = Clump(sphere, ('gas', 'density')) surf = ds.surface(clump, ('gas', 'density'), thresh) ratio = (surf.volume() / surf.surface_area).in_units('pc') But now I'm getting the error: File "my_analysis.py", line 108, in contours surf = ds.surface(clump, ('gas', 'density'), thresh) File "/home/brs/stack/yt/yt/data_objects/construction_data_containers.py", line 1557, in __init__ self.surface_field = data_source._determine_fields(surface_field)[0] P062 yt : [ERROR ] 2021-09-21 12:34:08,688 AttributeError: 'Clump' object has no attribute '_determine_fields' Many thanks, Sam PS: Apologies if this got sent twice, I believe there was an error in sending the first message The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th’ ann an Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh clàraidh SC005336.
Hi Sam, I've been thinking through this, and I'm actually not sure that we can quite do it as-is. The issue is basically that the surface calculation doesn't make any assumptions about the connectivity of the object, whereas the clump object does. But, the clump object doesn't actually make any comments about the actual value, just the thresholds. (The surface will compute the values it passes through assuming trilinear interpolation is satisfactory.) What I think would get you the closest would be to do something like this: 1. Identify the surface and compute its surface area 2. Compute the minimal bounding sphere or cylinder or other object which does *not* intersect with other clumps. 3. Use that sphere as the input to a clump identification in the range of densities that include your surface, and the output clump's volume can be used as the volume of the surface. This will not be an exact match, but it should be reasonably close if your clumps are big enough. The difference in exact values will be a result of the cells *at* the surface, where the surface identifier will assume smoothly varying fields but the clump identifier will use the exact (cell-centered) values. If more than one clump is within your input bounding object, you might get multiple clumps, and you'll have to check that they are the same object; looking at the approximate centroid should assist with this. -Matt On Fri, Oct 1, 2021 at 11:22 AM Samuel Patrick <spatrick@ed.ac.uk> wrote:
Hi Matthew,
I've modified the code so that the surface method is performed on a clump object:
clump = Clump(sphere, ('gas', 'density')) surf = ds.surface(clump, ('gas', 'density'), thresh) ratio = (surf.volume() / surf.surface_area).in_units('pc')
But now I'm getting the error:
File "my_analysis.py", line 108, in contours surf = ds.surface(clump, ('gas', 'density'), thresh) File "/home/brs/stack/yt/yt/data_objects/construction_data_containers.py", line 1557, in __init__ self.surface_field = data_source._determine_fields(surface_field)[0] P062 yt : [ERROR ] 2021-09-21 12:34:08,688 AttributeError: 'Clump' object has no attribute '_determine_fields'
Many thanks, Sam
PS: Apologies if this got sent twice, I believe there was an error in sending the first message
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th’ ann an Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh clàraidh SC005336. _______________________________________________ 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
Hi Matt, I'm afraid I don't quite follow. It would seem from the documentation that calling either a YTSurface or Clump would both result in possibly disconnected objects. I'm unsure of a way to implement this technique without first calling ds.surface, where the code fails, or possibly calling the extract_connected_sets() method to eliminate disconnected sets but again this would have to be after a YTSurface object had been initialized. Many thanks, Sam
Hi Sam, Thanks for re-sending -- this slipped off my radar. The clumps objects are checked for continuity; they're all topologically connected sets, which then can have additional validation criteria. Additionally, they are inclusive (i.e., threshold value) rather than surfaces. On Fri, Oct 15, 2021 at 7:18 AM Sam Patrick <sam.patrick@ed.ac.uk> wrote:
Hi Matt,
I'm afraid I don't quite follow. It would seem from the documentation that calling either a YTSurface or Clump would both result in possibly disconnected objects.
I'm unsure of a way to implement this technique without first calling ds.surface, where the code fails, or possibly calling the extract_connected_sets() method to eliminate disconnected sets but again this would have to be after a YTSurface object had been initialized.
Many thanks, Sam _______________________________________________ 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
participants (4)
-
Matthew Turk
-
PATRICK Samuel
-
Sam Patrick
-
Samuel Patrick