NOAA-ORR-ERD / gridded

A single API for accessing / working with gridded model results on multiple grid types
https://noaa-orr-erd.github.io/gridded/index.html
The Unlicense
64 stars 14 forks source link

Accelerate compuation of coordinates in GridU #64

Closed groutr closed 3 years ago

groutr commented 3 years ago

This avoid looping over numpy arrays and creating a whole bunch of temporary arrays.

On my decent sized network of 1664323 nodes and 3314515 faces (3 and 4 sided polygons). Old build_edge_coordinates() -> 3min 44s New build_edge_coordinates() -> 1.24s

Peak memory usage though could be an issue as we are allocating two large arrays. The first is a 3D array (self.nodes[self.edges]) of shape (4978836, 2, 2) and the second (allocated by mean operation) (4978836, 2). However, the performance benefit I think is worth the memory cost. Perhaps there is a more memory efficient way to compute this that is also fast.

groutr commented 3 years ago

ping @ChrisBarker-NOAA

ChrisBarker-NOAA commented 3 years ago

Thanks! not sure why I didn't do it that way in the first place.