Speed up landice.mesh.preprocess_ais_data extrapolation#949
Conversation
TestingUsing current implementation in Using these changes, we get this: So, a 200x speedup. |
Speed up extrapolation step in landice.mesh.preprocess_ais_data by replacing scipy.interpolate.NearestNDInterpolator with smarter algorithm using scipy.ndimage.distance_transform_edt.
58f699d to
0b028f5
Compare
Use 8km data source for Antarctica instead of 1km. The recent change to 1km was inadvertent, makes the code take far too long to run, and is only actually desirable when creating high-resolution meshes.
| self.add_output_file( | ||
| filename=f'{self.mesh_filename[:-3]}_ismip6_regionMasks.nc') | ||
| self.add_input_file( | ||
| filename='antarctica_1km_2024_01_29.nc', |
There was a problem hiding this comment.
Did you mean to switch to a coarser dataset? Is that accounting for any of the speedup you reported?
There was a problem hiding this comment.
Yes, this was intentional, and no I don't think it accounts for the speedup I reported. This was inadvertently switched from 8km to 1km in this recent commit: 0b52238#diff-992c4799a18d79fe0e3d55859f4b5f326104e5af5e6b8a5b0459848aa90a84ca (and was missed because there were far too many changes in that PR). This just resets to the original 8km data set, but I have been careful to be consistent in which resolution I use between main and this branch.
There was a problem hiding this comment.
In my most recent testing, in which I definitely used the 8km source dataset, I get All nearest-fill preprocessing completed in 0.288 seconds for this branch and All interpolations completed in 11.316709512029774 seconds. on main. So still a ~2 order of magnitude speedup when using a coarse data set, but not so impactful when just cutting of 11 seconds instead of 4100 seconds :).


Speed up extrapolation step in landice.mesh.preprocess_ais_data by replacing
scipy.interpolate.NearestNDInterpolatorwith smarter algorithm usingscipy.ndimage.distance_transform_edt.Checklist
Testingin this PR) any testing that was used to verify the changes