-
Notifications
You must be signed in to change notification settings - Fork 35
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 representation methods for TensorMesh #143
Conversation
Great, thanks for this quick draft. Could you put a screenshot of a more complicated model, along the lines of #142 ?
Also, my points from there hold:
So besides X/Y/Z Bounds also min(X/Y/Z) (which is simply min(mesh.hx), max(mesh.hx)). Also, maybe split the number of cells. Maybe leave Here again the 'sketch' from #142:
|
That is a really good starting point. I'll see if I get around soonish to polish it |
Codecov Report
@@ Coverage Diff @@
## master #143 +/- ##
==========================================
- Coverage 82.53% 82.07% -0.47%
==========================================
Files 22 22
Lines 4725 4743 +18
==========================================
- Hits 3900 3893 -7
- Misses 825 850 +25
Continue to review full report at Codecov.
|
Very cool! I think this would be a great improvement to discretize. I don't think the (also I had not seen a "draft" pr before - that is nice feature) |
First go at it, inputs welcome. @banesullivan, I simplified some stuff, because I didn't quite understand it. Maybe I simplified to much, can you have a look. @fourndo, I don't know if that also works for TreeMeshes, could you have a go? Similar for CylMeshes @lheagy. Just saw that I miss the tiles in the non-html version. |
@banesullivan, you put it into This means it is only for TensorMeshes and not other meshes, right now. I think this is the least friction, so it should be straight forward to merge. Similar steps should be taken to replace the |
The failures are related to Python 2.7. But it is an easy one to avoid, will do it. |
😄 Sorry @banesullivan, messed that up with assigning. Wanted to assign you as reviewer. But I think as you originally created it it doesn't take you as reviewer... |
The max stretching factor calculation failed if there was only one cell. Fixed now.
This looks really good @prisae! +1 Afterthoughts
Why can't this be generalized in the A few thoughts arise on other attributes to include:
|
Thanks @banesullivan for the feedback!
Well. There are a couple of thoughs:
So, in summary. Maybe it could be combined into a more general thing into Regarding your first point in the list: I am generally interested about the extent of a mesh, and the number of cells in a mesh. The first point to see if I cover my model and my sources/receivers, the second one to know if my memory will be able to handle the calculation. So I personally am not bothered about I think it would be good if you create a separate issue with your second point in the list. |
This is looking great! A couple questions / thoughts
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great! I would be happy to merge this as is and we can iterate in new prs. Thoughts @banesullivan, @prisae?
discretize/TensorMesh.py
Outdated
def _get_attrs(self): | ||
"""An internal helper for the representation methods""" | ||
attrs = [] | ||
dims = ['x', 'y', 'z'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be a property on the mesh - it would make it easier to inherit (then on the cyl mesh for example, all of this code could be re-used, but dims = ['r', 'theta', 'z']
Yes,
Will do, good input! |
Thinking about it: What do you mean with origin? that is basically what |
Have a look at the new screenshot. I changed Also, I converted |
The alternative to a
Opinions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good! My main comment is that I am hesitant to add a somewhat generic property attributes
to the tensor mesh. The tensor mesh is somewhat over-loaded as-is (e.g. see the docs... http://discretize.simpeg.xyz/en/master/api/generated/discretize.TensorMesh.html#module-discretize.TensorMesh), and most of the info in attributes
is already captured in some form through other properties.
Do you think we can make the print function still fairly transparent without it? or maybe have it as a hidden property for now?
discretize/TensorMesh.py
Outdated
|
||
# Get min/max node. | ||
n_vector = getattr(self, 'vectorN'+name) | ||
attrs[name]['origin'] = np.nanmin(n_vector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The origin of the mesh is also mesh.x0
. I am wondering if that might be a bit more transparent here?
discretize/TensorMesh.py
Outdated
fmt += "<tr>" # Start row | ||
fmt += "<td>{}</td>".format(name) | ||
fmt += "<td>{}</td>".format(iattr['nC']) | ||
for p in ['origin', 'extent', 'h_min', 'h_max', 'max_fact']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's agree on naming before I make any further changes: At the beginning I had min(N)
/max(N)
. You thought that is not very intuitive, which I agree, and we should add the origin. But the origin is the same as the minimum. So I changed min(N)
/max(N)
to origin
/extent
.
I think the possibilities are:
min
,start
,origin
,x0
max
,end
,extent
Having in mind that there is also min(h)
/max(h)
and we should avoid confusion.
Another idea might be to have a double-line header:
== TensorMesh: 2,097,152 cells ==
mesh extent cell width str fact
dir nC min max min max max
--------------------------------------------------------------------
x 128 0.00 8,352.67 25.00 143.00 1.03
y 128 -5,902.58 5,902.58 50.00 160.83 1.02
z 128 -14,303.35 0.00 20.00 355.79 1.05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I quite like the double-line header example you have listed last. It displays a lot of useful info, and I think is fairly clear to interpret.
discretize/TensorMesh.py
Outdated
return ['x', 'y', 'z'][:self.dim] | ||
|
||
@property | ||
def attributes(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate that this is handy, but I am a bit hesitant at this point to add another property to the Tensor Mesh that contains much of the same information as is already available through other properties (e.g. the list in the docs is pretty extensive already... http://discretize.simpeg.xyz/en/master/api/generated/discretize.TensorMesh.html#module-discretize.TensorMesh)
What do you think of performing these actions in the print statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lheagy, you confuse me here... 😄
I made this a property because in your previous review (#143 (review)) you said "this could be a property on the mesh - it would make it easier to inherit (then on the cyl mesh for example, all of this code could be re-used". But I am happy to go back to what it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion! In the previous review, I was only referring to the dimension_names
, and it was really only after working on #134 that I got a sense of how over-loaded the attributes are.
If you prefer to leave this as a property, I think it is okay, as long as we make it a private variable e.g. _attributes
I made a double header line in both, plain text and html. Also, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great - many thanks @prisae 🎉
Add representation methods for
TensorMesh
The current
TensorMesh
-string method is somewhat outdated, particularly for big meshes. This PR adds html and non-html representations which should be more generally applicable, for small and bigTensorMesh
's.Based on work by @banesullivan on
vtki
and @prisae on theprintversion
-tool.