clouddrift
clouddrift copied to clipboard
data structure for particle pair
Hi, I've recently doing relative dispersion analysis, in which particles are grouped into pairs like
pair = [p1, p2] # p1 is a particle represented as xr.Dataset, containing x, y, u, v
Then I write some diagnostics calculation such as relative dispersion:
def relative_dispersion(pair, power=2):
p1, p2 = pair
dx = p1.x - p2.x
dy = p1.y - p2.y
return np.hypot(dx, dy) ** power
If there is 100 particles, through combination one would get ~5000 (100*99/2) possible pairs. So a simple loop like:
rd = [relative_dispersion(pair) for pair in pairs]
would be quite slow due to unacceptable overhead. Although I can do parallel mapping in this case, I just wondering if there is a better solution for this. Do you guys have any suggestions on dealing with pair particle calcualtions?