passaH2O / dorado

For shallow-water Lagrangian particle routing.
https://passah2o.github.io/dorado
MIT License
54 stars 9 forks source link

Faster "exact" generation #24

Closed elbeejay closed 3 years ago

elbeejay commented 3 years ago

Speeding up the "exact" particle generation

The "exact" generation of particles seemed a bit slow to me, hence the creation of #23.

The former method of particle seeding involved nested loops which are known to be slow in Python. This PR changes the implementation by taking advantage of the list data format to more rapidly do the "exact" particle seeding. To do this, the divmod() function is used to get the number of particles per location (the number of particles that evenly divide across the seed locations). If the number of seed particles doesn't divide evenly into the seed locations, the "remainder" particles are seeded via loop.

To do before merge

Edit: This closes #23

wrightky commented 3 years ago

My bad, I got the notification for this days ago and forgot about it. Taking a look now!