-
Notifications
You must be signed in to change notification settings - Fork 74
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 new data encapsulation #65
Conversation
2 new classes are added in order to separate data and methods more cleanly. This is very much WIP, but I'd like to get a discussion started before I put in too much work. The `FieldData` class contains information about the mesh and it holds a dict containing the individual field values, which are defined on that mesh, e.g. "krige" and "cond".
This way, we do not need a temporary field to store the mean value.
I love the approach of being able to access data by using the index operator. One issue I have with the approach is, that it is almost a re-implementation of a mesh-container like in meshio: In pyevtk, the export routine "pointsToVTK" also creates a mesh, where the "cells" are simple vertices: So in general, I would follow the definition of a VTK file, where we have:
The
Then we could easy export meshes with meshio (at least in the unstructured case). Or we could totally move to pyvista and use it for IO and plotting, since there is no option to export a structured. (or we could just covert it to unstructured when exporting) I guess @banesullivan would be happy about that, since we come closer to the VTK representation of a mesh. These were my two cents ;-) |
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.
See the other comment.
gstools/field/base.py
Outdated
|
||
|
||
class Field: | ||
class Data: |
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 can be dropped. (See comment)
gstools/field/base.py
Outdated
self.value_type = value_type | ||
|
||
|
||
class FieldData: |
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 called a Mesh
class.
gstools/field/base.py
Outdated
raise ValueError("Unknown 'mesh_type': {}".format(mesh_type)) | ||
|
||
|
||
class Field(FieldData): |
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 the GSField
class, since it is our working horse.
Thanks for your pretty thought out input! I dig the name Are you suggesting to use nested
with the key of the |
As we don't have many variables belonging to auxiliary fields, we should simply add them to the |
When a field is called with a new |
I've changed the SRF-class and especially the call method to being more mesh-centric. In this concept, it doesn't make a whole lot of sense to give the position-tuple everytime an SRF is to be calculated. The pos-tuple belongs to the mesh. To not break the backwards compatibility, I've included warnings. |
@MuellerSeb Please explain to me how |
The way the conditioning functions get the |
I'll have a look at it. |
@LSchueler : Found the problem. it is in the In the specific case, the I think, the pos tuple components should be flattened when the mesh is created (and converted to numpy arrays with floats). |
Checklist:
|
Thanks for compiling our chat from yesterday! |
Do we need another chat on that? Would be lovely to see this getting merged! :-) |
We have created such spaghetti code... |
Oh no... now I feel guilty! |
Let's focus on |
Some new thoughts on this:
|
I'll close this PR for now, as GSTools has meanwhile gone into a different direction. |
2 new classes are added in order to separate data and methods more
cleanly. This is very much WIP, but I'd like to get a discussion
started before I put in too much work.
The
FieldData
class contains information about the mesh and itholds a dict containing the individual field values, which are
defined on that mesh, e.g. "krige" and "cond".
I'd like to more clearly differentiate between a class instance of
Data
and the actual field values contained in that instance, i.e. the numpy array. Any ideas?For a better discussion, I used several different ways to access both, like
field["srf"]
field.values
field.field
Questions
Field
be renamed toFieldMethods
?mesh_type
or newpos
, should only the field values be deleted or everything, includingmean
, ...?__call__
methods return?Data
instancesData
instance of the default fielddefault_field
in theData
class always be called"field"
, or should the name be more descriptive, like"srf"
or"krige"
?TODO
__setattr__
method in order to assign fields to each otherData
instances and the actual field valuesData