Closed rabernat closed 7 years ago
If I understand correctly, the spacing dx
, dy
of floats in the Floatset
is in general different than the spacing of the tracer cell (or velocity cell) grid points used in the advection simulation.
This means that we cannot pass get_hexmesh
just the simple mask (boolean array) taken without adjustment from the velocity field data or bathymetry file, for example.
Should we expect the user to "interpolate" their mask to a finer spatial resolution before passing it to get_hexmesh
? Or should we build this functionality into get_hexmesh
and include optional arguments for information about the mask's grid geometry/structure ? To the tune of
fs.get_hexmesh(mask=some_mask, mask_lat = some_1D_array, mask_lon = some_1D_array)
Here is a jupyter notebook walkthrough of a potential method to remove floater particles in masked regions. The method uses nearest neighbor searching on a k-d tree
of the masked grid data.
@nathanieltarshish: great to see you are digging into this. Apologies for not communicating earlier--I am visiting my family in Vermont and am mostly taking the week off.
Your KDtree approach seems pretty sophisticated. One comment on the code: I would rewrite the geo_to_xyz
and xyz_to_geo
functions using numpy so that they vectorize. That will speed things up a lot. (We generally avoid importing from math
in scientific code, as numpy versions of math routines are all faster.)
I would try implementing this within the generators
module. Do you know how to make a pull request on this repository? Once you open a PR, we can discuss the specifics of your implementation.
@rabernat Thanks for taking a look and the feedback. Very good to know about speed differences between numpy and math. In general, I am interested in any optimization suggestions you have and learning better science coding practices. I will rewrite those functions and try to incorporate it into generators
. Yes, I think I should be able to submit a PR on this repo.
Enjoy the break! I will be working on this throughout the week, but of course, no pressure to get back to me while you're away.
@rabernat In PR #14, I vectorized the algorithm and incorporated it into the generators
module as a new function: get_hexcoords
. I created this function independent of get_hexmesh
since I did not find the np.meshgrid
structure to be very compatible with the masked float coordinate set. I tested the function out on a few sample masks here. Looks like it does an overall okay job, but errs on the side of including a few inland floats around the coasts.
Closed by #14
We would like to do something like
This would blank out the regions where there is land and reduce memory usage, especially for global simulations.