Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

create the class PointMesh and its tests #410

Closed
wants to merge 6 commits into from
Closed

Conversation

birocoles
Copy link
Member

@birocoles birocoles commented Nov 3, 2017

Fixes #210

For some applications (e.g., Equivalent Layer), we need to generate a grid of point sources (spheres of unit volume). In the current version of Fatiando, we can only create regular or scatter grids of point sources. This PR proposes a new class (PointMesh) to define a set of point sources. In this class, the source locations are defined directly by using numpy arrays of the Cartesian coordinates x, y and z.

Checklist:

  • Make tests for new code (at least 80% coverage)
  • Create/update docstrings
  • Include relevant equations and citations in docstrings
  • Docstrings follow the style conventions
  • Code follows PEP8 style conventions
  • Code and docs have been spellchecked
  • Include new dependencies in doc/install.rst, environment.yml, ci/requirements.txt.
  • Documentation builds properly (run cd doc; make locally)
  • Changelog entry (leave for last to avoid conflicts)
  • First-time contributor? Add yourself to doc/contributors.rst (leave for last to avoid conflicts)

Copy link
Member

@leouieda leouieda left a comment

Choose a reason for hiding this comment

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

@birocoles thanks for implementing this. I left a few comments about how you could make the code a bit simpler.

The codacy and codeclimate errors mostly come from code duplication between PointMesh and PointGrid. You can ignore them for now because I haven't configured them correctly.

@@ -388,6 +388,117 @@ def copy(self):
return cp.deepcopy(self)


class PointMesh(object):
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps a better name would be IrregularPointMesh because we could also have a PointMesh that is like the PrismMesh.

Copy link
Member

Choose a reason for hiding this comment

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

This class is actually a more generic version of PointGrid and could be used as its base class. The PointGrid would need to generate the x, y, z arrays and pass to this classes __init__ method. This would remove all the duplicated code in __getitem__ etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to create the class IrregularPointMesh as the base of PointGrid.


Grid points are ordered like a C matrix, first each row in a column, then
change columns. In this case, the x direction (North-South) are the rows
and y (East-West) are the columns.
Copy link
Member

Choose a reason for hiding this comment

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

This paragraph doesn't really make sense anymore for this mesh type.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed


* x, y, z : 1d-arrays
The x, y, and z coordinates of each point in the mesh
(remember, z is positive downward).
Copy link
Member

Choose a reason for hiding this comment

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

Please include a note reminding that x points North and y points East.

Copy link
Member Author

Choose a reason for hiding this comment

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

Included

Copy link
Member

@leouieda leouieda left a comment

Choose a reason for hiding this comment

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

Great! Almost done.

@@ -71,6 +71,7 @@ Meshes and collections
TesseroidMesh
PrismRelief
PointGrid
PointMesh
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be updated to the new name.

x, y = gridder.regular(area, shape)
# The spacing between points
self.dx, self.dy = gridder.spacing(area, shape)
super().__init__(x, y, z, props)
Copy link
Member

Choose a reason for hiding this comment

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

Any attributes set by IrregularPointMesh don't need to be set here as well (props, radius, size).

@leouieda leouieda closed this Feb 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a PointScatter mesh object
2 participants