pyTMD icon indicating copy to clipboard operation
pyTMD copied to clipboard

Can the interpolation range be limited in advance to improve program efficiency?

Open lyingTree opened this issue 2 years ago • 3 comments

It's very slow when I use the program to read TPXO9-atlas-v5 and compute tidal elevations. So I check the profile of the code and found that the most time-consuming function is the interpolation part, so I wonder if I can limit the interpolation range in advance to improve operation efficiency?

These two log files are profiles before and after my modification. We can see that it's very useful when the data range we used is small. Can it become universal?

test_pytmd.py.txt before.log after.log

lyingTree avatar Apr 13 '22 00:04 lyingTree

I don't get it what your "modifications" are but from my experience (I'm just a user as well), what takes longest is reading the tide model grids. The code is such that the full grids of all constituents are read before the values for the selected locations are calculated (interpolated or extrapolated). However, I understand @tsutterley as reading only specific subregions around the data would probably complicate things substantially at many other parts of the code (especially when it comes to locations close to the poles/the dateline/Greenwich/... ). This would be nice in some future but surely means a lot of work.

So what improved the speed in my case significantly was creating tailored copies of the constituent files for my region of interest. Reading these subregion files (nlon x nlat = 1095 x 540) instead of the global ones (10800x5401 for TPXO) helps a lot to speed things up.

ludwigus avatar Apr 20 '22 12:04 ludwigus

That is the exact complication which makes this pretty tricky to implement universally. Thanks @DerLude!

tsutterley avatar Apr 20 '22 13:04 tsutterley

on this @lyingTree and @DerLude, I (finally) put in functions to output subsets of FES and TPXO9-atlas files for specific regions of interest in PR #139. Need to be careful handling specific regions of interest (i.e. dateline, prime meridian and poles) if using this functionality as @DerLude mentioned.

tsutterley avatar Dec 27 '22 21:12 tsutterley

@lyingTree I'm (finally) trying to add something to address this in #313

tsutterley avatar Jul 18 '24 02:07 tsutterley