Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spherical shell geometry support to DEM components #320

Merged
merged 3 commits into from May 29, 2023

Conversation

schunkes
Copy link
Member

@schunkes schunkes commented Apr 18, 2023

Description

This PR updates DEM-related components to allow using a spherical shell geometry with the DEMExperiment class.

Checklist

  • The code follows the relevant coding guidelines
  • The code generates no new warnings
  • The code is appropriately documented
  • The code is tested to prove its function
  • The feature branch is rebased on the current state of the main branch
  • I updated the change log if relevant
  • I give permission that the Eradiate project may redistribute my contributions under the terms of its license

Copy link
Member

@leroyvn leroyvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @schunkes, this is a first very quick review. Key points:

  • Please make the scope of this PR clear and as limited as possible, i.e. stick to extending DEMExperiment with spherical shell geometry support.
  • Please review the whole DEM processing code and vectorize it, it will be clearer, more compact and much faster.

src/eradiate/scenes/shapes/_buffermesh.py Outdated Show resolved Hide resolved
src/eradiate/scenes/core.py Outdated Show resolved Hide resolved
src/eradiate/experiments/_atmosphere.py Outdated Show resolved Hide resolved
src/eradiate/scenes/bsdfs/_opacity_mask.py Outdated Show resolved Hide resolved
src/eradiate/scenes/bsdfs/_opacity_mask.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
Copy link
Member

@leroyvn leroyvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @schunkes, thanks for proceeding with vectorization. It looks like a round of cleanup is required prior to proceeding with fine tuning, notably paying attention to:

  • unit handling;
  • docstring and annotation agreement.

Looking again at this, I think we are in a complicated situation where file buffering fundamentally breaks unit support (we already worked around this but it's not bulletproof).

Also, passing through a file write is something we've been trying to avoid and could be delegated to the user without losing too much convenience. The pattern would then be something like this (still breaking unit support):

# Tesselate DEM
dem_mesh: mi.Mesh = make_dem_from(some_data)
# Either use it directly, 
dem_surface = DEMSurface(shape=dem_mesh, ...)
# Or through a file
dem_mesh.write_ply("dem.ply")
dem_surface = DEMSurface(shape="dem.ply")

Let's review your code live after you're done cleaning it up a bit.

src/eradiate/experiments/_dem.py Outdated Show resolved Hide resolved
src/eradiate/experiments/_dem.py Show resolved Hide resolved
src/eradiate/experiments/_dem.py Outdated Show resolved Hide resolved
src/eradiate/experiments/_dem.py Outdated Show resolved Hide resolved
src/eradiate/experiments/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
@schunkes
Copy link
Member Author

schunkes commented May 3, 2023

@leroyvn would you mind, taking another look at the code now? I updated it according to what we discussed. Additionally, I gave the BufferMesh a write_ply method. If you want, I can also show you the workflow as it is now. :)

I did not update the tests yet, so do not expect them to work or pass.

Copy link
Member

@leroyvn leroyvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @schunkes, we're getting there on the design side. There are a lot of details to fix. I've been specific, but I probably missed some. Please:

  • Check defaults and type annotations. There are many missing or inconsistent entries. You also sometimes use mutables as defaults, which is very dangerous.
  • Check unit requirement consistency in all your functions. To keep it simple and safe, either all args should have units, or none (and then you might have to document arg units).
  • Please compile and check the documentation.

src/eradiate/scenes/bsdfs/_core.py Outdated Show resolved Hide resolved
src/eradiate/scenes/bsdfs/_opacity_mask.py Outdated Show resolved Hide resolved
src/eradiate/scenes/bsdfs/_opacity_mask.py Outdated Show resolved Hide resolved
src/eradiate/scenes/bsdfs/_opacity_mask.py Outdated Show resolved Hide resolved
src/eradiate/scenes/bsdfs/_opacity_mask.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
src/eradiate/scenes/surface/_dem.py Outdated Show resolved Hide resolved
@schunkes schunkes force-pushed the DEM_spherical_symmetry branch 2 times, most recently from 242d7a1 to 7eb79db Compare May 5, 2023 13:08
@leroyvn leroyvn marked this pull request as ready for review May 5, 2023 16:18
@schunkes schunkes force-pushed the DEM_spherical_symmetry branch 2 times, most recently from a1fd5ec to 90ba378 Compare May 15, 2023 14:17
@schunkes
Copy link
Member Author

All things we discussed are implemented. I think this can be reviewed again.

@leroyvn
Copy link
Member

leroyvn commented May 17, 2023

I applied a round of fixes. Main changes are:

  • Fixed and updated documentation (docstrings and Sphinx docs).
  • Improved conversion protocols (I added a new to_mi_scalar_transform()converter for convenience).
  • Exposed missing members.
  • Fixed mutable defaults.
  • Converted dict() to literals for consistency.
  • Refactored tests a bit to reduce boilerplate.
  • Updated change log.

@leroyvn leroyvn changed the title Dem spherical symmetry Add spherical shell geometry support to DEM components May 17, 2023
@schunkes
Copy link
Member Author

Looks good :)

@leroyvn leroyvn merged commit 9dd7545 into main May 29, 2023
@leroyvn leroyvn deleted the DEM_spherical_symmetry branch May 29, 2023 20:39
@leroyvn leroyvn restored the DEM_spherical_symmetry branch May 29, 2023 20:39
@leroyvn leroyvn deleted the DEM_spherical_symmetry branch June 14, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants